jPCT-AE - a 3d engine for Android > Support

How to pick and move object on a plane?

(1/2) > >>

Gohome:
I create a fixed plane and a fixed camera. And I put objects on the plane. With these codes, I can pick a specific object and remove it correctly. But, if I replace the codes doing remove with rotate or translate. Then it doesn't work.

Remove

--- Code: ---public void pickChess() {
SimpleVector dir = Interact2D.reproject2D3DWS(cam, fb, (int)firstX, (int)firstY).normalize();
Object[] res = world.calcMinDistanceAndObject3D(cam.getPosition(), dir, 10000 /*or whatever*/);

if (res[1] != null) {
    Object3D pickedObj = (Object3D)res[1];

    RigidBody box = (RigidBody)pickedObj.getUserObject();
    bodyList.remove(pickedObj.getUserObject());
    dynamicWorld.removeRigidBody(box);
    world.removeObject(pickedObj);
}
}
--- End code ---


Rotate

--- Code: ---public void pickChess() {
SimpleVector dir = Interact2D.reproject2D3DWS(cam, fb, (int)firstX, (int)firstY).normalize();
Object[] res = world.calcMinDistanceAndObject3D(cam.getPosition(), dir, 10000 /*or whatever*/);

if (res[1] != null) {
    Object3D pickedObj = (Object3D)res[1];

    pickedObj.rotateX(50);
}
}]
--- End code ---

 What happened? Thanks.

Gohome

EgonOlsen:
"Doesn't work" is a buit vague. What do you expect it to do and what does it do instead?

Gohome:
I want to drag or upside down the picked object. But now if I touch the object, nothing was happened.

Thomas.:
Look at the source code of physics example. You can move with any object by long touch. Is it what you want?

EgonOlsen:
Are you using enableLazyTransformations(). If so, then don't.

Navigation

[0] Message Index

[#] Next page

Go to full version