Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I get normalized screen coordinates through the following.</p> <pre><code>glSurfaceView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event != null) { // Convert touch coordinates into normalized device // coordinates, keeping in mind that Android's Y // coordinates are inverted. final float normalizedX = (event.getX() / (float) v.getWidth()) * 2 - 1; //final float normalizedY = -((event.getY() / (float) v.getHeight()) * 2 - 1);//commented to kill z axis //final float normalizedY; final float scrnx =event.getX(); final float scrny =event.getY(); if (event.getAction() == MotionEvent.ACTION_DOWN) { normalizedY = -((event.getY() / (float) v.getHeight()) * 2 - 1); glSurfaceView.queueEvent(new Runnable() { @Override public void run() { airHockeyRenderer.handleTouchPress( normalizedX, normalizedY); } }); } else if (event.getAction() == MotionEvent.ACTION_MOVE) { normalizedY = -((event.getY() / (float) v.getHeight()) * 2 - 1); glSurfaceView.queueEvent(new Runnable() { @Override public void run() { airHockeyRenderer.handleTouchDrag( normalizedX, normalizedY, scrnx, scrny); } }); } return true; } else { return false; } } }); </code></pre> <p>After translating the parent object, I use the x and z vertices of my parent circle which is laying flat on the z plane.</p> <pre><code>circPosition1.x = rcircle.vertexArray.rawFloatbuff[3*circcnter]; circPosition1.z = rcircle.vertexArray.rawFloatbuff[(3*circcnter)+2]; </code></pre> <p>'rcircle' is the parent object. </p> <p>'circcnter' is the position on the curve, or in this case circle.</p> <p>'circPosition1' is the child object which will be located to the edge of the parent object.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload