Revision: 7773
http://playerstage.svn.sourceforge.net/playerstage/?rev=7773&view=rev
Author: natepak
Date: 2009-06-03 13:51:30 +0000 (Wed, 03 Jun 2009)
Log Message:
-----------
Fixed RTT rendering problem.Gazebo will only use FBO from now on
Modified Paths:
--------------
code/gazebo/trunk/cmake/gazeborc.cmake
code/gazebo/trunk/server/GazeboConfig.cc
code/gazebo/trunk/server/GazeboConfig.hh
code/gazebo/trunk/server/Simulator.cc
code/gazebo/trunk/server/Simulator.hh
code/gazebo/trunk/server/gui/Gui.cc
code/gazebo/trunk/server/gui/Gui.hh
code/gazebo/trunk/server/physics/HeightmapGeom.cc
code/gazebo/trunk/server/rendering/OgreAdaptor.cc
code/gazebo/trunk/server/rendering/OgreAdaptor.hh
code/gazebo/trunk/server/rendering/OgreCamera.cc
code/gazebo/trunk/server/rendering/OgreCreator.cc
code/gazebo/trunk/worlds/epuck.world
Modified: code/gazebo/trunk/cmake/gazeborc.cmake
===================================================================
--- code/gazebo/trunk/cmake/gazeborc.cmake 2009-06-03 10:41:10 UTC (rev
7772)
+++ code/gazebo/trunk/cmake/gazeborc.cmake 2009-06-03 13:51:30 UTC (rev
7773)
@@ -2,5 +2,4 @@
<gazeborc>
<gazeboPath>@CMAKE_INSTALL_PREFIX@/share/gazebo</gazeboPath>
<ogrePath>@OGRE_LIBRARY_PATH@/OGRE</ogrePath>
- <RTTMode>PBuffer</RTTMode>
</gazeborc>
Modified: code/gazebo/trunk/server/GazeboConfig.cc
===================================================================
--- code/gazebo/trunk/server/GazeboConfig.cc 2009-06-03 10:41:10 UTC (rev
7772)
+++ code/gazebo/trunk/server/GazeboConfig.cc 2009-06-03 13:51:30 UTC (rev
7773)
@@ -72,6 +72,7 @@
}
this->ogrePaths.push_back(str.substr(pos1,str.size()-pos1));
}
+
char *gazebo_resource_path = getenv("GAZEBO_RESOURCE_PATH");
if(gazebo_resource_path)
{
@@ -116,7 +117,6 @@
node = node->GetNext("ogrePath");
}
}
- this->RTTMode = rc.GetRootNode()->GetString("RTTMode", "PBuffer");
}
else
@@ -125,16 +125,15 @@
if ( !gazebo_resource_path )
{
- this->gazeboPaths.push_back("/usr/local/share/gazebo");
+ this->gazeboPaths.push_back("/usr/local/share/gazebo");
}
if ( !ogre_resource_path )
{
- this->ogrePaths.push_back("/usr/local/lib/OGRE");
- this->ogrePaths.push_back("/usr/lib/OGRE");
+ this->ogrePaths.push_back("/usr/local/lib/OGRE");
+ this->ogrePaths.push_back("/usr/lib/OGRE");
}
- this->RTTMode="PBuffer";
}
}
@@ -147,9 +146,3 @@
{
return this->ogrePaths;
}
-
-std::string &GazeboConfig::GetRTTMode()
-{
- return this->RTTMode;
-}
-
Modified: code/gazebo/trunk/server/GazeboConfig.hh
===================================================================
--- code/gazebo/trunk/server/GazeboConfig.hh 2009-06-03 10:41:10 UTC (rev
7772)
+++ code/gazebo/trunk/server/GazeboConfig.hh 2009-06-03 13:51:30 UTC (rev
7773)
@@ -53,16 +53,12 @@
/// \brief Get paths to ogre install
public: std::list<std::string>& GetOgrePaths();
- public: std::string& GetRTTMode();
-
/// Paths gazebo install
private: std::list<std::string> gazeboPaths;
/// Paths to the ogre install
private: std::list<std::string> ogrePaths;
- private: std::string RTTMode;
-
};
Modified: code/gazebo/trunk/server/Simulator.cc
===================================================================
--- code/gazebo/trunk/server/Simulator.cc 2009-06-03 10:41:10 UTC (rev
7772)
+++ code/gazebo/trunk/server/Simulator.cc 2009-06-03 13:51:30 UTC (rev
7773)
@@ -37,7 +37,7 @@
#include "OgreVisual.hh"
#include "World.hh"
#include "XMLConfig.hh"
-#include "GuiAPI.hh"
+#include "Gui.hh"
#include "GazeboConfig.hh"
#include "gazebo.h"
#include "PhysicsEngine.hh"
@@ -184,16 +184,19 @@
if (childNode)
{
- int width = childNode->GetTupleInt("size",0,640);
- int height = childNode->GetTupleInt("size",1,480);
+ int width = childNode->GetTupleInt("size", 0, 800);
+ int height = childNode->GetTupleInt("size", 1, 600);
int x = childNode->GetTupleInt("pos",0,0);
int y = childNode->GetTupleInt("pos",1,0);
//gzmsg(1) << "Creating GUI: Pos[" << x << " " << y
// << "] Size[" << width << " " << height << "]\n";
+ printf("New gui\n");
// Create the GUI
- this->gui = new GuiAPI(x, y, width, height, "Gazebo");
+ this->gui = new Gui(x, y, width, height, "Gazebo");
+
+ printf("Load Gui\n");
this->gui->Load(childNode);
}
}
@@ -224,6 +227,7 @@
// Initialize the GUI
if (this->gui)
{
+ printf("Init gui\n");
this->gui->Init();
}
Modified: code/gazebo/trunk/server/Simulator.hh
===================================================================
--- code/gazebo/trunk/server/Simulator.hh 2009-06-03 10:41:10 UTC (rev
7772)
+++ code/gazebo/trunk/server/Simulator.hh 2009-06-03 13:51:30 UTC (rev
7773)
@@ -43,7 +43,7 @@
/// \{
// Forward declarations
- class GuiAPI;
+ class Gui;
class Server;
class SimulationIface;
class XMLConfig;
@@ -179,7 +179,7 @@
private: XMLConfig *xmlFile;
/// Pointer to the selected Gui
- private: GuiAPI *gui;
+ private: Gui *gui;
private: OgreAdaptor *renderEngine;
Modified: code/gazebo/trunk/server/gui/Gui.cc
===================================================================
--- code/gazebo/trunk/server/gui/Gui.cc 2009-06-03 10:41:10 UTC (rev 7772)
+++ code/gazebo/trunk/server/gui/Gui.cc 2009-06-03 13:51:30 UTC (rev 7773)
@@ -48,7 +48,7 @@
////////////////////////////////////////////////////////////////////////////////
/// Constructor
Gui::Gui (int x, int y, int width, int height, const std::string &t)
- : Fl_Window(x, y, width, height, t.c_str())
+ : Fl_Double_Window(x, y, width, height, t.c_str())
{
Fl::scheme("plastic");
@@ -92,10 +92,6 @@
Fl::check();
Fl::wait(0.3);
- // Create a dummy rendering window. This creates a context, and allows Ogre
- // to initialize properly
- OgreCreator::Instance()->CreateWindow(this, 1, 1);
-
this->hasFocus = true;
Fl::check();
Modified: code/gazebo/trunk/server/gui/Gui.hh
===================================================================
--- code/gazebo/trunk/server/gui/Gui.hh 2009-06-03 10:41:10 UTC (rev 7772)
+++ code/gazebo/trunk/server/gui/Gui.hh 2009-06-03 13:51:30 UTC (rev 7773)
@@ -31,7 +31,7 @@
#include <X11/Xutil.h>
#include <FL/Fl.H>
-#include <FL/Fl_Window.H>
+#include <FL/Fl_Double_Window.H>
#include <string>
#include <iostream>
@@ -48,7 +48,7 @@
class XMLConfigNode;
/// \brief FLTK Main Window
- class Gui : public Fl_Window
+ class Gui : public Fl_Double_Window
{
/// \brief Constructor
public: Gui (int x, int y, int w, int h, const std::string &t);
Modified: code/gazebo/trunk/server/physics/HeightmapGeom.cc
===================================================================
--- code/gazebo/trunk/server/physics/HeightmapGeom.cc 2009-06-03 10:41:10 UTC
(rev 7772)
+++ code/gazebo/trunk/server/physics/HeightmapGeom.cc 2009-06-03 13:51:30 UTC
(rev 7773)
@@ -183,6 +183,14 @@
pose.rot = pose.rot * quat;
this->body->SetPose(pose);
+
+ dQuaternion q;
+ q[0] = pose.rot.u;
+ q[1] = pose.rot.x;
+ q[2] = pose.rot.y;
+ q[3] = pose.rot.z;
+
+ dGeomSetQuaternion(this->geomId, q);
}
////////////////////////////////////////////////////////////////////////////////
Modified: code/gazebo/trunk/server/rendering/OgreAdaptor.cc
===================================================================
--- code/gazebo/trunk/server/rendering/OgreAdaptor.cc 2009-06-03 10:41:10 UTC
(rev 7772)
+++ code/gazebo/trunk/server/rendering/OgreAdaptor.cc 2009-06-03 13:51:30 UTC
(rev 7773)
@@ -136,10 +136,8 @@
// Setup the available resources
this->SetupResources();
- this->videoMode = "800 x 600 @ 32-bit colour";
-
// Setup the rendering system, and create the context
- this->SetupRenderSystem(true);
+ this->SetupRenderSystem();
// Initialize the root node, and don't create a window
this->root->initialise(false);
@@ -154,8 +152,9 @@
node = rootNode->GetChild("ogre", "rendering");
- /// Create a dummy rendering context if the GUI is disabled
- if (!Simulator::Instance()->GetGuiEnabled())
+ /// Create a dummy rendering context.
+ /// This will allow gazebo to run headless. And it also allows OGRE to
+ /// initialize properly
{
this->dummyDisplay = XOpenDisplay(0);
if (!this->dummyDisplay)
@@ -163,8 +162,8 @@
int screen = DefaultScreen(this->dummyDisplay);
- int attribList[8] = {GLX_RGBA, GLX_RED_SIZE, 8, GLX_GREEN_SIZE, 8,
- GLX_BLUE_SIZE, 8, None};
+ int attribList[] = {GLX_RGBA, GLX_DOUBLEBUFFER, GLX_DEPTH_SIZE, 16,
+ GLX_STENCIL_SIZE, 8, None };
this->dummyVisual = glXChooseVisual(this->dummyDisplay, screen,
(int *)attribList);
@@ -405,52 +404,45 @@
////////////////////////////////////////////////////////////////////////////////
// Setup render system
-void OgreAdaptor::SetupRenderSystem(bool create)
+void OgreAdaptor::SetupRenderSystem()
{
-
Ogre::RenderSystem *renderSys;
// Set parameters of render system (window size, etc.)
- //if (!this->root->restoreConfig())
- {
- Ogre::RenderSystemList *rsList = this->root->getAvailableRenderers();
- int c = 0;
+ Ogre::RenderSystemList *rsList = this->root->getAvailableRenderers();
+ int c = 0;
- renderSys = NULL;
+ renderSys = NULL;
- do
- {
- if (c == (int)rsList->size())
- break;
+ do
+ {
+ if (c == (int)rsList->size())
+ break;
- renderSys = rsList->at(c);
- c++;
- }
- while (renderSys->getName().compare("OpenGL Rendering Subsystem")!= 0);
+ renderSys = rsList->at(c);
+ c++;
+ }
+ while (renderSys->getName().compare("OpenGL Rendering Subsystem")!= 0);
- if (renderSys == NULL)
- {
- gzthrow( "unable to find rendering system" );
- }
+ if (renderSys == NULL)
+ {
+ gzthrow( "unable to find rendering system" );
+ }
+ // We operate in windowed mode
+ renderSys->setConfigOption("Full Screen","No");
- renderSys->setConfigOption("Full Screen","No");
- //renderSys->setConfigOption("FSAA","2");
+ // Full screen anti-aliasing
+ renderSys->setConfigOption("FSAA","2");
- // Set the preferred RRT mode. Options are: "PBuffer", "FBO", and "Copy",
can be set in the .gazeborc file
- renderSys->setConfigOption("RTT Preferred Mode",
Simulator::Instance()->GetGazeboConfig()->GetRTTMode());
+ /// We used to allow the user to set the RTT mode to PBuffer, FBO, or Copy.
+ /// Copy is slow, and there doesn't seem to be a good reason to use it
+ /// PBuffer limits the size of the renderable area of the RTT to the
+ /// size of the first window created.
+ /// FBO seem to be the only good option
+ renderSys->setConfigOption("RTT Preferred Mode", "FBO");
- if (create && this->videoMode != "None")
- {
- renderSys->setConfigOption("Video Mode",this->videoMode);
- this->root->setRenderSystem(renderSys);
- }
- else
- {
- std::cerr << "No render system selected\n";
- }
-
- }
+ this->root->setRenderSystem(renderSys);
}
Modified: code/gazebo/trunk/server/rendering/OgreAdaptor.hh
===================================================================
--- code/gazebo/trunk/server/rendering/OgreAdaptor.hh 2009-06-03 10:41:10 UTC
(rev 7772)
+++ code/gazebo/trunk/server/rendering/OgreAdaptor.hh 2009-06-03 13:51:30 UTC
(rev 7773)
@@ -110,7 +110,7 @@
private: void LoadPlugins();
private: void SetupResources();
- private: void SetupRenderSystem(bool create);
+ private: void SetupRenderSystem();
/// Pointer to the root scene node
public: Ogre::Root *root;
@@ -128,8 +128,6 @@
public: Ogre::ColourValue *backgroundColor;
- private: std::string videoMode;
-
private: Ogre::RaySceneQuery *raySceneQuery;
//bsp attributes saved to write XML file back
Modified: code/gazebo/trunk/server/rendering/OgreCamera.cc
===================================================================
--- code/gazebo/trunk/server/rendering/OgreCamera.cc 2009-06-03 10:41:10 UTC
(rev 7772)
+++ code/gazebo/trunk/server/rendering/OgreCamera.cc 2009-06-03 13:51:30 UTC
(rev 7773)
@@ -241,21 +241,40 @@
if (this->captureData)
{
boost::recursive_mutex::scoped_lock
mr_lock(*Simulator::Instance()->GetMRMutex());
- Ogre::HardwarePixelBufferSharedPtr mBuffer;
+
+ Ogre::HardwarePixelBufferSharedPtr pixelBuffer;
+ Ogre::RenderTexture *rTexture;
+ Ogre::Viewport* renderViewport;
+
size_t size;
// Get access to the buffer and make an image and write it to file
- mBuffer = this->renderTexture->getBuffer(0, 0);
+ pixelBuffer = this->renderTexture->getBuffer();
+ rTexture = pixelBuffer->getRenderTarget();
- size = this->imageSizeP->GetValue().x * this->imageSizeP->GetValue().y *
this->GetImageDepth();
+ Ogre::PixelFormat format = pixelBuffer->getFormat();
+ renderViewport = rTexture->getViewport(0);
+ std::cout << "Render viewport["
+ << renderViewport->getActualWidth() << " "
+ << renderViewport->getActualHeight() << "]\n";
+
+ size = Ogre::PixelUtil::getMemorySize((**this->imageSizeP).x,
+ (**this->imageSizeP).y,
+ 1,
+ format);
+
+ //size = this->imageSizeP->GetValue().x * this->imageSizeP->GetValue().y *
this->GetImageDepth();
+
+ printf("Size[%d] [%d]\n",size, this->imageSizeP->GetValue().x *
this->imageSizeP->GetValue().y * this->GetImageDepth());
+
// Allocate buffer
if (!this->saveFrameBuffer)
this->saveFrameBuffer = new unsigned char[size];
memset(this->saveFrameBuffer,128,size);
- mBuffer->lock(Ogre::HardwarePixelBuffer::HBL_READ_ONLY);
+ /*pixelBuffer->lock(Ogre::HardwarePixelBuffer::HBL_READ_ONLY);
int top = (int)((mBuffer->getHeight() - this->imageSizeP->GetValue().y) /
2.0);
int left = (int)((mBuffer->getWidth() - this->imageSizeP->GetValue().x) /
2.0);
@@ -263,7 +282,7 @@
int bottom = top + this->imageSizeP->GetValue().y;
// Get the center of the texture in RGB 24 bit format
- mBuffer->blitToMemory(
+ pixelBuffer->blitToMemory(
Ogre::Box(left, top, right, bottom),
Ogre::PixelBox(
@@ -274,9 +293,14 @@
this->saveFrameBuffer)
);
- mBuffer->unlock();
+ pixelBuffer->unlock();
+ */
+ Ogre::PixelBox box((**this->imageSizeP).x, (**this->imageSizeP).y,
+ 1, this->imageFormat, this->saveFrameBuffer);
+ pixelBuffer->blitToMemory( box );
+
if (this->saveFramesP->GetValue())
{
this->SaveFrame();
@@ -413,7 +437,11 @@
// Get the image size in bytes
size_t OgreCamera::GetImageByteSize() const
{
- return this->imageSizeP->GetValue().y * this->imageSizeP->GetValue().x *
this->GetImageDepth();
+
+ return Ogre::PixelUtil::getMemorySize((**this->imageSizeP).x,
+ (**this->imageSizeP).y,
+ 1,
+ this->imageFormat);
}
Modified: code/gazebo/trunk/server/rendering/OgreCreator.cc
===================================================================
--- code/gazebo/trunk/server/rendering/OgreCreator.cc 2009-06-03 10:41:10 UTC
(rev 7772)
+++ code/gazebo/trunk/server/rendering/OgreCreator.cc 2009-06-03 13:51:30 UTC
(rev 7773)
@@ -625,16 +625,38 @@
if (!Simulator::Instance()->GetRenderEngineEnabled())
return NULL;
+ std::stringstream ogreHandle;
+
Ogre::StringVector paramsVector;
Ogre::NameValuePairList params;
Ogre::RenderWindow *window = NULL;
+ std::string screenStr = DisplayString(display);
+ std::string::size_type dotPos = screenStr.find(".");
+ screenStr = screenStr.substr(dotPos+1, screenStr.size());
+
+ int attrList[] = {GLX_RGBA, GLX_DOUBLEBUFFER, GLX_DEPTH_SIZE, 16,
+ GLX_STENCIL_SIZE, 8, None };
+ XVisualInfo *vi = glXChooseVisual(fl_display, DefaultScreen(display),
+ attrList);
+ XSync(fl_display, false);
+
+ ogreHandle << (unsigned long)fl_display
+ << ":" << screenStr
+ << ":" << (unsigned long)winId
+ << ":" << (unsigned long)vi;
+
+ std::cout << "Ogre Handle[" << ogreHandle.str() << "]\n";
+
/// As of Ogre 1.6 this is the params method that makes a resizable window
- params["externalWindowHandle"] = Ogre::StringConverter::toString(display) +
+ /*params["externalWindowHandle"] = Ogre::StringConverter::toString(display)
+
":" + Ogre::StringConverter::toString(screen) +
":" + Ogre::StringConverter::toString(winId) +
":" + Ogre::StringConverter::toString(fl_visual);
+ */
+ params["externalWindowHandle"] = ogreHandle.str();
+
params["FSAA"] = "2";
std::ostringstream stream;
@@ -645,7 +667,8 @@
{
try
{
- window = OgreAdaptor::Instance()->root->createRenderWindow(
stream.str(), width, height, false, ¶ms);
+ window = OgreAdaptor::Instance()->root->createRenderWindow(
stream.str(),
+ width, height, false, ¶ms);
}
catch (...)
{
@@ -660,6 +683,7 @@
}
window->setActive(true);
+ window->setVisible(true);
window->setAutoUpdated(true);
this->windows.push_back(window);
Modified: code/gazebo/trunk/worlds/epuck.world
===================================================================
--- code/gazebo/trunk/worlds/epuck.world 2009-06-03 10:41:10 UTC (rev
7772)
+++ code/gazebo/trunk/worlds/epuck.world 2009-06-03 13:51:30 UTC (rev
7773)
@@ -53,7 +53,7 @@
<model:physical name="Observercam_model">
<xyz>0 0 2.65</xyz>
- <rpy>-90 90 0</rpy>
+ <rpy>90 90 0</rpy>
<static>true</static>
<body:empty name="Observercam_body">
<sensor:camera name="Observercam_sensor">
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises
looking to deploy the next generation of Solaris that includes the latest
innovations from Sun and the OpenSource community. Download a copy and
enjoy capabilities such as Networking, Storage and Virtualization.
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit