Collision Detection

elieajaltouni

05-06-2009 16:55:50

Hi everyone I am trying to add collision detection between the camera and an ofusion scene I have loaded
this is my code in the createScene:

void createScene(void)
{
OSMScene oScene;
oScene.initialise("pyramidAnim1.osm", NULL);
oScene.createScene();
mSceneMgr = oScene.getSceneManager();
mSceneMgr->setShadowTechnique(SHADOWTYPE_STENCIL_ADDITIVE);
mCamera = mSceneMgr->createCamera("PlayerCam");
// Position it at 500 in Z direction
mCamera->setPosition(Vector3(0,0,500));
// Look back along -Z
mCamera->lookAt(Vector3(0,0,-300));
mCamera->setNearClipDistance(5);

// If a viewport was not automatically created, (no cameras saved in the scene)
// create a default viewport, entire window
Viewport* vp = mWindow->addViewport(mCamera);
vp->setBackgroundColour(ColourValue(0,0,0));

// Alter the camera aspect ratio to match the viewport
mCamera->setAspectRatio(Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
}


Is it possible to be done? how to do it any ideas?

Lioric

05-06-2009 22:22:36

If you needs are simple, then you can test each object's bounding box (using ray queries) with the camera frustim at each frame and move the camera as needed

If you need more control just use some of the available libraries that implement complete support for this, and use the oSceneLoader callback event system to create a proxy object for each entity that is being loaded