// Copyright (C) 2002-2006 Nikolaus Gebhardt // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in irrlicht.h #pragma once #using using namespace System; using namespace System::Runtime::InteropServices; #pragma unmanaged #include "..\\..\\include\\irrlicht.h" #pragma managed #include "Line3D.h" #include "Triangle3D.h" #include "ITriangleSelector.h" #include "Position2D.h" #include "ICameraSceneNode.h" namespace Irrlicht { namespace Scene { /// /// The Scene Collision Manager provides methods for performing collision tests and /// picking on scene nodes. /// public __gc class ISceneCollisionManager { public: /// /// Creates a scm from a native C++ scene node. Don't use this, its better to /// get access to the ISceneCollisionManager via ISceneManager.SceneCollisionManager. /// ISceneCollisionManager(irr::scene::ISceneCollisionManager* realSCM); /// /// Finds the collision point of a line and lots of triangles, if there is one. /// /// Line with witch collisions are tested. /// TriangleSelector containing the triangles. It can /// be created for example using ISceneManager::createTriangleSelector() or /// ISceneManager::createTriangleOctTreeSelector(). /// If a collision is detected, this will contain the /// position of the nearest collision. /// If a collision is detected, this will contain the triangle /// with which the ray collided. /// Returns true if a collision was detected and false if not. bool GetCollisionPoint(Core::Line3D ray, Scene::ITriangleSelector* selector, [PARAMFLAG::Out] Core::Vector3D& outCollisionPoint, [PARAMFLAG::Out] Core::Triangle3D& outTriangle); /// /// 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. /// /// TriangleSelector containing the triangles of the world. /// It can be created for example using ISceneManager::createTriangleSelector() or /// ISceneManager::createTriangleOctTreeSelector(). /// Position of the ellipsoid. /// Radius of the ellipsoid. /// Direction and speed of /// the movement of the ellipsoid. /// Direction and force of gravity. /// Optional parameter where the last triangle causing a /// collision is stored, if there is a collision. /// Is set to true if the ellipsoid is falling down, caused /// by gravity. /// Set this to a small value lile 0.0005 /// Returns the new position of the ellipsoid. Core::Vector3D GetCollisionResultPosition( Scene::ITriangleSelector* selector, Core::Vector3D ellipsoidPosition, Core::Vector3D ellipsoidRadius, Core::Vector3D ellipsoidDirectionAndSpeed, [PARAMFLAG::Out] Core::Triangle3D& triout, [PARAMFLAG::Out] bool& outFalling, float slidingSpeed, Core::Vector3D gravityDirectionAndSpeed); /// /// Returns a 3d ray which would go through the 2d screen coodinates. /// /// Screen coordinates in pixels. /// Camera from which the ray starts. If null, the /// active camera is used. /// Returns a ray starting from the position of the camera /// and ending at a lenght of the far value of the camera at a position /// which would be behind the 2d screen coodinates. Core::Line3D GetRayFromScreenCoordinates( Core::Position2D pos, Scene::ICameraSceneNode* camera); /// /// Calculates 2d screen position from a 3d position. /// /// 3D position in world space to be transformed into /// 2d. /// Camera to be used. If null, the currently active /// camera is used. /// Returns the 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 (-10000,-10000). 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. Core::Position2D GetScreenCoordinatesFrom3DPosition( Core::Vector3D pos, Scene::ICameraSceneNode* camera); /// /// Returns the scene node, which is currently visible under the overgiven /// screencoordinates, viewed from the currently active camera. The collision /// tests are done using a bounding box for each scene node. /// /// Position in pixel screen coordinates, under which the returned /// scene node will be. /// Only scene nodes with an id with bits set like in this mask /// will be tested. If the BitMask is 0, this feature is disabled. /// Returns the visible scene node under screen coordinates with matching /// bits in its id. If there is no scene node under this position, 0 is returned. Scene::ISceneNode* GetSceneNodeFromScreenCoordinatesBB(Core::Position2D pos, int idBitMask, bool noDebugObjects); /// /// Returns the nearest scene node which collides with a 3d ray and /// which id matches a bitmask. The collision tests are done using a bounding /// box for each scene node. /// /// Line with witch collisions are tested. /// Only scene nodes with an id with bits set like in this mask /// will be tested. If the BitMask is 0, this feature is disabled. /// Returns the 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. Scene::ISceneNode* GetSceneNodeFromRayBB(Core::Line3D ray, int idBitMask, bool noDebugObjects); /// /// Returns the scene node, at which the overgiven camera is looking at and /// which id matches the bitmask. A ray is simply casted 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. /// /// Camera from which the ray is casted. /// Only scene nodes with an id with bits set like in this mask /// will be tested. If the BitMask is 0, this feature is disabled. /// Returns the 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. Scene::ISceneNode* GetSceneNodeFromCameraBB(Scene::ICameraSceneNode* camera, int idBitMask, bool noDebugObjects); protected: irr::scene::ISceneCollisionManager* SCM; }; } }