Update of /cvsroot/plib/plib/src/ssg
In directory usw-pr-cvs1:/tmp/cvs-serv27338/plib/src/ssg
Modified Files:
ssg.h ssgLocal.h ssgTween.cxx ssgTweenController.cxx
Log Message:
Added ability for Tween controllers to wrap-around their animations.
Index: ssg.h
===================================================================
RCS file: /cvsroot/plib/plib/src/ssg/ssg.h,v
retrieving revision 1.154
retrieving revision 1.155
diff -u -d -r1.154 -r1.155
--- ssg.h 28 Oct 2002 09:31:51 -0000 1.154
+++ ssg.h 4 Nov 2002 05:11:22 -0000 1.155
@@ -1609,9 +1609,13 @@
} ;
+#define SSGTWEEN_STOP_AT_END 0
+#define SSGTWEEN_REPEAT 1
+
class ssgTweenController : public ssgBranch
{
float curr_bank ;
+ int mode ; /* STOP_AT_END or REPEAT */
protected:
@@ -1622,6 +1626,9 @@
virtual ssgBase *clone ( int clone_flags = 0 ) ;
ssgTweenController (void) ;
virtual ~ssgTweenController (void) ;
+
+ void setMode ( int _mode ) { mode = _mode ; }
+ int getMode () { return mode ; }
void selectBank ( float f ) { curr_bank = f ; }
float getCurrBank () { return curr_bank ; }
Index: ssgLocal.h
===================================================================
RCS file: /cvsroot/plib/plib/src/ssg/ssgLocal.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- ssgLocal.h 2 Sep 2002 06:05:48 -0000 1.21
+++ ssgLocal.h 4 Nov 2002 05:11:22 -0000 1.22
@@ -117,6 +117,8 @@
float _ssgGetCurrentTweenState () ;
void _ssgSetCurrentTweenState ( float tweenstate ) ;
+int _ssgGetCurrentTweenMode () ;
+void _ssgSetCurrentTweenMode ( int tweenmode ) ;
/*
Routines for storing arbitrary ssgBase derived objects within SSG files.
Index: ssgTween.cxx
===================================================================
RCS file: /cvsroot/plib/plib/src/ssg/ssgTween.cxx,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- ssgTween.cxx 2 Sep 2002 06:05:49 -0000 1.9
+++ ssgTween.cxx 4 Nov 2002 05:11:22 -0000 1.10
@@ -27,16 +27,15 @@
#include "ul.h"
static float current_tween_state = 0.0f ;
+static int current_tween_mode = SSGTWEEN_STOP_AT_END ;
const char *ssgTween::getTypeName (void) { return "ssgTween" ; }
+int _ssgGetCurrentTweenMode () { return current_tween_mode ; }
float _ssgGetCurrentTweenState () { return current_tween_state ; }
-
-void _ssgSetCurrentTweenState ( float tstate )
-{
- current_tween_state = tstate ;
-}
+void _ssgSetCurrentTweenMode ( int mode ) { current_tween_mode = mode ; }
+void _ssgSetCurrentTweenState ( float tstate ) { current_tween_state= tstate ;}
void ssgTween::copy_from ( ssgTween *src, int clone_flags )
{
@@ -269,8 +268,17 @@
int state2 = state1 + 1 ;
float tween = tstate - (float) state1 ;
- if ( state1 >= num_banks ) state1 = num_banks - 1 ;
- if ( state2 >= num_banks ) state2 = num_banks - 1 ;
+ if ( _ssgGetCurrentTweenMode () == SSGTWEEN_REPEAT )
+ {
+ state1 %= num_banks ;
+ state2 %= num_banks ;
+ }
+ else
+ {
+ if ( state1 >= num_banks ) state1 = num_banks - 1 ;
+ if ( state2 >= num_banks ) state2 = num_banks - 1 ;
+ }
+
if ( state1 == state2 ) tween = 0.0f ;
int l1, l2 ;
Index: ssgTweenController.cxx
===================================================================
RCS file: /cvsroot/plib/plib/src/ssg/ssgTweenController.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- ssgTweenController.cxx 2 Sep 2002 06:05:49 -0000 1.5
+++ ssgTweenController.cxx 4 Nov 2002 05:11:22 -0000 1.6
@@ -58,11 +58,15 @@
void ssgTweenController::cull ( sgFrustum *f, sgMat4 m, int test_needed )
{
float tmp = _ssgGetCurrentTweenState () ;
+ int mm = _ssgGetCurrentTweenMode () ;
+
_ssgSetCurrentTweenState ( curr_bank ) ;
+ _ssgSetCurrentTweenMode ( mode ) ;
ssgBranch::cull ( f, m, test_needed ) ;
_ssgSetCurrentTweenState ( tmp ) ;
+ _ssgSetCurrentTweenMode ( mm ) ;
}
|