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