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


3D to 2D problem

Recommended Posts

im doing a map editor where i have to convert a point from 3d to 2d screen-coordinates. i have 4 different views: x-view (2d-view along the x-axis), y-view (along the y-axis), z-view (along the z-axis) and a 3d-view, everything like in worldcraft. the default translation is -1000.0f on the z-axis(for zooming away or closer to the grid). i have 2 functions: Point2DTo3D (this already works, im using gluUnProject) and Point3DTo2D (this doesn''t work, im using gluProject). i checked the first function by converting the current mouse position (window-coords) to 3d coords and set a vertex at this location. every time i translated on the x,y or z-axis the 3d point was set on the correct position. to test the second function (point3dto2d) i just converted the 3d point back to 2d. if i translate on the x-axis the x and y window coords are correct, but if i translate on the y-axis the y window coord is totally wrong, why? do i do it correct: double wx,wy,wz; gluProject(x,y,0,modelview,projection,viewport,&wx,&wy,&wz); dont wonder about the zero, since im looking along the z-axis i dont care about this value. i think i have to do something with the y value before i call this function.

Share this post

Link to post
Share on other sites