Hi
I have some difficulties setting a child of a parent object when parent is rotated.
I have a custom sphere object class name TheSphere that extends Object3D and implements CollisionListener
with the following overridden functions..
public void collision(CollisionEvent collisionEvent) {
this.mPickedCoordinate = collisionEvent.getFirstContact();
}
@Override
public boolean requiresPolygonIDs() {
return true;
}
And from the Graphics thread I'm taking the value stored in this.mPickedCoordinate to add a Primitives.getCube() at that coordinate with the following code.
SimpleVector touchPoint = Interact2D.reproject2D3DWS(cam, fB, (int) x, (int) y);
float distance = theSphere.calcMinDistance(camPos, touchPoint, 1000);
SimpleVector pickedCoordinate = theSphere.mPickedCoordinate;
pickedCoordinate.sub(SimpleVector.create(theSphere.getPosX(), theSphere.getPosY(), theSphere.getPosZ()));
Object3D cube = Primitives.getCube(5f);
theSphere.addChild(cube);
cube.translate(pickedCoordinate);
world.addObject(cube);
So when I'm touching the sphere it places a cube at the right point, but if I rotate the sphere and touch it again then a new cube will be added to the rotated side and not where I've put my finger.
How can I add a cube to the point where I've touched the sphere even when the sphere has been rotated up or down side to side doesn't matter as long as it places the cube where my finger where.
getFirstContact will always return the (not) rotated point
I'm lost here, please help me.
Regards, M