Revision: 7494
http://playerstage.svn.sourceforge.net/playerstage/?rev=7494&view=rev
Author: hsujohnhsu
Date: 2009-03-17 00:39:47 +0000 (Tue, 17 Mar 2009)
Log Message:
-----------
Update to support headless mode when renderEngineEnabled flag is set.
Modified Paths:
--------------
code/gazebo/branches/ogre-1.4.9/server/physics/Geom.cc
Modified: code/gazebo/branches/ogre-1.4.9/server/physics/Geom.cc
===================================================================
--- code/gazebo/branches/ogre-1.4.9/server/physics/Geom.cc 2009-03-17
00:34:59 UTC (rev 7493)
+++ code/gazebo/branches/ogre-1.4.9/server/physics/Geom.cc 2009-03-17
00:39:47 UTC (rev 7494)
@@ -33,6 +33,7 @@
#include "World.hh"
#include "Body.hh"
#include "Geom.hh"
+#include "Simulator.hh"
using namespace gazebo;
@@ -88,11 +89,14 @@
if (this->transId)
dGeomDestroy(this->transId);
- for (iter = this->visuals.begin(); iter != this->visuals.end(); iter++)
+ if (Simulator::Instance()->GetRenderEngineEnabled())
{
- GZ_DELETE (*iter)
+ for (iter = this->visuals.begin(); iter != this->visuals.end(); iter++)
+ {
+ GZ_DELETE (*iter)
+ }
+ this->visuals.clear();
}
- this->visuals.clear();
delete this->massP;
delete this->xyzP;
@@ -112,6 +116,8 @@
this->typeName = node->GetName();
this->nameP->Load(node);
+ this->SetName(this->nameP->GetValue());
+ this->nameP->Load(node);
this->massP->Load(node);
this->xyzP->Load(node);
this->rpyP->Load(node);
@@ -136,13 +142,17 @@
// TODO: This should probably be true....but "true" breaks trimesh postions.
this->SetPose(pose, true);
- childNode = node->GetChild("visual");
- while (childNode)
+
+ if (Simulator::Instance()->GetRenderEngineEnabled())
{
- OgreVisual *visual = new OgreVisual(this->visualNode, this);
- visual->Load(childNode);
- this->visuals.push_back(visual);
- childNode = childNode->GetNext("visual");
+ childNode = node->GetChild("visual");
+ while (childNode)
+ {
+ OgreVisual *visual = new OgreVisual(this->visualNode, this);
+ visual->Load(childNode);
+ this->visuals.push_back(visual);
+ childNode = childNode->GetNext("visual");
+ }
}
/*if (this->IsStatic())
@@ -159,8 +169,16 @@
Vector3 min(aabb[0], aabb[2], aabb[4]);
Vector3 max(aabb[1], aabb[3], aabb[5]);
- this->bbVisual = new OgreVisual(this->visualNode);
- this->bbVisual->AttachBoundingBox(min,max);
+ if (Simulator::Instance()->GetRenderEngineEnabled())
+ {
+ this->bbVisual = new OgreVisual(this->visualNode);
+ this->bbVisual->AttachBoundingBox(min,max);
+
+ // rotation is not set for bounding box
+ Pose3d localPose;
+ localPose.rot = pose.rot;
+ this->bbVisual->SetPose(localPose);
+ }
}
if (this->geomId && dGeomGetClass(this->geomId) != dPlaneClass &&
@@ -200,10 +218,11 @@
stream << prefix << " " << *(this->laserFiducialIdP) << "\n";
stream << prefix << " " << *(this->laserRetroP) << "\n";
- for (iter = this->visuals.begin(); iter != this->visuals.end(); iter++)
- {
- (*iter)->Save(p, stream);
- }
+ if (Simulator::Instance()->GetRenderEngineEnabled())
+ for (iter = this->visuals.begin(); iter != this->visuals.end(); iter++)
+ {
+ (*iter)->Save(p, stream);
+ }
stream << prefix << "</geom:" << this->typeName << ">\n";
}
@@ -307,11 +326,15 @@
dGeomSetPosition(this->geomId, localPose.pos.x, localPose.pos.y,
localPose.pos.z);
dGeomSetQuaternion(this->geomId, q);
- this->visualNode->SetPose(pose);
+ if (Simulator::Instance()->GetRenderEngineEnabled())
+ {
+ this->visualNode->SetPose(pose);
+ }
if (updateCoM)
{
this->body->UpdateCoM();
+ std::cout << " in SetPose, after UpdateCoM() GetCoMPose returns: " <<
this->body->GetCoMPose() << std::endl;
}
}
}
@@ -396,23 +419,24 @@
Pose3d pose;
dQuaternion q;
dMatrix3 r;
- dMass bodyMass;
if (!this->placeable)
return NULL;
- pose = this->GetPose();
+ pose = this->GetPose(); // get pose of the geometry
q[0] = pose.rot.u;
q[1] = pose.rot.x;
q[2] = pose.rot.y;
q[3] = pose.rot.z;
- dQtoR(q,r);
+ dQtoR(q,r); // turn quaternion into rotation matrix
-
+ // this->mass was init to zero at start,
+ // read user specified mass into this->dblMass and dMassAdd in this->mass
this->bodyMass = this->mass;
+
if (dMassCheck(&this->bodyMass))
{
dMassRotate(&this->bodyMass, r);
@@ -454,8 +478,9 @@
/// Set the visibility of the Bounding box of this geometry
void Geom::ShowBoundingBox(bool show)
{
- if (this->bbVisual)
- this->bbVisual->SetVisible(show);
+ if (Simulator::Instance()->GetRenderEngineEnabled())
+ if (this->bbVisual)
+ this->bbVisual->SetVisible(show);
}
// FIXME: ShowJoints and ShowPhysics will mess with each other and with the
user's defined transparency visibility
@@ -465,20 +490,15 @@
{
std::vector<OgreVisual*>::iterator iter;
- if (show)
- {
- for (iter = this->visuals.begin(); iter != this->visuals.end(); iter++)
+ if (Simulator::Instance()->GetRenderEngineEnabled())
+ if (show)
{
this->SetTransparency(0.6);
}
- }
- else
- {
- for (iter = this->visuals.begin(); iter != this->visuals.end(); iter++)
+ else
{
this->SetTransparency(0.0);
}
- }
}
////////////////////////////////////////////////////////////////////////////////
@@ -490,10 +510,8 @@
if (Simulator::Instance()->GetRenderEngineEnabled())
for (iter = this->visuals.begin(); iter != this->visuals.end(); iter++)
{
- (*iter)->SetTransparency(0.0);
(*iter)->SetTransparency(t);
}
- }
}
////////////////////////////////////////////////////////////////////////////////
@@ -502,26 +520,27 @@
{
std::vector<OgreVisual*>::iterator iter;
- if (show)
- {
- for (iter = this->visuals.begin(); iter != this->visuals.end(); iter++)
+ if (Simulator::Instance()->GetRenderEngineEnabled())
+ if (show)
{
- (*iter)->SetVisible(false, false);
+ for (iter = this->visuals.begin(); iter != this->visuals.end(); iter++)
+ {
+ (*iter)->SetVisible(false, false);
+ }
+ /*this->visualNode->SetVisible(true, false);
+ this->visualNode->SetTransparency(0.6);
+ */
}
- /*this->visualNode->SetVisible(true, false);
- this->visualNode->SetTransparency(0.6);
- */
- }
- else
- {
- for (iter = this->visuals.begin(); iter != this->visuals.end(); iter++)
+ else
{
- (*iter)->SetVisible(true, false);
+ for (iter = this->visuals.begin(); iter != this->visuals.end(); iter++)
+ {
+ (*iter)->SetVisible(true, false);
+ }
+ /*this->visualNode->SetVisible(false, false);
+ this->visualNode->SetTransparency(1.0);
+ */
}
- /*this->visualNode->SetVisible(false, false);
- this->visualNode->SetTransparency(1.0);
- */
- }
}
////////////////////////////////////////////////////////////////////////////////
@@ -536,15 +555,21 @@
/// Get the number of visuals
unsigned int Geom::GetVisualCount() const
{
- return this->visuals.size();
+ if (Simulator::Instance()->GetRenderEngineEnabled())
+ return this->visuals.size();
+ else
+ return 0;
}
////////////////////////////////////////////////////////////////////////////////
/// Get a visual
OgreVisual *Geom::GetVisual(unsigned int index) const
{
- if (index < this->visuals.size())
+ if (Simulator::Instance()->GetRenderEngineEnabled() &&
+ index < this->visuals.size())
return this->visuals[index];
+ else
+ return NULL;
}
////////////////////////////////////////////////////////////////////////////////
@@ -553,11 +578,12 @@
{
std::vector<OgreVisual*>::const_iterator iter;
- for (iter = this->visuals.begin(); iter != this->visuals.end(); iter++)
- {
- if ( (*iter)->GetId() == id)
- return *iter;
- }
+ if (Simulator::Instance()->GetRenderEngineEnabled())
+ for (iter = this->visuals.begin(); iter != this->visuals.end(); iter++)
+ {
+ if ( (*iter)->GetId() == id)
+ return *iter;
+ }
return NULL;
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit