Revision: 8413
          http://playerstage.svn.sourceforge.net/playerstage/?rev=8413&view=rev
Author:   natepak
Date:     2009-11-15 22:34:05 +0000 (Sun, 15 Nov 2009)

Log Message:
-----------
Fixed setting the FOV for user camera. Added triangle rendering count display

Modified Paths:
--------------
    code/gazebo/trunk/Media/materials/scripts/Gazebo.material
    code/gazebo/trunk/server/Simulator.cc
    code/gazebo/trunk/server/gui/GLFrame.cc
    code/gazebo/trunk/server/gui/GLFrame.hh
    code/gazebo/trunk/server/gui/GLWindow.cc
    code/gazebo/trunk/server/gui/GLWindow.hh
    code/gazebo/trunk/server/gui/StatusBar.cc
    code/gazebo/trunk/server/gui/StatusBar.hh
    code/gazebo/trunk/server/rendering/OgreCamera.cc
    code/gazebo/trunk/server/rendering/OgreCamera.hh
    code/gazebo/trunk/server/rendering/OgreCreator.cc
    code/gazebo/trunk/server/rendering/UserCamera.cc
    code/gazebo/trunk/server/rendering/UserCamera.hh
    code/gazebo/trunk/worlds/empty.world
    code/gazebo/trunk/worlds/willowgarage.world

Modified: code/gazebo/trunk/Media/materials/scripts/Gazebo.material
===================================================================
--- code/gazebo/trunk/Media/materials/scripts/Gazebo.material   2009-11-15 
20:08:47 UTC (rev 8412)
+++ code/gazebo/trunk/Media/materials/scripts/Gazebo.material   2009-11-15 
22:34:05 UTC (rev 8413)
@@ -570,6 +570,7 @@
                pass
                {
                        depth_write off
+      lighting off
 
                        texture_unit
                        {

Modified: code/gazebo/trunk/server/Simulator.cc
===================================================================
--- code/gazebo/trunk/server/Simulator.cc       2009-11-15 20:08:47 UTC (rev 
8412)
+++ code/gazebo/trunk/server/Simulator.cc       2009-11-15 22:34:05 UTC (rev 
8413)
@@ -327,7 +327,7 @@
 {
   double currTime = 0;
   double lastTime = 0;
-  double freq = 40.0;
+  double freq = 80.0;
 
 #ifdef TIMING
     double tmpT1 = this->GetWallTime();
@@ -351,6 +351,8 @@
       if (this->renderEngineEnabled)
         OgreAdaptor::Instance()->UpdateCameras();
 
+      currTime = this->GetWallTime();
+
       if (this->gui)
         this->gui->Update();
 
@@ -359,8 +361,6 @@
       if (this->renderEngineEnabled)
         World::Instance()->GraphicsUpdate();
 
-      currTime = this->GetWallTime();
-
       if (currTime - lastTime < 1/freq)
       {
         double sleepTime = (1/freq - (currTime - lastTime));

Modified: code/gazebo/trunk/server/gui/GLFrame.cc
===================================================================
--- code/gazebo/trunk/server/gui/GLFrame.cc     2009-11-15 20:08:47 UTC (rev 
8412)
+++ code/gazebo/trunk/server/gui/GLFrame.cc     2009-11-15 22:34:05 UTC (rev 
8413)
@@ -81,15 +81,38 @@
   this->outputXYZ->textsize(10);
   this->outputXYZ->value("[0.0 0.0 0.0]");
 
-  x1 += this->outputXYZ->w() + 5;
+  x1 += this->outputXYZ->w() + 20;
   this->outputRPY = new Fl_Output(x1, y1, 150, 20,"RPY");
   this->outputRPY->box(FL_NO_BOX);
   this->outputRPY->labelsize(10);
   this->outputRPY->textsize(10);
   this->outputRPY->value("[0.0 0.0 0.0]");
 
+  x1 += this->outputRPY->w();
+
+  Fl_Box *fillerBox = new Fl_Box(x1,y1,this->w() - (x1-x + 175) ,20);
+
+  x1 += fillerBox->w();
+
+  Fl_Group *statsGroup = new Fl_Group(x1, y1,100,20);
+  this->fps = new Fl_Value_Output(x1,y1,25,20,"FPS");
+  this->fps->labelsize(10);
+  this->fps->textsize(10);
+  this->fps->align(FL_ALIGN_RIGHT);
+  this->fps->precision(0);
+
+  x1 += this->fps->w() + 30;
+  this->triangleCount = new Fl_Value_Output(x1,y1,50,20,"Triangles");
+  this->triangleCount->labelsize(10);
+  this->triangleCount->textsize(10);
+  this->triangleCount->align(FL_ALIGN_RIGHT);
+  this->triangleCount->precision(0);
+  statsGroup->resizable(NULL);
+  statsGroup->end();
+
   this->footerBar->end();
   this->footerBar->resizable(NULL);
+  this->footerBar->resizable(fillerBox);
 
   this->end();
 
@@ -170,6 +193,9 @@
      RTOD(pose.rot.GetPitch()), RTOD(pose.rot.GetYaw()) );
   this->outputRPY->value(buff);
 
+  this->fps->value(this->glWindow->GetAvgFPS());
+  this->triangleCount->value(this->glWindow->GetTriangleCount());
+
   this->footerBar->redraw();
 }
 

Modified: code/gazebo/trunk/server/gui/GLFrame.hh
===================================================================
--- code/gazebo/trunk/server/gui/GLFrame.hh     2009-11-15 20:08:47 UTC (rev 
8412)
+++ code/gazebo/trunk/server/gui/GLFrame.hh     2009-11-15 22:34:05 UTC (rev 
8413)
@@ -31,6 +31,7 @@
 #include <FL/Fl_Choice.H>
 #include <FL/Fl_Value_Output.H>
 #include <FL/Fl_Output.H>
+#include <FL/Fl_Box.H>
 #include <string>
 
 #include "Pose3d.hh"
@@ -97,6 +98,9 @@
     private: Fl_Output *outputXYZ;
     private: Fl_Output *outputRPY;
 
+    private: Fl_Value_Output *fps;
+    private: Fl_Value_Output *triangleCount;
+
     /// Starting pose of the camera
     private: Pose3d startPose;
 

Modified: code/gazebo/trunk/server/gui/GLWindow.cc
===================================================================
--- code/gazebo/trunk/server/gui/GLWindow.cc    2009-11-15 20:08:47 UTC (rev 
8412)
+++ code/gazebo/trunk/server/gui/GLWindow.cc    2009-11-15 22:34:05 UTC (rev 
8413)
@@ -195,6 +195,13 @@
 }
 
 
////////////////////////////////////////////////////////////////////////////////
+/// Get the number of triangles being rendered
+unsigned int GLWindow::GetTriangleCount() const
+{
+  return this->activeCamera->GetTriangleCount();
+}
+
+////////////////////////////////////////////////////////////////////////////////
 /// Handle a mouse button push
 void GLWindow::HandleMousePush()
 {

Modified: code/gazebo/trunk/server/gui/GLWindow.hh
===================================================================
--- code/gazebo/trunk/server/gui/GLWindow.hh    2009-11-15 20:08:47 UTC (rev 
8412)
+++ code/gazebo/trunk/server/gui/GLWindow.hh    2009-11-15 22:34:05 UTC (rev 
8413)
@@ -93,9 +93,12 @@
     /// \brief Get a pointer to the camera
     public: UserCamera *GetCamera() const;
 
-    // \brief Get the average FPS for this window
+    /// \brief Get the average FPS for this window
     public: float GetAvgFPS() const;
 
+    /// \brief Get the number of triangles being rendered
+    public: unsigned int GetTriangleCount() const;
+
     /// \brief Set the active camera
     public: void SetActiveCamera( OgreCamera *camera );
 

Modified: code/gazebo/trunk/server/gui/StatusBar.cc
===================================================================
--- code/gazebo/trunk/server/gui/StatusBar.cc   2009-11-15 20:08:47 UTC (rev 
8412)
+++ code/gazebo/trunk/server/gui/StatusBar.cc   2009-11-15 22:34:05 UTC (rev 
8413)
@@ -46,13 +46,7 @@
   y += 5;
 
   this->box(FL_UP_BOX);
-  this->fps = new Fl_Value_Output(x,y,25,20,"FPS");
-  this->fps->labelsize(11);
-  this->fps->textsize(11);
-  this->fps->align(FL_ALIGN_RIGHT);
-  this->fps->precision(0);
 
-  x = this->fps->x() + this->fps->w() + 35;
   this->percentOutput = new Fl_Value_Output(x,y,40,20,"x Real Time");
   this->percentOutput->labelsize(11);
   this->percentOutput->align(FL_ALIGN_RIGHT);
@@ -109,15 +103,12 @@
 /// Update the toolbar data
 void StatusBar::Update()
 {
-  float avgFPS = 0;
   //float percent = 0;
   float sim = 0;
   float real = 0;
 
   if (Simulator::Instance()->GetRealTime() - this->lastUpdateTime > 
this->statusUpdatePeriod)
   {
-    avgFPS = this->gui->GetAvgFPS();
-
     if (Simulator::Instance()->GetRealTime() < this->statusUpdatePeriod )
     {
       this->percent = (Simulator::Instance()->GetSimTime() / 
Simulator::Instance()->GetRealTime());
@@ -177,7 +168,6 @@
     }
 
     //this->iterations->value(Simulator::Instance()->GetIterations());
-    this->fps->value(avgFPS);
     this->percentOutput->value(this->percent);
 
     //if (Simulator::Instance()->GetRealTime() - this->realTime->value() > 0.1)

Modified: code/gazebo/trunk/server/gui/StatusBar.hh
===================================================================
--- code/gazebo/trunk/server/gui/StatusBar.hh   2009-11-15 20:08:47 UTC (rev 
8412)
+++ code/gazebo/trunk/server/gui/StatusBar.hh   2009-11-15 22:34:05 UTC (rev 
8413)
@@ -55,7 +55,6 @@
 
     private: Fl_Value_Output *iterations;
     private: Fl_Value_Output *percentOutput;
-    private: Fl_Value_Output *fps;
     private: Fl_Value_Output *realTime;
     private: Fl_Value_Output *pauseTime;
     private: Fl_Value_Output *simTime;

Modified: code/gazebo/trunk/server/rendering/OgreCamera.cc
===================================================================
--- code/gazebo/trunk/server/rendering/OgreCamera.cc    2009-11-15 20:08:47 UTC 
(rev 8412)
+++ code/gazebo/trunk/server/rendering/OgreCamera.cc    2009-11-15 22:34:05 UTC 
(rev 8413)
@@ -68,7 +68,7 @@
 
   Param::Begin(&this->camParameters);
   this->nearClipP = new ParamT<double>("nearClip",0.1,0);
-  this->farClipP = new ParamT<double>("farClip",100,0);
+  this->farClipP = new ParamT<double>("farClip",50,0);
   this->saveFramesP = new ParamT<bool>("saveFrames",false,0);
   this->savePathnameP = new ParamT<std::string>("saveFramePath","",0);
   this->imageSizeP = new ParamT< Vector2<int> >("imageSize", Vector2<int>(320, 
240),0);
@@ -188,7 +188,9 @@
   if (!Simulator::Instance()->GetRenderEngineEnabled())
     return;
 
-  this->camera = OgreCreator::CreateCamera(this->cameraName, 
this->nearClipP->GetValue(), this->farClipP->GetValue(), 
*(this->hfovP->GetValue()), this->renderTarget );
+  this->camera = OgreCreator::CreateCamera(this->cameraName, 
+      **this->nearClipP, **this->farClipP, *(**this->hfovP), 
+      this->renderTarget );
 
   // Create a scene node to control pitch motion
   this->pitchNode = this->sceneNode->createChildSceneNode( this->cameraName + 
"PitchNode");

Modified: code/gazebo/trunk/server/rendering/OgreCamera.hh
===================================================================
--- code/gazebo/trunk/server/rendering/OgreCamera.hh    2009-11-15 20:08:47 UTC 
(rev 8412)
+++ code/gazebo/trunk/server/rendering/OgreCamera.hh    2009-11-15 22:34:05 UTC 
(rev 8413)
@@ -184,6 +184,9 @@
     /// \brief Get the average FPS
     public: virtual float GetAvgFPS() { return 0;}
 
+    /// \brief Get the triangle count
+    public: virtual unsigned int GetTriangleCount() {return 0;}
+
     /// \brief Set the aspect ratio
     public: void SetAspectRatio( float ratio );
 
@@ -211,7 +214,6 @@
     // Save the camera frame
     protected: virtual void SaveFrame();
 
-
     private: std::string name;
 
     protected: ParamT<Angle> *hfovP;
@@ -219,7 +221,7 @@
     protected: ParamT< Vector2<int> > *imageSizeP;
     protected: unsigned int textureWidth, textureHeight;
   
-    private: Ogre::Camera *camera;
+    protected: Ogre::Camera *camera;
     protected: Ogre::SceneNode *sceneNode;
     protected: Ogre::SceneNode *pitchNode;
   

Modified: code/gazebo/trunk/server/rendering/OgreCreator.cc
===================================================================
--- code/gazebo/trunk/server/rendering/OgreCreator.cc   2009-11-15 20:08:47 UTC 
(rev 8412)
+++ code/gazebo/trunk/server/rendering/OgreCreator.cc   2009-11-15 22:34:05 UTC 
(rev 8413)
@@ -288,11 +288,11 @@
     // Setup the viewport to use the texture
     cviewport = renderTarget->addViewport(camera);
     cviewport->setClearEveryFrame(true);
-    //cviewport->setBackgroundColour( 
*OgreAdaptor::Instance()->backgroundColor );
-    cviewport->setBackgroundColour( Ogre::ColourValue::Blue );
+    cviewport->setBackgroundColour( *OgreAdaptor::Instance()->backgroundColor 
);
 
     double ratio = (double)cviewport->getActualWidth() / 
(double)cviewport->getActualHeight();
     double vfov = 2.0 * atan(tan(hfov / 2.0) / ratio);
+    std::cout << "VFOV[" << vfov << "]\n";
     camera->setAspectRatio(ratio);
     camera->setFOVy(Ogre::Radian(vfov));
   }
@@ -397,7 +397,8 @@
         {*/
       Ogre::Quaternion orientation;
       orientation.FromAngleAxis( Ogre::Degree(90), Ogre::Vector3(1,0,0));
-      OgreAdaptor::Instance()->sceneMgr->setSkyDome(true,material,5,8, 4000, 
true, orientation);
+      //OgreAdaptor::Instance()->sceneMgr->setSkyDome(true,material,5,8, 4000, 
true, orientation);
+      OgreAdaptor::Instance()->sceneMgr->setSkyDome(true,material,10,8, 4, 
true, orientation);
       //}
 
     }

Modified: code/gazebo/trunk/server/rendering/UserCamera.cc
===================================================================
--- code/gazebo/trunk/server/rendering/UserCamera.cc    2009-11-15 20:08:47 UTC 
(rev 8412)
+++ code/gazebo/trunk/server/rendering/UserCamera.cc    2009-11-15 22:34:05 UTC 
(rev 8413)
@@ -69,9 +69,8 @@
 {
   OgreCamera::LoadCam(node);
 
-  this->SetClipDist(0.1, 50);
   this->SetFOV( DTOR(60) );
-
+  this->SetClipDist(0.2, 50);
 }
 
 
////////////////////////////////////////////////////////////////////////////////
@@ -138,10 +137,17 @@
 
   this->visual->AttachObject(line);
 
-  //this->renderTarget = this->window;
-
   this->SetCamera(this);
   this->lastUpdate = Simulator::Instance()->GetRealTime();
+
+  double ratio = (double)this->viewport->getActualWidth() / 
(double)this->viewport->getActualHeight();
+  double vfov = fabs(2.0 * atan(tan(this->GetHFOV().GetAsRadian() / 2.0) / 
ratio));
+  this->GetOgreCamera()->setAspectRatio(ratio);
+  this->GetOgreCamera()->setFOVy(Ogre::Radian(vfov));
+
+  this->viewport->setClearEveryFrame(true);
+  this->viewport->setBackgroundColour( 
*OgreAdaptor::Instance()->backgroundColor );
+  this->viewport->setVisibilityMask(this->visibilityMask);
 }
 
 void UserCamera::SetCamera( OgreCamera *cam )
@@ -152,11 +158,9 @@
     cam = this;
 
   this->viewport = this->window->addViewport(cam->GetOgreCamera());
-  this->viewport->setBackgroundColour(Ogre::ColourValue::Black);
 
   this->SetAspectRatio( Ogre::Real(this->viewport->getActualWidth()) / 
Ogre::Real(this->viewport->getActualHeight()) );
 
-  this->viewport->setVisibilityMask(this->visibilityMask);
 }
 
 
@@ -230,6 +234,13 @@
 }
 
 
////////////////////////////////////////////////////////////////////////////////
+/// Get the triangle count
+unsigned int UserCamera::GetTriangleCount()
+{
+  return this->window->getTriangleCount();
+}
+
+////////////////////////////////////////////////////////////////////////////////
 /// Get the ogre window
 Ogre::RenderWindow *UserCamera::GetWindow()
 {

Modified: code/gazebo/trunk/server/rendering/UserCamera.hh
===================================================================
--- code/gazebo/trunk/server/rendering/UserCamera.hh    2009-11-15 20:08:47 UTC 
(rev 8412)
+++ code/gazebo/trunk/server/rendering/UserCamera.hh    2009-11-15 22:34:05 UTC 
(rev 8413)
@@ -75,6 +75,9 @@
     /// \brief Get the average FPS
     public: virtual float GetAvgFPS();
 
+    /// \brief Get the triangle count
+    public: unsigned int GetTriangleCount();
+
     /// \brief Get the ogre window
     public: Ogre::RenderWindow *GetWindow();
 

Modified: code/gazebo/trunk/worlds/empty.world
===================================================================
--- code/gazebo/trunk/worlds/empty.world        2009-11-15 20:08:47 UTC (rev 
8412)
+++ code/gazebo/trunk/worlds/empty.world        2009-11-15 22:34:05 UTC (rev 
8413)
@@ -37,6 +37,7 @@
     <shadowTechnique>stencilAdditive</shadowTechnique>
     <grid>false</grid>
   </rendering:ogre>
+
    <!-- Ground Plane -->
    <model:physical name="plane1_model">
     <xyz>0 0 0</xyz>

Modified: code/gazebo/trunk/worlds/willowgarage.world
===================================================================
--- code/gazebo/trunk/worlds/willowgarage.world 2009-11-15 20:08:47 UTC (rev 
8412)
+++ code/gazebo/trunk/worlds/willowgarage.world 2009-11-15 22:34:05 UTC (rev 
8413)
@@ -87,6 +87,7 @@
     </body:trimesh>
   </model:physical>
 
+  <!--
   <model:physical name="pr2_model">
     <xyz>0 0 0</xyz>
     <rpy>0.0 0.0 0.0</rpy>
@@ -107,8 +108,8 @@
         <updateRate>20.0</updateRate>
       </sensor:camera>
     </body:box>
-
   </model:physical>
+  -->
 
 
   <!-- White Point light -->


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

Reply via email to