You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public void moveSelectedObject(float x, float y) {
if (mSelectedObject == null)
return;
//
// -- unproject the screen coordinate (2D) to the camera's near plane
//
GLU.gluUnProject(x, getViewportHeight() - y, 0, mViewMatrix.getDoubleValues(), 0,
mProjectionMatrix.getDoubleValues(), 0, mViewport, 0, mNearPos4, 0);
//
// -- unproject the screen coordinate (2D) to the camera's far plane
//
GLU.gluUnProject(x, getViewportHeight() - y, 1.f, mViewMatrix.getDoubleValues(), 0,
mProjectionMatrix.getDoubleValues(), 0, mViewport, 0, mFarPos4, 0);
//
// -- transform 4D coordinates (x, y, z, w) to 3D (x, y, z) by dividing
// each coordinate (x, y, z) by w.
//
mNearPos.setAll(mNearPos4[0] / mNearPos4[3], mNearPos4[1]
/ mNearPos4[3], mNearPos4[2] / mNearPos4[3]);
mFarPos.setAll(mFarPos4[0] / mFarPos4[3],
mFarPos4[1] / mFarPos4[3], mFarPos4[2] / mFarPos4[3]);
//
// -- now get the coordinates for the selected object
//
double factor = (Math.abs(mSelectedObject.getZ()) + mNearPos.z)
/ (getCurrentCamera().getFarPlane() - getCurrentCamera()
.getNearPlane());
mNewObjPos.setAll(mFarPos);
mNewObjPos.subtract(mNearPos);
mNewObjPos.multiply(factor);
mNewObjPos.add(mNearPos);
mSelectedObject.setX(mNewObjPos.x);
mSelectedObject.setY(mNewObjPos.y);
}
and got an error like this.
I want to pick and drag object smoothly, but it immediately jumps to the touched position.
How to correct it ?
Thank for any help!
The text was updated successfully, but these errors were encountered:
I coded follow the class TouchAndDragFragment:
and got an error like this.
![1](https://cloud.githubusercontent.com/assets/1621221/8077328/06699616-0f7f-11e5-844b-c972330777c8.gif)
I want to pick and drag object smoothly, but it immediately jumps to the touched position.
How to correct it ?
Thank for any help!
The text was updated successfully, but these errors were encountered: