Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (407)
games submitted by our members
Games in WIP (293)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Java Game APIs & Engines / OpenGL Development / Re: Trouble with frustum culling (Video included) on: 2012-02-13 16:54:09
Cool. Fitting the frustum to the bounding box of the objects seems to have worked well Smiley

http://screencast.com/t/jzyBQ8Fx

Thanks

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
   matrix = this.camera.getTransform();
   matrix.multiplyMatrix(Matrix4.createRotationX(this.planeRotation.x));
   matrix.multiplyMatrix(Matrix4.createRotationY(this.planeRotation.y));
   
   boundingBox = this.createBoundingBox(this.things, matrix);
   
   originalSettings = {left: -1.0, right: 1.0, top: 1.0, bottom: -1.0, near: 5.0};
   newSettings = {};

   angle = Math.atan(originalSettings.right / originalSettings.near);
   
   buffer = 1.0;
   
   newSettings.near   = Math.max(-boundingBox.maxCoords.z, 2.0) - buffer;
   newSettings.far    = Math.max(-boundingBox.minCoords.z, 2.0) + buffer;
   newSettings.left   = -newSettings.near * Math.tan(angle);
   newSettings.right  = newSettings.near * Math.tan(angle);
   newSettings.bottom = -newSettings.near * Math.tan(angle);
   newSettings.top    = newSettings.near * Math.tan(angle);
   
   aspectRatio = this.glViewportWidth / this.glViewportHeight;
   
   if (aspectRatio > 1.0) {
      newSettings.left *= aspectRatio;
      newSettings.right *= aspectRatio;
   } else {
      newSettings.bottom /= aspectRatio;
      newSettings.top /= aspectRatio;
   }
   
   this.frustum.near   = newSettings.near;
   this.frustum.far    = newSettings.far;
   this.frustum.left   = newSettings.left;
   this.frustum.right  = newSettings.right;
   this.frustum.bottom = newSettings.bottom;
   this.frustum.top    = newSettings.top;
2  Java Game APIs & Engines / OpenGL Development / Trouble with frustum culling (Video included) on: 2012-02-13 11:36:57
Hello Smiley

(I did already post this at OpenGL.org, but since I know there are some OpenGL genii here, I thought I would ask you guys. I hope it's not too offensive Smiley)

I'm working on an OpenGL application and I'm having trouble with my objects being clipped undesirably by frustum culling

The scene consists of a number of objects on an invisible plane. You can pan around by left clicking and dragging on the invisible plane (This does not translate the plane, it translates the camera). You can rotate the invisible plane by right clicking and dragging (This rotates the plane).

The problem comes when you rotate the plane and then pan so that the objects pass through the far plane of the frustum.

I would like my objects to never get clipped, no matter how far back you push them.

I'm currently using a constant frustum defined by

frustum.left = -1.0;
frustum.right = 1.0;
frustum.top = 1.0;
frustum.bottom = -1.0;
frustum.near = 5.0;
frustum.far = 500.0;

but I was thinking perhaps I could update the projection matrix and frustum every frame, ensuring that the near plane touches the front of the bounding box of my objects and the far plane touches the back of the bounding box of my objects.

Does anyone have any advice which could help me get rid of this unwanted clipping?

Please see accompanying video which visually describes the problem here: http://screencast.com/t/0L4oS1t9T

Thanks
Pages: [1]
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Browse for soundtracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (100 views)
2013-05-17 21:29:12

alaslipknot (108 views)
2013-05-16 21:24:48

gouessej (138 views)
2013-05-16 00:53:38

gouessej (133 views)
2013-05-16 00:17:58

theagentd (145 views)
2013-05-15 15:01:13

theagentd (131 views)
2013-05-15 15:00:54

StreetDoggy (174 views)
2013-05-14 15:56:26

kutucuk (196 views)
2013-05-12 17:10:36

kutucuk (198 views)
2013-05-12 15:36:09

UnluckyDevil (204 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!
Page created in 0.172 seconds with 21 queries.