Sign in to follow this  
seblon

Transform object to exact pixel position on screen

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this