Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

LWChannelEnvelope.h

Go to the documentation of this file.
00001 
00002 /*
00003     TEDDY - General graphics application library
00004     Copyright (C) 1999-2002  Timo Suoranta
00005     tksuoran@cc.helsinki.fi
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Lesser General Public
00009     License as published by the Free Software Foundation; either
00010     version 2.1 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Lesser General Public License for more details.
00016 
00017     You should have received a copy of the GNU Lesser General Public
00018     License along with this library; if not, write to the Free Software
00019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 
00021     $Id: LWChannelEnvelope.h,v 1.1 2002/02/16 12:41:39 tksuoran Exp $
00022 */
00023 
00024 
00025 #ifndef TEDDY__IMPORTS__LW_CHANNEL_ENVELOPE__H
00026 #define TEDDY__IMPORTS__LW_CHANNEL_ENVELOPE__H
00027 
00028 
00029 #include "Teddy/TeddyConfig.h"
00030 #if defined( TEDDY_INCLUDE_LW_SCENE )
00031 
00032 
00033 #include "Teddy/SysSupport/StdList.h"
00034 
00035 
00036 namespace Teddy   {
00037 namespace Imports {
00038 
00039 
00040 class LWChannelKey;
00041 
00042 
00043 //  Motion channels
00044 #define LW_CHANNEL_X   0  //   0 - Move X                                          
00045 #define LW_CHANNEL_Y   1  //   1 - Move Y                                          
00046 #define LW_CHANNEL_Z   2  //   2 - Move Z                                          
00047 #define LW_CHANNEL_H   3  //   3 - Rotate Heading                                  
00048 #define LW_CHANNEL_P   4  //   4 - Rotate Pitch                                    
00049 #define LW_CHANNEL_B   5  //   5 - Rotate Bank                                     
00050 #define LW_CHANNEL_SX  6  //   6 - Scale X / Size X (channels are connected)      
00051 #define LW_CHANNEL_SY  7  //   7 - Scale Y / Size Y (channels are connected)       
00052 #define LW_CHANNEL_SZ  8  //   8 - Scale Z / Size Z (channels are connected)       
00053 #define LW_CHANNEL_RX  9  //   9 - RestLength X                                    
00054 #define LW_CHANNEL_RY 10  //  10 - RestLength Y                                    
00055 #define LW_CHANNEL_RZ 11  //  11 - RestLength Z                                    
00056 #define LW_CHANNEL_PX  9  //   9 - Move PivotPoint X 
00057 #define LW_CHANNEL_PY 10  //  10 - Move PivotPoint Y
00058 #define LW_CHANNEL_PZ 11  //  11 - Move PivotPoint Z
00059 
00060 
00061 //  Motion channel span types
00062 #define LW_SPAN_TCB        0  //  TCB (Kochanek-Bartels) 
00063 #define LW_SPAN_HERMITE    1  //  Hermite 
00064 #define LW_SPAN_1D_BEZIER  2  //  1D Bezier (obsolete, equivalent to Hermite) 
00065 #define LW_SPAN_LINEAR     3  //  Linear 
00066 #define LW_SPAN_STEPPED    4  //  Stepped 
00067 #define LW_SPAN_2D_BEZIER  5  //  2D Bezier 
00068 
00069 //  Motion channel pre and post behaviors
00070 #define LW_BEHAVIOR_RESET          0  //  Reset          Sets the value to 0.0. 
00071 #define LW_BEHAVIOR_CONSTAT        1  //  Constant       Sets the value to the value at the nearest key. 
00072 #define LW_BEHAVIOR_REPEAT         2  //  Repeat         Repeats the interval between the first and last keys (the primary interval). 
00073 #define LW_BEHAVIOR_OSCILLATE      3  //  Oscillate      Like Repeat, but alternating copies of the primary interval are time-reversed. 
00074 #define LW_BEHAVIOR_OFFSET_REPEAT  4  //  Offset Repeat  Like Repeat, but offset by the difference between the values of the first and last keys. 
00075 #define LW_BEHAVIOR_LINEAR         5  //  Linear         Linearly extrapolates the value based on the tangent at the nearest key. 
00076 
00077 
00078 class LWChannelEnvelope {
00079 public:
00080     LWChannelEnvelope( int channel_id );
00081 
00082     int    getChannelId();
00083     void   insert      ( LWChannelKey *channel_key );
00084     void   setBehaviors( int pre, int post );
00085     float  eval        ( float key_position );
00086 
00087 protected:
00088     list<LWChannelKey*> keys;
00089     int                 channel_id;
00090     int                 steps;
00091     int                 pre_behavior;
00092     int                 post_behavior;
00093     float               last_time;
00094     float               last_value;
00095 };
00096 
00097 
00098 };  //  namespace Imports
00099 };  //  namespace Teddy
00100 
00101 
00102 #endif  //  TEDDY_INCLUDE_LW_SCENE
00103 #endif  //  TEDDY__IMPORTS__LW_CHANNEL_ENVELOPE__H
00104