1
Support / Translating an Object3D to the touch point
« on: November 23, 2011, 04:22:35 pm »
Hi Raft,
I am back
I am just trying a simple thing to make an Object3D follow my touch points i.e. the Object3D moves to whatever point that I touch on the screen. But I am unsuccessful
I used the basic cube example of the Hello World AE. I changed the onTouchEvent() as below:
Then I changed the onDrawFrame as below:
I see that the cube is moving, but very little!! Can you please let me know if I am missing something
I am back
I am just trying a simple thing to make an Object3D follow my touch points i.e. the Object3D moves to whatever point that I touch on the screen. But I am unsuccessful
I used the basic cube example of the Hello World AE. I changed the onTouchEvent() as below:
Code: [Select]
public boolean onTouchEvent(MotionEvent me)
{
if (me.getAction() == MotionEvent.ACTION_DOWN)
{
xpos = me.getX();
ypos = me.getY();
mTouchVector = Interact2D.reproject2D3DWS(world.getCamera(), fb,
(int)xpos, (int)ypos);
return true;
}
try
{
Thread.sleep(15);
}
catch (Exception e)
{
// No need for this...
}
return super.onTouchEvent(me);
}
Then I changed the onDrawFrame as below:
Code: [Select]
public void onDrawFrame(GL10 gl)
{
try
{
fb.clear(back);
if(mTouchVector != null)
{
cube.clearTranslation();
cube.translate(mTouchVector);
}
world.renderScene(fb);
world.draw(fb);
fb.display();
}
catch (Exception e)
{
Logger.log(e, Logger.MESSAGE);
}
}
I see that the cube is moving, but very little!! Can you please let me know if I am missing something