Hi
I’ve read somewhere several times actually on the Internet hints on that the BoundingFrustum isn’t or wasn’t working.
I’m having trouble with it myself when I’m trying to find out what 3D sphere is within the camera’s view and which one is not.
First I made a BoundingSphere for the sphere/planets I’m having all over the 3D space, creating it like.
BoundingSphere bs = new BoundingSphere(planetsTranslatedPosition, 100);
And I’m updating the cameras viewMatrix in the Update() of the application.
I have a projectionMatrix created on startup like
float viewAngle = MathHelper.PiOver4;
float aspectRatio = graphics.GraphicsDevice.Viewport.AspectRatio;
float nearPlane = 0.5f;
float farPlane = 6000.0f;
// Create the view with it's frustum (the camera lens)
projectionMatrix = Matrix.CreatePerspectiveFieldOfView(viewAngle, aspectRatio,
nearPlane, farPlane);
And I’m checking if the objects are within by the use of
if (this.cameraFrustum.Contains(pl.getPlanetsBoundingSphere()) != ContainmentType.Disjoint)
{
// pl = is the planet/sphere's BoundingSphere
// Drawing my objects here
}
The viewMatrix and the ProjectionMatrix are working, I’m using them all over without any problems, and the planets BoundingSpheres are created with the same translations as the ones used to place them in space.
Can’t see why it shouldn’t work then, except if there is still something wrong with the BoundingFrustum??
Some of the planets are visible and some are not depending on where they are located, but some of the not visible should be visible but are not. And if I rotate the camera around the pop in and pop out like crazy.
I’ve also tried to break the thing apart to the easiest little thing but got the same results!
Someone who knows?
Or, maybe can give me a hint of what I could be doing wrong here.
Thanks in advance
Kind Regards, Morgan