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

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

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

Modified: code/gazebo/branches/dev/server/Messages.hh
===================================================================
--- code/gazebo/branches/dev/server/Messages.hh 2010-11-30 02:29:38 UTC (rev 
8988)
+++ code/gazebo/branches/dev/server/Messages.hh 2010-11-30 05:02:10 UTC (rev 
8989)
@@ -1,12 +1,16 @@
 #ifndef MESSAGES_HH
 #define MESSAGES_HH
 
+#include <vector>
+
+#include "Vector3.hh"
 #include "Time.hh"
 #include "Pose3d.hh"
 
+
 namespace gazebo
 {
-  enum MessageType{ INSERT_MODEL };
+  enum MessageType{ INSERT_MODEL, VISUAL, POSE };
 
   class Message
   {
@@ -32,16 +36,17 @@
   class VisualMsg : public Message
   {
     public: enum ActionType {UPDATE, DELETE};
+    public: enum RenderType {MESH_RESOURCE, POINTS, LINE_LIST};
 
-    public: InsertVisualMsg() : Message(INSERT_VISUAL) {}
-    public: InsertVisualMsg(const InsertVisualMsg &m) : Message(m), 
-            xmlStr(m.xmlStr) {}
+    public: VisualMsg() : Message(VISUAL) {}
+    public: VisualMsg(const VisualMsg &m) : Message(m) {}
     public: virtual Message *Clone() const 
-            { InsertVisualMsg *msg = new InsertVisualMsg(*this); return msg; }
+            { VisualMsg *msg = new VisualMsg(*this); return msg; }
 
     public: std::string parentId;
     public: std::string id;
-    public: VisualMsgActionType action;
+    public: ActionType action;
+    public: RenderType render;
     public: std::string mesh;
     public: std::string material;
     public: bool castShadows;
@@ -49,9 +54,10 @@
     public: bool visible;
     public: Vector3 boundingbox_min;
     public: Vector3 boundingbox_max;
+    public: std::vector<Vector3> points;
   };
 
-  class UpdatePoseMsg : public Message
+  /*class UpdatePoseMsg : public Message
   {
     public: UpdatePoseMsg() : Message(UPDATE_POSE), id(0) {}
     public: UpdatePoseMsg(const UpdatePoseMsg &m) : Message(m), 
@@ -61,7 +67,7 @@
 
     public: std::string id;
     public: Pose3d pose;
-  };
+  };*/
 }
 
 #endif

Modified: code/gazebo/branches/dev/server/audio_video/AudioDecoder.hh
===================================================================
--- code/gazebo/branches/dev/server/audio_video/AudioDecoder.hh 2010-11-30 
02:29:38 UTC (rev 8988)
+++ code/gazebo/branches/dev/server/audio_video/AudioDecoder.hh 2010-11-30 
05:02:10 UTC (rev 8989)
@@ -31,6 +31,8 @@
 
 #ifdef HAVE_FFMPEG
 
+#include <inttypes.h>
+
 extern "C" {
 
 #include <avformat.h>

Modified: code/gazebo/branches/dev/server/physics/Body.cc
===================================================================
--- code/gazebo/branches/dev/server/physics/Body.cc     2010-11-30 02:29:38 UTC 
(rev 8988)
+++ code/gazebo/branches/dev/server/physics/Body.cc     2010-11-30 05:02:10 UTC 
(rev 8989)
@@ -111,9 +111,10 @@
   std::vector<Entity*>::iterator iter;
   std::vector< Sensor* >::iterator siter;
 
-  DeleteVisualMsg msg;
-  msg.id = this->cgVisualId;
-  Simulator::Instance()->SendMessage(msg);
+  this->cgVisualMsg->action = VisualMsg::DELETE;
+  Simulator::Instance()->SendMessage(*this->cgVisualMsg);
+  delete this->cgVisualMsg;
+  this->cgVisualMsg = NULL;
 
   for (giter = this->geoms.begin(); giter != this->geoms.end(); giter++)
     if (giter->second)
@@ -377,21 +378,20 @@
     std::ostringstream visname;
     visname << this->GetCompleteScopedName() + ":" + this->GetName() << 
"_CGVISUAL" ;
 
-    this->cgVisualId = visname.str();
+    this->cgVisualMsg = new VisualMsg();
+    this->cgVisualMsg->parentId = this->comEntity->GetName();
+    this->cgVisualMsg->id = visname.str();
+    this->cgVisualMsg->render = VisualMsg::MESH_RESOURCE;
+    this->cgVisualMsg->mesh = "body_cg";
+    this->cgVisualMsg->material = "Gazebo/Red";
+    this->cgVisualMsg->castShadows = false;
+    this->cgVisualMsg->attachAxes = true;
+    this->cgVisualMsg->visible = false;
+    Simulator::Instance()->SendMessage(*this->cgVisualMsg);
 
     VisualMsg msg;
-    msg.parentId = this->comEntity->GetName();
-    msg.id = this->cgVisualId;
-    msg.type = MESH_RESOURCE;
-    msg.mesh = "body_cg";
-    msg.material = "Gazebo/Red";
-    msg.castShadows = false;
-    msg.attachAxes = true;
-    msg.visible = false;
-    Simulator::Instance()->SendMessage(msg);
-
-    msg.parentId = this->cgVisualId;
-    msg.type = LINE_LIST;
+    msg.parentId = this->cgVisualMsg->id;
+    msg.render = VisualMsg::LINE_LIST;
     msg.attachAxes = false;
     msg.material = "Gazebo/GreenGlow";
 
@@ -702,16 +702,16 @@
 /// Toggle show the physics visualizations
 void Body::ToggleShowPhysics()
 {
-  if (this->cgVisual)
-    this->cgVisual->ToggleVisible();
+  this->cgVisualMsg->visible = !this->cgVisualMsg->visible;
+  Simulator::Instance()->SendMessage(*this->cgVisualMsg);
 }
 
 
////////////////////////////////////////////////////////////////////////////////
 /// Set to true to show the physics visualizations
 void Body::ShowPhysics(bool show)
 {
-  if (this->cgVisual)
-    this->cgVisual->SetVisible(show);
+  this->cgVisualMsg->visible = show;
+  Simulator::Instance()->SendMessage(*this->cgVisualMsg);
 }
 
 
////////////////////////////////////////////////////////////////////////////////

Modified: code/gazebo/branches/dev/server/physics/Body.hh
===================================================================
--- code/gazebo/branches/dev/server/physics/Body.hh     2010-11-30 02:29:38 UTC 
(rev 8988)
+++ code/gazebo/branches/dev/server/physics/Body.hh     2010-11-30 05:02:10 UTC 
(rev 8989)
@@ -41,6 +41,7 @@
   class Geom;
   class Sensor;
   class XMLConfigNode;
+  class VisualMsg;
 
   /// \addtogroup gazebo_physics
   /// \brief The body class
@@ -269,7 +270,7 @@
     protected: ParamT<bool> *turnGravityOffP;
     protected: ParamT<bool> *selfCollideP;
 
-    protected: Visual *cgVisual;
+    protected: VisualMsg *cgVisualMsg;
 
     protected: Vector3 linearAccel;
     protected: Vector3 angularAccel;

Modified: code/gazebo/branches/dev/server/physics/Geom.hh
===================================================================
--- code/gazebo/branches/dev/server/physics/Geom.hh     2010-11-30 02:29:38 UTC 
(rev 8988)
+++ code/gazebo/branches/dev/server/physics/Geom.hh     2010-11-30 05:02:10 UTC 
(rev 8989)
@@ -44,6 +44,7 @@
   class Body;
   class SurfaceParams;
   class XMLConfigNode;
+  class VisualMsg;
 
   /// \addtogroup gazebo_physics
   /// \brief Base class for all geoms

Modified: code/gazebo/branches/dev/server/physics/Joint.cc
===================================================================
--- code/gazebo/branches/dev/server/physics/Joint.cc    2010-11-30 02:29:38 UTC 
(rev 8988)
+++ code/gazebo/branches/dev/server/physics/Joint.cc    2010-11-30 05:02:10 UTC 
(rev 8989)
@@ -43,7 +43,9 @@
   : Common(NULL)
 {
   this->AddType(JOINT);
-  this->visual = NULL;
+  this->visualMsg = NULL;
+  this->line1Msg = NULL;
+  this->line2Msg = NULL;
   this->model = NULL;
 
   Param::Begin(&this->parameters);
@@ -72,12 +74,30 @@
 {
   Events::DisconnectShowJointsSignal(boost::bind(&Joint::ToggleShowJoints, 
this));
 
-  if (this->visual)
+  if (this->visualMsg)
   {
-    delete this->visual;
-    this->visual = NULL;
+    this->visualMsg->action = VisualMsg::DELETE;
+    Simulator::Instance()->SendMessage(*this->visualMsg);
+    delete this->visualMsg;
+    this->visualMsg = NULL;
   }
 
+  if (this->line1Msg)
+  {
+    this->line1Msg->action = VisualMsg::DELETE;
+    Simulator::Instance()->SendMessage(*this->line1Msg);
+    delete this->line1Msg;
+    this->line1Msg = NULL;
+  }
+
+  if (this->line2Msg)
+  {
+    this->line2Msg->action = VisualMsg::DELETE;
+    Simulator::Instance()->SendMessage(*this->line2Msg);
+    delete this->line2Msg;
+    this->line2Msg = NULL;
+  }
+
   delete this->erpP;
   delete this->cfmP;
   delete this->stopKpP;
@@ -147,18 +167,23 @@
   this->visualMsg->mesh = "joint_anchor";
   this->visualMsg->material = "Gazebo/JointAnchor";
   this->visualMsg->visible = false;
+  
+  this->line1Msg = new VisualMsg();
+  this->line1Msg->parentId = this->visualMsg->id;
+  this->line1Msg->id = "line1";
+  this->line1Msg->type = VisualMsg::LINE_LIST;
+  this->line1Msg->material = "Gazebo/BlueGlow";
+  this->line1Msg->points.push_back(Vector3(0,0,0));
+  this->line1Msg->points.push_back(Vector3(0,0,0));
 
-  this->line1 = this->visual->AddDynamicLine(RENDERING_LINE_LIST);
-  this->line2 = this->visual->AddDynamicLine(RENDERING_LINE_LIST);
+  this->line2Msg = new VisualMsg();
+  this->line2Msg->parentId = this->visualMsg->id;
+  this->line2Msg->id = "line2";
+  this->line2Msg->type = VisualMsg::LINE_LIST;
+  this->line2Msg->material = "Gazebo/BlueGlow";
+  this->line2Msg->points.push_back(Vector3(0,0,0));
+  this->line2Msg->points.push_back(Vector3(0,0,0));
 
-  this->line1->setMaterial("Gazebo/BlueGlow");
-  this->line2->setMaterial("Gazebo/BlueGlow");
-
-  this->line1->AddPoint(Vector3(0,0,0));
-  this->line1->AddPoint(Vector3(0,0,0));
-  this->line2->AddPoint(Vector3(0,0,0));
-  this->line2->AddPoint(Vector3(0,0,0));
-
   // Set the anchor vector
   if (this->anchorBody)
   {
@@ -196,20 +221,24 @@
   this->jointUpdateSignal();
 
   //TODO: Evaluate impact of this code on performance
-  if (this->visual && this->visual->GetVisible())
+  if (this->visualMsg && this->visualMsg->visible)
   {
     if (this->GetName() == "left_paddle_joint")
       std::cout << "Joint[" << this->GetName() << "] Angle[" << 
this->GetAngle(0) << "]\n";
     this->anchorPos = (Pose3d(**(this->anchorOffsetP),Quatern()) + 
         this->anchorBody->GetWorldPose()).pos;
 
-    this->visual->SetPosition(this->anchorPos);
+    this->visualMsg->pose.pos = this->anchorPos;
 
     if (this->body1) 
-      this->line1->SetPoint(1, this->body1->GetWorldPose().pos - 
this->anchorPos);
+      this->line1Msg->points[1] = this->body1->GetWorldPose().pos - 
this->anchorPos;
 
     if (this->body2)
-      this->line2->SetPoint(1, this->body2->GetWorldPose().pos - 
this->anchorPos);
+      this->line2Msg->poinst[1] = this->body2->GetWorldPose().pos - 
this->anchorPos;
+
+    Simulator::Instance()->SendMessage( *this->visualMsg );
+    Simulator::Instance()->SendMessage( *this->line1Msg );
+    Simulator::Instance()->SendMessage( *this->line2Msg );
   }
 }
 
@@ -217,8 +246,11 @@
 // Toggle joint visibility
 void Joint::ToggleShowJoints()
 {
-  if (this->visual)
-    this->visual->ToggleVisible();
+  if (this->visualMsg)
+  {
+    this->visualMsg->visible = !this->visualMsg->visible;
+    Simulator::Instance()->SendMessage( *this->visualMsg );
+  }
 }
 
 //////////////////////////////////////////////////////////////////////////////
@@ -226,7 +258,10 @@
 void Joint::ShowJoints(bool s)
 {
   if (this->visual)
-    this->visual->SetVisible(s);
+  {
+    this->visualMsg->visible = s;
+    Simulator::Instance()->SendMessage( *this->visualMsg );
+  }
 }
 
 //////////////////////////////////////////////////////////////////////////////

Modified: code/gazebo/branches/dev/server/physics/Joint.hh
===================================================================
--- code/gazebo/branches/dev/server/physics/Joint.hh    2010-11-30 02:29:38 UTC 
(rev 8988)
+++ code/gazebo/branches/dev/server/physics/Joint.hh    2010-11-30 05:02:10 UTC 
(rev 8989)
@@ -43,6 +43,7 @@
   class XMLConfigNode;
   class Model;
   class OgreDynamicLines;
+  class VisualMsg;
 
   /// \brief Base class for all joints
   class Joint : public Common

Modified: code/gazebo/branches/dev/server/physics/PhysicsEngine.cc
===================================================================
--- code/gazebo/branches/dev/server/physics/PhysicsEngine.cc    2010-11-30 
02:29:38 UTC (rev 8988)
+++ code/gazebo/branches/dev/server/physics/PhysicsEngine.cc    2010-11-30 
05:02:10 UTC (rev 8989)
@@ -28,15 +28,12 @@
 
 #include "RenderTypes.hh"
 
+#include "Messages.hh"
 #include "GazeboError.hh"
 #include "GazeboMessage.hh"
 #include "RenderState.hh"
 #include "Events.hh"
 #include "World.hh"
-#include "Visual.hh"
-#include "OgreDynamicLines.hh"
-#include "OgreCreator.hh"
-#include "Material.hh"
 #include "Shape.hh"
 #include "PhysicsEngine.hh"
 #include "Simulator.hh"  // disable X
@@ -61,10 +58,17 @@
 
   if (Simulator::Instance()->GetRenderEngineEnabled())
   {
-    this->visual = new Visual("Physics_Engine_Visual", 
this->world->GetScene());
-    this->visual->SetVisible(false);
-    this->visual->SetCastShadows(false);
-    this->visual->SetUseRTShader(false);
+    this->visualMsg = new VisualMsg();
+    this->visualMsg->parentId.clear();
+    this->visualMsg->id = "physics_engine_visual";
+    this->visualMsg->visible = false;
+    this->visualMsg->rtShader = false;
+    this->visualMsg->castShadows = false;
+    this->visualMsg->action = VisualMsg::UPDATE;
+
+    Simulator::Instance()->SendMessage( *this->visualMsg );
+
+    /* NATY: put this back in
     this->contactLines.resize(5000);
 
     Material *mat = new Material();
@@ -99,11 +103,13 @@
       (*this->contactLinesIter)->AddPoint(Vector3(0,0,0));
       (*this->contactLinesIter)->setMaterial(matName);
     }
+    */
 
     Events::ConnectShowContactsSignal( 
boost::bind(&PhysicsEngine::ToggleShowVisual, this) );
 
-    this->contactLinesIter = this->contactLines.begin();
-    delete mat;
+    // NATY: put this back in
+    //this->contactLinesIter = this->contactLines.begin();
+    //delete mat;
   }
 
 }
@@ -114,10 +120,12 @@
 {
   Events::DisconnectShowContactsSignal( 
boost::bind(&PhysicsEngine::ToggleShowVisual, this) );
 
-  if (this->visual)
+  if (this->visualMsg)
   {
-    delete this->visual;
-    this->visual = NULL;
+    this->visualMsg->action = VisualMsg::DELETE;
+    Simulator::Instance()->SendMessage( *this->visualMsg );
+    delete this->visualMsg;
+    this->visualMsg = NULL;
   }
 
   delete this->gravityP;
@@ -229,21 +237,24 @@
 // Toggle whether to show contacts
 void PhysicsEngine::ToggleShowVisual()
 {
-  if (!Simulator::Instance()->GetRenderEngineEnabled())
-    return;
-  this->visual->ToggleVisible();
-  this->contactLinesIter = this->contactLines.begin();
+  this->visualMsg->visible = !this->visualMsg->visible;
+  Simulator::Instance()->SendMessage(*this->visualMsg);
+
+  // NATY: put back in
+  //this->contactLinesIter = this->contactLines.begin();
 }
 
 
////////////////////////////////////////////////////////////////////////////////
 // Set whether to show contacts
 void PhysicsEngine::ShowVisual(bool show)
 {
-  if (!Simulator::Instance()->GetRenderEngineEnabled())
-    return;
-  this->visual->SetVisible(show);
+  this->visualMsg->visual = show;
+  Simulator::Instance()->SendMessage(*this->visualMsg);
+
+  /* NATY put back in
   if (show)
     this->contactLinesIter = this->contactLines.begin();
+    */
 }
 
 
////////////////////////////////////////////////////////////////////////////////

Modified: code/gazebo/branches/dev/server/physics/PhysicsEngine.hh
===================================================================
--- code/gazebo/branches/dev/server/physics/PhysicsEngine.hh    2010-11-30 
02:29:38 UTC (rev 8988)
+++ code/gazebo/branches/dev/server/physics/PhysicsEngine.hh    2010-11-30 
05:02:10 UTC (rev 8989)
@@ -44,7 +44,7 @@
   class Entity;
   class Body;
   class XMLConfigNode;
-  class Visual;
+  class VisualMsg;
   
   /// \addtogroup gazebo_physics_engine
   /** \{
@@ -237,7 +237,7 @@
     private: boost::recursive_mutex *mutex;
     private: bool locked;
 
-    protected: Visual *visual;
+    protected: VisualMsg *visualMsg;
 
     private: std::vector<OgreDynamicLines*> contactLines;
     private: std::vector<OgreDynamicLines*>::iterator contactLinesIter;


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