Sign in to follow this  
zaneski13

sphere vs isometric frustum collision

Recommended Posts

So I'm in the process of developing a 3D Isometric game in c++ and opengl. I'm currently working on the lighting system. Basicly I have a max number of lights that can be viewable at one time, but the level has no bounds of how many lights can exist. So I need to filter out the lights that are not viewable.

some valuable information:

EVERY LIGHT IN THE SCENE IS A POINT LIGHT, so a sphere...

The camera frustum is ISOMETRIC 3D. Its positioned about 30 feet above the character, and rotated 45degrees down X and 135 degrees Y (this may change)

I have a function implemented that casts rays from each corner of the screen. For each ray I calculate the x and z value when the y value is 0.
this is because the game is 2.5 D, no terrain to worry about. Ground is always at y = 0

So with these 4 points I can figure out how much of the level is in view (how many ground tiles i have to draw)

Each light has a 3D position and a radius.

Using that information, how can I figure out which lights in the level are visible at a given time?

Any help is appreciated. Thanks!

Share this post


Link to post
Share on other sites
Iterate the lights and test the center of each sphere against the six planes of the frustum, to determine if it is inside the frustum. If so, the light is visible. If not, iterate the planes of the frustum and find the point on each plane that is nearest the light. Calculate the distance between that point and the center of the sphere. If it is less than the radius of the sphere, then the light is visible.

Share this post


Link to post
Share on other sites
How would one go about finding the 4 planes of the isometric 3D camera? The 4 planes being left, right, top bottom. Dont really care about near and far because its a 2.5 D isometric game so lights wont be above the camera or below the floor.

The camera data I have access to in my engine is the position, rotation, modelview matrix, projection matrix.

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