[Opal-commits] opal/samples/src BaseOpalApp.h,1.5,1.6 ExampleApplication.h,1.4,1.5 PhysicalCamera.h,
Status: Inactive
Brought to you by:
tylerstreeter
|
From: tylerstreeter <tyl...@us...> - 2005-04-05 05:19:07
|
Update of /cvsroot/opal/opal/samples/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29607/samples/src Modified Files: BaseOpalApp.h ExampleApplication.h PhysicalCamera.h Log Message: fixed bugs in sample app Index: PhysicalCamera.h =================================================================== RCS file: /cvsroot/opal/opal/samples/src/PhysicalCamera.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PhysicalCamera.h 4 Apr 2005 13:09:10 -0000 1.2 --- PhysicalCamera.h 5 Apr 2005 05:18:53 -0000 1.3 *************** *** 4,7 **** --- 4,10 ---- #include <opal/opal.h> + // TODO: Make an option to switch from physical to non-physical and vice + // versa on the fly. + namespace opalSamples { *************** *** 168,172 **** assert(mSolid); ! // TODO... //// don't let the camera fly --- 171,175 ---- assert(mSolid); ! // TODO: finish this. //// don't let the camera fly *************** *** 207,210 **** --- 210,224 ---- //v *= 3; //mSolid->setGlobalLinearVel(v); + + Ogre::Matrix4 ogreCamMat = + mOgreCamera->getViewMatrix().inverse(); + Ogre::Vector3 localDir(dir[0], dir[1], dir[2]); + + // Convert the local direction vector to a global direction + // vector. Subtract out the camera's position. + Ogre::Vector3 globalDir = ogreCamMat * localDir; + globalDir -= mOgreCamera->getPosition(); + opal::Vec3r opalVec(globalDir[0], globalDir[1], globalDir[2]); + mSolid->setGlobalLinearVel(opalVec); } else *************** *** 375,383 **** { Ogre::Matrix4 ogreMat = mOgreCamera->getViewMatrix().inverse(); - //Ogre::Vector3 camPos = mOgreCamera->getPosition(); Ogre::Vector3 graspOffset(mGraspOffset[0], mGraspOffset[1], mGraspOffset[2]); ! // Transform the offset vector to global space. graspOffset = ogreMat * graspOffset; --- 389,397 ---- { Ogre::Matrix4 ogreMat = mOgreCamera->getViewMatrix().inverse(); Ogre::Vector3 graspOffset(mGraspOffset[0], mGraspOffset[1], mGraspOffset[2]); ! // Transform the offset vector (actually representing a point) ! // to global space. graspOffset = ogreMat * graspOffset; Index: BaseOpalApp.h =================================================================== RCS file: /cvsroot/opal/opal/samples/src/BaseOpalApp.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** BaseOpalApp.h 4 Apr 2005 13:09:09 -0000 1.5 --- BaseOpalApp.h 5 Apr 2005 05:18:53 -0000 1.6 *************** *** 6,10 **** #include "PhysicalEntity.h" #include "PhysicalCamera.h" - #include "OgreLine.h" #include <opal/opal.h> --- 6,9 ---- *************** *** 253,265 **** mSimulator->destroySolid(pe->getSolid()); ! // Destroy the PhysicalEntity's Ogre SceneNode. Ogre::SceneNode* sn = pe->getSceneNode(); ! // Detach and destroy all objects from the SceneNode. while(sn->numAttachedObjects() > 0) { MovableObject* thisObject = sn->detachObject(static_cast<unsigned short>(0)); ! delete thisObject; } --- 252,269 ---- mSimulator->destroySolid(pe->getSolid()); ! // Destroy the PhysicalEntity's Ogre SceneNode and ! // attached Entities. Ogre::SceneNode* sn = pe->getSceneNode(); ! // Detach and destroy all objects from the SceneNode; ! // in this case, there should only be a single entity ! // (which is why we can safely call 'removeEntity' ! // here). while(sn->numAttachedObjects() > 0) { MovableObject* thisObject = sn->detachObject(static_cast<unsigned short>(0)); ! std::string s = thisObject->getName(); ! mSceneMgr->removeEntity(thisObject->getName()); } *************** *** 268,274 **** --- 272,280 ---- mSceneMgr->getRootSceneNode()->removeAndDestroyChild( sn->getName()); + sn = NULL; // Delete the PhysicalEntity. delete pe; + pe = NULL; // Copy the last element over this one and pop the last *************** *** 287,297 **** void destroyAllPhysicalEntities() { - // TODO: fix this (and maybe destroyPhysicalEntity) since - // they break things when called in the middle of the app. while (!mPhysicalEntityList.empty()) { destroyPhysicalEntity(mPhysicalEntityList.back()); - //delete mPhysicalEntityList.back(); - //mPhysicalEntityList.pop_back(); } --- 293,299 ---- Index: ExampleApplication.h =================================================================== RCS file: /cvsroot/opal/opal/samples/src/ExampleApplication.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ExampleApplication.h 4 Apr 2005 13:09:10 -0000 1.4 --- ExampleApplication.h 5 Apr 2005 05:18:53 -0000 1.5 *************** *** 112,116 **** // If returned true, user clicked OK so initialise // Here we choose to let the system create a default rendering window by passing 'true' ! mWindow = mRoot->initialise(true); return true; } --- 112,116 ---- // If returned true, user clicked OK so initialise // Here we choose to let the system create a default rendering window by passing 'true' ! mWindow = mRoot->initialise(true, "OPAL-Ogre Sample Application"); return true; } |