E:/Download/ois-1.0RC1/includes/OISEffect.h

Go to the documentation of this file.
00001 /*
00002 The zlib/libpng License
00003 
00004 Copyright (c) 2006 Phillip Castaneda (pjcast -- www.wreckedgames.com)
00005 
00006 This software is provided 'as-is', without any express or implied warranty. In no event will
00007 the authors be held liable for any damages arising from the use of this software.
00008 
00009 Permission is granted to anyone to use this software for any purpose, including commercial
00010 applications, and to alter it and redistribute it freely, subject to the following
00011 restrictions:
00012 
00013     1. The origin of this software must not be misrepresented; you must not claim that
00014                 you wrote the original software. If you use this software in a product,
00015                 an acknowledgment in the product documentation would be appreciated but is
00016                 not required.
00017 
00018     2. Altered source versions must be plainly marked as such, and must not be
00019                 misrepresented as being the original software.
00020 
00021     3. This notice may not be removed or altered from any source distribution.
00022 */
00023 #ifndef OIS_Effect_H
00024 #define OIS_Effect_H
00025 
00026 #include "OISPrereqs.h"
00027 
00028 namespace OIS
00029 {
00030         //Predeclare some Effect Property structs
00031         struct ForceEffect;
00032         struct ConstantEffect;
00033         struct RampEffect;
00034         struct PeriodicEffect;
00035         struct ConditionalEffect;
00036 
00047         class _OISExport Effect
00048         {
00052                 Effect();
00053         public:
00055                 enum EForce
00056                 {
00057                         UnknownForce = 0,
00058                         ConstantForce,
00059                         RampForce,
00060                         PeriodicForce,
00061                         ConditionalForce,
00062                         CustomForce
00063                 };
00064 
00066                 enum EType
00067                 {
00068                         //Type ----- Pairs with force:
00069                         Unknown = 0, //UnknownForce
00070                         Constant,    //ConstantForce
00071                         Ramp,        //RampForce
00072                         Square,      //PeriodicForce
00073                         Triangle,    //PeriodicForce
00074             Sine,        //PeriodicForce
00075                         SawToothUp,  //PeriodicForce
00076                         SawToothDown,//PeriodicForce
00077                         Friction,    //ConditionalForce
00078                         Damper,      //ConditionalForce
00079                         Inertia,     //ConditionalForce
00080                         Spring,      //ConditionalForce
00081                         Custom       //CustomForce
00082                 };
00083 
00085                 enum EDirection
00086                 {
00087                         NorthWest,
00088                         North,
00089                         NorthEast,
00090                         East,
00091                         SouthEast,
00092                         South,
00093                         SouthWest,
00094                         West
00095                 };
00096 
00100                 Effect(EForce ef, EType et);
00101                 virtual ~Effect();
00102 
00103                 const EForce force;
00104                 const EType type;
00105 
00106                 //Infinite Time
00107                 static const unsigned int OIS_INFINITE = 0xFFFFFFFF;
00108 
00109                 //-------------------------------------------------------------------//
00110                 //--- Set these variables before uploading or modifying an effect ---//
00111 
00112                 //Direction to apply to the force - affects two axes+ effects
00113                 EDirection direction;
00114 
00115                 //Number of button triggering an effect (-1 means no trigger)
00116                 short trigger_button;
00117 
00118                 //Time to wait before an effect can be re-triggered (microseconds)
00119                 unsigned int trigger_interval;
00120 
00121                 //Duration of an effect (microseconds)
00122                 unsigned int replay_length;
00123 
00124                 //Time to wait before to start playing an effect (microseconds)
00125                 unsigned int replay_delay;
00126 
00127                 //Get the specific Force Effect. This should be cast depending on the EForce
00128                 ForceEffect* getForceEffect() const;
00129 
00136                 void setNumAxes(short nAxes);
00137 
00142                 short getNumAxes() const;
00143 
00144                 //------------- Library Internal -------------------------------------//
00150                 mutable int _handle;
00151         protected:
00152                 ForceEffect* effect; //Properties depend on EForce
00153                 short axes;          //Number of axes to use in effect
00154         };
00155 
00156         //-----------------------------------------------------------------------------//
00160         struct _OISExport ForceEffect
00161         {
00162                 virtual ~ForceEffect() {}
00163         };
00164 
00165         //-----------------------------------------------------------------------------//
00171         struct _OISExport Envelope : public ForceEffect
00172         {
00173                 Envelope() : attackLength(0), attackLevel(0), fadeLength(0), fadeLevel(0) {}
00174 #if defined(OIS_MSVC_COMPILER)
00175   #pragma warning (push)
00176   #pragma warning (disable : 4800)
00177 #endif
00178                 bool isUsed() { return attackLength | attackLevel | fadeLength | fadeLevel; }
00179 #if defined(OIS_MSVC_COMPILER)
00180   #pragma warning (pop)
00181 #endif
00182 
00183                 unsigned short attackLength;
00184                 unsigned short attackLevel;
00185                 unsigned short fadeLength;
00186                 unsigned short fadeLevel;
00187         };
00188 
00189         //-----------------------------------------------------------------------------//
00193         struct _OISExport ConstantEffect : public ForceEffect
00194         {
00195                 ConstantEffect() : level(5000) {}
00196 
00197                 struct Envelope envelope; //Optional envolope
00198                 signed short level;       //-10K to +10k
00199         };
00200 
00201         //-----------------------------------------------------------------------------//
00205         struct _OISExport RampEffect : public ForceEffect
00206         {
00207                 RampEffect() : startLevel(0), endLevel(0) {}
00208 
00209         struct Envelope envelope; //Optional envolope
00210                 signed short startLevel;  //-10K to +10k
00211                 signed short endLevel;    //-10K to +10k
00212         };
00213 
00214         //-----------------------------------------------------------------------------//
00218         struct _OISExport PeriodicEffect : public ForceEffect
00219         {
00220                 PeriodicEffect() : magnitude(0), offset(0), phase(0), period(0) {}
00221 
00222                 struct Envelope envelope;  //Optional Envelope
00223 
00224                 unsigned short magnitude;  //0 to 10,0000
00225                 signed short   offset;
00226                 unsigned short phase;      //Position at which playback begins 0 to 35,999
00227                 unsigned int   period;     //Period of effect (microseconds)
00228         };
00229 
00230         //-----------------------------------------------------------------------------//
00234         struct _OISExport ConditionalEffect : public ForceEffect
00235         {
00236                 ConditionalEffect() :
00237             rightCoeff(0), leftCoeff(0), rightSaturation(0), leftSaturation(0),
00238                         deadband(0), center(0) {}
00239 
00240                 signed short   rightCoeff;      //-10k to +10k (Positive Coeff)
00241                 signed short   leftCoeff;       //-10k to +10k (Negative Coeff)
00242 
00243                 unsigned short rightSaturation; //0 to 10k (Pos Saturation)
00244                 unsigned short leftSaturation;  //0 to 10k (Neg Saturation)
00245 
00246                 //Region around center in which the condition is not active, in the range
00247                 //from 0 through 10,000
00248                 unsigned short deadband;
00249 
00250                 //(Offset in DX) -10k and 10k
00251                 signed short center;
00252         };
00253 }
00254 #endif //OIS_Effect_H

Generated on Sat Dec 1 20:13:51 2007 for OIS by  doxygen 1.5.4