1 /*
2      PLIB - A Suite of Portable Game Libraries
3      Copyright (C) 1998,2002  Steve Baker
4 
5      This library is free software; you can redistribute it and/or
6      modify it under the terms of the GNU Library General Public
7      License as published by the Free Software Foundation; either
8      version 2 of the License, or (at your option) any later version.
9 
10      This library is distributed in the hope that it will be useful,
11      but WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13      Library General Public License for more details.
14 
15      You should have received a copy of the GNU Library General Public
16      License along with this library; if not, write to the Free Software
17      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18 
19      For further information visit http://plib.sourceforge.net
20 
21      $Id: ssgTexTrans.cxx 1568 2002-09-02 06:05:49Z sjbaker $
22 */
23 
24 
25 #include "ssgLocal.h"
26 
copy_from(ssgTexTrans * src,int clone_flags)27 void ssgTexTrans::copy_from ( ssgTexTrans *src, int clone_flags )
28 {
29   ssgBaseTransform::copy_from ( src, clone_flags ) ;
30 }
31 
clone(int clone_flags)32 ssgBase *ssgTexTrans::clone ( int clone_flags )
33 {
34   ssgTexTrans *b = new ssgTexTrans ;
35   b -> copy_from ( this, clone_flags ) ;
36   return b ;
37 }
38 
39 
ssgTexTrans(sgCoord * c)40 ssgTexTrans::ssgTexTrans ( sgCoord *c )
41 {
42   type = ssgTypeTexTrans () ;
43   setTransform ( c ) ;
44 }
45 
ssgTexTrans(void)46 ssgTexTrans::ssgTexTrans (void)
47 {
48   type = ssgTypeTexTrans () ;
49 }
50 
~ssgTexTrans(void)51 ssgTexTrans::~ssgTexTrans (void)
52 {
53 }
54 
setTransform(sgVec3 xyz)55 void ssgTexTrans::setTransform ( sgVec3 xyz )
56 {
57   sgMakeTransMat4 ( transform, xyz ) ;
58 }
59 
setTransform(sgCoord * xform,float sx,float sy,float sz)60 void ssgTexTrans::setTransform ( sgCoord *xform, float sx, float sy, float sz  )
61 {
62   sgMakeCoordMat4 ( transform, xform ) ;
63   sgScaleVec3 ( transform[0], sx ) ;
64   sgScaleVec3 ( transform[1], sy ) ;
65   sgScaleVec3 ( transform[2], sz ) ;
66 }
67 
setTransform(sgCoord * xform)68 void ssgTexTrans::setTransform ( sgCoord *xform )
69 {
70   sgMakeCoordMat4 ( transform, xform ) ;
71 }
72 
setTransform(sgMat4 xform)73 void ssgTexTrans::setTransform ( sgMat4 xform )
74 {
75   sgCopyMat4 ( transform, xform ) ;
76 }
77 
cull(sgFrustum * f,sgMat4 m,int test_needed)78 void ssgTexTrans::cull ( sgFrustum *f, sgMat4 m, int test_needed )
79 {
80   if ( ! preTravTests ( &test_needed, SSGTRAV_CULL ) )
81     return ;
82 
83   int cull_result = cull_test ( f, m, test_needed ) ;
84 
85   if ( cull_result == SSG_OUTSIDE )
86     return ;
87 
88   _ssgLoadTexMatrix ( transform ) ;
89   glMatrixMode ( GL_TEXTURE ) ;
90   glLoadMatrixf ( (float *) transform ) ;
91   glMatrixMode ( GL_MODELVIEW ) ;
92 
93   for ( ssgEntity *e = getKid ( 0 ) ; e != NULL ; e = getNextKid() )
94     e -> cull ( f, m, cull_result != SSG_INSIDE ) ;
95 
96   glMatrixMode ( GL_TEXTURE ) ;
97   glLoadIdentity () ;
98   glMatrixMode ( GL_MODELVIEW ) ;
99   _ssgUnloadTexMatrix () ;
100 
101   postTravTests ( SSGTRAV_CULL ) ;
102 }
103 
104 
105 
load(FILE * fd)106 int ssgTexTrans::load ( FILE *fd )
107 {
108   return ssgBaseTransform::load(fd) ;
109 }
110 
save(FILE * fd)111 int ssgTexTrans::save ( FILE *fd )
112 {
113   return ssgBaseTransform::save(fd) ;
114 }
115 
116 
117 
118