ProfesorX
22-09-2006 03:07:09
Hi friends, i am trying to use a FPS collision camera and TreeCollisionSceneParser::parseScene to parse a DotScene file so i can get the geometry of my level added to the physics simulation, and, in that way, get "simple" collision detection with walls/objects and camera movement using forces.
At the moment, i've been succesful using the code from here and now i have a camera moved with forces , but then, when i try to add my level, using parseScene, still get no collisions .
I used the following code:
It appears that only the ninja is added to OgreNewt, because i get debuglines only for the ninja and not all geometry, but even in the case of the ninja, can't get collision detection, so i can pass with the camera through it.
Is there something that i'm missing?
I am using 3D-Max/oFusion to get level, converting later to DotSceneFormat, and using DotSceneManager plugin.
Thanks in advance, and i'm sorry if i don't write correctly in english
At the moment, i've been succesful using the code from here and now i have a camera moved with forces , but then, when i try to add my level, using parseScene, still get no collisions .
I used the following code:
void IntroState::enter()
{
mInputDevice = INPUT_MGR.getInputDevice();
mRoot = Root::getSingletonPtr();
mSceneMgr = mRoot->getSceneManager(ST_GENERIC);
OgreNewt::Debugger::getSingleton().init(mSceneMgr);
mMoveScale = 1.0f;
mRotScale = 10.0f;
mRotateSpeed = 360;
mMoveSpeed = 100;
mTranslateVector = Vector3::ZERO;
mRotX = mRotY = 0;
// Creacion de la camara
mCamera = mSceneMgr->createCamera("IntroCamera");
mCamera->setPosition(Vector3(0.0, 0.0, 0.0));
mCamera->setNearClipDistance(5);
mViewport = mRoot->getAutoCreatedWindow()->addViewport(mCamera);
exitGame = false;
mResGroup=loadScene("escenario.esc");
// Añadir el modelo del ninja
Entity *ent = mSceneMgr->createEntity("ninja", "ninja.mesh");
mNinjaNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("NinjaNode");//, Ogre::Vector3(50.0, 0.0, 0.0));
mNinjaNode->attachObject(ent);
mNinjaNode->setScale(0.15, 0.15, 0.15);
// Rotar el ninja para que quede de frente a la camara
mNinjaNode->yaw(Degree(180));
// Añadido Por ProfesorX
mPositionOverlay = Ogre::OverlayManager::getSingleton().getByName("PositionOverlay");
if (mPositionOverlay)
{
mPositionOverlay->show();
}
// Fin
// using the new "SceneParser" TreeCollision primitive. this will automatically parse an entire tree of
// SceneNodes (parsing all children), and add collision for all meshes in the tree.
OgreNewt::CollisionPrimitives::TreeCollisionSceneParser* m_ColSceneParser = new OgreNewt::CollisionPrimitives::TreeCollisionSceneParser(mWorld);
m_ColSceneParser->parseScene(mSceneMgr->getRootSceneNode(), true);
OgreNewt::Body* bod = new OgreNewt::Body( mWorld, m_ColSceneParser );
delete m_ColSceneParser;
bod->attachToNode( mSceneMgr->getRootSceneNode() );
bod->setPositionOrientation( Ogre::Vector3(0.0,0.0,0.0), Ogre::Quaternion::IDENTITY );
mBodyCam = new CollisionCamera(mSceneMgr, mWorld, mCamera);
mBodyCam->createPhysicsCamera();
mBodyCam->setPositionOrientation(Ogre::Vector3(0,-35,50),Ogre::Quaternion::IDENTITY);
mRoot->startRendering();
}
It appears that only the ninja is added to OgreNewt, because i get debuglines only for the ninja and not all geometry, but even in the case of the ninja, can't get collision detection, so i can pass with the camera through it.
Is there something that i'm missing?
I am using 3D-Max/oFusion to get level, converting later to DotSceneFormat, and using DotSceneManager plugin.
Thanks in advance, and i'm sorry if i don't write correctly in english