Revision: 7058 http://playerstage.svn.sourceforge.net/playerstage/?rev=7058&view=rev Author: natepak Date: 2008-10-03 22:22:42 +0000 (Fri, 03 Oct 2008)
Log Message: ----------- Fixed some problems with point lights. Improved UV tiling of boxes Modified Paths: -------------- code/gazebo/trunk/server/Simulator.cc code/gazebo/trunk/server/gui/GLWindow.cc code/gazebo/trunk/server/gui/Gui.cc code/gazebo/trunk/server/rendering/OgreCamera.cc code/gazebo/trunk/server/rendering/OgreCreator.cc code/gazebo/trunk/server/rendering/OgreSimpleShape.cc code/gazebo/trunk/server/rendering/OgreSimpleShape.hh code/gazebo/trunk/server/rendering/OgreVisual.cc code/gazebo/trunk/server/rendering/OgreVisual.hh code/gazebo/trunk/server/rendering/UserCamera.cc Modified: code/gazebo/trunk/server/Simulator.cc =================================================================== --- code/gazebo/trunk/server/Simulator.cc 2008-10-02 00:44:06 UTC (rev 7057) +++ code/gazebo/trunk/server/Simulator.cc 2008-10-03 22:22:42 UTC (rev 7058) @@ -158,6 +158,8 @@ // Create the GUI this->gui = new Gui(x, y, width, height, "Gazebo"); + Fl::check(); + Fl::wait(0.3); this->gui->Load(childNode); } } Modified: code/gazebo/trunk/server/gui/GLWindow.cc =================================================================== --- code/gazebo/trunk/server/gui/GLWindow.cc 2008-10-02 00:44:06 UTC (rev 7057) +++ code/gazebo/trunk/server/gui/GLWindow.cc 2008-10-03 22:22:42 UTC (rev 7058) @@ -450,7 +450,7 @@ // Handle resizing the window void GLWindow::resize(int x, int y, int w, int h) { - Fl_Window::resize(x,y,w,h); + Fl_Gl_Window::resize(x,y,w,h); this->userCamera->Resize(w,h); this->redraw(); Modified: code/gazebo/trunk/server/gui/Gui.cc =================================================================== --- code/gazebo/trunk/server/gui/Gui.cc 2008-10-02 00:44:06 UTC (rev 7057) +++ code/gazebo/trunk/server/gui/Gui.cc 2008-10-03 22:22:42 UTC (rev 7058) @@ -29,6 +29,7 @@ #include <FL/Fl_Menu_Item.H> #include <FL/Fl_Menu_Bar.H> #include <FL/Fl_Choice.H> +#include <FL/Fl_Gl_Window.H> #include "Global.hh" #include "XMLConfig.hh" @@ -89,6 +90,7 @@ this->show(); Fl::check(); + Fl::wait(0.3); // Create a dummy rendering window. This creates a context, and allows Ogre // to initialize properly Modified: code/gazebo/trunk/server/rendering/OgreCamera.cc =================================================================== --- code/gazebo/trunk/server/rendering/OgreCamera.cc 2008-10-02 00:44:06 UTC (rev 7057) +++ code/gazebo/trunk/server/rendering/OgreCamera.cc 2008-10-03 22:22:42 UTC (rev 7058) @@ -158,6 +158,7 @@ this->pitchNode = this->sceneNode->createChildSceneNode( this->cameraName + "PitchNode"); this->pitchNode->pitch(Ogre::Degree(0)); this->pitchNode->attachObject(this->camera); + this->camera->setAutoAspectRatio(true); this->saveCount = 0; Modified: code/gazebo/trunk/server/rendering/OgreCreator.cc =================================================================== --- code/gazebo/trunk/server/rendering/OgreCreator.cc 2008-10-02 00:44:06 UTC (rev 7057) +++ code/gazebo/trunk/server/rendering/OgreCreator.cc 2008-10-03 22:22:42 UTC (rev 7058) @@ -68,7 +68,8 @@ // Create some basic shapes OgreSimpleShape::CreateSphere("unit_sphere",1.0, 32, 32); OgreSimpleShape::CreateSphere("joint_anchor",0.01, 32, 32); - OgreSimpleShape::CreateBox("unit_box", Vector3(1,1,1)); + OgreSimpleShape::CreateBox("unit_box_U1V1", Vector3(1,1,1), + Vector2<double>(1,1)); OgreSimpleShape::CreateCylinder("unit_cylinder", 0.5, 1.0, 1, 32); } @@ -159,7 +160,7 @@ // Set the direction which the light points vec = node->GetVector3("direction", Vector3(0.0, 0.0, -1.0)); - light->setDirection(vec.x, vec.y, vec.z); + //light->setDirection(vec.x, vec.y, vec.z); // Absolute range of light in world coordinates range = node->GetTupleDouble("attenuation",0,1000); @@ -571,6 +572,7 @@ Ogre::RenderWindow *window = NULL; params["parentWindowHandle"] = Ogre::StringConverter::toString(display) + ":" + Ogre::StringConverter::toString(screen) + ":" + Ogre::StringConverter::toString(winId); + //params["FSAA"] = Ogre::StringConverter::toString(2); std::ostringstream stream; stream << "OgreWindow(" << windowCounter++ << ")"; Modified: code/gazebo/trunk/server/rendering/OgreSimpleShape.cc =================================================================== --- code/gazebo/trunk/server/rendering/OgreSimpleShape.cc 2008-10-02 00:44:06 UTC (rev 7057) +++ code/gazebo/trunk/server/rendering/OgreSimpleShape.cc 2008-10-03 22:22:42 UTC (rev 7058) @@ -162,7 +162,8 @@ //////////////////////////////////////////////////////////////////////////////// /// Create a Box mesh -void OgreSimpleShape::CreateBox(const std::string &name, const Vector3 &sides) +void OgreSimpleShape::CreateBox(const std::string &name, const Vector3 &sides, + const Vector2<double> &uvCoords) { Ogre::MeshPtr mesh; Ogre::SubMesh *subMesh; @@ -237,33 +238,33 @@ // 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} + {-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}, + {-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 - int t[4][2] = + float t[4][2] = { - {0, 1}, {1,1}, {1, 0}, {0,0} + {uvCoords.x, 0}, {0, 0}, {0,uvCoords.y}, {uvCoords.x, uvCoords.y} }; // Vertices int faces[6][4] = { - {2, 1, 0, 3}, {6, 7, 4, 5}, + {2, 1, 0, 3}, {5, 6, 7, 4}, {2, 6, 5, 1}, {1, 5, 4, 0}, {0, 4, 7, 3}, {6, 2, 3, 7} }; @@ -275,14 +276,14 @@ 2, 3, 0, 4, 5, 7, 7, 5, 6, - 8, 9, 11, - 11, 9, 10, + 11,8,9, + 9,10,11, 12, 13, 15, 15, 13, 14, 16, 17, 18, 18, 19, 16, - 20, 21, 23, - 23, 21, 22 + 21,22,23, + 23,20,21, }; // Compute the vertices @@ -301,7 +302,9 @@ { // Set the vertex for (j=0; j<3; j++) + { *vertices++ = v[faces[i][k]][j]; + } // Set the normal for (j=0; j<3; j++) Modified: code/gazebo/trunk/server/rendering/OgreSimpleShape.hh =================================================================== --- code/gazebo/trunk/server/rendering/OgreSimpleShape.hh 2008-10-02 00:44:06 UTC (rev 7057) +++ code/gazebo/trunk/server/rendering/OgreSimpleShape.hh 2008-10-03 22:22:42 UTC (rev 7058) @@ -4,6 +4,7 @@ #include <Ogre.h> #include "Vector3.hh" +#include "Vector2.hh" namespace gazebo { @@ -23,7 +24,8 @@ public: static void CreateSphere(const std::string &name, float radius, int rings, int segments); /// \brief Create a Box mesh - public: static void CreateBox(const std::string &name, const Vector3 &sides); + public: static void CreateBox(const std::string &name, const Vector3 &sides, + const Vector2<double> &uvCoords); /// \brief Create a cylinder mesh public: static void CreateCylinder(const std::string &name, float radius, float height, int rings, int segments); Modified: code/gazebo/trunk/server/rendering/OgreVisual.cc =================================================================== --- code/gazebo/trunk/server/rendering/OgreVisual.cc 2008-10-02 00:44:06 UTC (rev 7057) +++ code/gazebo/trunk/server/rendering/OgreVisual.cc 2008-10-03 22:22:42 UTC (rev 7058) @@ -24,6 +24,7 @@ * SVN: $Id$ */ #include <Ogre.h> +#include "OgreSimpleShape.hh" #include "Entity.hh" #include "GazeboMessage.hh" #include "GazeboError.hh" @@ -67,6 +68,8 @@ this->rpyP->Callback( &OgreVisual::SetRotation, this ); this->meshNameP = new ParamT<std::string>("mesh","",1); + this->meshTileP = new ParamT< Vector2<double> >("uvTile", + Vector2<double>(1.0, 1.0), 0 ); this->materialNameP = new ParamT<std::string>("material",std::string(),0); this->materialNameP->Callback( &OgreVisual::SetMaterial, this ); @@ -89,6 +92,7 @@ delete this->xyzP; delete this->rpyP; delete this->meshNameP; + delete this->meshTileP; delete this->materialNameP; delete this->castShadowsP; } @@ -106,6 +110,7 @@ this->xyzP->Load(node); this->rpyP->Load(node); this->meshNameP->Load(node); + this->meshTileP->Load(node); this->materialNameP->Load(node); this->castShadowsP->Load(node); @@ -117,7 +122,21 @@ { // Create the entity stream << "ENTITY_" << this->sceneNode->getName(); - obj = (Ogre::MovableObject*)this->sceneNode->getCreator()->createEntity(stream.str(), this->meshNameP->GetValue()); + std::string meshName = (**this->meshNameP); + + if ( meshName == "unit_box") + { + meshName += "_U" + + boost::lexical_cast<std::string>(this->meshTileP->GetValue().x) + "V" + + boost::lexical_cast<std::string>(this->meshTileP->GetValue().y); + + if (!this->sceneNode->getCreator()->hasEntity(meshName)) + { + OgreSimpleShape::CreateBox(meshName, Vector3(1,1,1), **this->meshTileP); + } + } + + obj = (Ogre::MovableObject*)this->sceneNode->getCreator()->createEntity(stream.str(), meshName); } catch (Ogre::Exception e) { @@ -537,7 +556,7 @@ this->boundingBoxNode = this->sceneNode->createChildSceneNode(nodeName.str()); this->boundingBoxNode->setInheritScale(false); - Ogre::MovableObject *odeObj = (Ogre::MovableObject*)(this->sceneNode->getCreator()->createEntity(nodeName.str()+"_OBJ", "unit_box")); + Ogre::MovableObject *odeObj = (Ogre::MovableObject*)(this->sceneNode->getCreator()->createEntity(nodeName.str()+"_OBJ", "unit_box_U1V1")); this->boundingBoxNode->attachObject(odeObj); Vector3 diff = max-min; Modified: code/gazebo/trunk/server/rendering/OgreVisual.hh =================================================================== --- code/gazebo/trunk/server/rendering/OgreVisual.hh 2008-10-02 00:44:06 UTC (rev 7057) +++ code/gazebo/trunk/server/rendering/OgreVisual.hh 2008-10-03 22:22:42 UTC (rev 7058) @@ -147,6 +147,7 @@ private: ParamT<bool> *castShadowsP; private: ParamT<Vector3> *sizeP; private: ParamT<Vector3> *scaleP; + private: ParamT<Vector2<double> > *meshTileP; }; } Modified: code/gazebo/trunk/server/rendering/UserCamera.cc =================================================================== --- code/gazebo/trunk/server/rendering/UserCamera.cc 2008-10-02 00:44:06 UTC (rev 7057) +++ code/gazebo/trunk/server/rendering/UserCamera.cc 2008-10-03 22:22:42 UTC (rev 7058) @@ -98,9 +98,14 @@ /// Resize the camera void UserCamera::Resize(unsigned int w, unsigned int h) { - this->window->resize(w, h); - this->viewport->setDimensions(0,0,1,1); - this->SetAspectRatio( Ogre::Real(this->viewport->getActualWidth()) / Ogre::Real(this->viewport->getActualHeight()) ); + //this->window->resize(w, h); + //this->viewport->setDimensions(0,0,1,1); + //this->SetAspectRatio( Ogre::Real(this->viewport->getActualWidth()) / Ogre::Real(this->viewport->getActualHeight()) ); + //this->viewport->update(); + //this->viewport->_updateDimensions(); + + this->window->windowMovedOrResized(); + printf("Resize[%d %d] new[%d %d]\n", w, h, this->window->getWidth(), this->window->getHeight()); } //////////////////////////////////////////////////////////////////////////////// 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 Playerstage-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/playerstage-commit