aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/others/irrlicht-1.8.1/source/Irrlicht/CDefaultSceneNodeAnimatorFactory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/others/irrlicht-1.8.1/source/Irrlicht/CDefaultSceneNodeAnimatorFactory.cpp')
-rw-r--r--src/others/irrlicht-1.8.1/source/Irrlicht/CDefaultSceneNodeAnimatorFactory.cpp162
1 files changed, 162 insertions, 0 deletions
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/CDefaultSceneNodeAnimatorFactory.cpp b/src/others/irrlicht-1.8.1/source/Irrlicht/CDefaultSceneNodeAnimatorFactory.cpp
new file mode 100644
index 0000000..ec52d25
--- /dev/null
+++ b/src/others/irrlicht-1.8.1/source/Irrlicht/CDefaultSceneNodeAnimatorFactory.cpp
@@ -0,0 +1,162 @@
1// Copyright (C) 2002-2012 Nikolaus Gebhardt
2// This file is part of the "Irrlicht Engine".
3// For conditions of distribution and use, see copyright notice in irrlicht.h
4
5#include "CDefaultSceneNodeAnimatorFactory.h"
6#include "CSceneNodeAnimatorCameraFPS.h"
7#include "CSceneNodeAnimatorCameraMaya.h"
8#include "ICursorControl.h"
9#include "ISceneNodeAnimatorCollisionResponse.h"
10#include "ISceneManager.h"
11
12namespace irr
13{
14namespace scene
15{
16
17//! Names for scene node types
18const c8* const SceneNodeAnimatorTypeNames[] =
19{
20 "flyCircle",
21 "flyStraight",
22 "followSpline",
23 "rotation",
24 "texture",
25 "deletion",
26 "collisionResponse",
27 "cameraFPS",
28 "cameraMaya",
29 0
30};
31
32
33CDefaultSceneNodeAnimatorFactory::CDefaultSceneNodeAnimatorFactory(ISceneManager* mgr, gui::ICursorControl* crs)
34: Manager(mgr), CursorControl(crs)
35{
36 #ifdef _DEBUG
37 setDebugName("CDefaultSceneNodeAnimatorFactory");
38 #endif
39
40 // don't grab the scene manager here to prevent cyclic references
41 if (CursorControl)
42 CursorControl->grab();
43}
44
45
46CDefaultSceneNodeAnimatorFactory::~CDefaultSceneNodeAnimatorFactory()
47{
48 if (CursorControl)
49 CursorControl->drop();
50}
51
52
53//! creates a scene node animator based on its type id
54ISceneNodeAnimator* CDefaultSceneNodeAnimatorFactory::createSceneNodeAnimator(ESCENE_NODE_ANIMATOR_TYPE type, ISceneNode* target)
55{
56 scene::ISceneNodeAnimator* anim = 0;
57
58 switch(type)
59 {
60 case ESNAT_FLY_CIRCLE:
61 anim = Manager->createFlyCircleAnimator(core::vector3df(0,0,0), 10);
62 break;
63 case ESNAT_FLY_STRAIGHT:
64 anim = Manager->createFlyStraightAnimator(core::vector3df(0,0,0), core::vector3df(100,100,100), 10000, true );
65 break;
66 case ESNAT_FOLLOW_SPLINE:
67 {
68 core::array<core::vector3df> points;
69 points.push_back(core::vector3df(0,0,0));
70 points.push_back(core::vector3df(10,5,10));
71 anim = Manager->createFollowSplineAnimator(0, points);
72 }
73 break;
74 case ESNAT_ROTATION:
75 anim = Manager->createRotationAnimator(core::vector3df(0.3f,0,0));
76 break;
77 case ESNAT_TEXTURE:
78 {
79 core::array<video::ITexture*> textures;
80 anim = Manager->createTextureAnimator(textures, 250);
81 }
82 break;
83 case ESNAT_DELETION:
84 anim = Manager->createDeleteAnimator(5000);
85 break;
86 case ESNAT_COLLISION_RESPONSE:
87 anim = Manager->createCollisionResponseAnimator(0, target);
88 break;
89 case ESNAT_CAMERA_FPS:
90 anim = new CSceneNodeAnimatorCameraFPS(CursorControl);
91 break;
92 case ESNAT_CAMERA_MAYA:
93 anim = new CSceneNodeAnimatorCameraMaya(CursorControl);
94 break;
95 default:
96 break;
97 }
98
99 if (anim && target)
100 target->addAnimator(anim);
101
102 return anim;
103}
104
105
106//! creates a scene node animator based on its type name
107ISceneNodeAnimator* CDefaultSceneNodeAnimatorFactory::createSceneNodeAnimator(const c8* typeName, ISceneNode* target)
108{
109 return createSceneNodeAnimator( getTypeFromName(typeName), target );
110}
111
112
113//! returns amount of scene node animator types this factory is able to create
114u32 CDefaultSceneNodeAnimatorFactory::getCreatableSceneNodeAnimatorTypeCount() const
115{
116 return ESNAT_COUNT;
117}
118
119
120//! returns type of a createable scene node animator type
121ESCENE_NODE_ANIMATOR_TYPE CDefaultSceneNodeAnimatorFactory::getCreateableSceneNodeAnimatorType(u32 idx) const
122{
123 if (idx<ESNAT_COUNT)
124 return (ESCENE_NODE_ANIMATOR_TYPE)idx;
125 else
126 return ESNAT_UNKNOWN;
127}
128
129
130//! returns type name of a createable scene node animator type
131const c8* CDefaultSceneNodeAnimatorFactory::getCreateableSceneNodeAnimatorTypeName(u32 idx) const
132{
133 if (idx<ESNAT_COUNT)
134 return SceneNodeAnimatorTypeNames[idx];
135 else
136 return 0;
137}
138
139//! returns type name of a createable scene node animator type
140const c8* CDefaultSceneNodeAnimatorFactory::getCreateableSceneNodeAnimatorTypeName(ESCENE_NODE_ANIMATOR_TYPE type) const
141{
142 // for this factory: index == type
143
144 if (type<ESNAT_COUNT)
145 return SceneNodeAnimatorTypeNames[type];
146 else
147 return 0;
148}
149
150ESCENE_NODE_ANIMATOR_TYPE CDefaultSceneNodeAnimatorFactory::getTypeFromName(const c8* name) const
151{
152 for ( u32 i=0; SceneNodeAnimatorTypeNames[i]; ++i)
153 if (!strcmp(name, SceneNodeAnimatorTypeNames[i]) )
154 return (ESCENE_NODE_ANIMATOR_TYPE)i;
155
156 return ESNAT_UNKNOWN;
157}
158
159
160} // end namespace scene
161} // end namespace irr
162