Jump to content
  • Advertisement
Sign in to follow this  
seblon

Transform object to exact pixel position on screen

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

Hello,
how can i transform/pose an object pixel-exact on screen, for example for an UI-Interface?

I did that with "DeclarationUsage.PositionTransformed", so vertext-position is equal to screen-pixel-position. But the Problem with PositionTransformed is, i can't rotate the object.

Greetings

Share this post


Link to post
Share on other sites
Advertisement

If you're familiar with picking (selecting 3D objects with your mouse) you could go with a technique akin to that. You unproject your desired screen space coordinates to get a coordinate in world space where you can put your object so it remains in a fixed spot on the screen. You'll have to do this each frame if the camera is moving, but this way you can apply your desired rotation to the object and then translate it to this worldspace coordinate you obtained by unprojecting. This is probably only worth the hassle for real 3D models though (for example previewing an upgrade in your UI); for the 2D UI stuff it might be more useful to turn to sprites.

Share this post


Link to post
Share on other sites
Personally, I'd use an orthographic projection matrix for 2D items. Then you can specify the position of them in any coordinate system you like (E.g. (0, 0) to (width, height)).

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!