Revision: 8988
          http://playerstage.svn.sourceforge.net/playerstage/?rev=8988&view=rev
Author:   natepak
Date:     2010-11-30 02:29:38 +0000 (Tue, 30 Nov 2010)

Log Message:
-----------
Updates

Modified Paths:
--------------
    code/gazebo/branches/dev/server/Messages.hh
    code/gazebo/branches/dev/server/physics/Body.cc
    code/gazebo/branches/dev/server/physics/Geom.cc
    code/gazebo/branches/dev/server/physics/Geom.hh
    code/gazebo/branches/dev/server/physics/Joint.cc
    code/gazebo/branches/dev/server/physics/Joint.hh

Modified: code/gazebo/branches/dev/server/Messages.hh
===================================================================
--- code/gazebo/branches/dev/server/Messages.hh 2010-11-29 23:05:26 UTC (rev 
8987)
+++ code/gazebo/branches/dev/server/Messages.hh 2010-11-30 02:29:38 UTC (rev 
8988)
@@ -29,8 +29,10 @@
     public: std::string xmlStr;
   };
 
-  class InsertVisualMsg : public Message
+  class VisualMsg : public Message
   {
+    public: enum ActionType {UPDATE, DELETE};
+
     public: InsertVisualMsg() : Message(INSERT_VISUAL) {}
     public: InsertVisualMsg(const InsertVisualMsg &m) : Message(m), 
             xmlStr(m.xmlStr) {}
@@ -39,11 +41,14 @@
 
     public: std::string parentId;
     public: std::string id;
+    public: VisualMsgActionType action;
     public: std::string mesh;
     public: std::string material;
     public: bool castShadows;
     public: bool attachAxes;
     public: bool visible;
+    public: Vector3 boundingbox_min;
+    public: Vector3 boundingbox_max;
   };
 
   class UpdatePoseMsg : public Message

Modified: code/gazebo/branches/dev/server/physics/Body.cc
===================================================================
--- code/gazebo/branches/dev/server/physics/Body.cc     2010-11-29 23:05:26 UTC 
(rev 8987)
+++ code/gazebo/branches/dev/server/physics/Body.cc     2010-11-30 02:29:38 UTC 
(rev 8988)
@@ -379,7 +379,7 @@
 
     this->cgVisualId = visname.str();
 
-    InsertVisualMsg msg;
+    VisualMsg msg;
     msg.parentId = this->comEntity->GetName();
     msg.id = this->cgVisualId;
     msg.type = MESH_RESOURCE;

Modified: code/gazebo/branches/dev/server/physics/Geom.cc
===================================================================
--- code/gazebo/branches/dev/server/physics/Geom.cc     2010-11-29 23:05:26 UTC 
(rev 8987)
+++ code/gazebo/branches/dev/server/physics/Geom.cc     2010-11-30 02:29:38 UTC 
(rev 8988)
@@ -91,18 +91,18 @@
 // Destructor
 Geom::~Geom()
 {
-  for (std::vector<Visual*>::iterator iter = this->visuals.begin(); 
-       iter != this->visuals.end(); iter++)
-    if (*iter)
-      delete *iter;
-  this->visuals.clear();
-
-  if (this->bbVisual)
+  for (unsigned int i=0; i < this->visualMsgs.size(); i++)
   {
-    delete this->bbVisual;
-    this->bbVisual = NULL;
+    this->visualMsgs[i]->action = VisualMsg::DELETE;
+    Simulator::Instance()->SendMessage( *this->visualMsgs[i] );
+    delete this->visualMsgs[i];
   }
+  this->visualMsgs.clear();
 
+  this->bbVisualMsg->action = VisualMsg::DELETE;
+  Simulator::Instance()->SendMessage( *this->bbVisual );
+  delete this->bbVisualMsg;
+
   delete this->typeP;
   delete this->massP;
   delete this->xyzP;
@@ -114,7 +114,6 @@
   if (this->shape)
     delete this->shape;
   this->shape = NULL;
-
 }
 
 
////////////////////////////////////////////////////////////////////////////////
@@ -166,18 +165,20 @@
   {
     std::ostringstream visname;
     visname << this->GetCompleteScopedName() << "_VISUAL_" << 
-               this->visuals.size();
+               this->visualMsgs.size();
 
 
-    InsertVisualMsg msg;
-    msg.parentId = this->GetName();
-    msg.id = visname.str();
-    msg.Load(childNode);
-    msg.castShadows = false;
-    Simulator::Instance()->SendMessage( msg );
+    VisualMsg *msg = new VisualMsg();
 
-    this->visualNames.push_back(visname.str());
+    msg->parentId = this->GetName();
+    msg->id = visname.str();
+    msg->type = VisualMsg::MESH_RESOURCE;
+    msg->Load(childNode);
+    msg->castShadows = false;
+    Simulator::Instance()->SendMessage( *msg );
 
+    this->visualMsgs.push_back(msg);
+
     // NATY: get rid of this
     //visual->SetOwner(this);
     //visual->SetCastShadows(true);
@@ -203,11 +204,17 @@
     std::ostringstream visname;
     visname << this->GetCompleteScopedName() << "_BBVISUAL" ;
 
-    this->bbVisual = new Visual(visname.str(), this->visualNode);
-    this->bbVisual->SetCastShadows(false);
-    this->bbVisual->AttachBoundingBox(min,max);
-    this->bbVisual->SetVisible( RenderState::GetShowBoundingBoxes() );
-    this->bbVisual->SetOwner(this);
+    this->bbVisualMsg = new VisualMsg();
+
+    this->bbVisualMsg->type = VisualMsg::MESH_RESOURCE;
+    this->bbVisualMsg->parentId = this->GetName();
+    this->bbVisualMsg->id = this->GetName() + "_BBVISUAL";
+    this->bbVisualMsg->castShadows = false;
+    this->bbVisualMsg->visible = RenderState::GetShowBoundingBoxes();
+    this->bbVisualMsg->boundingbox_min = min;
+    this->bbVisualMsg->boundingbox_max = max;
+
+    Simulator::Instance()->SendMessage( *this->bbVisualMsg );
   }
 }
 
@@ -309,33 +316,38 @@
 // Toggle bounding box visibility
 void Geom::ToggleShowBoundingBox()
 {
-  if (this->bbVisual)
-    this->bbVisual->ToggleVisible();
+  if (this->bbVisualMsg)
+  {
+    this->bbVisualMsg->visible = !this->bbVisualMsg->visual;
+    this->bbVisualMsg->action = UPDATE;
+    Simulator::Instance()->SendMessage( *this->bbVisualMsg );
+  }
 }
 
 
////////////////////////////////////////////////////////////////////////////////
 /// Set the visibility of the Bounding box of this geometry
 void Geom::ShowBoundingBox(bool show)
 {
-  if (this->bbVisual)
-    this->bbVisual->SetVisible(show);
+  if (this->bbVisualMsg)
+  {
+    this->bbVisualMsg->visible = show;
+    this->bbVisualMsg->action = UPDATE;
+    Simulator::Instance()->SendMessage( *this->bbVisualMsg );
+  }
 }
 
 
////////////////////////////////////////////////////////////////////////////////
 // Toggle transparency
 void Geom::ToggleTransparent()
 {
-  std::vector<Visual*>::iterator iter;
-
-  for (iter = this->visuals.begin(); iter != this->visuals.end(); iter++)
+  for (unsigned int i = 0; i < this->visualMsgs.size(); i++)
   {
-    if (*iter)
-    {
-      if ((*iter)->GetTransparency() == 0.0)
-        (*iter)->SetTransparency(0.6);
-      else
-        (*iter)->SetTransparency(0.0);
-    }
+    this->visualMsgs[i].action = UPDATE;
+    if (this->visualMsgs[i].transparency == 0.0)
+      this->visualMsgs[i].transparency = 0.6;
+    else
+      this->visualMsgs[i].transparency = 0.0;
+    Simulator::Instance()->SetMessage( *this->visualMsgs[i] );
   }
 }
 
@@ -343,29 +355,14 @@
 /// Set the transparency
 void Geom::SetTransparent(bool show)
 {
-  std::vector<Visual*>::iterator iter;
-
-  if (show)
+for (unsigned int i = 0; i < this->visualMsgs.size(); i++)
   {
-    for (iter = this->visuals.begin(); iter != this->visuals.end(); iter++)
-    {
-      if (*iter)
-      {
-        (*iter)->SetVisible(true, false);
-        (*iter)->SetTransparency(0.6);
-      }
-    }
-  } 
-  else
-  {
-    for (iter = this->visuals.begin(); iter != this->visuals.end(); iter++)
-    {
-      if (*iter)
-      {
-        (*iter)->SetVisible(true, true);
-        (*iter)->SetTransparency(0.0);
-      }
-    }
+    this->visualMsgs[i].action = UPDATE;
+    if (show)
+      this->visualMsgs[i].transparency = 0.6;
+    else
+      this->visualMsgs[i].transparency = 0.0;
+    Simulator::Instance()->SetMessage( *this->visualMsgs[i] );
   }
 }
 
@@ -386,38 +383,6 @@
 }
 
 
////////////////////////////////////////////////////////////////////////////////
-/// Get the number of visuals
-unsigned int Geom::GetVisualCount() const
-{
-  return this->visuals.size();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-/// Get a visual
-Visual *Geom::GetVisual(unsigned int index) const
-{
-  if (index < this->visuals.size())
-    return this->visuals[index];
-  else
-    return NULL;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-/// Get a visual
-Visual *Geom::GetVisualById(int id) const
-{
-  std::vector<Visual*>::const_iterator iter;
-
-  for (iter = this->visuals.begin(); iter != this->visuals.end(); iter++)
-  {
-    if ( (*iter) && (*iter)->GetId() == id)
-      return *iter;
-  }
-
-  return NULL;
-}
-
-////////////////////////////////////////////////////////////////////////////////
 /// Get the body this geom belongs to
 Body *Geom::GetBody() const
 {
@@ -513,9 +478,11 @@
   if (this->bbVisual)
   {
     if (enabled)
-      this->bbVisual->SetBoundingBoxMaterial("Gazebo/GreenTransparent");
+      this->bbVisualMsg->material = "Gazebo/GreenTransparent";
     else
-      this->bbVisual->SetBoundingBoxMaterial("Gazebo/RedTransparent");
+      this->bbVisualMsg->material = "Gazebo/RedTransparent";
+
+    Simulator::Instance()->SendMessage( *this->bbVisualMsg );
   }
 }
 

Modified: code/gazebo/branches/dev/server/physics/Geom.hh
===================================================================
--- code/gazebo/branches/dev/server/physics/Geom.hh     2010-11-29 23:05:26 UTC 
(rev 8987)
+++ code/gazebo/branches/dev/server/physics/Geom.hh     2010-11-30 02:29:38 UTC 
(rev 8988)
@@ -44,7 +44,6 @@
   class Body;
   class SurfaceParams;
   class XMLConfigNode;
-  class Visual;
 
   /// \addtogroup gazebo_physics
   /// \brief Base class for all geoms
@@ -119,15 +118,6 @@
     /// \brief Set the mass
     public: void SetMass(const Mass &mass);
 
-    /// \brief Get the number of visuals
-    public: unsigned int GetVisualCount() const;
-
-    /// \brief Get a visual
-    public: Visual *GetVisual(unsigned int index) const; 
-
-    /// \brief Get a visual by id
-    public: Visual *GetVisualById( int id ) const;
-
     /// \brief Get the body this geom belongs to
     public: Body *GetBody() const;
 
@@ -234,7 +224,8 @@
     private: float transparency;
 
     /// All the visual apparence 
-    private: std::vector<std::string> visualNames;
+    private: std::vector<VisualMsg> visualMsgs;
+    private: VisualMsg *bbVisualMsg;
 
     protected: Shape *shape;
 

Modified: code/gazebo/branches/dev/server/physics/Joint.cc
===================================================================
--- code/gazebo/branches/dev/server/physics/Joint.cc    2010-11-29 23:05:26 UTC 
(rev 8987)
+++ code/gazebo/branches/dev/server/physics/Joint.cc    2010-11-30 02:29:38 UTC 
(rev 8988)
@@ -27,8 +27,6 @@
 #include "RenderTypes.hh"
 #include "Events.hh"
 #include "PhysicsEngine.hh"
-#include "Visual.hh"
-#include "OgreDynamicLines.hh"
 #include "GazeboError.hh"
 #include "GazeboMessage.hh"
 #include "Global.hh"
@@ -140,12 +138,15 @@
   this->Attach(this->body1, this->body2);
 
   /// Add a renderable for the joint
-  this->visual = new Visual(visname.str(), this);
-  this->visual->SetPosition(this->anchorPos);
-  this->visual->SetCastShadows(false);
-  this->visual->AttachMesh("joint_anchor");
-  this->visual->SetMaterial("Gazebo/JointAnchor");
-  this->visual->SetVisible(false);
+  this->visualMsg = new VisualMsg();
+  this->visualMsg->parentId = this->GetName();
+  this->visualMsg->id = visname.str();
+  this->visualMsg->type = VisualMsg::MESH_RESOURCE;
+  this->visualMsg->pose.pos = this->achorPos;
+  this->visualMsg->castShadows = false;
+  this->visualMsg->mesh = "joint_anchor";
+  this->visualMsg->material = "Gazebo/JointAnchor";
+  this->visualMsg->visible = false;
 
   this->line1 = this->visual->AddDynamicLine(RENDERING_LINE_LIST);
   this->line2 = this->visual->AddDynamicLine(RENDERING_LINE_LIST);

Modified: code/gazebo/branches/dev/server/physics/Joint.hh
===================================================================
--- code/gazebo/branches/dev/server/physics/Joint.hh    2010-11-29 23:05:26 UTC 
(rev 8987)
+++ code/gazebo/branches/dev/server/physics/Joint.hh    2010-11-30 02:29:38 UTC 
(rev 8988)
@@ -43,7 +43,6 @@
   class XMLConfigNode;
   class Model;
   class OgreDynamicLines;
-  class Visual; 
 
   /// \brief Base class for all joints
   class Joint : public Common
@@ -182,7 +181,7 @@
     protected: ParamT<bool> *provideFeedbackP;
     protected: ParamT<double> *fudgeFactorP;
 
-    protected: Visual *visual;
+    protected: VisualMsg *visualMsg;
 
     protected: Model *model;
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to