diff options
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/CSceneNodeAnimatorCollisionResponse.h')
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/CSceneNodeAnimatorCollisionResponse.h | 314 |
1 files changed, 157 insertions, 157 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CSceneNodeAnimatorCollisionResponse.h b/libraries/irrlicht-1.8/source/Irrlicht/CSceneNodeAnimatorCollisionResponse.h index 42ff71a..bf05a18 100644 --- a/libraries/irrlicht-1.8/source/Irrlicht/CSceneNodeAnimatorCollisionResponse.h +++ b/libraries/irrlicht-1.8/source/Irrlicht/CSceneNodeAnimatorCollisionResponse.h | |||
@@ -1,157 +1,157 @@ | |||
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 | #ifndef __C_SCENE_NODE_ANIMATOR_COLLISION_RESPONSE_H_INCLUDED__ | 5 | #ifndef __C_SCENE_NODE_ANIMATOR_COLLISION_RESPONSE_H_INCLUDED__ |
6 | #define __C_SCENE_NODE_ANIMATOR_COLLISION_RESPONSE_H_INCLUDED__ | 6 | #define __C_SCENE_NODE_ANIMATOR_COLLISION_RESPONSE_H_INCLUDED__ |
7 | 7 | ||
8 | #include "ISceneNodeAnimatorCollisionResponse.h" | 8 | #include "ISceneNodeAnimatorCollisionResponse.h" |
9 | 9 | ||
10 | namespace irr | 10 | namespace irr |
11 | { | 11 | { |
12 | namespace scene | 12 | namespace scene |
13 | { | 13 | { |
14 | 14 | ||
15 | //! Special scene node animator for doing automatic collision detection and response. | 15 | //! Special scene node animator for doing automatic collision detection and response. |
16 | /** This scene node animator can be attached to any scene node modifying it in that | 16 | /** This scene node animator can be attached to any scene node modifying it in that |
17 | way, that it cannot move through walls of the world, is influenced by gravity and | 17 | way, that it cannot move through walls of the world, is influenced by gravity and |
18 | acceleration. This animator is useful for example for first person shooter | 18 | acceleration. This animator is useful for example for first person shooter |
19 | games. Attach it for example to a first person shooter camera, and the camera will | 19 | games. Attach it for example to a first person shooter camera, and the camera will |
20 | behave as the player control in a first person shooter game: The camera stops and | 20 | behave as the player control in a first person shooter game: The camera stops and |
21 | slides at walls, walks up stairs, falls down if there is no floor under it, and so on. | 21 | slides at walls, walks up stairs, falls down if there is no floor under it, and so on. |
22 | */ | 22 | */ |
23 | class CSceneNodeAnimatorCollisionResponse : public ISceneNodeAnimatorCollisionResponse | 23 | class CSceneNodeAnimatorCollisionResponse : public ISceneNodeAnimatorCollisionResponse |
24 | { | 24 | { |
25 | public: | 25 | public: |
26 | 26 | ||
27 | //! constructor | 27 | //! constructor |
28 | CSceneNodeAnimatorCollisionResponse(ISceneManager* scenemanager, | 28 | CSceneNodeAnimatorCollisionResponse(ISceneManager* scenemanager, |
29 | ITriangleSelector* world, ISceneNode* object, | 29 | ITriangleSelector* world, ISceneNode* object, |
30 | const core::vector3df& ellipsoidRadius = core::vector3df(30,60,30), | 30 | const core::vector3df& ellipsoidRadius = core::vector3df(30,60,30), |
31 | const core::vector3df& gravityPerSecond = core::vector3df(0,-100.0f,0), | 31 | const core::vector3df& gravityPerSecond = core::vector3df(0,-100.0f,0), |
32 | const core::vector3df& ellipsoidTranslation = core::vector3df(0,0,0), | 32 | const core::vector3df& ellipsoidTranslation = core::vector3df(0,0,0), |
33 | f32 slidingSpeed = 0.0005f); | 33 | f32 slidingSpeed = 0.0005f); |
34 | 34 | ||
35 | //! destructor | 35 | //! destructor |
36 | virtual ~CSceneNodeAnimatorCollisionResponse(); | 36 | virtual ~CSceneNodeAnimatorCollisionResponse(); |
37 | 37 | ||
38 | //! Returns if the attached scene node is falling, which means that | 38 | //! Returns if the attached scene node is falling, which means that |
39 | //! there is no blocking wall from the scene node in the direction of | 39 | //! there is no blocking wall from the scene node in the direction of |
40 | //! the gravity. | 40 | //! the gravity. |
41 | virtual bool isFalling() const; | 41 | virtual bool isFalling() const; |
42 | 42 | ||
43 | //! Sets the radius of the ellipsoid with which collision detection and | 43 | //! Sets the radius of the ellipsoid with which collision detection and |
44 | //! response is done. | 44 | //! response is done. |
45 | virtual void setEllipsoidRadius(const core::vector3df& radius); | 45 | virtual void setEllipsoidRadius(const core::vector3df& radius); |
46 | 46 | ||
47 | //! Returns the radius of the ellipsoid with which the collision detection and | 47 | //! Returns the radius of the ellipsoid with which the collision detection and |
48 | //! response is done. | 48 | //! response is done. |
49 | virtual core::vector3df getEllipsoidRadius() const; | 49 | virtual core::vector3df getEllipsoidRadius() const; |
50 | 50 | ||
51 | //! Sets the gravity of the environment. | 51 | //! Sets the gravity of the environment. |
52 | virtual void setGravity(const core::vector3df& gravity); | 52 | virtual void setGravity(const core::vector3df& gravity); |
53 | 53 | ||
54 | //! 'Jump' the animator, by adding a jump speed opposite to its gravity | 54 | //! 'Jump' the animator, by adding a jump speed opposite to its gravity |
55 | virtual void jump(f32 jumpSpeed); | 55 | virtual void jump(f32 jumpSpeed); |
56 | 56 | ||
57 | //! Should the Target react on collision ( default = true ) | 57 | //! Should the Target react on collision ( default = true ) |
58 | virtual void setAnimateTarget ( bool enable ); | 58 | virtual void setAnimateTarget ( bool enable ); |
59 | virtual bool getAnimateTarget () const; | 59 | virtual bool getAnimateTarget () const; |
60 | 60 | ||
61 | //! Returns current vector of gravity. | 61 | //! Returns current vector of gravity. |
62 | virtual core::vector3df getGravity() const; | 62 | virtual core::vector3df getGravity() const; |
63 | 63 | ||
64 | //! Sets the translation of the ellipsoid for collision detection. | 64 | //! Sets the translation of the ellipsoid for collision detection. |
65 | virtual void setEllipsoidTranslation(const core::vector3df &translation); | 65 | virtual void setEllipsoidTranslation(const core::vector3df &translation); |
66 | 66 | ||
67 | //! Returns the translation of the ellipsoid for collision detection. | 67 | //! Returns the translation of the ellipsoid for collision detection. |
68 | virtual core::vector3df getEllipsoidTranslation() const; | 68 | virtual core::vector3df getEllipsoidTranslation() const; |
69 | 69 | ||
70 | //! Sets a triangle selector holding all triangles of the world with which | 70 | //! Sets a triangle selector holding all triangles of the world with which |
71 | //! the scene node may collide. | 71 | //! the scene node may collide. |
72 | virtual void setWorld(ITriangleSelector* newWorld); | 72 | virtual void setWorld(ITriangleSelector* newWorld); |
73 | 73 | ||
74 | //! Returns the current triangle selector containing all triangles for | 74 | //! Returns the current triangle selector containing all triangles for |
75 | //! collision detection. | 75 | //! collision detection. |
76 | virtual ITriangleSelector* getWorld() const; | 76 | virtual ITriangleSelector* getWorld() const; |
77 | 77 | ||
78 | //! animates a scene node | 78 | //! animates a scene node |
79 | virtual void animateNode(ISceneNode* node, u32 timeMs); | 79 | virtual void animateNode(ISceneNode* node, u32 timeMs); |
80 | 80 | ||
81 | //! Writes attributes of the scene node animator. | 81 | //! Writes attributes of the scene node animator. |
82 | virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const; | 82 | virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const; |
83 | 83 | ||
84 | //! Reads attributes of the scene node animator. | 84 | //! Reads attributes of the scene node animator. |
85 | virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); | 85 | virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); |
86 | 86 | ||
87 | //! Returns type of the scene node animator | 87 | //! Returns type of the scene node animator |
88 | virtual ESCENE_NODE_ANIMATOR_TYPE getType() const { return ESNAT_COLLISION_RESPONSE; } | 88 | virtual ESCENE_NODE_ANIMATOR_TYPE getType() const { return ESNAT_COLLISION_RESPONSE; } |
89 | 89 | ||
90 | //! Creates a clone of this animator. | 90 | //! Creates a clone of this animator. |
91 | /** Please note that you will have to drop | 91 | /** Please note that you will have to drop |
92 | (IReferenceCounted::drop()) the returned pointer after calling | 92 | (IReferenceCounted::drop()) the returned pointer after calling |
93 | this. */ | 93 | this. */ |
94 | virtual ISceneNodeAnimator* createClone(ISceneNode* node, ISceneManager* newManager=0); | 94 | virtual ISceneNodeAnimator* createClone(ISceneNode* node, ISceneManager* newManager=0); |
95 | 95 | ||
96 | //! Set the single node that this animator will act on. | 96 | //! Set the single node that this animator will act on. |
97 | virtual void setTargetNode(ISceneNode * node) { setNode(node); } | 97 | virtual void setTargetNode(ISceneNode * node) { setNode(node); } |
98 | 98 | ||
99 | //! Gets the single node that this animator is acting on. | 99 | //! Gets the single node that this animator is acting on. |
100 | virtual ISceneNode* getTargetNode(void) const { return Object; } | 100 | virtual ISceneNode* getTargetNode(void) const { return Object; } |
101 | 101 | ||
102 | //! Returns true if a collision occurred during the last animateNode() | 102 | //! Returns true if a collision occurred during the last animateNode() |
103 | virtual bool collisionOccurred() const { return CollisionOccurred; } | 103 | virtual bool collisionOccurred() const { return CollisionOccurred; } |
104 | 104 | ||
105 | //! Returns the last point of collision. | 105 | //! Returns the last point of collision. |
106 | virtual const core::vector3df & getCollisionPoint() const { return CollisionPoint; } | 106 | virtual const core::vector3df & getCollisionPoint() const { return CollisionPoint; } |
107 | 107 | ||
108 | //! Returns the last triangle that caused a collision. | 108 | //! Returns the last triangle that caused a collision. |
109 | virtual const core::triangle3df & getCollisionTriangle() const { return CollisionTriangle; } | 109 | virtual const core::triangle3df & getCollisionTriangle() const { return CollisionTriangle; } |
110 | 110 | ||
111 | virtual const core::vector3df & getCollisionResultPosition(void) const { return CollisionResultPosition; } | 111 | virtual const core::vector3df & getCollisionResultPosition(void) const { return CollisionResultPosition; } |
112 | 112 | ||
113 | virtual ISceneNode* getCollisionNode(void) const { return CollisionNode; } | 113 | virtual ISceneNode* getCollisionNode(void) const { return CollisionNode; } |
114 | 114 | ||
115 | 115 | ||
116 | //! Sets a callback interface which will be called if a collision occurs. | 116 | //! Sets a callback interface which will be called if a collision occurs. |
117 | /** \param callback: collision callback handler that will be called when a collision | 117 | /** \param callback: collision callback handler that will be called when a collision |
118 | occurs. Set this to 0 to disable the callback. | 118 | occurs. Set this to 0 to disable the callback. |
119 | */ | 119 | */ |
120 | virtual void setCollisionCallback(ICollisionCallback* callback); | 120 | virtual void setCollisionCallback(ICollisionCallback* callback); |
121 | 121 | ||
122 | private: | 122 | private: |
123 | 123 | ||
124 | void setNode(ISceneNode* node); | 124 | void setNode(ISceneNode* node); |
125 | 125 | ||
126 | core::vector3df Radius; | 126 | core::vector3df Radius; |
127 | core::vector3df Gravity; | 127 | core::vector3df Gravity; |
128 | core::vector3df Translation; | 128 | core::vector3df Translation; |
129 | core::vector3df FallingVelocity; // In the direction of Gravity. | 129 | core::vector3df FallingVelocity; // In the direction of Gravity. |
130 | 130 | ||
131 | core::vector3df LastPosition; | 131 | core::vector3df LastPosition; |
132 | core::triangle3df RefTriangle; | 132 | core::triangle3df RefTriangle; |
133 | 133 | ||
134 | ITriangleSelector* World; | 134 | ITriangleSelector* World; |
135 | ISceneNode* Object; | 135 | ISceneNode* Object; |
136 | ISceneManager* SceneManager; | 136 | ISceneManager* SceneManager; |
137 | u32 LastTime; | 137 | u32 LastTime; |
138 | f32 SlidingSpeed; | 138 | f32 SlidingSpeed; |
139 | 139 | ||
140 | core::vector3df CollisionPoint; | 140 | core::vector3df CollisionPoint; |
141 | core::triangle3df CollisionTriangle; | 141 | core::triangle3df CollisionTriangle; |
142 | core::vector3df CollisionResultPosition; | 142 | core::vector3df CollisionResultPosition; |
143 | ISceneNode * CollisionNode; | 143 | ISceneNode * CollisionNode; |
144 | ICollisionCallback* CollisionCallback; | 144 | ICollisionCallback* CollisionCallback; |
145 | 145 | ||
146 | bool Falling; | 146 | bool Falling; |
147 | bool IsCamera; | 147 | bool IsCamera; |
148 | bool AnimateCameraTarget; | 148 | bool AnimateCameraTarget; |
149 | bool CollisionOccurred; | 149 | bool CollisionOccurred; |
150 | bool FirstUpdate; | 150 | bool FirstUpdate; |
151 | }; | 151 | }; |
152 | 152 | ||
153 | } // end namespace scene | 153 | } // end namespace scene |
154 | } // end namespace irr | 154 | } // end namespace irr |
155 | 155 | ||
156 | #endif | 156 | #endif |
157 | 157 | ||