Revision: 8418 http://playerstage.svn.sourceforge.net/playerstage/?rev=8418&view=rev Author: natepak Date: 2009-11-18 18:17:29 +0000 (Wed, 18 Nov 2009)
Log Message: ----------- Fixed static visualizations Modified Paths: -------------- code/gazebo/trunk/server/Entity.cc code/gazebo/trunk/server/Model.cc code/gazebo/trunk/server/Simulator.cc code/gazebo/trunk/server/Simulator.hh code/gazebo/trunk/server/controllers/ControllerFactory.cc code/gazebo/trunk/server/physics/Geom.cc code/gazebo/trunk/server/rendering/OgreAdaptor.cc code/gazebo/trunk/server/rendering/OgreAdaptor.hh code/gazebo/trunk/server/rendering/OgreVisual.cc Modified: code/gazebo/trunk/server/Entity.cc =================================================================== --- code/gazebo/trunk/server/Entity.cc 2009-11-18 00:51:19 UTC (rev 8417) +++ code/gazebo/trunk/server/Entity.cc 2009-11-18 18:17:29 UTC (rev 8418) @@ -321,8 +321,11 @@ // Handle a change of pose void Entity::PoseChange(bool notify) { + if (Simulator::Instance()->GetState() == Simulator::RUN) + this->visualNode->SetDirty(true, this->relativePose); + else + this->visualNode->SetPose(this->relativePose); - this->visualNode->SetDirty(true, this->relativePose); if (notify) { this->OnPoseChange(); Modified: code/gazebo/trunk/server/Model.cc =================================================================== --- code/gazebo/trunk/server/Model.cc 2009-11-18 00:51:19 UTC (rev 8417) +++ code/gazebo/trunk/server/Model.cc 2009-11-18 18:17:29 UTC (rev 8418) @@ -176,7 +176,6 @@ { // Delete the existing one (this should only be reached when called // via the factory interface). - printf("Queuing duplicate model %s (%p) for deletion\n", scopedName.c_str(), dup); World::Instance()->DeleteEntity(scopedName.c_str()); } } @@ -203,7 +202,9 @@ pose.rot = **this->rpyP; if (this->IsStatic()) + { this->SetRelativePose( pose ); + } if (this->type == "physical") this->LoadPhysical(node); Modified: code/gazebo/trunk/server/Simulator.cc =================================================================== --- code/gazebo/trunk/server/Simulator.cc 2009-11-18 00:51:19 UTC (rev 8417) +++ code/gazebo/trunk/server/Simulator.cc 2009-11-18 18:17:29 UTC (rev 8418) @@ -131,6 +131,8 @@ /// Any error that reach this level must make the simulator exit void Simulator::Load(const std::string &worldFileName, unsigned int serverId ) { + this->state = LOAD; + if (loaded) { this->Close(); @@ -234,12 +236,15 @@ this->loaded=true; + //OgreAdaptor::Instance()->PrintSceneGraph(); } //////////////////////////////////////////////////////////////////////////////// /// Initialize the simulation void Simulator::Init() { + this->state = INIT; + //Initialize the world try { @@ -325,6 +330,8 @@ /// Main simulation loop, when this loop ends the simulation finish void Simulator::MainLoop() { + this->state = RUN; + double currTime = 0; double lastTime = 0; double freq = 80.0; @@ -725,4 +732,9 @@ return this->mutex; } - +//////////////////////////////////////////////////////////////////////////////// +/// Get the state of the simulation +Simulator::State Simulator::GetState() const +{ + return this->state; +} Modified: code/gazebo/trunk/server/Simulator.hh =================================================================== --- code/gazebo/trunk/server/Simulator.hh 2009-11-18 00:51:19 UTC (rev 8417) +++ code/gazebo/trunk/server/Simulator.hh 2009-11-18 18:17:29 UTC (rev 8418) @@ -62,6 +62,8 @@ */ class Simulator : public SingletonT<Simulator> { + public: enum State {LOAD, INIT, RUN}; + /// \brief Private constructor private: Simulator(); @@ -167,6 +169,9 @@ /// \brief Get the simulator mutex public:boost::recursive_mutex *GetMRMutex(); + /// \brief Get the state of the simulation + public: State GetState() const; + /// \brief Function to run gui. Used by guiThread private: void PhysicsLoop(); @@ -230,6 +235,8 @@ private: boost::recursive_mutex *mutex; + private: State state; + //Singleton implementation private: friend class DestroyerT<Simulator>; private: friend class SingletonT<Simulator>; Modified: code/gazebo/trunk/server/controllers/ControllerFactory.cc =================================================================== --- code/gazebo/trunk/server/controllers/ControllerFactory.cc 2009-11-18 00:51:19 UTC (rev 8417) +++ code/gazebo/trunk/server/controllers/ControllerFactory.cc 2009-11-18 18:17:29 UTC (rev 8418) @@ -73,7 +73,8 @@ void ControllerFactory::LoadPlugin(const std::string &plugin, const std::string &classname) { #ifdef HAVE_LTDL - + + std::cout << "Load Plugin[" << plugin << "] Classname[" << classname << "]\n"; static bool init_done = false; if (!init_done) @@ -82,7 +83,8 @@ if (errors) { std::ostringstream stream; - stream << "Error(s) initializing dynamic loader (" << errors << ", " << lt_dlerror() << ")"; + stream << "Error(s) initializing dynamic loader (" + << errors << ", " << lt_dlerror() << ")"; gzthrow(stream.str()); } else Modified: code/gazebo/trunk/server/physics/Geom.cc =================================================================== --- code/gazebo/trunk/server/physics/Geom.cc 2009-11-18 00:51:19 UTC (rev 8417) +++ code/gazebo/trunk/server/physics/Geom.cc 2009-11-18 18:17:29 UTC (rev 8418) @@ -132,11 +132,12 @@ if (visual) { visual->Load(childNode); - visual->SetIgnorePoseUpdates(true); + //visual->SetIgnorePoseUpdates(true); this->visuals.push_back(visual); visual->SetCastShadows(true); } + if (this->IsStatic()) visual->MakeStatic(); Modified: code/gazebo/trunk/server/rendering/OgreAdaptor.cc =================================================================== --- code/gazebo/trunk/server/rendering/OgreAdaptor.cc 2009-11-18 00:51:19 UTC (rev 8417) +++ code/gazebo/trunk/server/rendering/OgreAdaptor.cc 2009-11-18 18:17:29 UTC (rev 8418) @@ -537,3 +537,26 @@ { this->cameras.push_back( cam ); } + +//////////////////////////////////////////////////////////////////////////////// +/// Print scene graph +void OgreAdaptor::PrintSceneGraph() +{ + this->PrintSceneGraphHelper("", this->sceneMgr->getRootSceneNode()); +} + +//////////////////////////////////////////////////////////////////////////////// +/// Print scene graph +void OgreAdaptor::PrintSceneGraphHelper(std::string prefix, + Ogre::Node *node) +{ + std::cout << prefix << node->getName() << std::endl; + + prefix += " "; + for (unsigned int i=0; i < node->numChildren(); i++) + { + this->PrintSceneGraphHelper( prefix, node->getChild(i) ); + } +} + + Modified: code/gazebo/trunk/server/rendering/OgreAdaptor.hh =================================================================== --- code/gazebo/trunk/server/rendering/OgreAdaptor.hh 2009-11-18 00:51:19 UTC (rev 8417) +++ code/gazebo/trunk/server/rendering/OgreAdaptor.hh 2009-11-18 18:17:29 UTC (rev 8418) @@ -108,6 +108,12 @@ /// \brief Register a user camera public: void RegisterCamera( OgreCamera *cam ); + public: void PrintSceneGraph(); + + /// \brief Print scene graph + private: void PrintSceneGraphHelper(std::string prefix, + Ogre::Node *node); + private: void LoadPlugins(); private: void SetupResources(); private: void SetupRenderSystem(); Modified: code/gazebo/trunk/server/rendering/OgreVisual.cc =================================================================== --- code/gazebo/trunk/server/rendering/OgreVisual.cc 2009-11-18 00:51:19 UTC (rev 8417) +++ code/gazebo/trunk/server/rendering/OgreVisual.cc 2009-11-18 18:17:29 UTC (rev 8418) @@ -351,14 +351,22 @@ if (!this->staticGeom) this->staticGeom = OgreAdaptor::Instance()->sceneMgr->createStaticGeometry(this->sceneNode->getName() + "_Static"); - // Detach the scene node from the parent. Prevents double rendering - this->sceneNode->getParent()->removeChild(this->sceneNode); + //this->staticGeom->setRegionDimensions(Ogre::Vector3(1,1,1)); + //this->staticGeom->setOrigin(Ogre::Vector3(2,2,1)); + //this->sceneNode->setVisible(true); + // Add the scene node to the static geometry this->staticGeom->addSceneNode(this->sceneNode); // Build the static geometry this->staticGeom->build(); + + // Detach the scene node from the parent. Prevents double rendering + this->sceneNode->setVisible(false); + /*if (this->sceneNode->getParent()) + this->sceneNode->getParent()->removeChild(this->sceneNode); + */ } //////////////////////////////////////////////////////////////////////////////// @@ -668,6 +676,17 @@ return; this->sceneNode->setPosition(pos.x, pos.y, pos.z); + + if (this->IsStatic()) + { + //this->sceneNode->setParent( this->owner->GetVisu + //this->staticGeom->reset(); + //this->MakeStatic(); + } + else + { + //std::cout << "Dynamic SceneNodePos[" << this->sceneNode->_getDerivedPosition() << "] [" << pos << "]\n"; + } } //////////////////////////////////////////////////////////////////////////////// This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Playerstage-commit mailing list Playerstage-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/playerstage-commit