[Plib-devel] ssgBranch with pre and post draw callbacks
Brought to you by:
sjbaker
From: Eric E. <Eri...@fr...> - 2000-08-30 18:45:56
|
Hello, I have a small modification to submit for plib-ssg. This consists in allowing the call of the pre and post draw callbacks for branches and not only for leaves. I use this in TORCS to modify parameters not managed by ssgSimpleState, but from an object point of vue, because when an object is loaded from a modeler, it is painful to traverse the sub-tree for adding redundant pre and post callbacks to all the leaves. Here are the modifications: file ssgBranch.cxx: void ssgBranch::cull ( sgFrustum *f, sgMat4 m, int test_needed ) { int cull_result = cull_test ( f, m, test_needed ) ; if ( cull_result == SSG_OUTSIDE ) return ; for ( ssgEntity *e = getKid ( 0 ) ; e != NULL ; e = getNextKid() ) e -> cull ( f, m, cull_result != SSG_INSIDE ) ; } becomes: void ssgBranch::cull ( sgFrustum *f, sgMat4 m, int test_needed ) { int cull_result = cull_test ( f, m, test_needed ) ; if ( cull_result == SSG_OUTSIDE ) return ; if ( preDrawCB != NULL && ! (*preDrawCB)(this) ) return ; for ( ssgEntity *e = getKid ( 0 ) ; e != NULL ; e = getNextKid() ) e -> cull ( f, m, cull_result != SSG_INSIDE ) ; if ( postDrawCB != NULL ) (*postDrawCB)(this) ; } For the current version I use a derived version of ssgBranch to manage the GL_TEXTURE_GEN_[ST] states for env mapping and the glTexEnvf calls to display the textures in different manners. Eric. -- =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= TORCS The Open Racing Car Simulator http://torcs.org =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= |