Sign in to follow this  
Zaph-0

Object Position in 3D Space and Scaling

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
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

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