00001
00002
00003
00004
00005 #include "custtrans.hxx"
00006 void _ssgPushMatrix ( sgMat4 m );
00007 void _ssgPopMatrix ();
00008
00009 void SGCustomTransform::copy_from( SGCustomTransform *src, int clone_flags )
00010 {
00011 ssgBranch::copy_from( src, clone_flags );
00012 _callback = src->_callback;
00013 _data = src->_data;
00014 }
00015
00016 ssgBase *SGCustomTransform::clone( int clone_flags )
00017 {
00018 SGCustomTransform *b = new SGCustomTransform;
00019 b -> copy_from( this, clone_flags );
00020 return b;
00021 }
00022
00023
00024 SGCustomTransform::SGCustomTransform()
00025 : _callback(0),_data(0)
00026 {
00027 type = ssgTypeBranch();
00028 }
00029
00030 SGCustomTransform::~SGCustomTransform()
00031 {
00032 }
00033
00034 void SGCustomTransform::cull( sgFrustum *f, sgMat4 m, int test_needed )
00035 {
00036 if ( ! preTravTests( &test_needed, SSGTRAV_CULL ) )
00037 return;
00038
00039 if ( _callback ) {
00040 sgMat4 tmp;
00041 _callback( tmp, f, m, _data );
00042
00043 _ssgPushMatrix( tmp );
00044 glPushMatrix();
00045 glLoadMatrixf( (float *) tmp );
00046
00047 for ( ssgEntity *e = getKid ( 0 ); e != NULL; e = getNextKid() )
00048 e -> cull( f, tmp, test_needed );
00049
00050 glPopMatrix();
00051 _ssgPopMatrix();
00052 }
00053 postTravTests( SSGTRAV_CULL );
00054 }
00055
00056
00057 const char *SGCustomTransform::getTypeName (void) { return "SGCustomTransform"; }