Hi Egon,
I’ve to implement the following capability: I need to place some objects in the world using custom coordinate. So, for decide where place objects I’ve to move myself in the world (by the camera) and, where I decide to place an object, pressing the right click, my applet has to pass the camera’s coordinate to a html page. I’ve created this feature in this way:
if (event.getButton()==MouseEvent.BUTTON3) {
cameraPosition=camera.getPosition();
cameraX=(int)cameraPosition.x;
cameraY=(int)cameraPosition.y;
cameraZ=(int)cameraPosition.z;
clicked=true;
rightClick=true;
}
then I’ve created a function that creates and places the object using the camera’s coordinates:
public void loadFerito(String name, float x, float y, float z){
texMan=TextureManager.getInstance();
texMan.addTexture(name+".jpg",new Texture(getDocumentBase(),"textures/feriti/"+name+".jpg"));
Object3D[] ferito1Array=Loader.load3DS(getDocumentBase(),"3ds/"+name+".3ds", 20f);
ferito1=new Object3D(0);
ferito1=ferito1Array[0];
ferito1.setCenter(SimpleVector.ORIGIN);
ferito1.translate (x, y+109, z);
ferito1.rotateX((float)-Math.PI/2);
ferito1.rotateMesh();
ferito1.setRotationMatrix(new Matrix());
ferito1.createTriangleStrips(2);
ferito1.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
ferito1.setCollisionOptimization(Object3D.COLLISION_DETECTION_OPTIMIZED);
ferito1.enableLazyTransformations();
}
My problem is that the object in placed in a different position compared to the camera position where I’ve taken the camera’s coordinates. I guess the resulting camera’s coordinates don’t match the object coordinates method. Exist a way to make a matching?
Bye and thanks