diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/irrlicht-1.8.1/include/ISceneNodeAnimatorCollisionResponse.h | 171 |
1 files changed, 171 insertions, 0 deletions
diff --git a/libraries/irrlicht-1.8.1/include/ISceneNodeAnimatorCollisionResponse.h b/libraries/irrlicht-1.8.1/include/ISceneNodeAnimatorCollisionResponse.h new file mode 100644 index 0000000..299c0a7 --- /dev/null +++ b/libraries/irrlicht-1.8.1/include/ISceneNodeAnimatorCollisionResponse.h | |||
@@ -0,0 +1,171 @@ | |||
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 | #ifndef __I_SCENE_NODE_ANIMATOR_COLLISION_RESPONSE_H_INCLUDED__ | ||
6 | #define __I_SCENE_NODE_ANIMATOR_COLLISION_RESPONSE_H_INCLUDED__ | ||
7 | |||
8 | #include "ISceneNode.h" | ||
9 | |||
10 | namespace irr | ||
11 | { | ||
12 | namespace scene | ||
13 | { | ||
14 | |||
15 | class ISceneNodeAnimatorCollisionResponse; | ||
16 | |||
17 | //! Callback interface for catching events of collisions. | ||
18 | /** Implement this interface and use | ||
19 | ISceneNodeAnimatorCollisionResponse::setCollisionCallback to be able to | ||
20 | be notified if a collision has occurred. | ||
21 | **/ | ||
22 | class ICollisionCallback : public virtual IReferenceCounted | ||
23 | { | ||
24 | public: | ||
25 | |||
26 | //! Will be called when a collision occurrs. | ||
27 | /** See ISceneNodeAnimatorCollisionResponse::setCollisionCallback for more information. | ||
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. | ||
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 | ||
32 | to the location that triggered the collision check. | ||
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. | ||
35 | */ | ||
36 | virtual bool onCollision(const ISceneNodeAnimatorCollisionResponse& animator) = 0; | ||
37 | }; | ||
38 | |||
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 | ||
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. | ||
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 | ||
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. | ||
47 | |||
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 | ||
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(). | ||
52 | */ | ||
53 | class ISceneNodeAnimatorCollisionResponse : public ISceneNodeAnimator | ||
54 | { | ||
55 | public: | ||
56 | |||
57 | //! Destructor | ||
58 | virtual ~ISceneNodeAnimatorCollisionResponse() {} | ||
59 | |||
60 | //! Check if the attached scene node is falling. | ||
61 | /** Falling means that there is no blocking wall from the scene | ||
62 | node in the direction of the gravity. The implementation of | ||
63 | this method is very fast, no collision detection is done when | ||
64 | invoking it. | ||
65 | \return True if the scene node is falling, false if not. */ | ||
66 | virtual bool isFalling() const = 0; | ||
67 | |||
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 | ||
70 | the radius should be, you could use the following code to | ||
71 | determine it: | ||
72 | \code | ||
73 | core::aabbox<f32> box = yourSceneNode->getBoundingBox(); | ||
74 | core::vector3df radius = box.MaxEdge - box.getCenter(); | ||
75 | \endcode | ||
76 | \param radius: New radius of the ellipsoid. */ | ||
77 | virtual void setEllipsoidRadius(const core::vector3df& radius) = 0; | ||
78 | |||
79 | //! Returns the radius of the ellipsoid for collision detection and response. | ||
80 | /** \return Radius of the ellipsoid. */ | ||
81 | virtual core::vector3df getEllipsoidRadius() const = 0; | ||
82 | |||
83 | //! Sets the gravity of the environment. | ||
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 | ||
86 | gravity, make increase the length of the vector. You can | ||
87 | disable gravity by setting it to core::vector3df(0,0,0); | ||
88 | \param gravity: New gravity vector. */ | ||
89 | virtual void setGravity(const core::vector3df& gravity) = 0; | ||
90 | |||
91 | //! Get current vector of gravity. | ||
92 | //! \return Gravity vector. */ | ||
93 | virtual core::vector3df getGravity() const = 0; | ||
94 | |||
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 | ||
97 | to this animator's gravity vector. */ | ||
98 | virtual void jump(f32 jumpSpeed) = 0; | ||
99 | |||
100 | //! Should the Target react on collision ( default = true ) | ||
101 | virtual void setAnimateTarget ( bool enable ) = 0; | ||
102 | virtual bool getAnimateTarget () const = 0; | ||
103 | |||
104 | //! Set translation of the collision ellipsoid. | ||
105 | /** By default, the ellipsoid for collision detection is | ||
106 | created around the center of the scene node, which means that | ||
107 | the ellipsoid surrounds it completely. If this is not what you | ||
108 | want, you may specify a translation for the ellipsoid. | ||
109 | \param translation: Translation of the ellipsoid relative | ||
110 | to the position of the scene node. */ | ||
111 | virtual void setEllipsoidTranslation(const core::vector3df &translation) = 0; | ||
112 | |||
113 | //! Get the translation of the ellipsoid for collision detection. | ||
114 | /** See | ||
115 | ISceneNodeAnimatorCollisionResponse::setEllipsoidTranslation() | ||
116 | for more details. | ||
117 | \return Translation of the ellipsoid relative to the position | ||
118 | of the scene node. */ | ||
119 | virtual core::vector3df getEllipsoidTranslation() const = 0; | ||
120 | |||
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 | ||
123 | to let the scene node collide with. */ | ||
124 | virtual void setWorld(ITriangleSelector* newWorld) = 0; | ||
125 | |||
126 | //! Get the current triangle selector containing all triangles for collision detection. | ||
127 | virtual ITriangleSelector* getWorld() const = 0; | ||
128 | |||
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 | ||
131 | its last target position for the node, allowing setPosition() to teleport | ||
132 | the node through collision geometry. */ | ||
133 | virtual void setTargetNode(ISceneNode * node) = 0; | ||
134 | |||
135 | //! Gets the single node that this animator is acting on. | ||
136 | /** \return The node that this animator is acting on. */ | ||
137 | virtual ISceneNode* getTargetNode(void) const = 0; | ||
138 | |||
139 | //! Returns true if a collision occurred during the last animateNode() | ||
140 | virtual bool collisionOccurred() const = 0; | ||
141 | |||
142 | //! Returns the last point of collision. | ||
143 | virtual const core::vector3df & getCollisionPoint() const = 0; | ||
144 | |||
145 | //! Returns the last triangle that caused a collision | ||
146 | virtual const core::triangle3df & getCollisionTriangle() const = 0; | ||
147 | |||
148 | //! Returns the position that the target node will be moved to, unless the collision is consumed in a callback. | ||
149 | /** | ||
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 | ||
152 | move fully to the position that caused the collision to occur. */ | ||
153 | virtual const core::vector3df & getCollisionResultPosition(void) const = 0; | ||
154 | |||
155 | //! Returns the node that was collided with. | ||
156 | virtual ISceneNode* getCollisionNode(void) const = 0; | ||
157 | |||
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 | ||
160 | occurs. Set this to 0 to disable the callback. | ||
161 | */ | ||
162 | virtual void setCollisionCallback(ICollisionCallback* callback) = 0; | ||
163 | |||
164 | }; | ||
165 | |||
166 | |||
167 | } // end namespace scene | ||
168 | } // end namespace irr | ||
169 | |||
170 | #endif | ||
171 | |||