### Author Topic: Using project3D2D & reproject2D3D  (Read 3126 times)

#### stormp

• byte
• Posts: 38
##### Using project3D2D & reproject2D3D
« on: July 18, 2007, 12:32:13 am »
Hi,

I'm trying to draw a line that is 25 pixels away based on a position in my 3D scene but reporject2D3D seems to be not working for me.

Code: [Select]
`vertex1 = new SimpleVector(centerX, topY, minZ);// Get the point in 3D space and convert to 2D screen space.point1  = Interact2D.project3D2D(theWorld.getCamera(), fb, vertex1);if(point1 != null)                    {   // Add 25 to the screen X and convert back to 3D world space.   vertex2 = Interact2D.reproject2D3D(theWorld.getCamera(), fb, (int)point1.x+25,  (int)point1.y, minZ);`
vertex2 gives me back odd results.

Am I using this right?

Thanks for all the help thus far.

S.

#### EgonOlsen

• Posts: 11899
##### Re: Using project3D2D & reproject2D3D
« Reply #1 on: July 18, 2007, 08:53:34 am »
Odd in which way? The coordinates are in camera space, not in world space. Maybe this causes the confusion? Anyway, i should document this better...

#### stormp

• byte
• Posts: 38
##### Re: Using project3D2D & reproject2D3D
« Reply #2 on: July 18, 2007, 09:10:28 am »
Odd in which way? The coordinates are in camera space, not in world space. Maybe this causes the confusion? Anyway, i should document this better...

odd as in the X and Y are in the 10000's in world space and reproject2D3D returns x=51 and y=27.

When you say camera space, does that mean distance from the cameras origin?  Would I just need to add the cameras position to that then to get the world space?

Thanks so much.

S.

#### EgonOlsen

• Posts: 11899
##### Re: Using project3D2D & reproject2D3D
« Reply #3 on: July 18, 2007, 10:07:04 am »
You have to apply the inverted camera matrix to the resulting vector and then apply the camera's translation (i.e. what getPosition() returns). That should transform the vector into world space.

#### stormp

• byte
• Posts: 38
##### Re: Using project3D2D & reproject2D3D
« Reply #4 on: July 18, 2007, 10:14:10 am »
thanks for your help! will give it a try.