Collision Detection in OGRE (Full Version)
Original Korea http://www.hjpdiy.com Please indicate the reprint address
Note this example requires the code production of the new version of the RC of OGRE 0.15.
OGRE is an open source packaged DirectX and OpenGL 3D engine
OGRE download and installation http://www.uipower.com/bbs/dispbbs.asp?boardid=24&id=225&page=1
The related pictures of this topic are as follows:
Download code http://www.uipower.com/bbs/dispbbs.asp?boardid=24&id=233
OGRE uses a variety of "elements" (cameras, lights, objects, etc.) in the stump management scenario, all things are hanging on the "tree", and things that are not in the "tree" will not be rendered. Ogre :: SceneManager is the manager of "tree", OGRE :: SceneNode is created from SceneManager (of course, the management of BSP and 8 * trees is related to these two classes, this is not discussed).
AABB (axial enveloping box)
This thing is the basis of collision detection (how to always think of JJYY), and it is similar to it. There is also an OBB (with the enveloping box), because OBB creates complexity, OGRE uses AABB.
The simplest collision test:
Through Ogre :: Scenenode :: _ getWorldaab () Aabb (Ogre :: Axisalignedbox), OGRE :: Axisalignedbox encapsulates support for AABB, the member function Ogre :: axisalignedbox :: interts () Judging the intersection of AABB and "sphere, point, face, and other faces".
The leaves of the m_spherenode tree, hung a "ball" M_Cubenode tree, hung a "prescribed"
AxisalignedBox spbox = m_spherenode -> _ getWorldaabb (); axisalignedbox cbbox = m_cubenode -> _ getWorldaabb (); if (spbox.intersects (cbbox)) {// intersection
}
Regional query:
Simple talk is to find something in a certain area, divided into AABB, sphere, and face query.
// Create a sphere inquiry, here is the radius of the spheres hanging by m_spherenode spherescenequery * pquery = m_scenemgr-> createSphereQuery (sphere (m_spherenode-> getPosition (), 100)); // Execute this query SceneQueryResult QResult = PQuery -> EXECUTE (); // Traversal Query list to find out the object in the range for (std :: list
Intersection
Traverse all objects, find a pair of intersectings (nonsense, intersecting at least two objects).
// Create the intersection detection IntersectionSceneQuery * pISQuery = m_SceneMgr-> createIntersectionQuery (); // execute the query IntersectionSceneQueryResult QResult = pISQuery-> execute (); // traverse list of queries to find two intersecting objects for (SceneQueryMovableIntersectionList :: iterator iter = QResult.movables2movables.begin ();! iter = QResult.movables2movables.end (); iter) {SceneQueryMovableObjectPair pObject = static_cast
Original Korea http://www.hjpdiy.com Please indicate the reprint address