jPCT - a 3d engine for Java > Support

Interact2D

(1/2) > >>

AGP:
I'm trying to make a little level editor. Right now, all it will do is to allow you to position some enemies by clicking on the 3d map. I'm not very interested in the y coordinate, because they will place themselves relative to the floor's height). But the following code always places the enemiies in the same (marked) spot:
https://www.dropbox.com/s/r73iukqn0wdtcjs/LE.jpg?dl=0


--- Code: ---     public void mouseClicked(MouseEvent e) {
Point p = e.getPoint();
SimpleVector p3d = Interact2D.reproject2D3DWS(camera, buffer, p.x, p.y);
System.out.println("p3d: "+p3d);
p3d.y = -2000f;
objects[numberOfObjects++] = Primitives.getCube(100f);
objects[numberOfObjects-1].build();
objects[numberOfObjects-1].translate(p3d);
theWorld.addObject(objects[numberOfObjects-1]);
     }

--- End code ---

EgonOlsen:
That method assumes the z coordinate to be 1. I don't think that's what you want here. Either set it to the proper value or use the resulting vector as a direction vector and calculate the intersection point with the ground plane in some other way.

AGP:
I have x and y in screen coordinates, so about which z are you talking? And could you show me a snippet?

EgonOlsen:
The z is the depth of your plane in 3d.

AGP:
I don't need the height in wordspace. Only the x and the z.

Navigation

[0] Message Index

[#] Next page

Go to full version