Hi,
I want to make an interface such that user can click to select an object and then again click to place it somewhere else. I have already built it and it works fine with existing geometries (boxes) and models imported as objs. However when I try it on a model imported as Orge XML, only part of object gets transformed. This is because the object seems to have made of more than one geometry with different names. When the user selects the object only a part of object gets selected and when he clicks somewhere, only that part moves. How to move the entire object at once.
I have made the model in google sketchup and exported as Orge XML.
Here is the pick/ place code I’m using
[java] CollisionResult closest = results.getClosestCollision();
// Code to pick an object (if its in shootables)
Spatial shot = closest.getGeometry();
// Some useful log for debugging at this point
//System.out.println("\n" + "SIMAR" + "\n");
//System.out.println(shot.getParent().getName());
//System.out.println(shot.getParent().getParent().getName());
// Some objects have material, so we need to check parent and parent of parent
if ("Shootables".equals(shot.getParent().getName()) || "Shootables".equals(shot.getParent().getParent().getName())) {
// some shootable has been clicked
if (picked == null) {
picked = shot;
shootables.detachChild(picked);
rootNode.getLocalLightList().get(0).setColor(ColorRGBA.Red);
}
}
else
{
if (picked!=null)
{
Vector3f newLoc;
float height;
height = ((BoundingBox)picked.getWorldBound()).getXExtent();
newLoc = closest.getContactPoint().addLocal(0,height,0);
picked.setLocalTranslation(newLoc);
shootables.attachChild(picked);
picked = null;
rootNode.getLocalLightList().get(0).setColor(ColorRGBA.White);
//System.out.println("SIMAR\n\n\n" + cam.getLocation() + " " + newLoc);
}
} [/java]