Saga3D API Documentation  1.0-RC4
saga::scene::ISceneNodeAnimatorCollisionResponse Class Referenceabstract

Special scene node animator for doing automatic collision detection and response. More...

#include <ISceneNodeAnimatorCollisionResponse.h>

Inheritance diagram for saga::scene::ISceneNodeAnimatorCollisionResponse:
saga::scene::ISceneNodeAnimator saga::IEventReceiver

Public Member Functions

virtual ~ISceneNodeAnimatorCollisionResponse ()
 Destructor. More...
 
virtual bool isFalling () const =0
 Check if the attached scene node is falling. More...
 
virtual void setEllipsoidRadius (const glm::vec3 &radius)=0
 Sets the radius of the ellipsoid for collision detection and response. More...
 
virtual glm::vec3 getEllipsoidRadius () const =0
 Returns the radius of the ellipsoid for collision detection and response. More...
 
virtual void setGravity (const glm::vec3 &gravity)=0
 Sets the gravity of the environment. More...
 
virtual glm::vec3 getGravity () const =0
 
virtual void jump (float jumpSpeed)=0
 'Jump' the animator, by adding a jump speed opposite to its gravity More...
 
virtual void setAnimateTarget (bool enable)=0
 Should the Target react on collision (default = true) More...
 
virtual bool getAnimateTarget () const =0
 
virtual void setEllipsoidTranslation (const glm::vec3 &translation)=0
 Set translation of the collision ellipsoid. More...
 
virtual glm::vec3 getEllipsoidTranslation () const =0
 Get the translation of the ellipsoid for collision detection. More...
 
virtual void setWorld (ITriangleSelector *newWorld)=0
 Sets a triangle selector holding all triangles of the world with which the scene node may collide. More...
 
virtual ITriangleSelector * getWorld () const =0
 Get the current triangle selector containing all triangles for collision detection. More...
 
virtual void setTargetNode (ISceneNode *node)=0
 Set the single node that this animator will act on. More...
 
virtual ISceneNodegetTargetNode (void) const =0
 Gets the single node that this animator is acting on. More...
 
virtual bool collisionOccurred () const =0
 Returns true if a collision occurred during the last animateNode() More...
 
virtual const glm::vec3 & getCollisionPoint () const =0
 Returns the last point of collision. More...
 
virtual const core::triangle3dfgetCollisionTriangle () const =0
 Returns the last triangle that caused a collision. More...
 
virtual const glm::vec3 & getCollisionResultPosition (void) const =0
 Returns the position that the target node will be moved to, unless the collision is consumed in a callback. More...
 
virtual ISceneNodegetCollisionNode (void) const =0
 Returns the node that was collided with. More...
 
virtual void setCollisionCallback (ICollisionCallback *callback)=0
 Sets a callback interface which will be called if a collision occurs. More...
 
- Public Member Functions inherited from saga::scene::ISceneNodeAnimator
 ISceneNodeAnimator ()
 
virtual void animateNode (ISceneNode &node, const float time)=0
 Animates a scene node. More...
 
virtual void onEvent (const SDL_Event &event) override
 Creates a clone of this animator. More...
 
virtual E_SCENE_NODE_ANIMATOR_TYPE getType () const
 Returns type of the scene node animator. More...
 
virtual bool hasFinished (void) const
 Returns if the animator has finished. More...
 
virtual void setStartTime (std::uint32_t time, bool resetPauseTime=true)
 Reset a time-based movement by changing the starttime. More...
 
virtual std::uint32_t getStartTime () const
 Get the starttime. More...
 
virtual void setEnabled (bool enabled, std::uint32_t timeNow=0)
 Sets the enabled state of this element. More...
 
virtual bool isEnabled () const
 
- Public Member Functions inherited from saga::IEventReceiver
virtual ~IEventReceiver ()
 Destructor. More...
 

Additional Inherited Members

- Protected Attributes inherited from saga::scene::ISceneNodeAnimator
bool IsEnabled
 
std::uint32_t PauseTimeSum
 Only enabled animators are updated. More...
 
std::uint32_t PauseTimeStart
 Sum up time which the animator was disabled. More...
 
std::uint32_t StartTime
 Last time setEnabled(false) was called with a timer > 0. More...
 

Detailed Description

Special scene node animator for doing automatic collision detection and response.

This scene node animator can be attached to any single scene node and will then prevent it from moving through specified collision geometry (e.g. walls and floors of the) world, as well as having it fall under gravity. This animator provides a simple implementation of first person shooter cameras. Attach it to a camera, and the camera will behave as the player control in a first person shooter game: The camera stops and slides at walls, walks up stairs, falls down if there is no floor under it, and so on.

The animator will treat any change in the position of its target scene node as movement, including a setPosition(), as movement. If you want to teleport the target scene node manually to a location without it being effected by collision geometry, then call setTargetNode(node) after calling node->setPosition().

Definition at line 53 of file ISceneNodeAnimatorCollisionResponse.h.

Constructor & Destructor Documentation

◆ ~ISceneNodeAnimatorCollisionResponse()

virtual saga::scene::ISceneNodeAnimatorCollisionResponse::~ISceneNodeAnimatorCollisionResponse ( )
inlinevirtual

Destructor.

Definition at line 58 of file ISceneNodeAnimatorCollisionResponse.h.

Member Function Documentation

◆ collisionOccurred()

virtual bool saga::scene::ISceneNodeAnimatorCollisionResponse::collisionOccurred ( ) const
pure virtual

Returns true if a collision occurred during the last animateNode()

◆ getAnimateTarget()

virtual bool saga::scene::ISceneNodeAnimatorCollisionResponse::getAnimateTarget ( ) const
pure virtual

◆ getCollisionNode()

virtual ISceneNode* saga::scene::ISceneNodeAnimatorCollisionResponse::getCollisionNode ( void  ) const
pure virtual

Returns the node that was collided with.

◆ getCollisionPoint()

virtual const glm::vec3& saga::scene::ISceneNodeAnimatorCollisionResponse::getCollisionPoint ( ) const
pure virtual

Returns the last point of collision.

◆ getCollisionResultPosition()

virtual const glm::vec3& saga::scene::ISceneNodeAnimatorCollisionResponse::getCollisionResultPosition ( void  ) const
pure virtual

Returns the position that the target node will be moved to, unless the collision is consumed in a callback.

If you have a collision callback registered, and it consumes the collision, then the node will ignore the collision and will not stop at this position. Instead, it will move fully to the position that caused the collision to occur.

◆ getCollisionTriangle()

virtual const core::triangle3df& saga::scene::ISceneNodeAnimatorCollisionResponse::getCollisionTriangle ( ) const
pure virtual

Returns the last triangle that caused a collision.

◆ getEllipsoidRadius()

virtual glm::vec3 saga::scene::ISceneNodeAnimatorCollisionResponse::getEllipsoidRadius ( ) const
pure virtual

Returns the radius of the ellipsoid for collision detection and response.

Returns
Radius of the ellipsoid.

◆ getEllipsoidTranslation()

virtual glm::vec3 saga::scene::ISceneNodeAnimatorCollisionResponse::getEllipsoidTranslation ( ) const
pure virtual

Get the translation of the ellipsoid for collision detection.

See ISceneNodeAnimatorCollisionResponse::setEllipsoidTranslation() for more details.

Returns
Translation of the ellipsoid relative to the position of the scene node.

◆ getGravity()

virtual glm::vec3 saga::scene::ISceneNodeAnimatorCollisionResponse::getGravity ( ) const
pure virtual

Get current vector of gravity.

Returns
Gravity vector. *‍/

◆ getTargetNode()

virtual ISceneNode* saga::scene::ISceneNodeAnimatorCollisionResponse::getTargetNode ( void  ) const
pure virtual

Gets the single node that this animator is acting on.

Returns
The node that this animator is acting on.

◆ getWorld()

virtual ITriangleSelector* saga::scene::ISceneNodeAnimatorCollisionResponse::getWorld ( ) const
pure virtual

Get the current triangle selector containing all triangles for collision detection.

◆ isFalling()

virtual bool saga::scene::ISceneNodeAnimatorCollisionResponse::isFalling ( ) const
pure virtual

Check if the attached scene node is falling.

Falling means that there is no blocking wall from the scene node in the direction of the gravity. The implementation of this method is very fast, no collision detection is done when invoking it.

Returns
True if the scene node is falling, false if not.

◆ jump()

virtual void saga::scene::ISceneNodeAnimatorCollisionResponse::jump ( float  jumpSpeed)
pure virtual

'Jump' the animator, by adding a jump speed opposite to its gravity

Parameters
jumpSpeedThe initial speed of the jump; the velocity will be opposite to this animator's gravity vector.

◆ setAnimateTarget()

virtual void saga::scene::ISceneNodeAnimatorCollisionResponse::setAnimateTarget ( bool  enable)
pure virtual

Should the Target react on collision (default = true)

◆ setCollisionCallback()

virtual void saga::scene::ISceneNodeAnimatorCollisionResponse::setCollisionCallback ( ICollisionCallback callback)
pure virtual

Sets a callback interface which will be called if a collision occurs.

Parameters
callbackcollision callback handler that will be called when a collision occurs. Set this to 0 to disable the callback.

◆ setEllipsoidRadius()

virtual void saga::scene::ISceneNodeAnimatorCollisionResponse::setEllipsoidRadius ( const glm::vec3 &  radius)
pure virtual

Sets the radius of the ellipsoid for collision detection and response.

If you have a scene node, and you are unsure about how big the radius should be, you could use the following code to determine it:

core::aabbox<float> box = yourSceneNode->getBoundingBox();
glm::vec3 radius = box.MaxEdge - box.getCenter();
Parameters
radiusNew radius of the ellipsoid.

◆ setEllipsoidTranslation()

virtual void saga::scene::ISceneNodeAnimatorCollisionResponse::setEllipsoidTranslation ( const glm::vec3 &  translation)
pure virtual

Set translation of the collision ellipsoid.

By default, the ellipsoid for collision detection is created around the center of the scene node, which means that the ellipsoid surrounds it completely. If this is not what you want, you may specify a translation for the ellipsoid.

Parameters
translationTranslation of the ellipsoid relative to the position of the scene node.

◆ setGravity()

virtual void saga::scene::ISceneNodeAnimatorCollisionResponse::setGravity ( const glm::vec3 &  gravity)
pure virtual

Sets the gravity of the environment.

A good example value would be glm::vec3(0,-100.0f,0) for letting gravity affect all object to fall down. For bigger gravity, make increase the length of the vector. You can disable gravity by setting it to glm::vec3(0,0,0);

Parameters
gravityNew gravity vector.

◆ setTargetNode()

virtual void saga::scene::ISceneNodeAnimatorCollisionResponse::setTargetNode ( ISceneNode node)
pure virtual

Set the single node that this animator will act on.

Parameters
nodeThe new target node. Setting this will force the animator to update its last target position for the node, allowing setPosition() to teleport the node through collision geometry.

◆ setWorld()

virtual void saga::scene::ISceneNodeAnimatorCollisionResponse::setWorld ( ITriangleSelector *  newWorld)
pure virtual

Sets a triangle selector holding all triangles of the world with which the scene node may collide.

Parameters
newWorldNew triangle selector containing triangles to let the scene node collide with.

The documentation for this class was generated from the following file: