diff options
Diffstat (limited to 'libraries/irrlicht-1.8/include/ISceneNodeAnimatorCollisionResponse.h')
-rw-r--r-- | libraries/irrlicht-1.8/include/ISceneNodeAnimatorCollisionResponse.h | 342 |
1 files changed, 171 insertions, 171 deletions
diff --git a/libraries/irrlicht-1.8/include/ISceneNodeAnimatorCollisionResponse.h b/libraries/irrlicht-1.8/include/ISceneNodeAnimatorCollisionResponse.h index 299c0a7..e2bba8a 100644 --- a/libraries/irrlicht-1.8/include/ISceneNodeAnimatorCollisionResponse.h +++ b/libraries/irrlicht-1.8/include/ISceneNodeAnimatorCollisionResponse.h | |||
@@ -1,171 +1,171 @@ | |||
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 __I_SCENE_NODE_ANIMATOR_COLLISION_RESPONSE_H_INCLUDED__ | 5 | #ifndef __I_SCENE_NODE_ANIMATOR_COLLISION_RESPONSE_H_INCLUDED__ |
6 | #define __I_SCENE_NODE_ANIMATOR_COLLISION_RESPONSE_H_INCLUDED__ | 6 | #define __I_SCENE_NODE_ANIMATOR_COLLISION_RESPONSE_H_INCLUDED__ |
7 | 7 | ||
8 | #include "ISceneNode.h" | 8 | #include "ISceneNode.h" |
9 | 9 | ||
10 | namespace irr | 10 | namespace irr |
11 | { | 11 | { |
12 | namespace scene | 12 | namespace scene |
13 | { | 13 | { |
14 | 14 | ||
15 | class ISceneNodeAnimatorCollisionResponse; | 15 | class ISceneNodeAnimatorCollisionResponse; |
16 | 16 | ||
17 | //! Callback interface for catching events of collisions. | 17 | //! Callback interface for catching events of collisions. |
18 | /** Implement this interface and use | 18 | /** Implement this interface and use |
19 | ISceneNodeAnimatorCollisionResponse::setCollisionCallback to be able to | 19 | ISceneNodeAnimatorCollisionResponse::setCollisionCallback to be able to |
20 | be notified if a collision has occurred. | 20 | be notified if a collision has occurred. |
21 | **/ | 21 | **/ |
22 | class ICollisionCallback : public virtual IReferenceCounted | 22 | class ICollisionCallback : public virtual IReferenceCounted |
23 | { | 23 | { |
24 | public: | 24 | public: |
25 | 25 | ||
26 | //! Will be called when a collision occurrs. | 26 | //! Will be called when a collision occurrs. |
27 | /** See ISceneNodeAnimatorCollisionResponse::setCollisionCallback for more information. | 27 | /** See ISceneNodeAnimatorCollisionResponse::setCollisionCallback for more information. |
28 | \param animator: Collision response animator in which the collision occurred. You can call | 28 | \param animator: Collision response animator in which the collision occurred. You can call |
29 | this animator's methods to find the node, collisionPoint and/or collision triangle. | 29 | this animator's methods to find the node, collisionPoint and/or collision triangle. |
30 | \retval true if the collision was handled in the animator. The animator's target | 30 | \retval true if the collision was handled in the animator. The animator's target |
31 | node will *not* be stopped at the collision point, but will instead move fully | 31 | node will *not* be stopped at the collision point, but will instead move fully |
32 | to the location that triggered the collision check. | 32 | to the location that triggered the collision check. |
33 | \retval false if the collision was not handled in the animator. The animator's | 33 | \retval false if the collision was not handled in the animator. The animator's |
34 | target node will be moved to the collision position. | 34 | target node will be moved to the collision position. |
35 | */ | 35 | */ |
36 | virtual bool onCollision(const ISceneNodeAnimatorCollisionResponse& animator) = 0; | 36 | virtual bool onCollision(const ISceneNodeAnimatorCollisionResponse& animator) = 0; |
37 | }; | 37 | }; |
38 | 38 | ||
39 | //! Special scene node animator for doing automatic collision detection and response. | 39 | //! Special scene node animator for doing automatic collision detection and response. |
40 | /** This scene node animator can be attached to any single scene node | 40 | /** This scene node animator can be attached to any single scene node |
41 | and will then prevent it from moving through specified collision geometry | 41 | and will then prevent it from moving through specified collision geometry |
42 | (e.g. walls and floors of the) world, as well as having it fall under gravity. | 42 | (e.g. walls and floors of the) world, as well as having it fall under gravity. |
43 | This animator provides a simple implementation of first person shooter cameras. | 43 | This animator provides a simple implementation of first person shooter cameras. |
44 | Attach it to a camera, and the camera will behave as the player control in a | 44 | Attach it to a camera, and the camera will behave as the player control in a |
45 | first person shooter game: The camera stops and slides at walls, walks up stairs, | 45 | first person shooter game: The camera stops and slides at walls, walks up stairs, |
46 | falls down if there is no floor under it, and so on. | 46 | falls down if there is no floor under it, and so on. |
47 | 47 | ||
48 | The animator will treat any change in the position of its target scene | 48 | The animator will treat any change in the position of its target scene |
49 | node as movement, including a setPosition(), as movement. If you want to | 49 | node as movement, including a setPosition(), as movement. If you want to |
50 | teleport the target scene node manually to a location without it being effected | 50 | teleport the target scene node manually to a location without it being effected |
51 | by collision geometry, then call setTargetNode(node) after calling node->setPosition(). | 51 | by collision geometry, then call setTargetNode(node) after calling node->setPosition(). |
52 | */ | 52 | */ |
53 | class ISceneNodeAnimatorCollisionResponse : public ISceneNodeAnimator | 53 | class ISceneNodeAnimatorCollisionResponse : public ISceneNodeAnimator |
54 | { | 54 | { |
55 | public: | 55 | public: |
56 | 56 | ||
57 | //! Destructor | 57 | //! Destructor |
58 | virtual ~ISceneNodeAnimatorCollisionResponse() {} | 58 | virtual ~ISceneNodeAnimatorCollisionResponse() {} |
59 | 59 | ||
60 | //! Check if the attached scene node is falling. | 60 | //! Check if the attached scene node is falling. |
61 | /** Falling means that there is no blocking wall from the scene | 61 | /** Falling means that there is no blocking wall from the scene |
62 | node in the direction of the gravity. The implementation of | 62 | node in the direction of the gravity. The implementation of |
63 | this method is very fast, no collision detection is done when | 63 | this method is very fast, no collision detection is done when |
64 | invoking it. | 64 | invoking it. |
65 | \return True if the scene node is falling, false if not. */ | 65 | \return True if the scene node is falling, false if not. */ |
66 | virtual bool isFalling() const = 0; | 66 | virtual bool isFalling() const = 0; |
67 | 67 | ||
68 | //! Sets the radius of the ellipsoid for collision detection and response. | 68 | //! Sets the radius of the ellipsoid for collision detection and response. |
69 | /** If you have a scene node, and you are unsure about how big | 69 | /** If you have a scene node, and you are unsure about how big |
70 | the radius should be, you could use the following code to | 70 | the radius should be, you could use the following code to |
71 | determine it: | 71 | determine it: |
72 | \code | 72 | \code |
73 | core::aabbox<f32> box = yourSceneNode->getBoundingBox(); | 73 | core::aabbox<f32> box = yourSceneNode->getBoundingBox(); |
74 | core::vector3df radius = box.MaxEdge - box.getCenter(); | 74 | core::vector3df radius = box.MaxEdge - box.getCenter(); |
75 | \endcode | 75 | \endcode |
76 | \param radius: New radius of the ellipsoid. */ | 76 | \param radius: New radius of the ellipsoid. */ |
77 | virtual void setEllipsoidRadius(const core::vector3df& radius) = 0; | 77 | virtual void setEllipsoidRadius(const core::vector3df& radius) = 0; |
78 | 78 | ||
79 | //! Returns the radius of the ellipsoid for collision detection and response. | 79 | //! Returns the radius of the ellipsoid for collision detection and response. |
80 | /** \return Radius of the ellipsoid. */ | 80 | /** \return Radius of the ellipsoid. */ |
81 | virtual core::vector3df getEllipsoidRadius() const = 0; | 81 | virtual core::vector3df getEllipsoidRadius() const = 0; |
82 | 82 | ||
83 | //! Sets the gravity of the environment. | 83 | //! Sets the gravity of the environment. |
84 | /** A good example value would be core::vector3df(0,-100.0f,0) | 84 | /** A good example value would be core::vector3df(0,-100.0f,0) |
85 | for letting gravity affect all object to fall down. For bigger | 85 | for letting gravity affect all object to fall down. For bigger |
86 | gravity, make increase the length of the vector. You can | 86 | gravity, make increase the length of the vector. You can |
87 | disable gravity by setting it to core::vector3df(0,0,0); | 87 | disable gravity by setting it to core::vector3df(0,0,0); |
88 | \param gravity: New gravity vector. */ | 88 | \param gravity: New gravity vector. */ |
89 | virtual void setGravity(const core::vector3df& gravity) = 0; | 89 | virtual void setGravity(const core::vector3df& gravity) = 0; |
90 | 90 | ||
91 | //! Get current vector of gravity. | 91 | //! Get current vector of gravity. |
92 | //! \return Gravity vector. */ | 92 | //! \return Gravity vector. */ |
93 | virtual core::vector3df getGravity() const = 0; | 93 | virtual core::vector3df getGravity() const = 0; |
94 | 94 | ||
95 | //! 'Jump' the animator, by adding a jump speed opposite to its gravity | 95 | //! 'Jump' the animator, by adding a jump speed opposite to its gravity |
96 | /** \param jumpSpeed The initial speed of the jump; the velocity will be opposite | 96 | /** \param jumpSpeed The initial speed of the jump; the velocity will be opposite |
97 | to this animator's gravity vector. */ | 97 | to this animator's gravity vector. */ |
98 | virtual void jump(f32 jumpSpeed) = 0; | 98 | virtual void jump(f32 jumpSpeed) = 0; |
99 | 99 | ||
100 | //! Should the Target react on collision ( default = true ) | 100 | //! Should the Target react on collision ( default = true ) |
101 | virtual void setAnimateTarget ( bool enable ) = 0; | 101 | virtual void setAnimateTarget ( bool enable ) = 0; |
102 | virtual bool getAnimateTarget () const = 0; | 102 | virtual bool getAnimateTarget () const = 0; |
103 | 103 | ||
104 | //! Set translation of the collision ellipsoid. | 104 | //! Set translation of the collision ellipsoid. |
105 | /** By default, the ellipsoid for collision detection is | 105 | /** By default, the ellipsoid for collision detection is |
106 | created around the center of the scene node, which means that | 106 | created around the center of the scene node, which means that |
107 | the ellipsoid surrounds it completely. If this is not what you | 107 | the ellipsoid surrounds it completely. If this is not what you |
108 | want, you may specify a translation for the ellipsoid. | 108 | want, you may specify a translation for the ellipsoid. |
109 | \param translation: Translation of the ellipsoid relative | 109 | \param translation: Translation of the ellipsoid relative |
110 | to the position of the scene node. */ | 110 | to the position of the scene node. */ |
111 | virtual void setEllipsoidTranslation(const core::vector3df &translation) = 0; | 111 | virtual void setEllipsoidTranslation(const core::vector3df &translation) = 0; |
112 | 112 | ||
113 | //! Get the translation of the ellipsoid for collision detection. | 113 | //! Get the translation of the ellipsoid for collision detection. |
114 | /** See | 114 | /** See |
115 | ISceneNodeAnimatorCollisionResponse::setEllipsoidTranslation() | 115 | ISceneNodeAnimatorCollisionResponse::setEllipsoidTranslation() |
116 | for more details. | 116 | for more details. |
117 | \return Translation of the ellipsoid relative to the position | 117 | \return Translation of the ellipsoid relative to the position |
118 | of the scene node. */ | 118 | of the scene node. */ |
119 | virtual core::vector3df getEllipsoidTranslation() const = 0; | 119 | virtual core::vector3df getEllipsoidTranslation() const = 0; |
120 | 120 | ||
121 | //! Sets a triangle selector holding all triangles of the world with which the scene node may collide. | 121 | //! Sets a triangle selector holding all triangles of the world with which the scene node may collide. |
122 | /** \param newWorld: New triangle selector containing triangles | 122 | /** \param newWorld: New triangle selector containing triangles |
123 | to let the scene node collide with. */ | 123 | to let the scene node collide with. */ |
124 | virtual void setWorld(ITriangleSelector* newWorld) = 0; | 124 | virtual void setWorld(ITriangleSelector* newWorld) = 0; |
125 | 125 | ||
126 | //! Get the current triangle selector containing all triangles for collision detection. | 126 | //! Get the current triangle selector containing all triangles for collision detection. |
127 | virtual ITriangleSelector* getWorld() const = 0; | 127 | virtual ITriangleSelector* getWorld() const = 0; |
128 | 128 | ||
129 | //! Set the single node that this animator will act on. | 129 | //! Set the single node that this animator will act on. |
130 | /** \param node The new target node. Setting this will force the animator to update | 130 | /** \param node The new target node. Setting this will force the animator to update |
131 | its last target position for the node, allowing setPosition() to teleport | 131 | its last target position for the node, allowing setPosition() to teleport |
132 | the node through collision geometry. */ | 132 | the node through collision geometry. */ |
133 | virtual void setTargetNode(ISceneNode * node) = 0; | 133 | virtual void setTargetNode(ISceneNode * node) = 0; |
134 | 134 | ||
135 | //! Gets the single node that this animator is acting on. | 135 | //! Gets the single node that this animator is acting on. |
136 | /** \return The node that this animator is acting on. */ | 136 | /** \return The node that this animator is acting on. */ |
137 | virtual ISceneNode* getTargetNode(void) const = 0; | 137 | virtual ISceneNode* getTargetNode(void) const = 0; |
138 | 138 | ||
139 | //! Returns true if a collision occurred during the last animateNode() | 139 | //! Returns true if a collision occurred during the last animateNode() |
140 | virtual bool collisionOccurred() const = 0; | 140 | virtual bool collisionOccurred() const = 0; |
141 | 141 | ||
142 | //! Returns the last point of collision. | 142 | //! Returns the last point of collision. |
143 | virtual const core::vector3df & getCollisionPoint() const = 0; | 143 | virtual const core::vector3df & getCollisionPoint() const = 0; |
144 | 144 | ||
145 | //! Returns the last triangle that caused a collision | 145 | //! Returns the last triangle that caused a collision |
146 | virtual const core::triangle3df & getCollisionTriangle() const = 0; | 146 | virtual const core::triangle3df & getCollisionTriangle() const = 0; |
147 | 147 | ||
148 | //! Returns the position that the target node will be moved to, unless the collision is consumed in a callback. | 148 | //! Returns the position that the target node will be moved to, unless the collision is consumed in a callback. |
149 | /** | 149 | /** |
150 | If you have a collision callback registered, and it consumes the collision, then the | 150 | If you have a collision callback registered, and it consumes the collision, then the |
151 | node will ignore the collision and will not stop at this position. Instead, it will | 151 | node will ignore the collision and will not stop at this position. Instead, it will |
152 | move fully to the position that caused the collision to occur. */ | 152 | move fully to the position that caused the collision to occur. */ |
153 | virtual const core::vector3df & getCollisionResultPosition(void) const = 0; | 153 | virtual const core::vector3df & getCollisionResultPosition(void) const = 0; |
154 | 154 | ||
155 | //! Returns the node that was collided with. | 155 | //! Returns the node that was collided with. |
156 | virtual ISceneNode* getCollisionNode(void) const = 0; | 156 | virtual ISceneNode* getCollisionNode(void) const = 0; |
157 | 157 | ||
158 | //! Sets a callback interface which will be called if a collision occurs. | 158 | //! Sets a callback interface which will be called if a collision occurs. |
159 | /** \param callback: collision callback handler that will be called when a collision | 159 | /** \param callback: collision callback handler that will be called when a collision |
160 | occurs. Set this to 0 to disable the callback. | 160 | occurs. Set this to 0 to disable the callback. |
161 | */ | 161 | */ |
162 | virtual void setCollisionCallback(ICollisionCallback* callback) = 0; | 162 | virtual void setCollisionCallback(ICollisionCallback* callback) = 0; |
163 | 163 | ||
164 | }; | 164 | }; |
165 | 165 | ||
166 | 166 | ||
167 | } // end namespace scene | 167 | } // end namespace scene |
168 | } // end namespace irr | 168 | } // end namespace irr |
169 | 169 | ||
170 | #endif | 170 | #endif |
171 | 171 | ||