arsa  2.7
ISceneCollisionManager.h
Go to the documentation of this file.
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_COLLISION_MANAGER_H_INCLUDED__
6 #define __I_SCENE_COLLISION_MANAGER_H_INCLUDED__
7 
8 #include "IReferenceCounted.h"
9 #include "vector3d.h"
10 #include "triangle3d.h"
11 #include "position2d.h"
12 #include "line3d.h"
13 
14 namespace irr
15 {
16 
17 namespace scene
18 {
19  class ISceneNode;
20  class ICameraSceneNode;
21  class ITriangleSelector;
22  class IMeshBuffer;
23 
25  {
28 
31 
34 
37 
40 
43 
45  {}
46  };
47 
50  {
51  public:
52 
54 
58  virtual bool getCollisionPoint(SCollisionHit& hitResult, const core::line3d<f32>& ray,
59  ITriangleSelector* selector) = 0;
60 
62 
74  virtual bool getCollisionPoint(const core::line3d<f32>& ray,
75  ITriangleSelector* selector, core::vector3df& outCollisionPoint,
76  core::triangle3df& outTriangle, ISceneNode*& outNode)
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  }
88 
90 
113  ITriangleSelector* selector,
114  const core::vector3df &ellipsoidPosition,
115  const core::vector3df& ellipsoidRadius,
116  const core::vector3df& ellipsoidDirectionAndSpeed,
117  core::triangle3df& triout,
118  core::vector3df& hitPosition,
119  bool& outFalling,
120  ISceneNode*& outNode,
121  f32 slidingSpeed = 0.0005f,
122  const core::vector3df& gravityDirectionAndSpeed
123  = core::vector3df(0.0f, 0.0f, 0.0f)) = 0;
124 
126 
133  const core::position2d<s32>& pos, const ICameraSceneNode* camera = 0) = 0;
134 
136 
150  virtual core::position2d<s32> getScreenCoordinatesFrom3DPosition(
151  const core::vector3df& pos, const ICameraSceneNode* camera=0, bool useViewPort=false) = 0;
152 
154 
169  virtual ISceneNode* getSceneNodeFromScreenCoordinatesBB(const core::position2d<s32>& pos,
170  s32 idBitMask=0, bool bNoDebugObjects=false, ISceneNode* root=0) =0;
171 
173 
186  s32 idBitMask=0, bool bNoDebugObjects=false, ISceneNode* root=0) =0;
187 
189 
206  s32 idBitMask=0, bool bNoDebugObjects = false) = 0;
207 
208 
210 
237  SCollisionHit& hitResult,
238  const core::line3df& ray,
239  s32 idBitMask = 0,
240  ISceneNode * collisionRootNode = 0,
241  bool noDebugObjects = false) = 0;
242 
244 
262  const core::line3df& ray,
263  core::vector3df& outCollisionPoint,
264  core::triangle3df& outTriangle,
265  s32 idBitMask = 0,
266  ISceneNode * collisionRootNode = 0,
267  bool noDebugObjects = false)
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  }
278 
279  };
280 
281 } // end namespace scene
282 } // end namespace irr
283 
284 #endif
Interface to return triangles with specific properties.
Scene Node which is a (controllable) camera.
ISceneNode * Node
Node which contained the triangle (is 0 when selector doesn't have that information)
float f32
32 bit floating point variable.
Definition: irrTypes.h:108
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.
ITriangleSelector * TriangleSelector
Triangle selector which contained the colliding triangle (useful when having MetaTriangleSelector)
Scene node interface.
Definition: ISceneNode.h:40
3d triangle template class for doing collision detection and other things.
Definition: triangle3d.h:20
const IMeshBuffer * MeshBuffer
Meshbuffer which contained the triangle (is 0 when the selector doesn't have that information,...
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 th...
Everything in the Irrlicht Engine can be found in this namespace.
Definition: CARSADPad.h:6
virtual core::line3d< f32 > getRayFromScreenCoordinates(const core::position2d< s32 > &pos, const ICameraSceneNode *camera=0)=0
Returns a 3d ray which would go through the 2d screen coordinates.
3D line between two points with intersection methods.
Definition: line3d.h:18
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.
signed int s32
32 bit signed variable.
Definition: irrTypes.h:70
Struct for holding a mesh with a single material.
Definition: IMeshBuffer.h:39
virtual ISceneNode * getSceneNodeAndCollisionPointFromRay(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.
core::vector3df Intersection
Point of collision.
GLfloat f
unsigned int u32
32 bit unsigned variable.
Definition: irrTypes.h:62
virtual ISceneNode * getSceneNodeFromRayBB(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.
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.
virtual ISceneNode * getSceneNodeFromScreenCoordinatesBB(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,...
virtual ISceneNode * getSceneNodeFromCameraBB(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.
Base class of most objects of the Irrlicht Engine.
core::triangle3df Triangle
Triangle with which we collided.
The Scene Collision Manager provides methods for performing collision tests and picking on scene node...
virtual core::position2d< s32 > getScreenCoordinatesFrom3DPosition(const core::vector3df &pos, const ICameraSceneNode *camera=0, bool useViewPort=false)=0
Calculates 2d screen position from a 3d position.
irr::u32 MaterialIndex
Index of selected material of the triangle in the SceneNode. Usually only valid when MeshBuffer is al...