Jump to content
  • Advertisement
Sign in to follow this  
spiffycrony

3d to 2d

This topic is 4113 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

I have rendered a model using directx8 drawprimitive function as a list of triangles. These triangles are in 3d. I want to know the 2d equivalent of the triangle points at which they are drawn on the screen. How do i get the 2d equivalent(screen coordinates) of the 3d points?

Share this post


Link to post
Share on other sites
Advertisement
Edit: I got this all wrong first time.

You should project the vertices manually. The IDirect3DDevice9::ProcessVertices function may come in handy: it will pump a set of vertices through the current vertex shader (in software, I believe). If you're only interested in the positions of the transformed vertices under the FFP, then it may be faster and easier to project them using D3DXVec3Project or to take the direct route:

transformed_vertex = untransformed_vertex * world_matrix * view_matrix * projection_matrix * viewport_matrix.

If you are processing several vertices per frame, then you should calculate the matrix product first, then apply it to the list of untransformed vertices, so as to avoid unnecessary arithmetic.

Admiral

Share this post


Link to post
Share on other sites
You can use D3DXVec3Project to transform a 3D vertex coordinate to a screen coordinate. You just have to pass it the matrices you are using to render your scene.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!