namespace scene\r
{\r
\r
- //! The Scene Collision Manager provides methods for performing collision tests and picking on scene nodes.\r
class CSceneCollisionManager : public ISceneCollisionManager\r
{\r
public:\r
//! destructor\r
virtual ~CSceneCollisionManager();\r
\r
- //! Returns the scene node, which is currently visible at the given\r
- //! screen coordinates, viewed from the currently active camera.\r
- virtual ISceneNode* getSceneNodeFromScreenCoordinatesBB(const core::position2d<s32>& pos,\r
- s32 idBitMask=0, bool bNoDebugObjects=false, ISceneNode* root=0) _IRR_OVERRIDE_;\r
-\r
- //! Returns the nearest scene node which collides with a 3d ray and\r
- //! whose id matches a bitmask.\r
- virtual ISceneNode* getSceneNodeFromRayBB(const core::line3d<f32>& ray,\r
- s32 idBitMask=0, bool bNoDebugObjects=false,\r
- ISceneNode* root=0) _IRR_OVERRIDE_;\r
-\r
- //! Returns the scene node, at which the given camera is looking at and\r
- //! which id matches the bitmask.\r
- virtual ISceneNode* getSceneNodeFromCameraBB(const ICameraSceneNode* camera,\r
- s32 idBitMask=0, bool bNoDebugObjects = false) _IRR_OVERRIDE_;\r
-\r
- //! Finds the nearest collision point of a line and lots of triangles, if there is one.\r
- virtual bool getCollisionPoint(SCollisionHit& hitResult, const core::line3d<f32>& ray,\r
- ITriangleSelector* selector) _IRR_OVERRIDE_;\r
-\r
- //! Collides a moving ellipsoid with a 3d world with gravity and returns\r
- //! the resulting new position of the ellipsoid.\r
- virtual core::vector3df getCollisionResultPosition(\r
- ITriangleSelector* selector,\r
- const core::vector3df &ellipsoidPosition,\r
- const core::vector3df& ellipsoidRadius,\r
- const core::vector3df& ellipsoidDirectionAndSpeed,\r
- core::triangle3df& triout,\r
- core::vector3df& hitPosition,\r
- bool& outFalling,\r
- ISceneNode*& outNode,\r
- f32 slidingSpeed,\r
- const core::vector3df& gravityDirectionAndSpeed) _IRR_OVERRIDE_;\r
-\r
//! Returns a 3d ray which would go through the 2d screen coordinates.\r
virtual core::line3d<f32> getRayFromScreenCoordinates(\r
- const core::position2d<s32> & pos, const ICameraSceneNode* camera = 0) _IRR_OVERRIDE_;\r
-\r
- //! Calculates 2d screen position from a 3d position.\r
- virtual core::position2d<s32> getScreenCoordinatesFrom3DPosition(\r
- const core::vector3df & pos, const ICameraSceneNode* camera=0, bool useViewPort=false) _IRR_OVERRIDE_;\r
-\r
- //! Gets the scene node and nearest collision point for a ray based on\r
- //! the nodes' id bitmasks, bounding boxes and triangle selectors.\r
- virtual ISceneNode* getSceneNodeAndCollisionPointFromRay(\r
- SCollisionHit& hitResult, \r
- const core::line3df& ray,\r
- s32 idBitMask = 0,\r
- ISceneNode * collisionRootNode = 0,\r
- bool noDebugObjects = false) _IRR_OVERRIDE_;\r
+ const core::position2d<s32> & pos, const ICameraSceneNode* camera = 0) override;\r
\r
private:\r
\r
- //! recursive method for going through all scene nodes\r
- void getPickedNodeBB(ISceneNode* root, core::line3df& ray, s32 bits,\r
- bool bNoDebugObjects,\r
- f32& outbestdistance, ISceneNode*& outbestnode);\r
-\r
- //! recursive method for going through all scene nodes\r
- void getPickedNodeFromBBAndSelector(\r
- SCollisionHit& hitResult,\r
- ISceneNode * root,\r
- core::line3df & ray,\r
- s32 bits,\r
- bool noDebugObjects,\r
- f32 & outBestDistanceSquared);\r
-\r
-\r
- struct SCollisionData\r
- {\r
- core::vector3df eRadius;\r
-\r
- core::vector3df R3Velocity;\r
- core::vector3df R3Position;\r
-\r
- core::vector3df velocity;\r
- core::vector3df normalizedVelocity;\r
- core::vector3df basePoint;\r
-\r
- bool foundCollision;\r
- f32 nearestDistance;\r
- core::vector3df intersectionPoint;\r
-\r
- core::triangle3df intersectionTriangle;\r
- irr::scene::ISceneNode* node;\r
- s32 triangleHits;\r
-\r
- f32 slidingSpeed;\r
-\r
- ITriangleSelector* selector;\r
- };\r
-\r
- //! Tests the current collision data against an individual triangle.\r
- /**\r
- \param colData: the collision data.\r
- \param triangle: the triangle to test against.\r
- \return true if the triangle is hit (and is the closest hit), false otherwise */\r
- bool testTriangleIntersection(SCollisionData* colData,\r
- const core::triangle3df& triangle);\r
-\r
- //! recursive method for doing collision response\r
- core::vector3df collideEllipsoidWithWorld(ITriangleSelector* selector,\r
- const core::vector3df &position,\r
- const core::vector3df& radius, const core::vector3df& velocity,\r
- f32 slidingSpeed,\r
- const core::vector3df& gravity, core::triangle3df& triout,\r
- core::vector3df& hitPosition,\r
- bool& outFalling,\r
- ISceneNode*& outNode);\r
-\r
- core::vector3df collideWithWorld(s32 recursionDepth, SCollisionData &colData,\r
- const core::vector3df& pos, const core::vector3df& vel);\r
-\r
- inline bool getLowestRoot(f32 a, f32 b, f32 c, f32 maxR, f32* root) const;\r
-\r
ISceneManager* SceneManager;\r
video::IVideoDriver* Driver;\r
- core::array<core::triangle3df> Triangles; // triangle buffer\r
};\r
\r
\r
} // end namespace irr\r
\r
#endif\r
-\r