1 | /* |
---|
2 | ----------------------------------------------------------------------------- |
---|
3 | This source file is part of OGRE |
---|
4 | (Object-oriented Graphics Rendering Engine) |
---|
5 | For the latest info, see http://www.ogre3d.org/ |
---|
6 | |
---|
7 | Copyright (c) 2000-2006 Torus Knot Software Ltd |
---|
8 | Also see acknowledgements in Readme.html |
---|
9 | |
---|
10 | This program is free software; you can redistribute it and/or modify it under |
---|
11 | the terms of the GNU Lesser General Public License as published by the Free Software |
---|
12 | Foundation; either version 2 of the License, or (at your option) any later |
---|
13 | version. |
---|
14 | |
---|
15 | This program is distributed in the hope that it will be useful, but WITHOUT |
---|
16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
---|
17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
---|
18 | |
---|
19 | You should have received a copy of the GNU Lesser General Public License along with |
---|
20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
---|
21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to |
---|
22 | http://www.gnu.org/copyleft/lesser.txt. |
---|
23 | |
---|
24 | You may alternatively use this source under the terms of a specific version of |
---|
25 | the OGRE Unrestricted License provided you have obtained such a license from |
---|
26 | Torus Knot Software Ltd. |
---|
27 | ----------------------------------------------------------------------------- |
---|
28 | */ |
---|
29 | #include "OgreStableHeaders.h" |
---|
30 | #include "OgreAnimable.h" |
---|
31 | |
---|
32 | namespace Ogre { |
---|
33 | //-------------------------------------------------------------------------- |
---|
34 | AnimableObject::AnimableDictionaryMap AnimableObject::msAnimableDictionary; |
---|
35 | //-------------------------------------------------------------------------- |
---|
36 | void AnimableValue::resetToBaseValue(void) |
---|
37 | { |
---|
38 | switch(mType) |
---|
39 | { |
---|
40 | case INT: |
---|
41 | setValue(mBaseValueInt); |
---|
42 | break; |
---|
43 | case REAL: |
---|
44 | setValue(mBaseValueReal[0]); |
---|
45 | break; |
---|
46 | case VECTOR2: |
---|
47 | setValue(Vector2(mBaseValueReal)); |
---|
48 | break; |
---|
49 | case VECTOR3: |
---|
50 | setValue(Vector3(mBaseValueReal)); |
---|
51 | break; |
---|
52 | case VECTOR4: |
---|
53 | setValue(Vector4(mBaseValueReal)); |
---|
54 | break; |
---|
55 | case QUATERNION: |
---|
56 | setValue(Quaternion(mBaseValueReal)); |
---|
57 | break; |
---|
58 | case COLOUR: |
---|
59 | setValue(ColourValue(mBaseValueReal[0], mBaseValueReal[1], |
---|
60 | mBaseValueReal[2], mBaseValueReal[3])); |
---|
61 | break; |
---|
62 | } |
---|
63 | } |
---|
64 | //-------------------------------------------------------------------------- |
---|
65 | void AnimableValue::setAsBaseValue(const Any& val) |
---|
66 | { |
---|
67 | switch(mType) |
---|
68 | { |
---|
69 | case INT: |
---|
70 | setAsBaseValue(any_cast<int>(val)); |
---|
71 | break; |
---|
72 | case REAL: |
---|
73 | setAsBaseValue(any_cast<Real>(val)); |
---|
74 | break; |
---|
75 | case VECTOR2: |
---|
76 | setAsBaseValue(any_cast<Vector2>(val)); |
---|
77 | break; |
---|
78 | case VECTOR3: |
---|
79 | setAsBaseValue(any_cast<Vector3>(val)); |
---|
80 | break; |
---|
81 | case VECTOR4: |
---|
82 | setAsBaseValue(any_cast<Vector4>(val)); |
---|
83 | break; |
---|
84 | case QUATERNION: |
---|
85 | setAsBaseValue(any_cast<Quaternion>(val)); |
---|
86 | break; |
---|
87 | case COLOUR: |
---|
88 | setAsBaseValue(any_cast<ColourValue>(val)); |
---|
89 | break; |
---|
90 | } |
---|
91 | } |
---|
92 | //-------------------------------------------------------------------------- |
---|
93 | void AnimableValue::setValue(const Any& val) |
---|
94 | { |
---|
95 | switch(mType) |
---|
96 | { |
---|
97 | case INT: |
---|
98 | setValue(any_cast<int>(val)); |
---|
99 | break; |
---|
100 | case REAL: |
---|
101 | setValue(any_cast<Real>(val)); |
---|
102 | break; |
---|
103 | case VECTOR2: |
---|
104 | setValue(any_cast<Vector2>(val)); |
---|
105 | break; |
---|
106 | case VECTOR3: |
---|
107 | setValue(any_cast<Vector3>(val)); |
---|
108 | break; |
---|
109 | case VECTOR4: |
---|
110 | setValue(any_cast<Vector4>(val)); |
---|
111 | break; |
---|
112 | case QUATERNION: |
---|
113 | setValue(any_cast<Quaternion>(val)); |
---|
114 | break; |
---|
115 | case COLOUR: |
---|
116 | setValue(any_cast<ColourValue>(val)); |
---|
117 | break; |
---|
118 | } |
---|
119 | } |
---|
120 | //-------------------------------------------------------------------------- |
---|
121 | void AnimableValue::applyDeltaValue(const Any& val) |
---|
122 | { |
---|
123 | switch(mType) |
---|
124 | { |
---|
125 | case INT: |
---|
126 | applyDeltaValue(any_cast<int>(val)); |
---|
127 | break; |
---|
128 | case REAL: |
---|
129 | applyDeltaValue(any_cast<Real>(val)); |
---|
130 | break; |
---|
131 | case VECTOR2: |
---|
132 | applyDeltaValue(any_cast<Vector2>(val)); |
---|
133 | break; |
---|
134 | case VECTOR3: |
---|
135 | applyDeltaValue(any_cast<Vector3>(val)); |
---|
136 | break; |
---|
137 | case VECTOR4: |
---|
138 | applyDeltaValue(any_cast<Vector4>(val)); |
---|
139 | break; |
---|
140 | case QUATERNION: |
---|
141 | applyDeltaValue(any_cast<Quaternion>(val)); |
---|
142 | break; |
---|
143 | case COLOUR: |
---|
144 | applyDeltaValue(any_cast<ColourValue>(val)); |
---|
145 | break; |
---|
146 | } |
---|
147 | } |
---|
148 | |
---|
149 | |
---|
150 | |
---|
151 | } |
---|