Estimating rendered model size given dist, radius and projection matrix

Started by
5 comments, last by Aken H Bosch 14 years, 6 months ago
Hi there, I need help figuring out how to estimate the rendered size of a model. I'll use the bounding sphere surrounding the model as an approximation. It has a 3-d vector for it's center position and a float representing the sphere's radius. I have a 3-d projection matrix computed using the standard FOV matrix computation, and I can compute the distance from the center of the model to the camera using: distToCamera = vector length (model center - camera center) Not sure how to estimate how large in screen space pixels the model will likely be rendered at? I have the z-near and z-far data handy as well. Any help or links to Google would be appreciated. Thanks!
Advertisement
Hi,
You probably want to give a look onto
gluProject
Thanks I actually want to estimate the size of the model after the projection so I can cull it if it's too small. I'm using DirectX and could use the alternative D3DXVec3Project() (or probably just vector-matrix multiply the center of the bounding sphere by the world-view-projection matrix myself), but I still don't understand how to figure out how big the transformed object will be?
You might be interested in this thread from a while ago.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Calculate a scissor rectangle from bounding box points projected to screen... And use width & height to determine what you need.

Okay, I can give you some code tomorrow, its for lights, but will work for models as well.
Thanks for the replies guys,

What I'm trying now is projecting the bounding sphere center and a point along the radius to screen space then subtracting the two vectors and taking their length and using that as the estimated screen space radius of the projected model.

EDIT: Worked great, will rate up all who replied thx!
Unless the object is particularly elongated (e.g. a needle), you can probably do this based on the radius of the object.

Then, your size (linear, not area) will always be:

k * radius / distance

where k is some constant of proporitionality, which would be a function of the projection. Figuring out the specifics for the constant is a bit more complicated, however.
Signature go here.

This topic is closed to new replies.

Advertisement