Author Topic: Camera position object3D position mismatching  (Read 3729 times)

Offline Tornado7

  • byte
  • *
  • Posts: 45
    • View Profile
Camera position object3D position mismatching
« on: June 14, 2004, 05:51:01 pm »
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:

Code: [Select]

if (event.getButton()==MouseEvent.BUTTON3) {

then Iíve created a function that creates and places the object using the cameraís coordinates:

Code: [Select]

public void loadFerito(String name, float x, float y, float z){
      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.translate (x, y+109, z);
      ferito1.setRotationMatrix(new Matrix());


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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12291
    • View Profile
Camera position object3D position mismatching
« Reply #1 on: June 14, 2004, 06:20:04 pm »
There are some places in your code where things can go wrong. The first thing is: Are you actually calling build() on your loaded object somewhere? Are you adding it to the world? (Obviously you do, because you couldn't even see it's just that i can't spot that place in your code). Anyway, you are rotating the mesh. If you do this without calling build() before, your rotation pivot could be wrong. It will be placed at the origin, which may be correct but it doesn't have to. It depends on your model, so try to call build() before doing this or check if a rotation pivot at the origin is really what you want.
If it still doesn't work, try to figure out in which way your cam's position and the one of the object differ. Maybe that will help to see what's wrong here.

Offline Tornado7

  • byte
  • *
  • Posts: 45
    • View Profile
Camera position object3D position mismatching
« Reply #2 on: June 16, 2004, 09:53:46 am »
Itís a problem related to the position of the obj in Mayaís world coordinates: placing the obj in the center on the Mayaís coordinates (0,0,0), it behaves correctly in jPCTís world.

Bye and thanks again.