aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/source/Irrlicht/CSceneNodeAnimatorFlyCircle.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/CSceneNodeAnimatorFlyCircle.cpp')
-rw-r--r--libraries/irrlicht-1.8/source/Irrlicht/CSceneNodeAnimatorFlyCircle.cpp200
1 files changed, 100 insertions, 100 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CSceneNodeAnimatorFlyCircle.cpp b/libraries/irrlicht-1.8/source/Irrlicht/CSceneNodeAnimatorFlyCircle.cpp
index dc887fa..ebabe40 100644
--- a/libraries/irrlicht-1.8/source/Irrlicht/CSceneNodeAnimatorFlyCircle.cpp
+++ b/libraries/irrlicht-1.8/source/Irrlicht/CSceneNodeAnimatorFlyCircle.cpp
@@ -1,100 +1,100 @@
1// Copyright (C) 2002-2012 Nikolaus Gebhardt 1// Copyright (C) 2002-2012 Nikolaus Gebhardt
2// This file is part of the "Irrlicht Engine". 2// This file is part of the "Irrlicht Engine".
3// For conditions of distribution and use, see copyright notice in irrlicht.h 3// For conditions of distribution and use, see copyright notice in irrlicht.h
4 4
5#include "CSceneNodeAnimatorFlyCircle.h" 5#include "CSceneNodeAnimatorFlyCircle.h"
6 6
7namespace irr 7namespace irr
8{ 8{
9namespace scene 9namespace scene
10{ 10{
11 11
12 12
13//! constructor 13//! constructor
14CSceneNodeAnimatorFlyCircle::CSceneNodeAnimatorFlyCircle(u32 time, 14CSceneNodeAnimatorFlyCircle::CSceneNodeAnimatorFlyCircle(u32 time,
15 const core::vector3df& center, f32 radius, f32 speed, 15 const core::vector3df& center, f32 radius, f32 speed,
16 const core::vector3df& direction, f32 radiusEllipsoid) 16 const core::vector3df& direction, f32 radiusEllipsoid)
17 : Center(center), Direction(direction), Radius(radius), 17 : Center(center), Direction(direction), Radius(radius),
18 RadiusEllipsoid(radiusEllipsoid), Speed(speed), StartTime(time) 18 RadiusEllipsoid(radiusEllipsoid), Speed(speed), StartTime(time)
19{ 19{
20 #ifdef _DEBUG 20 #ifdef _DEBUG
21 setDebugName("CSceneNodeAnimatorFlyCircle"); 21 setDebugName("CSceneNodeAnimatorFlyCircle");
22 #endif 22 #endif
23 init(); 23 init();
24} 24}
25 25
26 26
27void CSceneNodeAnimatorFlyCircle::init() 27void CSceneNodeAnimatorFlyCircle::init()
28{ 28{
29 Direction.normalize(); 29 Direction.normalize();
30 30
31 if (Direction.Y != 0) 31 if (Direction.Y != 0)
32 VecV = core::vector3df(50,0,0).crossProduct(Direction).normalize(); 32 VecV = core::vector3df(50,0,0).crossProduct(Direction).normalize();
33 else 33 else
34 VecV = core::vector3df(0,50,0).crossProduct(Direction).normalize(); 34 VecV = core::vector3df(0,50,0).crossProduct(Direction).normalize();
35 VecU = VecV.crossProduct(Direction).normalize(); 35 VecU = VecV.crossProduct(Direction).normalize();
36} 36}
37 37
38 38
39//! animates a scene node 39//! animates a scene node
40void CSceneNodeAnimatorFlyCircle::animateNode(ISceneNode* node, u32 timeMs) 40void CSceneNodeAnimatorFlyCircle::animateNode(ISceneNode* node, u32 timeMs)
41{ 41{
42 if ( 0 == node ) 42 if ( 0 == node )
43 return; 43 return;
44 44
45 f32 time; 45 f32 time;
46 46
47 // Check for the condition where the StartTime is in the future. 47 // Check for the condition where the StartTime is in the future.
48 if(StartTime > timeMs) 48 if(StartTime > timeMs)
49 time = ((s32)timeMs - (s32)StartTime) * Speed; 49 time = ((s32)timeMs - (s32)StartTime) * Speed;
50 else 50 else
51 time = (timeMs-StartTime) * Speed; 51 time = (timeMs-StartTime) * Speed;
52 52
53// node->setPosition(Center + Radius * ((VecU*cosf(time)) + (VecV*sinf(time)))); 53// node->setPosition(Center + Radius * ((VecU*cosf(time)) + (VecV*sinf(time))));
54 f32 r2 = RadiusEllipsoid == 0.f ? Radius : RadiusEllipsoid; 54 f32 r2 = RadiusEllipsoid == 0.f ? Radius : RadiusEllipsoid;
55 node->setPosition(Center + (Radius*cosf(time)*VecU) + (r2*sinf(time)*VecV ) ); 55 node->setPosition(Center + (Radius*cosf(time)*VecU) + (r2*sinf(time)*VecV ) );
56} 56}
57 57
58 58
59//! Writes attributes of the scene node animator. 59//! Writes attributes of the scene node animator.
60void CSceneNodeAnimatorFlyCircle::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const 60void CSceneNodeAnimatorFlyCircle::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const
61{ 61{
62 out->addVector3d("Center", Center); 62 out->addVector3d("Center", Center);
63 out->addFloat("Radius", Radius); 63 out->addFloat("Radius", Radius);
64 out->addFloat("Speed", Speed); 64 out->addFloat("Speed", Speed);
65 out->addVector3d("Direction", Direction); 65 out->addVector3d("Direction", Direction);
66 out->addFloat("RadiusEllipsoid", RadiusEllipsoid); 66 out->addFloat("RadiusEllipsoid", RadiusEllipsoid);
67} 67}
68 68
69 69
70//! Reads attributes of the scene node animator. 70//! Reads attributes of the scene node animator.
71void CSceneNodeAnimatorFlyCircle::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) 71void CSceneNodeAnimatorFlyCircle::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
72{ 72{
73 Center = in->getAttributeAsVector3d("Center"); 73 Center = in->getAttributeAsVector3d("Center");
74 Radius = in->getAttributeAsFloat("Radius"); 74 Radius = in->getAttributeAsFloat("Radius");
75 Speed = in->getAttributeAsFloat("Speed"); 75 Speed = in->getAttributeAsFloat("Speed");
76 Direction = in->getAttributeAsVector3d("Direction"); 76 Direction = in->getAttributeAsVector3d("Direction");
77 StartTime = 0; 77 StartTime = 0;
78 78
79 if (Direction.equals(core::vector3df(0,0,0))) 79 if (Direction.equals(core::vector3df(0,0,0)))
80 Direction.set(0,1,0); // irrlicht 1.1 backwards compatibility 80 Direction.set(0,1,0); // irrlicht 1.1 backwards compatibility
81 else 81 else
82 Direction.normalize(); 82 Direction.normalize();
83 83
84 RadiusEllipsoid = in->getAttributeAsFloat("RadiusEllipsoid"); 84 RadiusEllipsoid = in->getAttributeAsFloat("RadiusEllipsoid");
85 init(); 85 init();
86} 86}
87 87
88 88
89ISceneNodeAnimator* CSceneNodeAnimatorFlyCircle::createClone(ISceneNode* node, ISceneManager* newManager) 89ISceneNodeAnimator* CSceneNodeAnimatorFlyCircle::createClone(ISceneNode* node, ISceneManager* newManager)
90{ 90{
91 CSceneNodeAnimatorFlyCircle * newAnimator = 91 CSceneNodeAnimatorFlyCircle * newAnimator =
92 new CSceneNodeAnimatorFlyCircle(StartTime, Center, Radius, Speed, Direction, RadiusEllipsoid); 92 new CSceneNodeAnimatorFlyCircle(StartTime, Center, Radius, Speed, Direction, RadiusEllipsoid);
93 93
94 return newAnimator; 94 return newAnimator;
95} 95}
96 96
97 97
98} // end namespace scene 98} // end namespace scene
99} // end namespace irr 99} // end namespace irr
100 100