Jump to content
  • Advertisement
Sign in to follow this  
redeemer91

Keeping the size of an object the same

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

Hi, I'm trying to keep the size of an object the same, regardless of it's distance from a perceptive camera. I have all the details for the perspective camera like horizontal+vertical FOV's position of the object and camera, but I just can't seem to come up with a solution. Any ideas? - Sid

Share this post


Link to post
Share on other sites
Advertisement
Is using orthographic projection an option? If it is, that should solve your problem.

Share this post


Link to post
Share on other sites
I would have taken that route, but I'd like this object to go in to the Z buffer and test against the same. Also the position of the object will be given with respect to other 3D objects, so it needs to stay in the same position in the world when I rotate and move the camera.

Share this post


Link to post
Share on other sites
After going back to the basics, and breaking them down, I got a solution to the problem. Here is what needs to be done...

Pos = WorldPos of object x,y,z,w (Set w=1)
W2VMat = View Matrix * Projection Matrix (World Mat to View Mat)

Now do Pos = W2VMat*Pos

Pos.w now contains the amount that you need to scale the object by so that it's size remains the same.

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!