Archived

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

using D3DTLVERTEX

This topic is 6390 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do I use D3DTLVERTEX? I have the coordintes in world space how do I convert them to screen space? (if that is the space that D3DTLVERTEX is saved in?

Share this post


Link to post
Share on other sites
The D3DTLvertex, is just that, TL stands for translated and lit, meaning that when rendering using this data type you give the coords in screen space and you don''t bother with external lighting. This type is particularly useful for 3d tile engines or specific regions of the screen which you want to cover.

If you have world coordinates just use the D3DLVERTEXT which is a lit vertex in world space. When you render this type D3D will automatically convert them to screen coords.

Share this post


Link to post
Share on other sites
iwasbiggs: Actually, it''s Transformed and Lit.

zohare: I can give you pseudo code....

tmat = worldmatrix * viewmatrix * projectionmatrix

px = tmat.m11 * InputX + tmat.m21 * InputY + tmat.m31 * InputZ + tmat.m41
py = tmat.m12 * InputX + tmat.m22 * InputY + tmat.m32 * InputZ + tmat.m42
pz = tmat.m13 * InputX + tmat.m23 * InputY + tmat.m33 * InputZ + tmat.m43
pw = tmat.m14 * InputX + tmat.m24 * InputY + tmat.m34 * InputZ + tmat.m44

After that, you convert to screen space. This is what I THINK it is. Someone correct me if I''m wrong

vert.x = (xp/pw) * (window.width *.5)
vert.y = (yp/pw) * (window.height *.5)
vert.z = (zp/pw)
vert.rhw = pw

That SHOULD be it. I don''t have access to the sdk right now so if someone could correct me, it would be very nice.

------------------------
Captured Reality.

Share this post


Link to post
Share on other sites
Correct me if I''m wrong, but when I use D3DTLVERTEX the projection matrix will not determine how large the object would seem, because the engine will not do any further transformations on the vertices ????

Share this post


Link to post
Share on other sites
quote:
Original post by zohare

Correct me if I''m wrong, but when I use D3DTLVERTEX the projection matrix will not determine how large the object would seem, because the engine will not do any further transformations on the vertices ????


Yep, those vertex types are already scaled to screen coords so it won''t even use matrices.

Transformed, translated same diff

Share this post


Link to post
Share on other sites
I think that there''s something wrong with this code and my guess is that it is in this part:

vert.x = (px/pw) * (window.width *.5)
vert.y = (py/pw) * (window.height *.5)
vert.z = (pz/pw)
vert.rhw = pw


Share this post


Link to post
Share on other sites