2
\$\begingroup\$

How can I calculate or get the farthest X-Value of a Viewport during gameplay?

Say a model is moving in from the right-hand side (beyond Viewport) and starting from a certain X-Value it is visible on the viewport. I'd like get that certain X-Value.

But the more I zoom out (Z-Axis) the greater the farthest visible X gets (Max X). How could I approach this?

\$\endgroup\$
1
  • \$\begingroup\$ For a perspective 3D viewport, you also need to consider Z of the model. Or rather, max X is a function of Z. \$\endgroup\$ Commented Jun 6, 2013 at 1:41

1 Answer 1

1
\$\begingroup\$

What you probably want to use is the BoundingFrustum class (MSDN).

A bounding frustum gives you a volume shaped like this:

Bounding Frustum

A bounding frustum created with your projection matrix will contain the volume you are interested in. You can then use the various Intersects or Contains overloads to test against various shapes (BoundingBox and BoundingSphere) that you can use to approximate the volume of your 3D model for culling purposes.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .