arsa  2.7
Public Member Functions | List of all members
irr::scene::ISceneCollisionManager Class Referenceabstract

The Scene Collision Manager provides methods for performing collision tests and picking on scene nodes. More...

#include <ISceneCollisionManager.h>

Inheritance diagram for irr::scene::ISceneCollisionManager:
irr::IReferenceCounted

Public Member Functions

virtual bool getCollisionPoint (SCollisionHit &hitResult, const core::line3d< f32 > &ray, ITriangleSelector *selector)=0
 Finds the nearest collision point of a line and lots of triangles, if there is one. More...
 
virtual bool getCollisionPoint (const core::line3d< f32 > &ray, ITriangleSelector *selector, core::vector3df &outCollisionPoint, core::triangle3df &outTriangle, ISceneNode *&outNode)
 Finds the nearest collision point of a line and lots of triangles, if there is one. More...
 
virtual core::vector3df getCollisionResultPosition (ITriangleSelector *selector, const core::vector3df &ellipsoidPosition, const core::vector3df &ellipsoidRadius, const core::vector3df &ellipsoidDirectionAndSpeed, core::triangle3df &triout, core::vector3df &hitPosition, bool &outFalling, ISceneNode *&outNode, f32 slidingSpeed=0.0005f, const core::vector3df &gravityDirectionAndSpeed=core::vector3df(0.0f, 0.0f, 0.0f))=0
 Collides a moving ellipsoid with a 3d world with gravity and returns the resulting new position of the ellipsoid. More...
 
virtual core::line3d< f32getRayFromScreenCoordinates (const core::position2d< s32 > &pos, const ICameraSceneNode *camera=0)=0
 Returns a 3d ray which would go through the 2d screen coordinates. More...
 
virtual core::position2d< s32getScreenCoordinatesFrom3DPosition (const core::vector3df &pos, const ICameraSceneNode *camera=0, bool useViewPort=false)=0
 Calculates 2d screen position from a 3d position. More...
 
virtual ISceneNodegetSceneNodeFromScreenCoordinatesBB (const core::position2d< s32 > &pos, s32 idBitMask=0, bool bNoDebugObjects=false, ISceneNode *root=0)=0
 Gets the scene node, which is currently visible under the given screen coordinates, viewed from the currently active camera. More...
 
virtual ISceneNodegetSceneNodeFromRayBB (const core::line3d< f32 > &ray, s32 idBitMask=0, bool bNoDebugObjects=false, ISceneNode *root=0)=0
 Returns the nearest scene node which collides with a 3d ray and whose id matches a bitmask. More...
 
virtual ISceneNodegetSceneNodeFromCameraBB (const ICameraSceneNode *camera, s32 idBitMask=0, bool bNoDebugObjects=false)=0
 Get the scene node, which the given camera is looking at and whose id matches the bitmask. More...
 
virtual ISceneNodegetSceneNodeAndCollisionPointFromRay (SCollisionHit &hitResult, const core::line3df &ray, s32 idBitMask=0, ISceneNode *collisionRootNode=0, bool noDebugObjects=false)=0
 Perform a ray/box and ray/triangle collision check on a hierarchy of scene nodes. More...
 
virtual ISceneNodegetSceneNodeAndCollisionPointFromRay (const core::line3df &ray, core::vector3df &outCollisionPoint, core::triangle3df &outTriangle, s32 idBitMask=0, ISceneNode *collisionRootNode=0, bool noDebugObjects=false)
 Perform a ray/box and ray/triangle collision check on a hierarchy of scene nodes. More...
 
- Public Member Functions inherited from irr::IReferenceCounted
 IReferenceCounted ()
 Constructor. More...
 
virtual ~IReferenceCounted ()
 Destructor. More...
 
void grab () const
 Grabs the object. Increments the reference counter by one. More...
 
bool drop () const
 Drops the object. Decrements the reference counter by one. More...
 
s32 getReferenceCount () const
 Get the reference count. More...
 
const c8getDebugName () const
 Returns the debug name of the object. More...
 

Additional Inherited Members

- Protected Member Functions inherited from irr::IReferenceCounted
void setDebugName (const c8 *newName)
 Sets the debug name of the object. More...
 

Detailed Description

The Scene Collision Manager provides methods for performing collision tests and picking on scene nodes.

Definition at line 49 of file ISceneCollisionManager.h.

Member Function Documentation

◆ getCollisionPoint() [1/2]

virtual bool irr::scene::ISceneCollisionManager::getCollisionPoint ( SCollisionHit hitResult,
const core::line3d< f32 > &  ray,
ITriangleSelector selector 
)
pure virtual

Finds the nearest collision point of a line and lots of triangles, if there is one.

Parameters
hitResultContains collision result when there was a collision detected.
rayLine with which collisions are tested.
selectorTriangleSelector to be used for the collision check.
Returns
true if a collision was detected and false if not.

◆ getCollisionPoint() [2/2]

virtual bool irr::scene::ISceneCollisionManager::getCollisionPoint ( const core::line3d< f32 > &  ray,
ITriangleSelector selector,
core::vector3df outCollisionPoint,
core::triangle3df outTriangle,
ISceneNode *&  outNode 
)
inlinevirtual

Finds the nearest collision point of a line and lots of triangles, if there is one.

Parameters
rayLine with which collisions are tested.
selectorTriangleSelector containing the triangles. It can be created for example using ISceneManager::createTriangleSelector() or ISceneManager::createTriangleOctreeSelector().
outCollisionPointIf a collision is detected, this will contain the position of the nearest collision to the line-start.
outTriangleIf a collision is detected, this will contain the triangle with which the ray collided.
outNodeIf a collision is detected, this will contain the scene node associated with the triangle that was hit.
Returns
True if a collision was detected and false if not.

Definition at line 74 of file ISceneCollisionManager.h.

77  {
78  SCollisionHit hitResult;
79  if ( getCollisionPoint(hitResult, ray, selector) )
80  {
81  outCollisionPoint = hitResult.Intersection;
82  outTriangle = hitResult.Triangle;
83  outNode = hitResult.Node;
84  return true;
85  }
86  return false;
87  }
virtual bool getCollisionPoint(SCollisionHit &hitResult, const core::line3d< f32 > &ray, ITriangleSelector *selector)=0
Finds the nearest collision point of a line and lots of triangles, if there is one.

◆ getCollisionResultPosition()

virtual core::vector3df irr::scene::ISceneCollisionManager::getCollisionResultPosition ( ITriangleSelector selector,
const core::vector3df ellipsoidPosition,
const core::vector3df ellipsoidRadius,
const core::vector3df ellipsoidDirectionAndSpeed,
core::triangle3df triout,
core::vector3df hitPosition,
bool &  outFalling,
ISceneNode *&  outNode,
f32  slidingSpeed = 0.0005f,
const core::vector3df gravityDirectionAndSpeed = core::vector3df(0.0f, 0.0f, 0.0f) 
)
pure virtual

Collides a moving ellipsoid with a 3d world with gravity and returns the resulting new position of the ellipsoid.

This can be used for moving a character in a 3d world: The character will slide at walls and is able to walk up stairs. The method used how to calculate the collision result position is based on the paper "Improved Collision detection and Response" by Kasper Fauerby.

Parameters
selectorTriangleSelector containing the triangles of the world. It can be created for example using ISceneManager::createTriangleSelector() or ISceneManager::createTriangleOctreeSelector().
ellipsoidPositionPosition of the ellipsoid.
ellipsoidRadiusRadius of the ellipsoid.
ellipsoidDirectionAndSpeedDirection and speed of the movement of the ellipsoid.
trioutOptional parameter where the last triangle causing a collision is stored, if there is a collision.
hitPositionReturn value for the position of the collision
outFallingIs set to true if the ellipsoid is falling down, caused by gravity.
outNodethe node with which the ellipsoid collided (if any)
slidingSpeedDOCUMENTATION NEEDED.
gravityDirectionAndSpeedDirection and force of gravity.
Returns
New position of the ellipsoid.

◆ getRayFromScreenCoordinates()

virtual core::line3d<f32> irr::scene::ISceneCollisionManager::getRayFromScreenCoordinates ( const core::position2d< s32 > &  pos,
const ICameraSceneNode camera = 0 
)
pure virtual

Returns a 3d ray which would go through the 2d screen coordinates.

Parameters
posScreen coordinates in pixels.
cameraCamera from which the ray starts. If null, the active camera is used.
Returns
Ray starting from the position of the camera and ending at a length of the far value of the camera at a position which would be behind the 2d screen coordinates.

◆ getSceneNodeAndCollisionPointFromRay() [1/2]

virtual ISceneNode* irr::scene::ISceneCollisionManager::getSceneNodeAndCollisionPointFromRay ( SCollisionHit hitResult,
const core::line3df ray,
s32  idBitMask = 0,
ISceneNode collisionRootNode = 0,
bool  noDebugObjects = false 
)
pure virtual

Perform a ray/box and ray/triangle collision check on a hierarchy of scene nodes.

This checks all scene nodes under the specified one, first by ray/bounding box, and then by accurate ray/triangle collision, finding the nearest collision, and the scene node containing it. It returns the node hit, and (via output parameters) the position of the collision, and the triangle that was hit.

All scene nodes in the hierarchy tree under the specified node are checked. Only nodes that are visible, with an ID that matches at least one bit in the supplied bitmask, and which have a triangle selector are considered as candidates for being hit. You do not have to build a meta triangle selector; the individual triangle selectors of each candidate scene node are used automatically.

Parameters
rayLine with which collisions are tested.
outCollisionPointIf a collision is detected, this will contain the position of the nearest collision.
outTriangleIf a collision is detected, this will contain the triangle with which the ray collided.
idBitMaskOnly scene nodes with an id which matches at least one of the bits contained in this mask will be tested. However, if this parameter is 0, then all nodes are checked.
collisionRootNodethe scene node at which to begin checking. Only this node and its children will be checked. If you want to check the entire scene, pass 0, and the root scene node will be used (this is the default).
noDebugObjectswhen true, debug objects are not considered viable targets. Debug objects are scene nodes with IsDebugObject() = true.
Returns
Returns the scene node containing the hit triangle nearest to ray.start. If no collision is detected, then 0 is returned.

◆ getSceneNodeAndCollisionPointFromRay() [2/2]

virtual ISceneNode* irr::scene::ISceneCollisionManager::getSceneNodeAndCollisionPointFromRay ( const core::line3df ray,
core::vector3df outCollisionPoint,
core::triangle3df outTriangle,
s32  idBitMask = 0,
ISceneNode collisionRootNode = 0,
bool  noDebugObjects = false 
)
inlinevirtual

Perform a ray/box and ray/triangle collision check on a hierarchy of scene nodes.

Works same as other getSceneNodeAndCollisionPointFromRay but returns less information. (was written before the other getSceneNodeAndCollisionPointFromRay implementation).

Parameters
rayLine with which collisions are tested.
outCollisionPointIf a collision is detected, this will contain the position of the nearest collision.
outTriangleIf a collision is detected, this will contain the triangle with which the ray collided.
idBitMaskOnly scene nodes with an id which matches at least one of the bits contained in this mask will be tested. However, if this parameter is 0, then all nodes are checked.
collisionRootNodethe scene node at which to begin checking. Only this node and its children will be checked. If you want to check the entire scene, pass 0, and the root scene node will be used (this is the default).
noDebugObjectswhen true, debug objects are not considered viable targets. Debug objects are scene nodes with IsDebugObject() = true.
Returns
Returns the scene node containing the hit triangle nearest to ray.start. If no collision is detected, then 0 is returned.

Definition at line 261 of file ISceneCollisionManager.h.

268  {
269  SCollisionHit hitResult;
270  ISceneNode* node = getSceneNodeAndCollisionPointFromRay(hitResult, ray, idBitMask, collisionRootNode, noDebugObjects);
271  if ( node )
272  {
273  outCollisionPoint = hitResult.Intersection;
274  outTriangle = hitResult.Triangle;
275  }
276  return node;
277  }
virtual ISceneNode * getSceneNodeAndCollisionPointFromRay(SCollisionHit &hitResult, const core::line3df &ray, s32 idBitMask=0, ISceneNode *collisionRootNode=0, bool noDebugObjects=false)=0
Perform a ray/box and ray/triangle collision check on a hierarchy of scene nodes.

◆ getSceneNodeFromCameraBB()

virtual ISceneNode* irr::scene::ISceneCollisionManager::getSceneNodeFromCameraBB ( const ICameraSceneNode camera,
s32  idBitMask = 0,
bool  bNoDebugObjects = false 
)
pure virtual

Get the scene node, which the given camera is looking at and whose id matches the bitmask.

A ray is simply cast from the position of the camera to the view target position, and all scene nodes are tested against this ray. The collision tests are done using a bounding box for each scene node.

Parameters
cameraCamera from which the ray is cast.
idBitMaskOnly scene nodes with an id which matches at least one of the bits contained in this mask will be tested. However, if this parameter is 0, then all nodes are checked. feature is disabled. Please note that the default node id of -1 will match with every bitmask != 0
bNoDebugObjectsDoesn't take debug objects into account when true. These are scene nodes with IsDebugObject() = true.
Returns
Scene node nearest to the camera, which collides with the ray and matches the idBitMask, if the mask is not null. If no scene node is found, 0 is returned.

◆ getSceneNodeFromRayBB()

virtual ISceneNode* irr::scene::ISceneCollisionManager::getSceneNodeFromRayBB ( const core::line3d< f32 > &  ray,
s32  idBitMask = 0,
bool  bNoDebugObjects = false,
ISceneNode root = 0 
)
pure virtual

Returns the nearest scene node which collides with a 3d ray and whose id matches a bitmask.

The collision tests are done using a bounding box for each scene node. The recursive search can be limited be specifying a scene node.

Parameters
rayLine with which collisions are tested.
idBitMaskOnly scene nodes with an id which matches at least one of the bits contained in this mask will be tested. However, if this parameter is 0, then all nodes are checked.
bNoDebugObjectsDoesn't take debug objects into account when true. These are scene nodes with IsDebugObject() = true.
rootIf different from 0, the search is limited to the children of this node.
Returns
Scene node nearest to ray.start, which collides with the ray and matches the idBitMask, if the mask is not null. If no scene node is found, 0 is returned.

◆ getSceneNodeFromScreenCoordinatesBB()

virtual ISceneNode* irr::scene::ISceneCollisionManager::getSceneNodeFromScreenCoordinatesBB ( const core::position2d< s32 > &  pos,
s32  idBitMask = 0,
bool  bNoDebugObjects = false,
ISceneNode root = 0 
)
pure virtual

Gets the scene node, which is currently visible under the given screen coordinates, viewed from the currently active camera.

The collision tests are done using a bounding box for each scene node. You can limit the recursive search so just all children of the specified root are tested.

Parameters
posPosition in pixel screen coordinates, under which the returned scene node will be.
idBitMaskOnly scene nodes with an id with bits set like in this mask will be tested. If the BitMask is 0, this feature is disabled. Please note that the default node id of -1 will match with every bitmask != 0
bNoDebugObjectsDoesn't take debug objects into account when true. These are scene nodes with IsDebugObject() = true.
rootIf different from 0, the search is limited to the children of this node.
Returns
Visible scene node under screen coordinates with matching bits in its id. If there is no scene node under this position, 0 is returned.

◆ getScreenCoordinatesFrom3DPosition()

virtual core::position2d<s32> irr::scene::ISceneCollisionManager::getScreenCoordinatesFrom3DPosition ( const core::vector3df pos,
const ICameraSceneNode camera = 0,
bool  useViewPort = false 
)
pure virtual

Calculates 2d screen position from a 3d position.

Parameters
pos3D position in world space to be transformed into 2d.
cameraCamera to be used. If null, the currently active camera is used.
useViewPortCalculate screen coordinates relative to the current view port. Please note that unless the driver does not take care of the view port, it is usually best to get the result in absolute screen coordinates (flag=false).
Returns
2d screen coordinates which a object in the 3d world would have if it would be rendered to the screen. If the 3d position is behind the camera, it is set to (-1000,-1000). In most cases you can ignore this fact, because if you use this method for drawing a decorator over a 3d object, it will be clipped by the screen borders.

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