Sign in to follow this  
redeemer91

Keeping the size of an object the same

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

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