Revision: 8392
http://playerstage.svn.sourceforge.net/playerstage/?rev=8392&view=rev
Author: natepak
Date: 2009-11-12 02:09:12 +0000 (Thu, 12 Nov 2009)
Log Message:
-----------
Fixed window split, and added visualization of the camera pose
Modified Paths:
--------------
code/gazebo/trunk/Media/materials/scripts/Gazebo.material
code/gazebo/trunk/server/MeshManager.cc
code/gazebo/trunk/server/MeshManager.hh
code/gazebo/trunk/server/gui/GLWindow.cc
code/gazebo/trunk/server/rendering/OgreCamera.hh
code/gazebo/trunk/server/rendering/OgreVisual.cc
code/gazebo/trunk/server/rendering/OgreVisual.hh
code/gazebo/trunk/server/rendering/UserCamera.cc
code/gazebo/trunk/server/rendering/UserCamera.hh
Modified: code/gazebo/trunk/Media/materials/scripts/Gazebo.material
===================================================================
--- code/gazebo/trunk/Media/materials/scripts/Gazebo.material 2009-11-11
23:48:31 UTC (rev 8391)
+++ code/gazebo/trunk/Media/materials/scripts/Gazebo.material 2009-11-12
02:09:12 UTC (rev 8392)
@@ -196,6 +196,23 @@
}
}
+material Gazebo/WhiteEmissive
+{
+ receive_shadows off
+
+ technique
+ {
+ pass
+ {
+ ambient 1.000000 1.000000 1.000000 1.000000
+ diffuse 1.000000 1.000000 1.000000 1.000000
+ specular 0.200000 0.200000 0.200000 1.000000
+ emissive 1.000000 1.000000 1.000000 1.000000
+ lighting on
+ }
+ }
+}
+
material Gazebo/RedEmissive
{
receive_shadows off
Modified: code/gazebo/trunk/server/MeshManager.cc
===================================================================
--- code/gazebo/trunk/server/MeshManager.cc 2009-11-11 23:48:31 UTC (rev
8391)
+++ code/gazebo/trunk/server/MeshManager.cc 2009-11-12 02:09:12 UTC (rev
8392)
@@ -31,6 +31,7 @@
Vector2<double>(1,1));
this->CreateCylinder("unit_cylinder", 0.5, 1.0, 1, 32);
this->CreateCone("unit_cone", 0.5, 1.0, 5, 32);
+ this->CreateCamera("unit_camera", 0.5);
}
////////////////////////////////////////////////////////////////////////////////
@@ -314,7 +315,102 @@
subMesh->AddIndex(ind[i]);
}
+////////////////////////////////////////////////////////////////////////////////
+/// Create a Camera mesh
+void MeshManager::CreateCamera(const std::string &name, float scale)
+{
+ int i,k;
+ if (this->HasMesh(name))
+ {
+ return;
+ }
+
+ Mesh *mesh = new Mesh();
+ mesh->SetName(name);
+ this->meshes.insert( std::make_pair(name, mesh) );
+
+ SubMesh *subMesh = new SubMesh();
+ mesh->AddSubMesh(subMesh);
+
+ // Vertex values
+ float v[8][3] =
+ {
+ {-1, -1, -1}, {-1, -1, +1}, {+1, -1, +1}, {+1, -1, -1},
+ {-1, +1, -1}, {-1, +1, +1}, {+1, +1, +1}, {+1, +1, -1}
+ };
+
+ // Normals for each vertex
+ float n[8][3]=
+ {
+ {-0.577350, -0.577350, -0.577350},
+ {-0.577350, -0.577350, 0.577350},
+ {0.577350, -0.577350, 0.577350},
+ {0.577350, -0.577350, -0.577350},
+ {-0.577350, 0.577350, -0.577350},
+ {-0.577350, 0.577350, 0.577350},
+ {0.577350, 0.577350, 0.577350},
+ {0.577350, 0.577350, -0.577350}
+ };
+
+ // Texture coords
+ /*float t[4][2] =
+ {
+ {uvCoords.x, 0}, {0, 0}, {0,uvCoords.y}, {uvCoords.x, uvCoords.y}
+ };*/
+
+ // Vertices
+ int faces[6][4] =
+ {
+ {2, 1, 0, 3}, {5, 6, 7, 4},
+ {2, 6, 5, 1}, {1, 5, 4, 0},
+ {0, 4, 7, 3}, {6, 2, 3, 7}
+ };
+
+ // Indices
+ int ind[36] =
+ {
+ 0, 1, 2,
+ 2, 3, 0,
+ 4, 5, 7,
+ 7, 5, 6,
+ 11,8,9,
+ 9,10,11,
+ 12, 13, 15,
+ 15, 13, 14,
+ 16, 17, 18,
+ 18, 19, 16,
+ 21,22,23,
+ 23,20,21,
+ };
+
+ // Compute the vertices
+ for (i = 0; i < 8; i++)
+ {
+ v[i][0] *= scale * 0.5;
+ v[i][1] *= scale * 0.5;
+ v[i][2] *= scale * 0.5;
+ }
+
+ // For each face
+ for (i = 0; i < 6; i++)
+ {
+ // For each vertex in the face
+ for (k=0; k<4; k++)
+ {
+ subMesh->AddVertex(v[faces[i][k]][0], v[faces[i][k]][1],
+ v[faces[i][k]][2]);
+ subMesh->AddNormal(n[faces[i][k]][0], n[faces[i][k]][1],
+ n[faces[i][k]][2]);
+ //subMesh->AddTexCoord(t[k][0], t[k][1]);
+ }
+ }
+
+ // Set the indices
+ for (i=0;i<36; i++)
+ subMesh->AddIndex(ind[i]);
+}
+
////////////////////////////////////////////////////////////////////////////////
/// Create a cylinder mesh
void MeshManager::CreateCylinder(const std::string &name, float radius,
Modified: code/gazebo/trunk/server/MeshManager.hh
===================================================================
--- code/gazebo/trunk/server/MeshManager.hh 2009-11-11 23:48:31 UTC (rev
8391)
+++ code/gazebo/trunk/server/MeshManager.hh 2009-11-12 02:09:12 UTC (rev
8392)
@@ -55,6 +55,9 @@
public: void CreateTube(const std::string &name, float innerRadius,
float outterRadius, float height, int rings,
int segments);
+
+ /// \brief Create a Camera mesh
+ public: void CreateCamera(const std::string &name, float scale);
private: OgreLoader *ogreLoader;
private: AssimpLoader *assimpLoader;
Modified: code/gazebo/trunk/server/gui/GLWindow.cc
===================================================================
--- code/gazebo/trunk/server/gui/GLWindow.cc 2009-11-11 23:48:31 UTC (rev
8391)
+++ code/gazebo/trunk/server/gui/GLWindow.cc 2009-11-12 02:09:12 UTC (rev
8392)
@@ -65,6 +65,7 @@
{
this->end();
+ this->userCamera = NULL;
this->moveAmount = 0.1;
this->moveScale = 1;
this->rotateAmount = 0.1;
@@ -112,6 +113,13 @@
Fl::check();
this->mouseDrag = false;
+ if (this->userCamera == NULL)
+ {
+ // Create the default camera.
+ this->userCamera = new UserCamera( this );
+ this->userCamera->Load(NULL);
+ }
+
this->userCamera->Init();
this->userCamera->RotatePitch( DTOR(30) );
this->userCamera->Translate( Vector3(-5, 0, 1) );
@@ -776,6 +784,10 @@
{
pose.rot.SetFromEuler( Vector3(0, 0,0) );
}
+ else
+ {
+ this->activeCamera = CameraManager::Instance()->GetCamera( view );
+ }
cam->SetWorldPose( pose );
}
Modified: code/gazebo/trunk/server/rendering/OgreCamera.hh
===================================================================
--- code/gazebo/trunk/server/rendering/OgreCamera.hh 2009-11-11 23:48:31 UTC
(rev 8391)
+++ code/gazebo/trunk/server/rendering/OgreCamera.hh 2009-11-12 02:09:12 UTC
(rev 8392)
@@ -220,8 +220,8 @@
protected: unsigned int textureWidth, textureHeight;
private: Ogre::Camera *camera;
- private: Ogre::SceneNode *sceneNode;
- private: Ogre::SceneNode *pitchNode;
+ protected: Ogre::SceneNode *sceneNode;
+ protected: Ogre::SceneNode *pitchNode;
private: Pose3d pose;
Modified: code/gazebo/trunk/server/rendering/OgreVisual.cc
===================================================================
--- code/gazebo/trunk/server/rendering/OgreVisual.cc 2009-11-11 23:48:31 UTC
(rev 8391)
+++ code/gazebo/trunk/server/rendering/OgreVisual.cc 2009-11-12 02:09:12 UTC
(rev 8392)
@@ -46,12 +46,35 @@
OgreVisual::OgreVisual(OgreVisual *node, Entity *_owner)
: Common()
{
+ Ogre::SceneNode *pnode = NULL;
+ this->owner = _owner;
+
+ if (Simulator::Instance()->GetRenderEngineEnabled())
+ {
+ if (!node)
+ pnode = OgreAdaptor::Instance()->sceneMgr->getRootSceneNode();
+ else
+ pnode = node->GetSceneNode();
+ }
+
+ this->ConstructorHelper(pnode);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+/// Constructor
+OgreVisual::OgreVisual (Ogre::SceneNode *node)
+{
+ this->owner = NULL;
+ this->ConstructorHelper(node);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Helper for the contructor
+void OgreVisual::ConstructorHelper(Ogre::SceneNode *node)
+{
std::ostringstream stream;
-
this->mutex = new boost::recursive_mutex();
- this->owner = _owner;
-
Param::Begin(&this->parameters);
this->xyzP = new ParamT<Vector3>("xyz", Vector3(0,0,0), 0);
this->xyzP->Callback( &OgreVisual::SetPosition, this );
@@ -82,11 +105,7 @@
if (Simulator::Instance()->GetRenderEngineEnabled())
{
- if (!node)
- this->parentNode = OgreAdaptor::Instance()->sceneMgr->getRootSceneNode();
- else
- this->parentNode = node->GetSceneNode();
-
+ this->parentNode = node;
this->sceneBlendType = Ogre::SBT_TRANSPARENT_ALPHA;
// Create a unique name for the scene node
@@ -98,6 +117,7 @@
}
}
+
////////////////////////////////////////////////////////////////////////////////
/// Destructor
OgreVisual::~OgreVisual()
@@ -268,7 +288,6 @@
/// Detach all objects
void OgreVisual::DetachObjects()
{
- printf("Detaching objects\n");
boost::recursive_mutex::scoped_lock lock(*this->mutex);
// Stop here if the rendering engine has been disabled
Modified: code/gazebo/trunk/server/rendering/OgreVisual.hh
===================================================================
--- code/gazebo/trunk/server/rendering/OgreVisual.hh 2009-11-11 23:48:31 UTC
(rev 8391)
+++ code/gazebo/trunk/server/rendering/OgreVisual.hh 2009-11-12 02:09:12 UTC
(rev 8392)
@@ -53,6 +53,12 @@
/// \brief Constructor
public: OgreVisual (OgreVisual *node, Entity *owner = NULL);
+ /// \brief Constructor
+ public: OgreVisual (Ogre::SceneNode *node);
+
+ /// \brief Helper for the contructor
+ private: void ConstructorHelper(Ogre::SceneNode *node);
+
/// \brief Destructor
public: virtual ~OgreVisual();
Modified: code/gazebo/trunk/server/rendering/UserCamera.cc
===================================================================
--- code/gazebo/trunk/server/rendering/UserCamera.cc 2009-11-11 23:48:31 UTC
(rev 8391)
+++ code/gazebo/trunk/server/rendering/UserCamera.cc 2009-11-12 02:09:12 UTC
(rev 8392)
@@ -33,6 +33,8 @@
#include "OgreCamera.hh"
#include "OgreAdaptor.hh"
#include "OgreCreator.hh"
+#include "OgreVisual.hh"
+#include "OgreDynamicLines.hh"
#include "UserCamera.hh"
using namespace gazebo;
@@ -80,6 +82,63 @@
this->InitCam();
+ this->visual = new OgreVisual(this->pitchNode);
+ OgreDynamicLines *line = OgreCreator::Instance()->CreateDynamicLine(
+ OgreDynamicRenderable::OT_LINE_LIST);
+
+ float d = 0.5;
+ float b = 0.01;
+ float f = 0.2;
+
+ // Create the front face
+ line->AddPoint(Vector3(0, -f, -f));
+ line->AddPoint(Vector3(0, -f, +f));
+
+ line->AddPoint(Vector3(0, -f, +f));
+ line->AddPoint(Vector3(0, +f, +f));
+
+ line->AddPoint(Vector3(0, +f, +f));
+ line->AddPoint(Vector3(0, +f, -f));
+
+ line->AddPoint(Vector3(0, +f, -f));
+ line->AddPoint(Vector3(0, -f, -f));
+
+
+ // Create the connecting lines
+ line->AddPoint(Vector3(-0.4, 0, 0));
+ line->AddPoint(Vector3(+0.0, -f, -f));
+
+ line->AddPoint(Vector3(-0.4, 0, 0));
+ line->AddPoint(Vector3(+0.0, -f, +f));
+
+ line->AddPoint(Vector3(-0.4, 0, 0));
+ line->AddPoint(Vector3(+0.0, +f, +f));
+
+ line->AddPoint(Vector3(-0.4, 0, 0));
+ line->AddPoint(Vector3(+0.0, +f, -f));
+
+ line->AddPoint(Vector3(-0.4, 0, 0));
+ line->AddPoint(Vector3(+0.0, -f, -f));
+
+ // Draw up arrow
+ line->AddPoint(Vector3(0, 0, +f));
+ line->AddPoint(Vector3(0, 0, +f+0.1));
+
+ line->AddPoint(Vector3(0.0, -0.02, +f+0.1));
+ line->AddPoint(Vector3(0.0, +0.02, +f+0.1));
+
+ line->AddPoint(Vector3(0.0, +0.02, +f+0.1));
+ line->AddPoint(Vector3(0.0, +0.00, +f+0.15));
+
+ line->AddPoint(Vector3(0.0, +0.00, +f+0.15));
+ line->AddPoint(Vector3(0.0, -0.02, +f+0.1));
+
+ line->setMaterial("Gazebo/WhiteEmissive");
+ line->setVisibilityFlags(GZ_LASER_CAMERA);
+
+ this->visual->AttachObject(line);
+
+
this->viewport = this->window->addViewport(this->GetOgreCamera());
this->viewport->setBackgroundColour(Ogre::ColourValue::Black);
Modified: code/gazebo/trunk/server/rendering/UserCamera.hh
===================================================================
--- code/gazebo/trunk/server/rendering/UserCamera.hh 2009-11-11 23:48:31 UTC
(rev 8391)
+++ code/gazebo/trunk/server/rendering/UserCamera.hh 2009-11-12 02:09:12 UTC
(rev 8392)
@@ -39,6 +39,7 @@
{
class GLWindow;
class XMLConfigNode;
+ class OgreVisual;
class UserCamera : public OgreCamera
{
@@ -84,6 +85,8 @@
private: std::string name;
private: static unsigned int cameraCount;
private: static int count;
+
+ private: OgreVisual *visual;
};
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit