Jump to content
  • Advertisement
Sign in to follow this  
Zaph-0

Object Position in 3D Space and Scaling

This topic is 3194 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 have a little Problem and hope anyone of you can help me with this. I have 2 identical transparent objects in 3D space. From the Camera object one (lets call it A) is behind the other one (lets call this one B). Obviously A looks smaller as it is further away. And on screen it looks as if they are centered around the same point, which of course they aren't in 3D space but only because of the conversion to 2D and the current camera position. My problem now is that I need to increase the scale of object A so that the they match each other on screen. In 3D space object A would be much bigger than object B but because B is closer they would look the same. Kind of complicated but I can't really figure the math out as to how to scale object A based on its distance to B. I would really appreciate some help with this. Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
I have to make some assumptions about what you know about your objects. Assume you know the radii of object A and object B and you know the distances from the camera to each object. From your description, it sounds like you want to know how to scale the radius of Object A such that it appears to be the same size as object B from the camera's point of view.

Assume:
float A = radius of Object A
float B = radius of Object B
float C = distance to Object A from the camera
float D = distance to Object B from the camera

Calculate float E = B * C/D;
scale S = E/A;

That is, the new radius of object A when scaled = A*S = E.

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!