]> git.mxchange.org Git - simgear.git/blob - simgear/scene/model/custtrans.cxx
Better encapsulation for personality
[simgear.git] / simgear / scene / model / custtrans.cxx
1 /*
2      $Id$
3 */
4
5 #include "custtrans.hxx"
6 void _ssgPushMatrix ( sgMat4 m );
7 void _ssgPopMatrix  ();
8
9 void SGCustomTransform::copy_from( SGCustomTransform *src, int clone_flags )
10 {
11   ssgBranch::copy_from( src, clone_flags );
12   _callback = src->_callback;
13   _data = src->_data;
14 }
15
16 ssgBase *SGCustomTransform::clone( int clone_flags )
17 {
18   SGCustomTransform *b = new SGCustomTransform;
19   b -> copy_from( this, clone_flags );
20   return b;
21 }
22
23
24 SGCustomTransform::SGCustomTransform()
25  : _callback(0),_data(0)
26 {
27   type = ssgTypeBranch();
28 }
29
30 SGCustomTransform::~SGCustomTransform()
31 {
32 }
33
34 void SGCustomTransform::cull( sgFrustum *f, sgMat4 m, int test_needed )
35 {
36   if ( ! preTravTests( &test_needed, SSGTRAV_CULL ) )
37     return;
38
39   if ( _callback ) {
40     sgMat4 tmp;
41     _callback( tmp, f, m, _data );
42
43     _ssgPushMatrix( tmp );
44     glPushMatrix();
45     glLoadMatrixf( (float *) tmp );
46
47     for ( ssgEntity *e = getKid ( 0 ); e != NULL; e = getNextKid() )
48       e -> cull( f, tmp, test_needed );
49
50     glPopMatrix();
51     _ssgPopMatrix();
52   }
53   postTravTests( SSGTRAV_CULL );
54 }
55
56
57 const char *SGCustomTransform::getTypeName (void) { return "SGCustomTransform"; }