Some D3D Questions

Started by
3 comments, last by CMN 23 years, 10 months ago
I have just recentrly started coding with Direct 3D (7) and there are some things that i would appreciate if someone filled me in on. 1. I know that a 3d-point can be projected to 2d by using the formula X=x/z and Y=y/z (and then scaling with width and height of the viewport). I have been thinking a lot about this and I''m pretty sure that those formulas are used in the Direct 3D pipeline somewhere, if that''s the case, where? 2. How can i use orthogal projection in D3D, and just saying "use the functions D3DXSetOrthogalProjectionMatrix (or whatever) won''t do as an answer! (but pointing me to an URL that explains the concept will) 3. I''m working on a level editor and i''m using four different viewports, with different cameras (like in any 3D-editing program). Everything works fine except that no clipping is performed for the left and right edges of the viewports. Is this normal? Thanks in advance. /Carl-Magnus Nordin
Advertisement
Well i can tell u how to get the 2d coords of a 3d Point,heres how u do it -


//to calculate Coordinate Location of Mesh
Temp = m_matWorld * m_matView;
Final = Temp * m_matProj;
XTemp = (Final._11 * vLoc.x) + (Final._21 * vLoc.y) + (Final._31 * vLoc.z) + Final._41;
YTemp = (Final._12 * vLoc.x) + (Final._22 * vLoc.y) + (Final._32 * vLoc.z) + Final._42;
ZTemp = (Final._13 * vLoc.x) + (Final._23 * vLoc.y) + (Final._33 * vLoc.z) + Final._43;
WTemp = (Final._14 * vLoc.x) + (Final._24 * vLoc.y) + (Final._34 * vLoc.z) + Final._44;

RW = 1.0f / WTemp;
ScreenX = (1.0f + (XTemp * RW)) * 640 / 2.0f;
ScreenY = (1.0f - (YTemp * RW)) * 480 / 2.0f;
ScreenZ = ZTemp * RW;
ScreenW = WTemp;

this worx for a scr res of 640x480
if u have any problems contact me at sandeep_kl@mailcity.com

Sandeep.K.L





The only way around it is Through it!!
Thanks, but what I really wanted to know was if Direct 3D is using X=x/z and Y=y/z somehwere in the pipeline before the selected Projection Matrix is applied.

But I understand how that works now, so never mind...

But I still want to know how orthogal projection works, anyone? Please?

/Carl-Magnus Nordin

Edited by - CMN on June 13, 2000 10:10:49 AM
I guess u can check out the tutorials at the foll website -
http://www.mr-gamemaker.co.uk/

here are some really cool tutorials like object picking with the mouse etc.

another neat site - www.flipcode.com

Sandeep


The only way around it is Through it!!
Thanks!

This topic is closed to new replies.

Advertisement