Skip to main content
gamedev.net
🔒 Locked

Coordinate Transform problem?

Started by zho 1 reply 200+ views
Original Post
zho
zho
how to transfor 2d screen coordinate to 3d world coordinate? link function..P vector(x,y,z) = P(screenx,screeny)
fifty1
fifty1
If your using OpenGL look up gluProject() and gluUnProject(). You''ve gotta supply a screenz though, otherwise there is no unique solution.
Raptor
Raptor
D3DVECTOR ProcessScreenCoords(D3DVECTOR point)
{
D3DVECTOR out;
//to calculate Coordinate Location of Mesh
Temp = m_matWorld * m_matView;
Final = Temp * m_matProj;

XTemp = (Final._11 * point.x) + (Final._21 * point.y) + (Final._31 * point.z) + Final._41;
YTemp = (Final._12 * point.x) + (Final._22 * point.y) + (Final._32 * point.z) + Final._42;
ZTemp = (Final._13 * point.x) + (Final._23 * point.y) + (Final._33 * point.z) + Final._43;
WTemp = (Final._14 * point.x) + (Final._24 * point.y) + (Final._34 * point.z) + Final._44;

RW = fAspect / WTemp;
out.x = (1.0f + (XTemp * RW)) * scrWidth / 2.0f;
out.y = (1.0f - (YTemp * RW)) * scrHeight / 2.0f;
//out.z = ZTemp * RW;
out.z = ScreenW = WTemp;
return out;
}

hope this helps!

Edited by - raptor on October 2, 2000 1:40:54 PM

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.