Revision: 7018
http://playerstage.svn.sourceforge.net/playerstage/?rev=7018&view=rev
Author: natepak
Date: 2008-09-10 03:51:13 +0000 (Wed, 10 Sep 2008)
Log Message:
-----------
Added a Common class for ease of processing parameters
Modified Paths:
--------------
code/gazebo/trunk/server/Entity.cc
code/gazebo/trunk/server/Entity.hh
code/gazebo/trunk/server/Param.cc
code/gazebo/trunk/server/SConscript
code/gazebo/trunk/server/gui/GLWindow.cc
code/gazebo/trunk/server/gui/Toolbar.cc
code/gazebo/trunk/server/gui/Toolbar.hh
code/gazebo/trunk/server/physics/Geom.cc
code/gazebo/trunk/server/physics/Geom.hh
code/gazebo/trunk/server/physics/Joint.cc
code/gazebo/trunk/server/physics/Joint.hh
code/gazebo/trunk/server/rendering/OgreVisual.cc
code/gazebo/trunk/server/rendering/OgreVisual.hh
Added Paths:
-----------
code/gazebo/trunk/server/Common.cc
code/gazebo/trunk/server/Common.hh
Added: code/gazebo/trunk/server/Common.cc
===================================================================
--- code/gazebo/trunk/server/Common.cc (rev 0)
+++ code/gazebo/trunk/server/Common.cc 2008-09-10 03:51:13 UTC (rev 7018)
@@ -0,0 +1,101 @@
+/*
+ * Gazebo - Outdoor Multi-Robot Simulator
+ * Copyright (C) 2003
+ * Nate Koenig & Andrew Howard
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+/* Desc: Base class shared by all classes in Gazebo.
+ * Author: Nate Koenig
+ * Date: 09 Sept. 2008
+ * SVN: $Id:$
+ */
+
+#include "Common.hh"
+#include "GazeboMessage.hh"
+
+using namespace gazebo;
+
+unsigned int Common::idCounter = 0;
+
+////////////////////////////////////////////////////////////////////////////////
+/// Constructor
+Common::Common()
+{
+ this->id = ++idCounter;
+
+ Param::Begin(&this->parameters);
+ this->nameP = new ParamT<std::string>("name","noname",1);
+ Param::End();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+/// Destructor
+Common::~Common()
+{
+ delete this->nameP;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+/// Set the name of the entity
+void Common::SetName(const std::string &name)
+{
+ this->nameP->SetValue( name );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+/// Return the name of the entity
+std::string Common::GetName() const
+{
+ return this->nameP->GetValue();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+/// Get the parameters
+std::vector<Param*> *Common::GetParams()
+{
+ return &this->parameters;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+/// Get a parameter by name
+Param *Common::GetParam(const std::string &key) const
+{
+ std::vector<Param*>::const_iterator iter;
+ Param *result = NULL;
+
+ for (iter = this->parameters.begin(); iter != this->parameters.end(); iter++)
+ {
+ if ((*iter)->GetKey() == key)
+ {
+ result = *iter;
+ break;
+ }
+ }
+
+ if (result == NULL)
+ gzerr(0) << "Unable to find Param using key[" << key << "]\n";
+
+ return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+/// Return the ID of this entity. This id is unique
+int Common::GetId() const
+{
+ return this->id;
+}
Added: code/gazebo/trunk/server/Common.hh
===================================================================
--- code/gazebo/trunk/server/Common.hh (rev 0)
+++ code/gazebo/trunk/server/Common.hh 2008-09-10 03:51:13 UTC (rev 7018)
@@ -0,0 +1,80 @@
+/*
+ * Gazebo - Outdoor Multi-Robot Simulator
+ * Copyright (C) 2003
+ * Nate Koenig & Andrew Howard
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+/* Desc: Base class shared by all classes in Gazebo.
+ * Author: Nate Koenig
+ * Date: 09 Sept. 2008
+ * SVN: $Id:$
+ */
+
+#ifndef COMMON_HH
+#define COMMON_HH
+
+#include <vector>
+#include <string>
+
+#include "Param.hh"
+
+namespace gazebo
+{
+
+ class Common
+ {
+ /// \brief Constructor
+ public: Common();
+
+ /// \brief Destructor
+ public: virtual ~Common();
+
+ /// \brief Set the name of the entity
+ /// \param name Body name
+ public: void SetName(const std::string &name);
+
+ /// \brief Return the name of the entity
+ /// \return Name of the entity
+ public: std::string GetName() const;
+
+ /// \brief Get the parameters
+ public: std::vector<Param*> *GetParams();
+
+ /// \brief Get a parameter by name
+ public: Param *GetParam(const std::string &key) const;
+
+ /// \brief Return the ID of this entity. This id is unique
+ /// \return Integer ID
+ public: int GetId() const;
+
+ /// \brief This entities ID
+ private: unsigned int id;
+
+ /// \brief Used to automaticaly chose a unique ID on creation
+ private: static unsigned int idCounter;
+
+ /// Name of the entity
+ protected: ParamT<std::string> *nameP;
+
+ /// List of all the parameters
+ protected: std::vector<Param*> parameters;
+ };
+}
+
+#endif
+
Modified: code/gazebo/trunk/server/Entity.cc
===================================================================
--- code/gazebo/trunk/server/Entity.cc 2008-09-09 23:48:33 UTC (rev 7017)
+++ code/gazebo/trunk/server/Entity.cc 2008-09-10 03:51:13 UTC (rev 7018)
@@ -34,16 +34,14 @@
#include "Entity.hh"
using namespace gazebo;
-unsigned int Entity::idCounter = 0;
+////////////////////////////////////////////////////////////////////////////////
+// Constructor
Entity::Entity(Entity *parent)
-: parent(parent),
- id(++idCounter),
- visualNode(0)
+: Common(), parent(parent), visualNode(0)
{
Param::Begin(&this->parameters);
- this->nameP = new ParamT<std::string>("name","",1);
this->staticP = new ParamT<bool>("static",false,0);
//this->staticP->Callback( &Entity::SetStatic, this);
Param::End();
@@ -65,39 +63,38 @@
World::Instance()->GetPhysicsEngine()->AddEntity(this);
}
+////////////////////////////////////////////////////////////////////////////////
+// Destructor
Entity::~Entity()
{
- delete this->nameP;
delete this->staticP;
GZ_DELETE(this->visualNode);
World::Instance()->GetPhysicsEngine()->RemoveEntity(this);
}
-int Entity::GetId() const
-{
- return this->id;
-}
-
+////////////////////////////////////////////////////////////////////////////////
// Return the ID of the parent
int Entity::GetParentId() const
{
return this->parent == NULL ? 0 : this->parent->GetId();
}
-
+////////////////////////////////////////////////////////////////////////////////
// Set the parent
void Entity::SetParent(Entity *parent)
{
this->parent = parent;
}
+////////////////////////////////////////////////////////////////////////////////
// Get the parent
Entity *Entity::GetParent() const
{
return this->parent;
}
+////////////////////////////////////////////////////////////////////////////////
// Add a child to this entity
void Entity::AddChild(Entity *child)
{
@@ -108,18 +105,21 @@
this->children.push_back(child);
}
+////////////////////////////////////////////////////////////////////////////////
// Get all children
std::vector< Entity* > &Entity::GetChildren()
{
return this->children;
}
+////////////////////////////////////////////////////////////////////////////////
// Return this entitie's sceneNode
OgreVisual *Entity::GetVisualNode() const
{
return this->visualNode;
}
+////////////////////////////////////////////////////////////////////////////////
// Set the scene node
void Entity::SetVisualNode(OgreVisual *visualNode)
{
@@ -127,21 +127,6 @@
}
////////////////////////////////////////////////////////////////////////////////
-// Set the name of the body
-void Entity::SetName(const std::string &name)
-{
- this->nameP->SetValue( name );
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// Return the name of the body
-std::string Entity::GetName() const
-{
- return this->nameP->GetValue();
-}
-
-
-////////////////////////////////////////////////////////////////////////////////
// Set whether this entity is static: immovable
void Entity::SetStatic(const bool &s)
{
@@ -198,32 +183,3 @@
{
return ent.GetName() == this->GetName();
}
-
-////////////////////////////////////////////////////////////////////////////////
-/// Get the parameters
-std::vector<Param*> *Entity::GetParams()
-{
- return &this->parameters;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-/// Get a parameter by name
-Param *Entity::GetParam(const std::string &key) const
-{
- std::vector<Param*>::const_iterator iter;
- Param *result = NULL;
-
- for (iter = this->parameters.begin(); iter != this->parameters.end(); iter++)
- {
- if ((*iter)->GetKey() == key)
- {
- result = *iter;
- break;
- }
- }
-
- if (result == NULL)
- gzerr(0) << "Unable to find Param using key[" << key << "]\n";
-
- return result;
-}
Modified: code/gazebo/trunk/server/Entity.hh
===================================================================
--- code/gazebo/trunk/server/Entity.hh 2008-09-09 23:48:33 UTC (rev 7017)
+++ code/gazebo/trunk/server/Entity.hh 2008-09-10 03:51:13 UTC (rev 7018)
@@ -18,8 +18,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
-
-/* Desc: External interfaces for Gazebo
+/* Desc: Base class for all physical entities
* Author: Nate Koenig
* Date: 03 Apr 2007
* SVN: $Id$
@@ -32,6 +31,7 @@
#include <string>
#include <ode/ode.h>
+#include "Common.hh"
#include "Param.hh"
namespace gazebo
@@ -46,7 +46,7 @@
/*
* Facilitates meshing of physics engine with rendering engine
*/
- class Entity
+ class Entity : public Common
{
/// \brief Constructor
/// \param parent Parent of the entity.
@@ -54,11 +54,7 @@
/// \brief Destructor
public: virtual ~Entity();
-
- /// \brief Return the ID of this entity. This id is unique
- /// \return Integer ID
- public: int GetId() const;
-
+
/// \brief Return the ID of the parent
/// \return Integer ID
public: int GetParentId() const;
@@ -86,15 +82,7 @@
/// \brief Set the scene node
/// \param sceneNode Ogre scene node
public: void SetVisualNode(OgreVisual *visualNode);
-
- /// \brief Set the name of the entity
- /// \param name Body name
- public: void SetName(const std::string &name);
-
- /// \brief Return the name of the entity
- /// \return Name of the entity
- public: std::string GetName() const;
-
+
/// \brief Set whether this entity is static: immovable
/// \param s Bool, true = static
public: void SetStatic(const bool &s);
@@ -113,24 +101,12 @@
/// \brief Returns true if the entities are the same. Checks only the name
public: bool operator==(const Entity &ent) const;
- /// \brief Get the parameters
- public: std::vector<Param*> *GetParams();
-
- /// \brief Get a parameter by name
- public: Param *GetParam(const std::string &key) const;
-
/// \brief Parent of this entity
protected: Entity *parent;
/// \brief Children of this entity
protected: std::vector< Entity* > children;
- /// \brief This entities ID
- private: unsigned int id;
-
- /// \brief Used to automaticaly chose a unique ID on creation
- private: static unsigned int idCounter;
-
// is this an static entity
protected: ParamT<bool> *staticP;
@@ -140,14 +116,7 @@
/// \brief ODE Stuff (should be go somewhere else)
public: dSpaceID spaceId;
- /// \brief Name of the entity
- protected: ParamT<std::string> *nameP;
-
- /// List of all the parameters
- protected: std::vector<Param*> parameters;
-
private: bool selected;
-
};
/// \}
Modified: code/gazebo/trunk/server/Param.cc
===================================================================
--- code/gazebo/trunk/server/Param.cc 2008-09-09 23:48:33 UTC (rev 7017)
+++ code/gazebo/trunk/server/Param.cc 2008-09-10 03:51:13 UTC (rev 7018)
@@ -1,3 +1,29 @@
+/*
+ * Gazebo - Outdoor Multi-Robot Simulator
+ * Copyright (C) 2003
+ * Nate Koenig & Andrew Howard
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+/* Desc: Parameter class
+ * Author: Nate Koenig
+ * Date: 14 Aug 2008
+ * SVN: $Id:$
+ */
+
#include "GazeboError.hh"
#include "Param.hh"
Modified: code/gazebo/trunk/server/SConscript
===================================================================
--- code/gazebo/trunk/server/SConscript 2008-09-09 23:48:33 UTC (rev 7017)
+++ code/gazebo/trunk/server/SConscript 2008-09-10 03:51:13 UTC (rev 7018)
@@ -7,6 +7,7 @@
SConscript('%s/SConscript' % subdir)
sources = ['main.cc',
+ 'Common.cc',
'Vector3.cc',
'Vector4.cc',
'Quatern.cc',
Modified: code/gazebo/trunk/server/gui/GLWindow.cc
===================================================================
--- code/gazebo/trunk/server/gui/GLWindow.cc 2008-09-09 23:48:33 UTC (rev
7017)
+++ code/gazebo/trunk/server/gui/GLWindow.cc 2008-09-10 03:51:13 UTC (rev
7018)
@@ -351,8 +351,6 @@
{
this->keys[keyNum] = 0;
- Simulator* sim = Simulator::Instance();
-
// Handle all toggle keys
switch (keyNum)
{
Modified: code/gazebo/trunk/server/gui/Toolbar.cc
===================================================================
--- code/gazebo/trunk/server/gui/Toolbar.cc 2008-09-09 23:48:33 UTC (rev
7017)
+++ code/gazebo/trunk/server/gui/Toolbar.cc 2008-09-10 03:51:13 UTC (rev
7018)
@@ -30,13 +30,17 @@
#include <FL/Fl_Input.H>
#include <FL/Fl_Button.H>
+#include <boost/lexical_cast.hpp>
+
#include "World.hh"
#include "Body.hh"
#include "Geom.hh"
#include "Entity.hh"
+#include "Common.hh"
#include "Model.hh"
#include "Simulator.hh"
#include "CameraManager.hh"
+#include "OgreVisual.hh"
#include "OgreCamera.hh"
#include "Toolbar.hh"
#include "Global.hh"
@@ -127,6 +131,16 @@
value = "@[EMAIL PROTECTED]@s -Geom:[EMAIL PROTECTED]@[EMAIL
PROTECTED]" + giter->second->GetName();
this->AddToParamBrowser(value);
this->AddEntityToParamBrowser( giter->second, " " );
+
+ for (unsigned int i=0; i < giter->second->GetVisualCount(); i++)
+ {
+ OgreVisual *vis = giter->second->GetVisual(i);
+ std::ostringstream stream;
+ stream << vis->GetId();
+ value = "@[EMAIL PROTECTED]@s -Visual:[EMAIL PROTECTED]@[EMAIL
PROTECTED]" + stream.str();
+ this->AddToParamBrowser(value);
+ this->AddEntityToParamBrowser( vis, " " );
+ }
}
}
}
@@ -190,8 +204,10 @@
Model *model =
dynamic_cast<Model*>(Simulator::Instance()->GetSelectedEntity());
Body *body = NULL;
Geom *geom = NULL;
- std::string geomName, bodyName, value, label;
+ OgreVisual *vis = NULL;
+ std::string geomName, bodyName, visNum, value, label;
+
// Make sure we have a valid model
if (!model)
{
@@ -215,6 +231,8 @@
geomName = lineText.substr( lastAmp, lineText.size()-lastAmp );
else if (lineText.find("-Body:") != std::string::npos && bodyName.empty())
bodyName = lineText.substr( lastAmp, lineText.size()-lastAmp );
+ else if (lineText.find("-Visual:") != std::string::npos && visNum.empty())
+ visNum = lineText.substr( lastAmp, lineText.size()-lastAmp );
selected--;
}
@@ -227,9 +245,14 @@
if (!geomName.empty() && body)
geom = body->GetGeom(geomName);
+ if (!visNum.empty() && geom)
+ vis = geom->GetVisualById(boost::lexical_cast<int>(visNum));
+
// Get the parameter
Param *param = NULL;
- if (geom)
+ if (vis)
+ param = vis->GetParam(label);
+ else if (geom)
param = geom->GetParam(label);
else if (body)
param = body->GetParam(label);
@@ -256,7 +279,7 @@
////////////////////////////////////////////////////////////////////////////////
// Add entity to browser
-void Toolbar::AddEntityToParamBrowser(Entity *entity, std::string prefix)
+void Toolbar::AddEntityToParamBrowser(Common *entity, std::string prefix)
{
std::vector<Param*> *parameters;
std::vector<Param*>::iterator iter;
Modified: code/gazebo/trunk/server/gui/Toolbar.hh
===================================================================
--- code/gazebo/trunk/server/gui/Toolbar.hh 2008-09-09 23:48:33 UTC (rev
7017)
+++ code/gazebo/trunk/server/gui/Toolbar.hh 2008-09-10 03:51:13 UTC (rev
7018)
@@ -37,7 +37,7 @@
namespace gazebo
{
- class Entity;
+ class Common;
/// \brief Toolbar
class Toolbar : public Fl_Group
@@ -61,7 +61,7 @@
public: static void EntityBrowserCB( Fl_Widget *w, void *data );
/// \brief Add an entity ot the param browser
- private: void AddEntityToParamBrowser(Entity *ent, std::string prefix);
+ private: void AddEntityToParamBrowser(Common *ent, std::string prefix);
/// \brief Add a line to the param browser
private: void AddToParamBrowser(const std::string &line);
Modified: code/gazebo/trunk/server/physics/Geom.cc
===================================================================
--- code/gazebo/trunk/server/physics/Geom.cc 2008-09-09 23:48:33 UTC (rev
7017)
+++ code/gazebo/trunk/server/physics/Geom.cc 2008-09-10 03:51:13 UTC (rev
7018)
@@ -517,3 +517,32 @@
this->body->UpdateCoM();
}
+////////////////////////////////////////////////////////////////////////////////
+/// Get the number of visuals
+unsigned int Geom::GetVisualCount() const
+{
+ return this->visuals.size();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+/// Get a visual
+OgreVisual *Geom::GetVisual(unsigned int index) const
+{
+ if (index < this->visuals.size())
+ return this->visuals[index];
+}
+
+////////////////////////////////////////////////////////////////////////////////
+/// Get a visual
+OgreVisual *Geom::GetVisualById(int id) const
+{
+ std::vector<OgreVisual*>::const_iterator iter;
+
+ for (iter = this->visuals.begin(); iter != this->visuals.end(); iter++)
+ {
+ if ( (*iter)->GetId() == id)
+ return *iter;
+ }
+
+ return NULL;
+}
Modified: code/gazebo/trunk/server/physics/Geom.hh
===================================================================
--- code/gazebo/trunk/server/physics/Geom.hh 2008-09-09 23:48:33 UTC (rev
7017)
+++ code/gazebo/trunk/server/physics/Geom.hh 2008-09-10 03:51:13 UTC (rev
7018)
@@ -143,6 +143,15 @@
/// \brief Set the mass
public: void SetMass(const double &mass);
+ /// \brief Get the number of visuals
+ public: unsigned int GetVisualCount() const;
+
+ /// \brief Get a visual
+ public: OgreVisual *GetVisual(unsigned int index) const;
+
+ /// \brief Get a visual by id
+ public: OgreVisual *GetVisualById( int id ) const;
+
/// Contact parameters
public: ContactParams *contact;
Modified: code/gazebo/trunk/server/physics/Joint.cc
===================================================================
--- code/gazebo/trunk/server/physics/Joint.cc 2008-09-09 23:48:33 UTC (rev
7017)
+++ code/gazebo/trunk/server/physics/Joint.cc 2008-09-10 03:51:13 UTC (rev
7018)
@@ -36,12 +36,12 @@
//////////////////////////////////////////////////////////////////////////////
// Constructor
Joint::Joint()
+ : Common()
{
this->visual = NULL;
this->model = NULL;
Param::Begin(&this->parameters);
- this->nameP = new ParamT<std::string>("name","",1);
this->erpP = new ParamT<double>("erp",0.4,0);
this->cfmP = new ParamT<double>("cfm",10e-3,0);
this->suspensionCfmP = new ParamT<double>("suspensionCfm",0.0,0);
@@ -59,7 +59,6 @@
Joint::~Joint()
{
dJointDestroy( this->jointId );
- delete this->nameP;
delete this->erpP;
delete this->cfmP;
delete this->suspensionCfmP;
Modified: code/gazebo/trunk/server/physics/Joint.hh
===================================================================
--- code/gazebo/trunk/server/physics/Joint.hh 2008-09-09 23:48:33 UTC (rev
7017)
+++ code/gazebo/trunk/server/physics/Joint.hh 2008-09-10 03:51:13 UTC (rev
7018)
@@ -29,6 +29,7 @@
#include <ode/ode.h>
+#include "Common.hh"
#include "Param.hh"
#include "Vector3.hh"
@@ -45,7 +46,7 @@
class OgreVisual;
/// \brief Base class for all joints
- class Joint
+ class Joint : public Common
{
/// \brief Type of joint
public: enum Type {SLIDER, HINGE, HINGE2, BALL, UNIVERSAL};
@@ -153,7 +154,6 @@
private: Body *body2;
/// Name of this joint
- private: ParamT<std::string> *nameP;
private: ParamT<double> *erpP;
private: ParamT<double> *cfmP;
private: ParamT<double> *suspensionCfmP;
@@ -166,8 +166,6 @@
/// Feedback data for this joint
private: dJointFeedback *feedback;
- protected: std::vector<Param*> parameters;
-
private: OgreVisual *visual;
private: Model *model;
Modified: code/gazebo/trunk/server/rendering/OgreVisual.cc
===================================================================
--- code/gazebo/trunk/server/rendering/OgreVisual.cc 2008-09-09 23:48:33 UTC
(rev 7017)
+++ code/gazebo/trunk/server/rendering/OgreVisual.cc 2008-09-10 03:51:13 UTC
(rev 7018)
@@ -39,6 +39,7 @@
////////////////////////////////////////////////////////////////////////////////
// Constructor
OgreVisual::OgreVisual(OgreVisual *node, Entity *owner)
+ : Common()
{
std::ostringstream stream;
@@ -60,10 +61,19 @@
Param::Begin(&this->parameters);
this->xyzP = new ParamT<Vector3>("xyz", Vector3(0,0,0), 0);
+ this->xyzP->Callback( &OgreVisual::SetPosition, this );
+
this->rpyP = new ParamT<Quatern>("rpy", Quatern(1,0,0,0), 0);
+ this->rpyP->Callback( &OgreVisual::SetRotation, this );
+
this->meshNameP = new ParamT<std::string>("mesh","",1);
+
this->materialNameP = new ParamT<std::string>("material",std::string(),0);
+ this->materialNameP->Callback( &OgreVisual::SetMaterial, this );
+
this->castShadowsP = new ParamT<bool>("castShadows",true,0);
+ this->castShadowsP->Callback( &OgreVisual::SetCastShadows, this );
+
this->scaleP = new ParamT<Vector3>("scale", Vector3(1,1,1), 0);
this->sizeP = new ParamT<Vector3>("size", Vector3(1,1,1), 0);
Param::End();
@@ -277,7 +287,10 @@
// Clone the material. This will allow us to change the look of each geom
// individually.
- this->myMaterial = this->origMaterial->clone(myMaterialName);
+ if (Ogre::MaterialManager::getSingleton().resourceExists(myMaterialName))
+ this->myMaterial =
(Ogre::MaterialPtr)(Ogre::MaterialManager::getSingleton().getByName(myMaterialName));
+ else
+ this->myMaterial = this->origMaterial->clone(myMaterialName);
Ogre::Material::TechniqueIterator techniqueIt =
this->myMaterial->getTechniqueIterator ();
@@ -421,7 +434,7 @@
////////////////////////////////////////////////////////////////////////////////
/// Set whether the visual should cast shadows
-void OgreVisual::SetCastShadows(bool shadows)
+void OgreVisual::SetCastShadows(const bool &shadows)
{
for (int i=0; i < this->sceneNode->numAttachedObjects(); i++)
{
@@ -566,5 +579,3 @@
if (node)
node->showBoundingBox(value);
}
-
-
Modified: code/gazebo/trunk/server/rendering/OgreVisual.hh
===================================================================
--- code/gazebo/trunk/server/rendering/OgreVisual.hh 2008-09-09 23:48:33 UTC
(rev 7017)
+++ code/gazebo/trunk/server/rendering/OgreVisual.hh 2008-09-10 03:51:13 UTC
(rev 7018)
@@ -33,6 +33,7 @@
#include "Pose3d.hh"
#include "Quatern.hh"
#include "Vector3.hh"
+#include "Common.hh"
#include "Param.hh"
namespace gazebo
@@ -42,7 +43,7 @@
class Entity;
/// \brief Ogre Visual Object
- class OgreVisual : public Ogre::UserDefinedObject
+ class OgreVisual : public Common, public Ogre::UserDefinedObject
{
/// \brief Constructor
public: OgreVisual (OgreVisual *node, Entity *owner = NULL);
@@ -82,7 +83,7 @@
public: void SetHighlight( bool highlight);
/// \brief Set whether the visual should cast shadows
- public: void SetCastShadows(bool shadows);
+ public: void SetCastShadows(const bool &shadows);
/// \brief Set whether the visual is visible
/// \param visible set this node visible
@@ -123,7 +124,6 @@
// user selection
public: void ShowSelectionBox( bool value );
-
private: Ogre::MaterialPtr origMaterial;
private: Ogre::MaterialPtr myMaterial;
private: Ogre::SceneBlendType sceneBlendType;
@@ -147,7 +147,6 @@
private: ParamT<bool> *castShadowsP;
private: ParamT<Vector3> *sizeP;
private: ParamT<Vector3> *scaleP;
- private: std::vector<Param*> parameters;
};
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit