From: Kerry L. B. <ke...@vs...> - 2000-06-30 18:52:20
|
Hello Ben! I've done something similar w/ terrain and other objects. The way I link all the objects in my Java based scene graph is to have a class called Renderer which extends GLAnimCanvas and abstracts a rendering target. Within the overridden GLAnimCanvas.display() method I initiate a traversal of my scene graph, during which the Renderer object is passed to each object being rendered. Then, objects like terrain that need access to gl4Java call one of two helper methods on the Renderer object: public gl4java.GLFunc getGl() { return gl; } public gl4java.GLUFunc getGlu() { return glu; } This lets you write code like (forgive C++ proto syntax :) void Patch::render( Renderer renderer ) { gl4java.GLFunc gl = renderer.getGl(); ... gl.glBegin( gl.GL_TRIANGLES ); ... } Works great. I also recommend for terrain managing your own frustrum, so you can add this code or some equivalent: void Patch::render( Renderer renderer ) { Frustrum frustrum = renderer.getFrustrum(); if( !frustrum.intersects( this.bounds ) ) return; gl4java.GLFunc gl = renderer.getGl(); ... } CLOD is one case where you can't rely on GL tri culling if you are shooting for visible triangle targets link like in ROAM. At 04:31 PM 6/30/00 GMT, Ben Hesketh wrote: >Hi, > >I'm trying to port the LOD terrain rendering to Java using GL4Java. >I have a base class Terrain which deals with the whole landscape and then I >have a class called Patch which handles the level of detail and rendering >for a small section of the landscape. > >The landscape is stored in a binary tree with each leaf representing a final >triangle to be drawn. The renderer walks this tree and when it finds a leaf >node, it draws it. My problem is that Terrain (the top level class) is an >extension of GLAnimCanvas (so that it can be run in an applet) but I don't >know what to do with the Patch class. Should it extend GLFuncJNI? Or should >it extend something like GLContext? > >To see a 2D version at work (it'll probably give you a better idea) look at >http://thor.cam.ac.uk/~jbgh2 > >Thanks in advance, > >BEN >________________________________________________________________________ >Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com > > >_______________________________________________ >gl4java-usergroup mailing list >gl4...@li... >http://lists.sourceforge.net/mailman/listinfo/gl4java-usergroup > > |