Jump to content
  • Advertisement
Sign in to follow this  
G-Man9566

[DX9 - Solved] Object to be constant size relative to screen

This topic is 3119 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 want to render/draw an object to be the same size relative to the screen, no matter how far away or close to the object I am. How can I do that? I believe that it will have someting to do with the way i set the world, view and projection matrix for that object when drawing it. [Edited by - G-Man9566 on March 9, 2010 11:17:06 PM]

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Adam_42
Using an orthographic projection matrix will give you that effect.


ok, so i can do that even with the rest of my scene being draw as normal perspective?

Share this post


Link to post
Share on other sites
What are you drawing, exactly? If you use a perspective transform and an orthographic transform, the Z-buffer values will be meaningless - so you'll need to disable the Z-buffer for one object type (Probably the orthographic one).

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
What are you drawing, exactly?


Im drawing move and rotate gizmos, so that the user can move the object around in the scene. i want the gizmos to be the same size relative to the screen, as 3ds max does it, for instance.

is there another or better way of doing this that drawing the gizmo orthographically?

[Edited by - G-Man9566 on March 9, 2010 4:26:13 AM]

Share this post


Link to post
Share on other sites
I would probably try to resize the object based on its distance to the camera. Both sounds like an easy operation to do (get the distance, resize), but I cannot guarantee the result, I haven't tried it.

Share this post


Link to post
Share on other sites
If you're just drawing a gizmo, you don't need the Z-buffer at all - back-facing triangles will be culled anyway, and you won't really have any overlapping meshes.

Share this post


Link to post
Share on other sites
Ok, so using a orthographic matrix to render the gizmo works nicely to keep it at a constant size relative to the screen.

The problem I have now is that the gizmo is not render at the center of the object that I want to move, as it did before. If I render it with the perspective matrix, it sits nicely at the center of the object, but when I use the ortho, it moves around as I look around.

When I look straight at the object, the gizmo is positioned at its center but as I look away the gizmo also "moves" away but is not positioned at the center of the object anymore or the viewport.

Share this post


Link to post
Share on other sites
Apply a translation matrix to your gizmo with center point values of the object in question.

Share this post


Link to post
Share on other sites
Quote:
Original post by ddlox
Apply a translation matrix to your gizmo with center point values of the object in question.


Well, i have done that, otherwise it would not have rendered correctly using the Perspective matrix and it does render in the correct position when I use the Perspective matrix, but when I use the Ortographic matrix it only renders in the correct position when the object is in the center of my viewport.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!