Hello, I try to place an object that has well over a sphere! but I grew a problem of roatation: / because this one does not go “right”
a picture to illustrate
and my code :
[java] rootNode.attachChild(teapot);
CollisionResults results = new CollisionResults();
Vector2f click2d = inputManager.getCursorPosition();
Vector3f click3d = cam.getWorldCoordinates(new Vector2f(click2d.x, click2d.y), 0f);
dir = cam.getWorldCoordinates(new Vector2f(click2d.x, click2d.y), 1f).subtract(click3d).normalizeLocal();
ray = new Ray(click3d, dir);
rootNode.collideWith(ray, results);
if (results.size() > 0){
if(results.getClosestCollision().getGeometry().getParent().getClass().equals(Planet.class)){
CollisionResult closest = results.getClosestCollision();
System.out.println(results.getClosestCollision().getGeometry().getWorldTranslation());
teapot.setLocalTranslation(closest.getContactPoint());
teapot.lookAt(results.getClosestCollision().getGeometry().getWorldTranslation(),Vector3f.ZERO);
Quaternion roll45=new Quaternion();
roll45.fromAngleAxis(FastMath.HALF_PI,Vector3f.UNIT_Y);
//teapot.getLocalRotation().mult(roll45);
Quaternion b= roll45.mult(teapot.getLocalRotation());
// teapot.setLocalRotation(roll45);
//teapot.rotate(b);
Quaternion roll44=new Quaternion();
roll44.fromAngleAxis(-FastMath.HALF_PI,Vector3f.UNIT_X);
//teapot.getLocalRotation().mult(roll45);
Quaternion c= roll44.mult(teapot.getLocalRotation());
// teapot.setLocalRotation©;
}
}
[/java]
help
