Update of /cvsroot/opal/opal/samples/playpen
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29607/samples/playpen
Modified Files:
main.cpp
Log Message:
fixed bugs in sample app
Index: main.cpp
===================================================================
RCS file: /cvsroot/opal/opal/samples/playpen/main.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** main.cpp 4 Apr 2005 13:09:09 -0000 1.5
--- main.cpp 5 Apr 2005 05:18:52 -0000 1.6
***************
*** 1,4 ****
--- 1,5 ----
#include <time.h>
#include "../src/BaseOpalApp.h"
+ #include "../src/OgreLine.h"
namespace playpen
***************
*** 20,23 ****
--- 21,27 ----
virtual bool processUnbufferedMouseInput(Ogre::Real dt);
+ /// Creates the initial objects in the world.
+ void setupInitialPhysicalEntities();
+
/// Builds a wall of boxes centered at the origin.
void createWall(unsigned int length, unsigned height,
***************
*** 54,57 ****
--- 58,79 ----
PlaypenApp::~PlaypenApp()
{
+ // Destroy the grasping line and its SceneNode.
+ Ogre::SceneNode* sn = mGraspingSpringLine->getParentSceneNode();
+
+ // Detach and destroy all objects from the SceneNode. The
+ // scene node should only have the OgreLine attached which
+ // we must delete explicitly.
+ while(sn->numAttachedObjects() > 0)
+ {
+ MovableObject* thisObject =
+ sn->detachObject(static_cast<unsigned short>(0));
+ delete thisObject;
+ }
+
+ // Destroy the SceneNodes all of its children.
+ sn->removeAndDestroyAllChildren();
+ mSceneMgr->getRootSceneNode()->removeAndDestroyChild(
+ sn->getName());
+ sn = NULL;
}
***************
*** 100,132 ****
mGraspingSpringLine->setVisible(false);
- //// Create a physical ground plane.
- //mSimulator->createPlane(0, 1, 0, 0);
-
- //// Create a visual ground plane.
- //Ogre::Plane plane(Ogre::Vector3(0, 0, -1), 0);
- //Ogre::MeshManager::getSingleton().createPlane("plane", "General",
- // plane, 3000, 3000, 10, 10);
- //Entity* e = mSceneMgr->createEntity("ground plane", "plane");
- //e->setMaterialName("Flat/Gray");
- //Ogre::SceneNode* sn = mSceneMgr->getRootSceneNode()->
- // createChildSceneNode("ground plane");
- //sn->attachObject(e);
- //Ogre::Radian angle(Ogre::Degree(90));
- //sn->rotate(Ogre::Vector3(1, 0, 0), angle);
-
- // Create a static box for a ground plane.
- Ogre::Vector3 groundDim(100, 8, 100);
- opal::Solid* s = mSimulator->createSolid();
- s->setStatic(true);
- s->setPosition(0, -4, 0);
- opal::BoxShapeData data;
- data.dimensions.set(groundDim[0], groundDim[1], groundDim[2]);
- s->addShape(data);
- createPhysicalEntityBox("ground", "Plastic/Gray", groundDim, s);
-
// Make a crosshairs for picking.
-
// Load models, create physical objects, etc. here.
}
--- 122,130 ----
mGraspingSpringLine->setVisible(false);
// Make a crosshairs for picking.
// Load models, create physical objects, etc. here.
+
+ setupInitialPhysicalEntities();
}
***************
*** 190,194 ****
--- 188,195 ----
if(mInputDevice->isKeyDown(KC_R))
{
+ // Make sure the PhysicalCamera isn't grabbing anything.
+ mPhysicalCamera->release();
destroyAllPhysicalEntities();
+ setupInitialPhysicalEntities();
}
***************
*** 354,358 ****
// The following code updates the camera's position.
! opal::Vec3r cameraDir;
bool cameraMoved = false;
--- 355,359 ----
// The following code updates the camera's position.
! opal::Vec3r cameraDir(0, 0, 0);
bool cameraMoved = false;
***************
*** 469,472 ****
--- 470,501 ----
}
+ void PlaypenApp::setupInitialPhysicalEntities()
+ {
+ //// Create a physical ground plane.
+ //mSimulator->createPlane(0, 1, 0, 0);
+
+ //// Create a visual ground plane.
+ //Ogre::Plane plane(Ogre::Vector3(0, 0, -1), 0);
+ //Ogre::MeshManager::getSingleton().createPlane("plane", "General",
+ // plane, 3000, 3000, 10, 10);
+ //Entity* e = mSceneMgr->createEntity("ground plane", "plane");
+ //e->setMaterialName("Flat/Gray");
+ //Ogre::SceneNode* sn = mSceneMgr->getRootSceneNode()->
+ // createChildSceneNode("ground plane");
+ //sn->attachObject(e);
+ //Ogre::Radian angle(Ogre::Degree(90));
+ //sn->rotate(Ogre::Vector3(1, 0, 0), angle);
+
+ // Create a static box for a ground plane.
+ Ogre::Vector3 groundDim(100, 8, 100);
+ opal::Solid* s = mSimulator->createSolid();
+ s->setStatic(true);
+ s->setPosition(0, -4, 0);
+ opal::BoxShapeData data;
+ data.dimensions.set(groundDim[0], groundDim[1], groundDim[2]);
+ s->addShape(data);
+ createPhysicalEntityBox("ground", "Plastic/Gray", groundDim, s);
+ }
+
void PlaypenApp::createWall(unsigned int length, unsigned height,
const opal::Vec3r& boxDim, const opal::Matrix44r& baseTransform)
|