• Advertisement
Sign in to follow this  

Screen point from model space

This topic is 3859 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 can I achieve the screen point of a model? For example i want to determine the center of my mesh on the screen(monitor) after pipeline transformation. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
What you want to do is transform the point by the model-view-projection matrix to get it into clip-space. Then you apply the viewport transformation to get it into client coordinates for your window. From there you'd use Win32 functions (such as GetWindowRect) to determine the location in absolute window space, or even absolute desktop space.

You have to apply the first two transformations yourself, so you need to have those matrices available either by grabbing them from DX (if you can) or generating them yourself.

Share this post


Link to post
Share on other sites
NOTE: I tried to reply several hours ago, but the blessed HTTP-500's thought better of that...[rolleyes]
It would help to understand the pipeline steps involved in transformation. These are all described in the help files as well as any good computer graphics textbook - the knowledge will serve you well going forwards [smile]

The order is:

Model -> World -> View -> Projection -> Viewport

So you simply transform your mesh coordinate by the 4 transformations (indicated by the ->'s).

Look up D3DXVec3Project() if you need a helping hand with the maths [wink]

hth
Jack

Share this post


Link to post
Share on other sites
I think I found it!

Vector3.Project Method

public void Project(
object viewport,
Matrix projection,
Matrix view,
Matrix world
);

Share this post


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

  • Advertisement