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 #include "OISEffect.h" 00024 #include "OISException.h" 00025 00026 using namespace OIS; 00027 00028 //VC7.1 had a problem with these not getting included.. 00029 //Perhaps a case of a crazy extreme optimizer :/ (moved to header) 00030 //const unsigned int Effect::OIS_INFINITE = 0xFFFFFFFF; 00031 00032 //------------------------------------------------------------------------------// 00033 Effect::Effect() : 00034 force(UnknownForce), 00035 type(Unknown), 00036 effect(0), 00037 axes(1) 00038 { 00039 } 00040 00041 //------------------------------------------------------------------------------// 00042 Effect::Effect(EForce ef, EType et) : 00043 force(ef), 00044 type(et), 00045 direction(North), 00046 trigger_button(-1), 00047 trigger_interval(0), 00048 replay_length(Effect::OIS_INFINITE), 00049 replay_delay(0), 00050 _handle(-1), 00051 axes(1) 00052 { 00053 effect = 0; 00054 00055 switch( ef ) 00056 { 00057 case ConstantForce: effect = new ConstantEffect(); break; 00058 case RampForce: effect = new RampEffect(); break; 00059 case PeriodicForce: effect = new PeriodicEffect(); break; 00060 case ConditionalForce: effect = new ConditionalEffect(); break; 00061 default: break; 00062 } 00063 } 00064 00065 //------------------------------------------------------------------------------// 00066 Effect::~Effect() 00067 { 00068 delete effect; 00069 } 00070 00071 //------------------------------------------------------------------------------// 00072 ForceEffect* Effect::getForceEffect() const 00073 { 00074 //If no effect was created in constructor, then we raise an error here 00075 if( effect == 0 ) 00076 OIS_EXCEPT( E_NotSupported, "Requested ForceEffect is null!" ); 00077 00078 return effect; 00079 } 00080 00081 //------------------------------------------------------------------------------// 00082 void Effect::setNumAxes(short nAxes) 00083 { 00084 //Can only be set before a handle was assigned (effect created) 00085 if( _handle != -1 ) 00086 axes = nAxes; 00087 } 00088 00089 //------------------------------------------------------------------------------// 00090 short Effect::getNumAxes() const 00091 { 00092 return axes; 00093 }
1.5.4