Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/tutoriallevel/src/external/ois/OISEffect.cpp @ 8474

Last change on this file since 8474 was 5781, checked in by rgrieder, 15 years ago

Reverted trunk again. We might want to find a way to delete these revisions again (x3n's changes are still available as diff in the commit mails).

  • Property svn:eol-style set to native
File size: 3.8 KB
Line 
1/*
2The zlib/libpng License
3
4Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
5
6This software is provided 'as-is', without any express or implied warranty. In no event will
7the authors be held liable for any damages arising from the use of this software.
8
9Permission is granted to anyone to use this software for any purpose, including commercial
10applications, and to alter it and redistribute it freely, subject to the following
11restrictions:
12
13    1. The origin of this software must not be misrepresented; you must not claim that
14                you wrote the original software. If you use this software in a product,
15                an acknowledgment in the product documentation would be appreciated but is
16                not required.
17
18    2. Altered source versions must be plainly marked as such, and must not be
19                misrepresented as being the original software.
20
21    3. This notice may not be removed or altered from any source distribution.
22*/
23#include "OISEffect.h"
24#include "OISException.h"
25
26using namespace OIS;
27
28//VC7.1 had a problem with these not getting included..
29//Perhaps a case of a crazy extreme optimizer :/ (moved to header)
30//const unsigned int Effect::OIS_INFINITE = 0xFFFFFFFF;
31
32//------------------------------------------------------------------------------//
33static const char* pszEForceString[] = 
34  { "UnknownForce",
35    "ConstantForce", 
36    "RampForce", 
37    "PeriodicForce", 
38    "ConditionalForce", 
39    "CustomForce" };
40
41const char* Effect::getForceTypeName(Effect::EForce eValue)
42{
43  return (eValue >= 0 && eValue < _ForcesNumber) ? pszEForceString[eValue] : "<Bad force type>";
44}
45
46static const char* pszETypeString[] = 
47  { "Unknown",
48    "Constant",
49    "Ramp",
50    "Square", "Triangle", "Sine", "SawToothUp", "SawToothDown",
51    "Friction", "Damper", "Inertia", "Spring",
52    "Custom" };
53
54const char* Effect::getEffectTypeName(Effect::EType eValue)
55{
56  return (eValue >= 0 && eValue < _TypesNumber) ? pszETypeString[eValue] : "<Bad effect type>";
57}
58
59static const char* pszEDirectionString[] = 
60  { "NorthWest", "North", "NorthEast", "East", "SouthEast", "South", "SouthWest", "West"};
61
62const char* Effect::getDirectionName(Effect::EDirection eValue)
63{
64  return (eValue >= 0 && eValue < _DirectionsNumber) ? pszEDirectionString[eValue] : "<Bad direction>";
65}
66
67//------------------------------------------------------------------------------//
68Effect::Effect() : 
69        force(UnknownForce), 
70        type(Unknown),
71        effect(0),
72        axes(1)
73{
74}
75
76//------------------------------------------------------------------------------//
77Effect::Effect(EForce ef, EType et) : 
78        force(ef), 
79        type(et),
80        direction(North), 
81        trigger_button(-1),
82        trigger_interval(0),
83        replay_length(Effect::OIS_INFINITE),
84        replay_delay(0),
85        _handle(-1),
86        axes(1)
87{
88        effect = 0;
89
90        switch( ef )
91        {
92        case ConstantForce:    effect = new ConstantEffect(); break;
93        case RampForce:        effect = new RampEffect(); break;
94        case PeriodicForce:    effect = new PeriodicEffect(); break;
95        case ConditionalForce: effect = new ConditionalEffect(); break;
96        default: break;
97        }
98}
99
100//------------------------------------------------------------------------------//
101Effect::~Effect()
102{
103        delete effect;
104}
105
106//------------------------------------------------------------------------------//
107ForceEffect* Effect::getForceEffect() const
108{
109        //If no effect was created in constructor, then we raise an error here
110        if( effect == 0 )
111                OIS_EXCEPT( E_NotSupported, "Requested ForceEffect is null!" );
112
113        return effect;
114}
115
116//------------------------------------------------------------------------------//
117void Effect::setNumAxes(short nAxes)
118{
119        //Can only be set before a handle was assigned (effect created)
120        if( _handle != -1 )
121        axes = nAxes;
122}
123
124//------------------------------------------------------------------------------//
125short Effect::getNumAxes() const
126{
127        return axes;
128}
Note: See TracBrowser for help on using the repository browser.