Revision: 7110
http://playerstage.svn.sourceforge.net/playerstage/?rev=7110&view=rev
Author: natepak
Date: 2008-10-21 21:46:11 +0000 (Tue, 21 Oct 2008)
Log Message:
-----------
Added the ability to save frames from a user camera
Modified Paths:
--------------
code/gazebo/trunk/server/gui/GLFrame.cc
code/gazebo/trunk/server/gui/GLFrame.hh
code/gazebo/trunk/server/rendering/OgreCamera.cc
code/gazebo/trunk/server/rendering/OgreCamera.hh
code/gazebo/trunk/server/rendering/UserCamera.cc
code/gazebo/trunk/server/rendering/UserCamera.hh
Modified: code/gazebo/trunk/server/gui/GLFrame.cc
===================================================================
--- code/gazebo/trunk/server/gui/GLFrame.cc 2008-10-20 20:02:26 UTC (rev
7109)
+++ code/gazebo/trunk/server/gui/GLFrame.cc 2008-10-21 21:46:11 UTC (rev
7110)
@@ -107,11 +107,14 @@
// Load the frame
void GLFrame::Load( XMLConfigNode *node )
{
+ this->saveFrames = false;
if (node)
{
this->startPose.pos = node->GetVector3("xyz", Vector3(0,0,0));
this->startPose.rot = node->GetRotation("rpy", Quatern());
+ this->saveFrames = node->GetBool("saveFrames",false,0);
+ this->savePathname = node->GetString("saveFramePath","",0);
}
}
@@ -122,6 +125,8 @@
{
this->glWindow->Init();
this->glWindow->GetCamera()->SetWorldPose(this->startPose);
+ this->glWindow->GetCamera()->EnableSaveFrame(this->saveFrames);
+ this->glWindow->GetCamera()->SetSaveFramePathname(this->savePathname);
CameraManager::Instance()->ConnectAddCameraSignal(
boost::bind(&GLFrame::CameraAddedSlot, this, _1) );
}
Modified: code/gazebo/trunk/server/gui/GLFrame.hh
===================================================================
--- code/gazebo/trunk/server/gui/GLFrame.hh 2008-10-20 20:02:26 UTC (rev
7109)
+++ code/gazebo/trunk/server/gui/GLFrame.hh 2008-10-21 21:46:11 UTC (rev
7110)
@@ -96,6 +96,9 @@
/// Starting pose of the camera
private: Pose3d startPose;
+
+ private: bool saveFrames;
+ private: std::string savePathname;
};
}
Modified: code/gazebo/trunk/server/rendering/OgreCamera.cc
===================================================================
--- code/gazebo/trunk/server/rendering/OgreCamera.cc 2008-10-20 20:02:26 UTC
(rev 7109)
+++ code/gazebo/trunk/server/rendering/OgreCamera.cc 2008-10-21 21:46:11 UTC
(rev 7110)
@@ -313,6 +313,21 @@
}
//////////////////////////////////////////////////////////////////////////////
+// Set the save frame pathname
+void OgreCamera::SetSaveFramePathname(const std::string &pathname)
+{
+ this->savePathnameP->SetValue( pathname );
+
+ // Create the directory to store frames
+ if (this->saveFramesP->GetValue())
+ {
+ std::string command;
+ command = "mkdir " + this->savePathnameP->GetValue() + " 2>>/dev/null";
+ system(command.c_str());
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
/// Toggle saving of frames
void OgreCamera::ToggleSaveFrame()
{
Modified: code/gazebo/trunk/server/rendering/OgreCamera.hh
===================================================================
--- code/gazebo/trunk/server/rendering/OgreCamera.hh 2008-10-20 20:02:26 UTC
(rev 7109)
+++ code/gazebo/trunk/server/rendering/OgreCamera.hh 2008-10-21 21:46:11 UTC
(rev 7110)
@@ -141,7 +141,10 @@
/// \brief Enable or disable saving
public: void EnableSaveFrame(bool enable);
-
+
+ /// \brief Set the save frame pathname
+ public: void SetSaveFramePathname(const std::string &pathname);
+
/// \brief Toggle saving of frames
public: void ToggleSaveFrame();
Modified: code/gazebo/trunk/server/rendering/UserCamera.cc
===================================================================
--- code/gazebo/trunk/server/rendering/UserCamera.cc 2008-10-20 20:02:26 UTC
(rev 7109)
+++ code/gazebo/trunk/server/rendering/UserCamera.cc 2008-10-21 21:46:11 UTC
(rev 7110)
@@ -36,13 +36,21 @@
using namespace gazebo;
+int UserCamera::count = 0;
+
////////////////////////////////////////////////////////////////////////////////
/// Constructor
UserCamera::UserCamera(GLWindow *parentWindow)
: OgreCamera("UserCamera")
{
+ std::stringstream stream;
+
this->window = OgreCreator::CreateWindow(parentWindow,
parentWindow->w(), parentWindow->h());
+
+
+ stream << "UserCamera_" << this->count++;
+ this->name = stream.str();
}
////////////////////////////////////////////////////////////////////////////////
@@ -75,6 +83,7 @@
this->SetAspectRatio( Ogre::Real(this->viewport->getActualWidth()) /
Ogre::Real(this->viewport->getActualHeight()) );
this->viewport->setVisibilityMask(this->visibilityMask);
+
}
////////////////////////////////////////////////////////////////////////////////
@@ -84,6 +93,25 @@
OgreCamera::UpdateCam();
OgreAdaptor::Instance()->UpdateWindow(this->window, this);
+
+
+ if (this->saveFramesP->GetValue())
+ {
+ char tmp[1024];
+ if (!this->savePathnameP->GetValue().empty())
+ {
+ sprintf(tmp, "%s/%s-%04d.jpg", this->savePathnameP->GetValue().c_str(),
+ this->name.c_str(), this->saveCount);
+ }
+ else
+ {
+ sprintf(tmp, "%s-%04d.jpg", this->name.c_str(), this->saveCount);
+ }
+
+ this->window->writeContentsToFile(tmp);
+
+ this->saveCount++;
+ }
}
Modified: code/gazebo/trunk/server/rendering/UserCamera.hh
===================================================================
--- code/gazebo/trunk/server/rendering/UserCamera.hh 2008-10-20 20:02:26 UTC
(rev 7109)
+++ code/gazebo/trunk/server/rendering/UserCamera.hh 2008-10-21 21:46:11 UTC
(rev 7110)
@@ -80,6 +80,7 @@
private: std::string name;
private: static unsigned int cameraCount;
+ private: static int count;
};
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit