Revision: 8977
http://playerstage.svn.sourceforge.net/playerstage/?rev=8977&view=rev
Author: natepak
Date: 2010-11-25 01:09:22 +0000 (Thu, 25 Nov 2010)
Log Message:
-----------
Lots of changes to Visuals
Modified Paths:
--------------
code/gazebo/branches/dev/server/Entity.cc
code/gazebo/branches/dev/server/GraphicsIfaceHandler.cc
code/gazebo/branches/dev/server/physics/Body.cc
code/gazebo/branches/dev/server/physics/Geom.cc
code/gazebo/branches/dev/server/physics/Joint.cc
code/gazebo/branches/dev/server/physics/MultiRayShape.cc
code/gazebo/branches/dev/server/physics/PhysicsEngine.cc
code/gazebo/branches/dev/server/physics/RayShape.cc
code/gazebo/branches/dev/server/rendering/CMakeLists.txt
code/gazebo/branches/dev/server/rendering/Light.cc
code/gazebo/branches/dev/server/rendering/OgreAdaptor.cc
code/gazebo/branches/dev/server/rendering/OgreAdaptor.hh
code/gazebo/branches/dev/server/rendering/OgreDynamicLines.hh
code/gazebo/branches/dev/server/rendering/OgreDynamicRenderable.cc
code/gazebo/branches/dev/server/rendering/OgreDynamicRenderable.hh
code/gazebo/branches/dev/server/rendering/OrbitViewController.cc
code/gazebo/branches/dev/server/rendering/RTShaderSystem.cc
code/gazebo/branches/dev/server/rendering/Scene.cc
code/gazebo/branches/dev/server/rendering/Scene.hh
code/gazebo/branches/dev/server/rendering/UserCamera.cc
code/gazebo/branches/dev/server/rendering/Visual.cc
code/gazebo/branches/dev/server/rendering/Visual.hh
code/gazebo/branches/dev/server/wx/BoxMaker.cc
code/gazebo/branches/dev/server/wx/BoxMaker.hh
code/gazebo/branches/dev/server/wx/CylinderMaker.cc
code/gazebo/branches/dev/server/wx/CylinderMaker.hh
code/gazebo/branches/dev/server/wx/PointLightMaker.cc
code/gazebo/branches/dev/server/wx/PointLightMaker.hh
code/gazebo/branches/dev/server/wx/SphereMaker.cc
code/gazebo/branches/dev/server/wx/SphereMaker.hh
Modified: code/gazebo/branches/dev/server/Entity.cc
===================================================================
--- code/gazebo/branches/dev/server/Entity.cc 2010-11-24 03:27:30 UTC (rev
8976)
+++ code/gazebo/branches/dev/server/Entity.cc 2010-11-25 01:09:22 UTC (rev
8977)
@@ -57,18 +57,16 @@
{
Entity *ep = (Entity*)(this->parent);
if (Simulator::Instance()->GetRenderEngineEnabled())
- this->visualNode = new Visual(ep);
+ this->visualNode = new Visual(visname.str(), ep);
this->SetStatic(ep->IsStatic());
}
else
{
if (Simulator::Instance()->GetRenderEngineEnabled())
- this->visualNode = new Visual(this);
+ this->visualNode = new Visual(visname.str(), this);
}
this->visualNode->SetOwner(this);
- this->visualNode->SetName(visname.str());
- this->visualNode->Init();
}
void Entity::SetName(const std::string &name)
Modified: code/gazebo/branches/dev/server/GraphicsIfaceHandler.cc
===================================================================
--- code/gazebo/branches/dev/server/GraphicsIfaceHandler.cc 2010-11-24
03:27:30 UTC (rev 8976)
+++ code/gazebo/branches/dev/server/GraphicsIfaceHandler.cc 2010-11-25
01:09:22 UTC (rev 8977)
@@ -26,6 +26,7 @@
#include <stdint.h>
+#include "RenderTypes.hh"
#include "Scene.hh"
#include "World.hh"
#include "Entity.hh"
@@ -59,6 +60,11 @@
delete this->threeDIface;
this->threeDIface = NULL;
}
+
+ std::map<std::string, Visual* >::iterator iter;
+ for (iter = this->visuals.begin(); iter != this->visuals.end(); iter++)
+ delete iter->second;
+ this->visuals.clear();
}
////////////////////////////////////////////////////////////////////////////////
@@ -111,11 +117,7 @@
nodeName << "GraphicsIfaceHandler_" << this->name << ": "
<< this->visuals.size();
- if (this->parent)
- vis = OgreCreator::Instance()->CreateVisual(nodeName.str(),
- this->parent->GetVisualNode());
- else
- vis = OgreCreator::Instance()->CreateVisual(nodeName.str());
+ vis = new Visual(nodeName.str(), this->parent);
this->visuals[visName] = vis;
}
@@ -167,28 +169,28 @@
{
Vector3 pos;
bool attached = false;
- OgreDynamicRenderable::OperationType opType;
+ OperationType opType;
OgreDynamicLines *line;
switch(data->drawMode)
{
case libgazebo::Graphics3dDrawData::POINTS:
- opType = OgreDynamicRenderable::OT_POINT_LIST;
+ opType = RENDERING_POINT_LIST;
break;
case libgazebo::Graphics3dDrawData::LINES:
- opType = OgreDynamicRenderable::OT_LINE_LIST;
+ opType = RENDERING_LINE_LIST;
break;
case libgazebo::Graphics3dDrawData::LINE_STRIP:
- opType = OgreDynamicRenderable::OT_LINE_STRIP;
+ opType = RENDERING_LINE_STRIP;
break;
case libgazebo::Graphics3dDrawData::TRIANGLES:
- opType = OgreDynamicRenderable::OT_TRIANGLE_LIST;
+ opType = RENDERING_TRIANGLE_LIST;
break;
case libgazebo::Graphics3dDrawData::TRIANGLE_STRIP:
- opType = OgreDynamicRenderable::OT_TRIANGLE_STRIP;
+ opType = RENDERING_TRIANGLE_STRIP;
break;
case libgazebo::Graphics3dDrawData::TRIANGLE_FAN:
- opType = OgreDynamicRenderable::OT_TRIANGLE_FAN;
+ opType = RENDERING_TRIANGLE_FAN;
break;
default:
gzerr(0) << "Unknown draw operation mode["
@@ -203,7 +205,9 @@
attached = true;
}
else
+ {
line = vis->AddDynamicLine(opType);
+ }
line->setMaterial(OgreCreator::CreateMaterial( data->color.r,
data->color.g,
Modified: code/gazebo/branches/dev/server/physics/Body.cc
===================================================================
--- code/gazebo/branches/dev/server/physics/Body.cc 2010-11-24 03:27:30 UTC
(rev 8976)
+++ code/gazebo/branches/dev/server/physics/Body.cc 2010-11-25 01:09:22 UTC
(rev 8977)
@@ -27,6 +27,7 @@
#include <sstream>
#include <float.h>
+#include "RenderTypes.hh"
#include "Events.hh"
#include "SensorManager.hh"
#include "XMLConfig.hh"
@@ -379,9 +380,7 @@
if (this->cgVisual == NULL)
{
- this->cgVisual = new Visual(this->comEntity);
- this->cgVisual->SetName(visname.str());
- this->cgVisual->Init();
+ this->cgVisual = new Visual(visname.str(), this->comEntity);
}
else
this->cgVisual->DetachObjects();
@@ -398,7 +397,7 @@
// Create a line to each geom
for (giter = this->geoms.begin(); giter != this->geoms.end(); giter++)
{
- OgreDynamicLines *line =
this->cgVisual->AddDynamicLine(OgreDynamicRenderable::OT_LINE_LIST);
+ OgreDynamicLines *line =
this->cgVisual->AddDynamicLine(RENDERING_LINE_LIST);
line->setMaterial("Gazebo/GreenGlow");
line->AddPoint(Vector3(0,0,0));
line->AddPoint(giter->second->GetRelativePose().pos);
Modified: code/gazebo/branches/dev/server/physics/Geom.cc
===================================================================
--- code/gazebo/branches/dev/server/physics/Geom.cc 2010-11-24 03:27:30 UTC
(rev 8976)
+++ code/gazebo/branches/dev/server/physics/Geom.cc 2010-11-25 01:09:22 UTC
(rev 8977)
@@ -169,12 +169,10 @@
{
std::ostringstream visname;
visname << this->GetCompleteScopedName() << "_VISUAL_" <<
this->visuals.size();
- Visual *visual = new Visual(this->visualNode);
+ Visual *visual = new Visual(visname.str(), this->visualNode);
visual->Load(childNode);
- visual->SetName(visname.str());
visual->SetIgnorePoseUpdates(true);
visual->SetOwner(this);
- visual->Init();
visual->SetCastShadows(true);
this->visuals.push_back(visual);
@@ -198,9 +196,7 @@
std::ostringstream visname;
visname << this->GetCompleteScopedName() << "_BBVISUAL" ;
- this->bbVisual = new Visual(this->visualNode);
- this->bbVisual->SetName(visname.str());
- this->bbVisual->Init();
+ this->bbVisual = new Visual(visname.str(), this->visualNode);
this->bbVisual->SetCastShadows(false);
this->bbVisual->AttachBoundingBox(min,max);
this->bbVisual->SetVisible( RenderState::GetShowBoundingBoxes() );
Modified: code/gazebo/branches/dev/server/physics/Joint.cc
===================================================================
--- code/gazebo/branches/dev/server/physics/Joint.cc 2010-11-24 03:27:30 UTC
(rev 8976)
+++ code/gazebo/branches/dev/server/physics/Joint.cc 2010-11-25 01:09:22 UTC
(rev 8977)
@@ -24,6 +24,7 @@
* CVS: $Id$
*/
+#include "RenderTypes.hh"
#include "Events.hh"
#include "PhysicsEngine.hh"
#include "Visual.hh"
@@ -139,17 +140,15 @@
this->Attach(this->body1, this->body2);
/// Add a renderable for the joint
- this->visual = new Visual(this);
- this->visual->SetName(visname.str());
- this->visual->Init();
+ 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->line1 =
this->visual->AddDynamicLine(OgreDynamicRenderable::OT_LINE_LIST);
- this->line2 =
this->visual->AddDynamicLine(OgreDynamicRenderable::OT_LINE_LIST);
+ this->line1 = this->visual->AddDynamicLine(RENDERING_LINE_LIST);
+ this->line2 = this->visual->AddDynamicLine(RENDERING_LINE_LIST);
this->line1->setMaterial("Gazebo/BlueGlow");
this->line2->setMaterial("Gazebo/BlueGlow");
Modified: code/gazebo/branches/dev/server/physics/MultiRayShape.cc
===================================================================
--- code/gazebo/branches/dev/server/physics/MultiRayShape.cc 2010-11-24
03:27:30 UTC (rev 8976)
+++ code/gazebo/branches/dev/server/physics/MultiRayShape.cc 2010-11-25
01:09:22 UTC (rev 8977)
@@ -1,3 +1,4 @@
+#include "RenderTypes.hh"
#include "XMLConfig.hh"
#include "MultiRayShape.hh"
@@ -10,10 +11,10 @@
this->AddType(MULTIRAY_SHAPE);
this->rayFan = this->geomParent->GetVisualNode()->AddDynamicLine(
- OgreDynamicRenderable::OT_TRIANGLE_FAN);
+ RENDERING_TRIANGLE_FAN);
this->rayFanOutline = this->geomParent->GetVisualNode()->AddDynamicLine(
- OgreDynamicRenderable::OT_LINE_STRIP);
+ RENDERING_LINE_STRIP);
this->rayFan->setMaterial("Gazebo/BlueLaser");
this->rayFanOutline->setMaterial("Gazebo/BlueGlow");
Modified: code/gazebo/branches/dev/server/physics/PhysicsEngine.cc
===================================================================
--- code/gazebo/branches/dev/server/physics/PhysicsEngine.cc 2010-11-24
03:27:30 UTC (rev 8976)
+++ code/gazebo/branches/dev/server/physics/PhysicsEngine.cc 2010-11-25
01:09:22 UTC (rev 8977)
@@ -26,6 +26,8 @@
#include <boost/thread/recursive_mutex.hpp>
+#include "RenderTypes.hh"
+
#include "GazeboError.hh"
#include "GazeboMessage.hh"
#include "RenderState.hh"
@@ -59,8 +61,7 @@
if (Simulator::Instance()->GetRenderEngineEnabled())
{
- this->visual = new Visual(NULL); //this->world->GetScene();
- this->visual->SetName("Physics_Engine_Visual");
+ this->visual = new Visual("Physics_Engine_Visual",
this->world->GetScene());
this->visual->SetVisible(false);
this->visual->SetCastShadows(false);
this->visual->SetUseRTShader(false);
@@ -79,8 +80,7 @@
this->contactLinesIter != this->contactLines.end();
this->contactLinesIter++, i++)
{
- (*this->contactLinesIter) = this->visual->AddDynamicLine(
- OgreDynamicRenderable::OT_LINE_LIST);
+ (*this->contactLinesIter) =
this->visual->AddDynamicLine(RENDERING_LINE_LIST);
(*this->contactLinesIter)->AddPoint(Vector3(0,0,0));
(*this->contactLinesIter)->AddPoint(Vector3(0,0,0));
(*this->contactLinesIter)->AddPoint(Vector3(0,0,0));
Modified: code/gazebo/branches/dev/server/physics/RayShape.cc
===================================================================
--- code/gazebo/branches/dev/server/physics/RayShape.cc 2010-11-24 03:27:30 UTC
(rev 8976)
+++ code/gazebo/branches/dev/server/physics/RayShape.cc 2010-11-25 01:09:22 UTC
(rev 8977)
@@ -24,6 +24,7 @@
* SVN: $Id:$
*/
+#include "RenderTypes.hh"
#include "RayShape.hh"
using namespace gazebo;
@@ -37,8 +38,7 @@
if (displayRays && Simulator::Instance()->GetRenderEngineEnabled() )
{
- this->line = this->geomParent->GetVisualNode()->AddDynamicLine(
- OgreDynamicRenderable::OT_LINE_LIST);
+ this->line =
this->geomParent->GetVisualNode()->AddDynamicLine(RENDERING_LINE_LIST);
// Add two points
this->line->AddPoint(Vector3(0,0,0));
Modified: code/gazebo/branches/dev/server/rendering/CMakeLists.txt
===================================================================
--- code/gazebo/branches/dev/server/rendering/CMakeLists.txt 2010-11-24
03:27:30 UTC (rev 8976)
+++ code/gazebo/branches/dev/server/rendering/CMakeLists.txt 2010-11-25
01:09:22 UTC (rev 8977)
@@ -53,6 +53,7 @@
Scene.hh
RenderState.hh
WindowManager.hh
+ RenderTypes.hh
)
add_library(gazebo_rendering SHARED ${sources})
Modified: code/gazebo/branches/dev/server/rendering/Light.cc
===================================================================
--- code/gazebo/branches/dev/server/rendering/Light.cc 2010-11-24 03:27:30 UTC
(rev 8976)
+++ code/gazebo/branches/dev/server/rendering/Light.cc 2010-11-25 01:09:22 UTC
(rev 8977)
@@ -207,8 +207,7 @@
return;
// The lines draw a visualization of the camera
- this->line = this->visualNode->AddDynamicLine(
- OgreDynamicRenderable::OT_LINE_LIST);
+ this->line = this->visualNode->AddDynamicLine( RENDERING_LINE_LIST );
if ( **this->lightTypeP == "point" )
{
Modified: code/gazebo/branches/dev/server/rendering/OgreAdaptor.cc
===================================================================
--- code/gazebo/branches/dev/server/rendering/OgreAdaptor.cc 2010-11-24
03:27:30 UTC (rev 8976)
+++ code/gazebo/branches/dev/server/rendering/OgreAdaptor.cc 2010-11-25
01:09:22 UTC (rev 8977)
@@ -23,18 +23,22 @@
* Date: 13 Feb 2006
* CVS: $Id$
*/
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <GL/glx.h>
+
#include <stdint.h>
+#include <sys/types.h>
+#include <dirent.h>
+#include <iostream>
+#include <string.h>
#include <Ogre.h>
#include <OgreDataStream.h>
#include <OgreLogManager.h>
#include <OgreWindowEventUtilities.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <iostream>
-#include <string.h>
-
#include "gazebo_config.h"
#include "WindowManager.hh"
@@ -78,9 +82,10 @@
{
if (this->dummyDisplay)
{
- glXDestroyContext(this->dummyDisplay, this->dummyContext);
- XDestroyWindow(this->dummyDisplay, this->dummyWindowId);
- XCloseDisplay(this->dummyDisplay);
+ glXDestroyContext((Display*)this->dummyDisplay,
+ (GLXContext)this->dummyContext);
+ XDestroyWindow((Display*)this->dummyDisplay, this->dummyWindowId);
+ XCloseDisplay((Display*)this->dummyDisplay);
}
}
@@ -225,16 +230,17 @@
int attribList[] = {GLX_RGBA, GLX_DOUBLEBUFFER, GLX_DEPTH_SIZE, 16,
GLX_STENCIL_SIZE, 8, None };
- this->dummyVisual = glXChooseVisual(this->dummyDisplay, screen,
- (int *)attribList);
+ XVisualInfo *dummyVisual = glXChooseVisual((Display*)this->dummyDisplay,
+ screen, (int *)attribList);
- this->dummyWindowId = XCreateSimpleWindow(this->dummyDisplay,
- RootWindow(this->dummyDisplay, screen), 0, 0, 1, 1, 0, 0, 0);
+ this->dummyWindowId = XCreateSimpleWindow((Display*)this->dummyDisplay,
+ RootWindow((Display*)this->dummyDisplay, screen), 0, 0, 1, 1, 0, 0, 0);
- this->dummyContext = glXCreateContext(this->dummyDisplay,
- this->dummyVisual, NULL, 1);
+ this->dummyContext = glXCreateContext((Display*)this->dummyDisplay,
+ dummyVisual, NULL, 1);
- glXMakeCurrent(this->dummyDisplay, this->dummyWindowId,
this->dummyContext);
+ glXMakeCurrent((Display*)this->dummyDisplay,
+ this->dummyWindowId, (GLXContext)this->dummyContext);
std::stringstream stream;
stream << (int32_t)this->dummyWindowId;
Modified: code/gazebo/branches/dev/server/rendering/OgreAdaptor.hh
===================================================================
--- code/gazebo/branches/dev/server/rendering/OgreAdaptor.hh 2010-11-24
03:27:30 UTC (rev 8976)
+++ code/gazebo/branches/dev/server/rendering/OgreAdaptor.hh 2010-11-25
01:09:22 UTC (rev 8977)
@@ -21,19 +21,11 @@
/* Desc: Middleman between OGRE and Gazebo
* Author: Nate Koenig
* Date: 13 Feb 2006
- * SVN: $Id$
*/
#ifndef OGREADAPTOR
#define OGREADAPTOR
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <GL/glx.h>
-
-#include "Vector4.hh"
-#include "Param.hh"
-#include "Vector2.hh"
#include "SingletonT.hh"
namespace Ogre
@@ -132,16 +124,13 @@
private: Ogre::LogManager *logManager;
/// ID for a dummy window. Used for gui-less operation
- protected: Window dummyWindowId;
+ protected: unsigned long dummyWindowId;
- /// Pointer to the dummy Xvisual.Used for gui-less operation
- protected: XVisualInfo *dummyVisual;
-
/// Pointer to the dummy display.Used for gui-less operation
- protected: Display *dummyDisplay;
+ protected: void *dummyDisplay;
/// GLX context used to render the scenes.Used for gui-less operation
- protected: GLXContext dummyContext;
+ protected: void* dummyContext;
private: friend class DestroyerT<OgreAdaptor>;
private: friend class SingletonT<OgreAdaptor>;
Modified: code/gazebo/branches/dev/server/rendering/OgreDynamicLines.hh
===================================================================
--- code/gazebo/branches/dev/server/rendering/OgreDynamicLines.hh
2010-11-24 03:27:30 UTC (rev 8976)
+++ code/gazebo/branches/dev/server/rendering/OgreDynamicLines.hh
2010-11-25 01:09:22 UTC (rev 8977)
@@ -42,7 +42,7 @@
class OgreDynamicLines : public OgreDynamicRenderable
{
/// Constructor
- public: OgreDynamicLines(OperationType opType=OT_LINE_STRIP);
+ public: OgreDynamicLines(OperationType opType=RENDERING_LINE_STRIP);
/// Destructor
public: virtual ~OgreDynamicLines();
Modified: code/gazebo/branches/dev/server/rendering/OgreDynamicRenderable.cc
===================================================================
--- code/gazebo/branches/dev/server/rendering/OgreDynamicRenderable.cc
2010-11-24 03:27:30 UTC (rev 8976)
+++ code/gazebo/branches/dev/server/rendering/OgreDynamicRenderable.cc
2010-11-25 01:09:22 UTC (rev 8977)
@@ -46,27 +46,27 @@
{
switch (opType)
{
- case OT_POINT_LIST:
+ case RENDERING_POINT_LIST:
this->mRenderOp.operationType = Ogre::RenderOperation::OT_POINT_LIST;
break;
- case OT_LINE_LIST:
+ case RENDERING_LINE_LIST:
this->mRenderOp.operationType = Ogre::RenderOperation::OT_LINE_LIST;
break;
- case OT_LINE_STRIP:
+ case RENDERING_LINE_STRIP:
this->mRenderOp.operationType = Ogre::RenderOperation::OT_LINE_STRIP;
break;
- case OT_TRIANGLE_LIST:
+ case RENDERING_TRIANGLE_LIST:
this->mRenderOp.operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST;
break;
- case OT_TRIANGLE_STRIP:
+ case RENDERING_TRIANGLE_STRIP:
this->mRenderOp.operationType = Ogre::RenderOperation::OT_TRIANGLE_STRIP;
break;
- case OT_TRIANGLE_FAN:
+ case RENDERING_TRIANGLE_FAN:
this->mRenderOp.operationType = Ogre::RenderOperation::OT_TRIANGLE_FAN;
break;
}
@@ -74,29 +74,37 @@
////////////////////////////////////////////////////////////////////////////////
// Get the render operation type
-OgreDynamicRenderable::OperationType OgreDynamicRenderable::GetOperationType()
const
+OperationType OgreDynamicRenderable::GetOperationType() const
{
- OperationType type = OT_POINT_LIST;
+ OperationType type;
switch (this->mRenderOp.operationType)
{
- case Ogre::RenderOperation::OT_POINT_LIST:
- type = OT_POINT_LIST;
-
case Ogre::RenderOperation::OT_LINE_LIST:
- type = OT_LINE_LIST;
+ type = RENDERING_LINE_LIST;
+ break;
case Ogre::RenderOperation::OT_LINE_STRIP:
- type = OT_LINE_STRIP;
+ type = RENDERING_LINE_STRIP;
+ break;
case Ogre::RenderOperation::OT_TRIANGLE_LIST:
- type = OT_TRIANGLE_LIST;
+ type = RENDERING_TRIANGLE_LIST;
+ break;
case Ogre::RenderOperation::OT_TRIANGLE_STRIP:
- type = OT_TRIANGLE_STRIP;
+ type = RENDERING_TRIANGLE_STRIP;
+ break;
case Ogre::RenderOperation::OT_TRIANGLE_FAN:
- type = OT_TRIANGLE_FAN;
+ type = RENDERING_TRIANGLE_FAN;
+ break;
+
+ default:
+ case Ogre::RenderOperation::OT_POINT_LIST:
+ type = RENDERING_POINT_LIST;
+ break;
}
+
return type;
}
Modified: code/gazebo/branches/dev/server/rendering/OgreDynamicRenderable.hh
===================================================================
--- code/gazebo/branches/dev/server/rendering/OgreDynamicRenderable.hh
2010-11-24 03:27:30 UTC (rev 8976)
+++ code/gazebo/branches/dev/server/rendering/OgreDynamicRenderable.hh
2010-11-25 01:09:22 UTC (rev 8977)
@@ -3,6 +3,8 @@
#include <OgreSimpleRenderable.h>
+#include "RenderTypes.hh"
+
namespace gazebo
{
@@ -12,27 +14,6 @@
/// \brief Abstract base class providing mechanisms for dynamically growing
hardware buffers.
class OgreDynamicRenderable : public Ogre::SimpleRenderable
{
- public: enum OperationType
- {
- /// A list of points, 1 vertex per point
- OT_POINT_LIST = 0,//Ogre::RenderOperation::OT_POINT_LIST,
-
- /// A list of lines, 2 vertices per line
- OT_LINE_LIST = 1,//Ogre::RenderOperation::OT_LINE_LIST,
-
- /// A strip of connected lines, 1 vertex per line plus 1 start vertex
- OT_LINE_STRIP = 2,//Ogre::RenderOperation::OT_LINE_STRIP,
-
- /// A list of triangles, 3 vertices per triangle
- OT_TRIANGLE_LIST = 3,//Ogre::RenderOperation::OT_TRIANGLE_LIST,
-
- /// A strip of triangles, 3 vertices for the first triangle, and 1 per
triangle after that
- OT_TRIANGLE_STRIP = 4,//Ogre::RenderOperation::OT_TRIANGLE_STRIP,
-
- /// A fan of triangles, 3 vertices for the first triangle, and 1 per
triangle after that
- OT_TRIANGLE_FAN = 5,//Ogre::RenderOperation::OT_TRIANGLE_FAN
- };
-
/// \brief Constructor
public: OgreDynamicRenderable();
@@ -46,13 +27,13 @@
/// \param operationType The type of render operation to perform.
/// \param useIndices Specifies whether to use indices to determine the
/// vertices to use as input.
- public: void Init(OperationType operationType, bool useIndices);
+ public: void Init(OperationType operationType, bool useIndices=false);
/// \brief Set the render operation type
public: void SetOperationType(OperationType opType);
/// \brief Get the render operation type
- public: OgreDynamicRenderable::OperationType GetOperationType() const;
+ public: OperationType GetOperationType() const;
/// \brief Implementation of Ogre::SimpleRenderable
public: virtual Ogre::Real getBoundingRadius(void) const;
Modified: code/gazebo/branches/dev/server/rendering/OrbitViewController.cc
===================================================================
--- code/gazebo/branches/dev/server/rendering/OrbitViewController.cc
2010-11-24 03:27:30 UTC (rev 8976)
+++ code/gazebo/branches/dev/server/rendering/OrbitViewController.cc
2010-11-25 01:09:22 UTC (rev 8977)
@@ -22,7 +22,7 @@
this->focalPoint.Set(0,0,0);
this->distance = this->camera->GetWorldPosition().Distance(this->focalPoint);
- this->refVisual = new Visual(this->camera->GetScene());
+ this->refVisual = new Visual("OrbitViewController",
this->camera->GetSceneNode());
this->refVisual->Init();
this->refVisual->AttachMesh("unit_sphere");
this->refVisual->SetScale(Vector3(0.2,0.2,0.1));
Modified: code/gazebo/branches/dev/server/rendering/RTShaderSystem.cc
===================================================================
--- code/gazebo/branches/dev/server/rendering/RTShaderSystem.cc 2010-11-24
03:27:30 UTC (rev 8976)
+++ code/gazebo/branches/dev/server/rendering/RTShaderSystem.cc 2010-11-25
01:09:22 UTC (rev 8977)
@@ -194,9 +194,9 @@
if (!this->initialized || !vis->GetUseRTShader())
return;
- for (unsigned int k=0; k < vis->sceneNode->numAttachedObjects(); k++)
+ for (unsigned int k=0; k < vis->GetSceneNode()->numAttachedObjects(); k++)
{
- Ogre::MovableObject *obj = vis->sceneNode->getAttachedObject(k);
+ Ogre::MovableObject *obj = vis->GetSceneNode()->getAttachedObject(k);
Ogre::Entity *entity = dynamic_cast<Ogre::Entity*>(obj);
if (!entity)
continue;
Modified: code/gazebo/branches/dev/server/rendering/Scene.cc
===================================================================
--- code/gazebo/branches/dev/server/rendering/Scene.cc 2010-11-24 03:27:30 UTC
(rev 8976)
+++ code/gazebo/branches/dev/server/rendering/Scene.cc 2010-11-25 01:09:22 UTC
(rev 8977)
@@ -321,9 +321,9 @@
////////////////////////////////////////////////////////////////////////////////
/// Get an entity at a pixel location using a camera. Used for mouse picking.
-Entity *Scene::GetEntityAt(Camera *camera, Vector2<int> mousePos, std::string
&mod)
+Common *Scene::GetEntityAt(Camera *camera, Vector2<int> mousePos, std::string
&mod)
{
- Entity *entity = NULL;
+ Common *entity = NULL;
Ogre::Camera *ogreCam = camera->GetCamera();
Ogre::Vector3 camPos = ogreCam->getPosition();
Modified: code/gazebo/branches/dev/server/rendering/Scene.hh
===================================================================
--- code/gazebo/branches/dev/server/rendering/Scene.hh 2010-11-24 03:27:30 UTC
(rev 8976)
+++ code/gazebo/branches/dev/server/rendering/Scene.hh 2010-11-25 01:09:22 UTC
(rev 8977)
@@ -19,6 +19,7 @@
class Camera;
class UserCamera;
class Entity;
+ class Common;
class Scene
{
@@ -93,7 +94,7 @@
/// \param camera The ogre camera, used to do mouse picking
/// \param mousePos The position of the mouse in screen coordinates
/// \return The selected entity, or NULL
- public: Entity *GetEntityAt(Camera *camera,
+ public: Common *GetEntityAt(Camera *camera,
Vector2<int> mousePos, std::string &mod);
/// \brief Get the world pos of a the first contact at a pixel location
Modified: code/gazebo/branches/dev/server/rendering/UserCamera.cc
===================================================================
--- code/gazebo/branches/dev/server/rendering/UserCamera.cc 2010-11-24
03:27:30 UTC (rev 8976)
+++ code/gazebo/branches/dev/server/rendering/UserCamera.cc 2010-11-25
01:09:22 UTC (rev 8977)
@@ -30,6 +30,7 @@
#include "FPSViewController.hh"
#include "OrbitViewController.hh"
+#include "RenderTypes.hh"
#include "GazeboError.hh"
#include "Model.hh"
#include "Body.hh"
@@ -106,9 +107,10 @@
Camera::Init();
- this->visual = new Visual(this->pitchNode);
+ this->visual = new Visual(this->GetName() + "_OUTLINE", this->pitchNode);
+
// The lines draw a visualization of the camera
- OgreDynamicLines *line = this->visual->AddDynamicLine(
OgreDynamicRenderable::OT_LINE_LIST );
+ OgreDynamicLines *line = this->visual->AddDynamicLine( RENDERING_LINE_LIST );
float f = 0.2;
Modified: code/gazebo/branches/dev/server/rendering/Visual.cc
===================================================================
--- code/gazebo/branches/dev/server/rendering/Visual.cc 2010-11-24 03:27:30 UTC
(rev 8976)
+++ code/gazebo/branches/dev/server/rendering/Visual.cc 2010-11-25 01:09:22 UTC
(rev 8977)
@@ -23,6 +23,7 @@
* Date: 14 Dec 2007
*/
+#include <Ogre.h>
#include <boost/thread/recursive_mutex.hpp>
#include "World.hh"
@@ -49,29 +50,80 @@
////////////////////////////////////////////////////////////////////////////////
// Constructor
-Visual::Visual(Common *parent)
+Visual::Visual(const std::string &name, Common *parent)
: Common(parent)
{
+ this->SetName(name);
this->AddType(VISUAL);
- this->transparency = 0.0;
- this->hasMaterial = false;
+ this->sceneNode = NULL;
- bool isStatic = false;
- this->useRTShader = true;
+ std::ostringstream stream;
+ stream << this->GetName() << "_VISUAL_" << visualCounter++;
- this->visible = true;
- this->ribbonTrail = NULL;
+ Ogre::SceneNode *pnode = NULL;
+ if (this->GetParent()->HasType(ENTITY))
+ pnode = ((Entity*)this->GetParent())->GetVisualNode()->GetSceneNode();
+ else if ( this->GetParent()->HasType(VISUAL))
+ pnode = ((Visual*)this->GetParent())->GetSceneNode();
+ else
+ gzerr(0) << "Create a visual, invalid parent!!!\n";
+
+ this->sceneNode = pnode->createChildSceneNode( stream.str() );
+
+ this->Init();
}
+////////////////////////////////////////////////////////////////////////////////
+/// Constructor
+Visual::Visual (const std::string &name, Ogre::SceneNode *parent)
+ : Common(NULL)
+{
+ this->SetName(name);
+ this->AddType(VISUAL);
+ this->sceneNode = NULL;
+ std::ostringstream stream;
+ stream << this->GetName() << "_VISUAL_" << visualCounter++;
+
+ this->sceneNode = parent->createChildSceneNode( stream.str() );
+
+ this->Init();
+}
+
////////////////////////////////////////////////////////////////////////////////
+/// Constructor
+Visual::Visual (const std::string &name, Scene *scene)
+ : Common(NULL)
+{
+ this->SetName(name);
+ this->AddType(VISUAL);
+ this->sceneNode = NULL;
+
+ std::ostringstream stream;
+ stream << this->GetName() << "_VISUAL_" << visualCounter++;
+
+ this->sceneNode =
scene->GetManager()->getRootSceneNode()->createChildSceneNode(stream.str());
+
+ this->Init();
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
// Helper for the contructor
void Visual::Init()
{
- std::ostringstream stream;
this->mutex = new boost::recursive_mutex();
this->dirty = false;
+ this->transparency = 0.0;
+ this->hasMaterial = false;
+ this->isStatic = false;
+ this->useRTShader = true;
+ this->visible = true;
+ this->ribbonTrail = NULL;
+ this->boundingBoxNode = NULL;
+ this->ignorePoseUpdates = false;
+ this->staticGeom = NULL;
Param::Begin(&this->parameters);
this->xyzP = new ParamT<Vector3>("xyz", Vector3(0,0,0), 0);
@@ -82,7 +134,7 @@
this->meshNameP = new ParamT<std::string>("mesh","",1);
this->meshTileP = new ParamT< Vector2<double> >("uvTile",
- Vector2<double>(1.0, 1.0), 0 );
+ Vector2<double>(1.0, 1.0), 0 );
//default to Gazebo/White
this->materialNameP = new ParamT<std::string>("material",
@@ -103,32 +155,25 @@
this->shaderP->Callback( &Visual::SetShader, this );
Param::End();
- this->boundingBoxNode = NULL;
-
- this->ignorePoseUpdates = false;
-
- if (Simulator::Instance()->GetRenderEngineEnabled())
+ /*if (this->sceneNode == NULL)
{
- this->sceneBlendType = Ogre::SBT_TRANSPARENT_ALPHA;
+ std::ostringstream stream;
// Create a unique name for the scene node
- //FIXME: what if we add the capability to delete and add new children?
stream << this->GetParent()->GetName() << "_VISUAL_" << visualCounter++;
Ogre::SceneNode *pnode = NULL;
if (!this->GetParent())
pnode = this->GetWorld()->GetScene()->GetManager()->getRootSceneNode();
else if ( this->GetParent()->HasType(VISUAL))
- pnode = this->GetParent()->GetSceneNode();
+ pnode = ((Visual*)this->GetParent())->GetSceneNode();
else if (this->GetParent()->HasType(ENTITY))
- pnode = this->GetParent()->GetVisualNode()->GetSceneNode();
+ pnode = ((Entity*)this->GetParent())->GetVisualNode()->GetSceneNode();
// Create the scene node
this->sceneNode = pnode->createChildSceneNode( stream.str() );
- }
+ }*/
- this->staticGeom = NULL;
-
RTShaderSystem::Instance()->AttachEntity(this);
}
@@ -513,11 +558,13 @@
if (materialName.empty())
return;
+ Ogre::MaterialPtr origMaterial;
+
try
{
this->origMaterialName = materialName;
// Get the original material
- this->origMaterial= Ogre::MaterialManager::getSingleton().getByName
(materialName);;
+ origMaterial= Ogre::MaterialManager::getSingleton().getByName
(materialName);;
}
catch (Ogre::Exception e)
{
@@ -526,7 +573,7 @@
return;
}
- if (this->origMaterial.isNull())
+ if (origMaterial.isNull())
{
gzmsg(0) << "Unable to get Material[" << materialName << "] for Geometry["
<< this->sceneNode->getName() << ". Object will appear white\n";
@@ -537,14 +584,16 @@
// Create a custom material name
this->myMaterialName = this->sceneNode->getName() + "_MATERIAL_" +
materialName;
+ Ogre::MaterialPtr myMaterial;
+
// Clone the material. This will allow us to change the look of each geom
// individually.
if
(Ogre::MaterialManager::getSingleton().resourceExists(this->myMaterialName))
- this->myMaterial =
(Ogre::MaterialPtr)(Ogre::MaterialManager::getSingleton().getByName(this->myMaterialName));
+ myMaterial =
(Ogre::MaterialPtr)(Ogre::MaterialManager::getSingleton().getByName(this->myMaterialName));
else
- this->myMaterial = this->origMaterial->clone(myMaterialName);
+ myMaterial = origMaterial->clone(this->myMaterialName);
- Ogre::Material::TechniqueIterator techniqueIt =
this->myMaterial->getTechniqueIterator ();
+ Ogre::Material::TechniqueIterator techniqueIt =
myMaterial->getTechniqueIterator ();
/*while (techniqueIt.hasMoreElements ())
{
@@ -1136,11 +1185,11 @@
////////////////////////////////////////////////////////////////////////////////
// Add a line to the visual
-OgreDynamicLines *Visual::AddDynamicLine(OgreDynamicRenderable::OperationType
opType)
+OgreDynamicLines *Visual::AddDynamicLine(OperationType type)
{
Events::ConnectPreRenderSignal( boost::bind(&Visual::Update, this) );
- OgreDynamicLines *line = new OgreDynamicLines(opType);
+ OgreDynamicLines *line = new OgreDynamicLines(type);
this->lines.push_back(line);
this->AttachObject(line);
return line;
Modified: code/gazebo/branches/dev/server/rendering/Visual.hh
===================================================================
--- code/gazebo/branches/dev/server/rendering/Visual.hh 2010-11-24 03:27:30 UTC
(rev 8976)
+++ code/gazebo/branches/dev/server/rendering/Visual.hh 2010-11-25 01:09:22 UTC
(rev 8977)
@@ -27,16 +27,23 @@
#ifndef OGREVISUAL_HH
#define OGREVISUAL_HH
-#include <Ogre.h>
#include <string>
-#include "OgreDynamicRenderable.hh"
+#include "RenderTypes.hh"
#include "Pose3d.hh"
#include "Quatern.hh"
#include "Vector3.hh"
#include "Common.hh"
#include "Param.hh"
+namespace Ogre
+{
+ class MovableObject;
+ class SceneNode;
+ class StaticGeometry;
+ class RibbonTrail;
+}
+
namespace boost
{
class recursive_mutex;
@@ -52,11 +59,17 @@
class OgreDynamicLines;
/// \brief Ogre Visual Object
- class Visual : public Common, public Ogre::Any
+ class Visual : public Common //, public Ogre::Any
{
/// \brief Constructor
- public: Visual (Common *parent = NULL);
+ public: Visual (const std::string &name, Common *parent);
+ /// \brief Constructor
+ public: Visual (const std::string &name, Ogre::SceneNode *parent);
+
+ /// \brief Constructor
+ public: Visual (const std::string &name, Scene *scene);
+
/// \brief Destructor
public: virtual ~Visual();
@@ -209,8 +222,7 @@
public: bool GetUseRTShader() const;
/// \brief Add a line to the visual
- public: OgreDynamicLines *AddDynamicLine(
- OgreDynamicRenderable::OperationType opType);
+ public: OgreDynamicLines *AddDynamicLine(OperationType type);
/// \brief Delete a dynamic line
public: void DeleteDynamicLine(OgreDynamicLines *line);
@@ -221,14 +233,11 @@
/// \brief Return true if a material is set for this visual
public: bool HasMaterial() const;
- private: Ogre::MaterialPtr origMaterial;
- private: Ogre::MaterialPtr myMaterial;
private: std::string myMaterialName;
private: std::string origMaterialName;
- private: Ogre::SceneBlendType sceneBlendType;
private: Ogre::SceneNode *parentNode;
- public: Ogre::SceneNode *sceneNode;
+ private: Ogre::SceneNode *sceneNode;
private: Ogre::SceneNode *boundingBoxNode;
private: float transparency;
Modified: code/gazebo/branches/dev/server/wx/BoxMaker.cc
===================================================================
--- code/gazebo/branches/dev/server/wx/BoxMaker.cc 2010-11-24 03:27:30 UTC
(rev 8976)
+++ code/gazebo/branches/dev/server/wx/BoxMaker.cc 2010-11-25 01:09:22 UTC
(rev 8977)
@@ -11,12 +11,13 @@
using namespace gazebo;
+unsigned int BoxMaker::counter = 0;
+
BoxMaker::BoxMaker()
: EntityMaker()
{
this->state = 0;
this->visualName = "";
- this->index = 0;
}
BoxMaker::~BoxMaker()
@@ -26,15 +27,7 @@
void BoxMaker::Start()
{
std::ostringstream stream;
- std::string boxName = "user_box";
-
- do
- {
- stream.str("");
- stream << boxName << index;
- this->index++;
- } while (OgreCreator::Instance()->GetVisual(stream.str()));
-
+ stream << "user_box_" << counter++;
this->visualName = stream.str();
this->state = 1;
}
Modified: code/gazebo/branches/dev/server/wx/BoxMaker.hh
===================================================================
--- code/gazebo/branches/dev/server/wx/BoxMaker.hh 2010-11-24 03:27:30 UTC
(rev 8976)
+++ code/gazebo/branches/dev/server/wx/BoxMaker.hh 2010-11-25 01:09:22 UTC
(rev 8977)
@@ -24,7 +24,8 @@
private: bool leftMousePressed;
private: Vector2<int> mousePushPos;
private: std::string visualName;
- private: int index;
+
+ private: static unsigned int counter;
};
}
Modified: code/gazebo/branches/dev/server/wx/CylinderMaker.cc
===================================================================
--- code/gazebo/branches/dev/server/wx/CylinderMaker.cc 2010-11-24 03:27:30 UTC
(rev 8976)
+++ code/gazebo/branches/dev/server/wx/CylinderMaker.cc 2010-11-25 01:09:22 UTC
(rev 8977)
@@ -10,13 +10,13 @@
#include "CylinderMaker.hh"
using namespace gazebo;
+unsigned int CylinderMaker::counter = 0;
CylinderMaker::CylinderMaker()
: EntityMaker()
{
this->state = 0;
this->visualName = "";
- this->index = 0;
}
CylinderMaker::~CylinderMaker()
@@ -26,15 +26,7 @@
void CylinderMaker::Start()
{
std::ostringstream stream;
- std::string name = "user_cylinder";
-
- do
- {
- stream.str("");
- stream << name << index;
- this->index++;
- } while (OgreCreator::Instance()->GetVisual(stream.str()));
-
+ stream << "user_cylinder_" << counter++;
this->visualName = stream.str();
this->state = 1;
}
Modified: code/gazebo/branches/dev/server/wx/CylinderMaker.hh
===================================================================
--- code/gazebo/branches/dev/server/wx/CylinderMaker.hh 2010-11-24 03:27:30 UTC
(rev 8976)
+++ code/gazebo/branches/dev/server/wx/CylinderMaker.hh 2010-11-25 01:09:22 UTC
(rev 8977)
@@ -25,7 +25,8 @@
private: bool leftMousePressed;
private: Vector2<int> mousePushPos;
private: std::string visualName;
- private: int index;
+
+ private: static unsigned int counter;
};
}
#endif
Modified: code/gazebo/branches/dev/server/wx/PointLightMaker.cc
===================================================================
--- code/gazebo/branches/dev/server/wx/PointLightMaker.cc 2010-11-24
03:27:30 UTC (rev 8976)
+++ code/gazebo/branches/dev/server/wx/PointLightMaker.cc 2010-11-25
01:09:22 UTC (rev 8977)
@@ -10,12 +10,13 @@
using namespace gazebo;
+unsigned int PointLightMaker::counter = 0;
+
PointLightMaker::PointLightMaker()
: EntityMaker()
{
this->state = 0;
this->lightName = "";
- this->index = 0;
}
PointLightMaker::~PointLightMaker()
@@ -25,15 +26,7 @@
void PointLightMaker::Start()
{
std::ostringstream stream;
- std::string name = "user_light";
-
- do
- {
- stream.str("");
- stream << name << index;
- this->index++;
- } while (Common::GetByName(stream.str()));
-
+ stream << "user_light_" << counter++;
this->lightName = stream.str();
this->state = 1;
}
Modified: code/gazebo/branches/dev/server/wx/PointLightMaker.hh
===================================================================
--- code/gazebo/branches/dev/server/wx/PointLightMaker.hh 2010-11-24
03:27:30 UTC (rev 8976)
+++ code/gazebo/branches/dev/server/wx/PointLightMaker.hh 2010-11-25
01:09:22 UTC (rev 8977)
@@ -23,7 +23,7 @@
private: int state;
private: Vector3 createPos;
private: std::string lightName;
- private: int index;
+ private: unsigned int counter;
};
}
Modified: code/gazebo/branches/dev/server/wx/SphereMaker.cc
===================================================================
--- code/gazebo/branches/dev/server/wx/SphereMaker.cc 2010-11-24 03:27:30 UTC
(rev 8976)
+++ code/gazebo/branches/dev/server/wx/SphereMaker.cc 2010-11-25 01:09:22 UTC
(rev 8977)
@@ -11,12 +11,13 @@
using namespace gazebo;
+unsigned int SphereMaker::counter = 0;
+
SphereMaker::SphereMaker()
: EntityMaker()
{
this->state = 0;
this->visualName = "";
- this->index = 0;
}
SphereMaker::~SphereMaker()
@@ -26,15 +27,7 @@
void SphereMaker::Start()
{
std::ostringstream stream;
- std::string name = "user_sphere";
-
- do
- {
- stream.str("");
- stream << name << index;
- this->index++;
- } while (OgreCreator::Instance()->GetVisual(stream.str()));
-
+ stream << "user_sphere_" << counter++;
this->visualName = stream.str();
this->state = 1;
}
Modified: code/gazebo/branches/dev/server/wx/SphereMaker.hh
===================================================================
--- code/gazebo/branches/dev/server/wx/SphereMaker.hh 2010-11-24 03:27:30 UTC
(rev 8976)
+++ code/gazebo/branches/dev/server/wx/SphereMaker.hh 2010-11-25 01:09:22 UTC
(rev 8977)
@@ -25,8 +25,8 @@
private: bool leftMousePressed;
private: Vector2<int> mousePushPos;
private: std::string visualName;
- private: int index;
-
+
+ private: static unsigned int counter;
};
}
#endif
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