Archived

This topic is now archived and is closed to further replies.

Vector unprojection produces funny stuff

Recommended Posts

Christoph    122
Hi there, I simply want to know the screen coordinates of a 3D-vector (the sun for lens flares...). I am using the Vector3.Unproject function (yes, it's managed DirectX...).

d3dDev.Transform.World = Matrix.Identity

Dim v As New Viewport
v.Width = d3dDev.PresentationParameters.BackBufferWidth '1024
v.Height = d3dDev.PresentationParameters.BackBufferHeight '768
v.MaxZ = 1

r_Vector.Unproject(vec, v, engine.d3dDev.Transform.Projection, engine.d3dDev.Transform.View, engine.d3dDev.Transform.World)

However, the result is weird and unlogical. For testing, I just took the vector (0,0,0), but at the starting point, when the camera is looking directly at this point, the unprojection is not (512|384|0) (the center of the screen), but (0|0|0). Only when the camera changes its position, the values are changing as well, but they don't represent screen coordinates... Can somebody please tell me how I really receive screen coordinates from a vector? [edited by - Christoph on May 25, 2004 2:56:12 PM]

Share on other sites
Christoph    122
Sorry guys,
I mixed up unproject and project...
Now it works :-)