]> git.mxchange.org Git - simgear.git/blob - simgear/scene/model/custtrans.cxx
Small cleanups to the SGGeo[dc] classes, provide more hooks to use them directly
[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 void _ssgReadInt     ( FILE *fd,                int   *var );
9 void _ssgWriteInt    ( FILE *fd, const          int    var );
10 extern sgMat4 _ssgOpenGLAxisSwapMatrix;
11
12 void SGCustomTransform::copy_from( SGCustomTransform *src, int clone_flags )
13 {
14   ssgBranch::copy_from( src, clone_flags );
15   _callback = src->_callback;
16   _data = src->_data;
17 }
18
19 ssgBase *SGCustomTransform::clone( int clone_flags )
20 {
21   SGCustomTransform *b = new SGCustomTransform;
22   b -> copy_from( this, clone_flags );
23   return b;
24 }
25
26
27 SGCustomTransform::SGCustomTransform()
28  : _callback(0),_data(0)
29 {
30   type = ssgTypeBranch();
31 }
32
33 SGCustomTransform::~SGCustomTransform()
34 {
35 }
36
37 void SGCustomTransform::cull( sgFrustum *f, sgMat4 m, int test_needed )
38 {
39   if ( ! preTravTests( &test_needed, SSGTRAV_CULL ) )
40     return;
41
42   if ( _callback ) {
43     sgMat4 tmp;
44     _callback( tmp, f, m, _data );
45
46     _ssgPushMatrix( tmp );
47     glPushMatrix();
48     glLoadMatrixf( (float *) tmp );
49
50     for ( ssgEntity *e = getKid ( 0 ); e != NULL; e = getNextKid() )
51       e -> cull( f, tmp, test_needed );
52
53     glPopMatrix();
54     _ssgPopMatrix();
55   }
56   postTravTests( SSGTRAV_CULL );
57 }
58
59
60 const char *SGCustomTransform::getTypeName (void) { return "SGCustomTransform"; }