From: Oliver O. <fr...@us...> - 2007-06-17 13:39:37
|
Update of /cvsroot/simspark/simspark/spark/kerosin/renderserver In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv21072/kerosin/renderserver Modified Files: rendercontrol.cpp rendercontrol.h rendercontrol_c.cpp renderserver.cpp renderserver.h renderserver_c.cpp Added Files: baserenderserver.cpp baserenderserver.h baserenderserver_c.cpp Log Message: merge from projectx branch --- NEW FILE: baserenderserver.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of simspark Tue May 9 2006 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2007 RoboCup Soccer Server 3D Maintenance Group $Id: baserenderserver.cpp,v 1.2 2007/06/17 13:38:30 fruit Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. BaseRenderServer NOTE: This is an abstract renderserver in order to support different render servers HISTORY: 29/03/07 - OO - Initial version */ #include "baserenderserver.h" #include <oxygen/sceneserver/sceneserver.h> #include <oxygen/sceneserver/scene.h> #include <zeitgeist/logserver/logserver.h> using namespace oxygen; using namespace kerosin; using namespace salt; using namespace zeitgeist; void BaseRenderServer::OnLink() { // setup SceneServer reference RegisterCachedPath(mSceneServer, "/sys/server/scene"); if (mSceneServer.expired()) { GetLog()->Error() << "(BaseRenderServer) ERROR: SceneServer not found\n"; } } void BaseRenderServer::OnUnlink() { mActiveScene.reset(); Leaf::OnUnlink(); } bool BaseRenderServer::GetActiveScene() { if (mSceneServer.expired()) { mActiveScene.reset(); } mActiveScene = mSceneServer->GetActiveScene(); if (mActiveScene.get() == 0) { GetLog()->Error() << "(BaseRenderServer) ERROR: found no active scene\n"; return false; } return true; } void BaseRenderServer::UpdateCached() { mActiveScene.reset(); } --- NEW FILE: baserenderserver.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of simspark Tue May 9 2006 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2007 RoboCup Soccer Server 3D Maintenance Group $Id: baserenderserver.h,v 1.2 2007/06/17 13:38:31 fruit Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. BaseRenderServer NOTE: This is an abstract renderserver in order to support different render servers HISTORY: 29/03/07 - OO - Initial version */ #ifndef KEROSIN_BASERENDERSERVER_H #define KEROSIN_BASERENDERSERVER_H #include <zeitgeist/class.h> #include <zeitgeist/leaf.h> namespace oxygen { class Scene; class SceneServer; class Camera; class BaseNode; } namespace kerosin { class BaseRenderServer : public zeitgeist::Leaf { public: virtual ~BaseRenderServer() {} //! display the current active scene virtual void Render() = 0; //! width of the render target virtual int Width() const { return 0; } //! height of the render target virtual int Height() const { return 0; } //! get a shot of the current frame virtual bool CopyFrame(char* /* buffer */) const { return false; } protected: /** get the active scene node from the sceneServer */ virtual bool GetActiveScene(); /** set up SceneServer reference */ virtual void OnLink(); /** reset SceneServer reference */ virtual void OnUnlink(); /** update variables from a script */ virtual void UpdateCached(); // // Members // protected: /** reference to the current active scene */ boost::shared_ptr<oxygen::Scene> mActiveScene; /** reference to the SceneServer */ CachedPath<oxygen::SceneServer> mSceneServer; }; DECLARE_ABSTRACTCLASS(BaseRenderServer); } //namespace kerosin #endif // KEROSIN_BASERENDERSERVER_H Index: renderserver_c.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/kerosin/renderserver/renderserver_c.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** renderserver_c.cpp 5 Dec 2005 21:38:23 -0000 1.1 --- renderserver_c.cpp 17 Jun 2007 13:38:31 -0000 1.2 *************** *** 1,2 **** --- 1,23 ---- + /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- + + this file is part of simspark + Tue May 9 2006 + Copyright (C) 2002,2003 Koblenz University + Copyright (C) 2007 RoboCup Soccer Server 3D Maintenance Group + $Id$ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ #include "renderserver.h" *************** *** 6,11 **** ! void CLASS(RenderServer)::DefineClass() { ! DEFINE_BASECLASS(zeitgeist/Leaf); } --- 27,33 ---- ! void ! CLASS(RenderServer)::DefineClass() { ! DEFINE_BASECLASS(kerosin/BaseRenderServer); } Index: renderserver.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/kerosin/renderserver/renderserver.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** renderserver.cpp 9 Apr 2007 17:02:25 -0000 1.4 --- renderserver.cpp 17 Jun 2007 13:38:31 -0000 1.5 *************** *** 1,28 **** /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- ! this file is part of rcssserver3D ! Fri May 9 2003 ! Copyright (C) 2002,2003 Koblenz University ! Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group ! $Id$ ! This program is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; version 2 of the License. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - #include "renderserver.h" #include <oxygen/sceneserver/sceneserver.h> #include <oxygen/sceneserver/scene.h> #include <oxygen/sceneserver/camera.h> #include <kerosin/openglserver/openglwrapper.h> #include <kerosin/sceneserver/staticmesh.h> --- 1,28 ---- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- ! this file is part of rcssserver3D ! Fri May 9 2003 ! Copyright (C) 2002,2003 Koblenz University ! Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group ! $Id$ ! This program is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; version 2 of the License. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "renderserver.h" #include <oxygen/sceneserver/sceneserver.h> #include <oxygen/sceneserver/scene.h> #include <oxygen/sceneserver/camera.h> + #include <oxygen/physicsserver/spherecollider.h> #include <kerosin/openglserver/openglwrapper.h> #include <kerosin/sceneserver/staticmesh.h> *************** *** 39,43 **** static GLuint gSelectBuffer[4096]; ! RenderServer::RenderServer() : Leaf() { mAmbientColor = RGBA(0.0,0.0,0.0,0.0); --- 39,43 ---- static GLuint gSelectBuffer[4096]; ! RenderServer::RenderServer() : BaseRenderServer() { mAmbientColor = RGBA(0.0,0.0,0.0,0.0); *************** *** 48,95 **** } - RenderServer::~RenderServer() - { - } - - void - RenderServer::OnLink() - { - // setup SceneServer reference - RegisterCachedPath(mSceneServer, "/sys/server/scene"); - - if (mSceneServer.expired()) - { - GetLog()->Error() - << "(RenderServer) ERROR: SceneServer not found\n"; - } - } - - void - RenderServer::OnUnlink() - { - mActiveScene.reset(); - Leaf::OnUnlink(); - } - - bool - RenderServer::GetActiveScene() - { - if (mSceneServer.expired()) - { - mActiveScene.reset(); - } - - mActiveScene = mSceneServer->GetActiveScene(); - - if (mActiveScene.get() == 0) - { - GetLog()->Error() << - "(RenderServer) ERROR: found no active scene\n"; - return false; - } - - return true; - } - void RenderServer::PreparePicking() --- 48,51 ---- *************** *** 107,113 **** if (! GetActiveScene()) ! { ! return; ! } // get a camera to render with --- 63,69 ---- if (! GetActiveScene()) ! { ! return; ! } // get a camera to render with *************** *** 116,124 **** if (camera.get() == 0) ! { ! GetLog()->Error() ! << "(RenderServer) ERROR: found no camera node in the active scene\n"; ! return; ! } glClearColor( --- 72,80 ---- if (camera.get() == 0) ! { ! GetLog()->Error() ! << "(RenderServer) ERROR: found no camera node in the active scene\n"; ! return; ! } glClearColor( *************** *** 147,168 **** if (lights.size() == 0) ! { ! // no lights in the scene, disable lighting ! glDisable(GL_LIGHTING); ! } else ! { ! glEnable(GL_LIGHTING); ! glShadeModel (GL_SMOOTH); ! // prepare all lights ! for ( ! TLeafList::iterator iter = lights.begin(); ! iter != lights.end(); ! ++iter ! ) ! { ! (shared_static_cast<Light>(*iter))->Prepare(); ! } ! } // standard rendering --- 103,125 ---- if (lights.size() == 0) ! { ! // no lights in the scene, disable lighting ! glDisable(GL_LIGHTING); ! } ! else ! { ! glEnable(GL_LIGHTING); ! glShadeModel (GL_SMOOTH); ! // prepare all lights ! for ( ! TLeafList::iterator iter = lights.begin(); ! iter != lights.end(); ! ++iter ! ) ! { ! (shared_static_cast<Light>(*iter))->Prepare(); ! } ! } // standard rendering *************** *** 173,179 **** if (mEnablePicking) ! { ! ProcessPicks(); ! } } --- 130,198 ---- if (mEnablePicking) ! { ! ProcessPicks(); ! } ! } ! ! ! int ! RenderServer::Width() const ! { ! if (mActiveScene.get() == 0) return 0; ! ! // get camera ! shared_ptr<Camera> camera = ! shared_static_cast<Camera>(mActiveScene->GetChildOfClass("Camera", true)); ! ! if (camera.get() == 0) ! { ! GetLog()->Error() ! << "(RenderServer) ERROR: found no camera node in the active scene\n"; ! return 0; ! } ! return camera->GetViewportWidth(); ! } ! ! int ! RenderServer::Height() const ! { ! if (mActiveScene.get() == 0) return 0; ! ! // get camera ! shared_ptr<Camera> camera = ! shared_static_cast<Camera>(mActiveScene->GetChildOfClass("Camera", true)); ! ! if (camera.get() == 0) ! { ! GetLog()->Error() ! << "(RenderServer) ERROR: found no camera node in the active scene\n"; ! return 0; ! } ! return camera->GetViewportHeight(); ! } ! ! bool ! RenderServer::CopyFrame(char* buffer) const ! { ! if (mActiveScene.get() == 0) return false; ! glReadPixels(0,0,Width()-1,Height()-1,GL_RGB,GL_UNSIGNED_BYTE,buffer); ! ! size_t len = Width() * 3; ! uint8_t* line = new uint8_t[len]; /* one line of packed RGB pixels */ ! ! unsigned char* a; ! unsigned char* b; ! ! for (int y = 0; y < Height() >> 1; ++y) ! { ! a = ( unsigned char * ) & buffer[y * len]; ! b = ( unsigned char * ) & buffer[(Height() - ( y + 1 )) * len]; ! ! memcpy(line, a, len); ! memcpy(a, b, len); ! memcpy(b, line, len); ! } ! delete[] line; ! return true; } *************** *** 212,216 **** ptr += names+2; } - mPickedNode.reset(); for (;;) --- 231,234 ---- *************** *** 237,241 **** RenderServer::RenderScene(boost::shared_ptr<BaseNode> node) { ! // test for and render using a RenderNode shared_ptr<RenderNode> renderNode = shared_dynamic_cast<RenderNode>(node); if (renderNode.get() != 0) --- 255,265 ---- RenderServer::RenderScene(boost::shared_ptr<BaseNode> node) { ! #if 0 ! shared_ptr<SphereCollider> collider = shared_dynamic_cast<SphereCollider>(node); ! if (collider != 0) ! { ! std::cerr << "RenderScene (spherecollider radius: " << collider->GetRadius() << ")\n"; ! } ! #endif shared_ptr<RenderNode> renderNode = shared_dynamic_cast<RenderNode>(node); if (renderNode.get() != 0) *************** *** 253,257 **** glMultMatrixf(node->GetWorldTransform().m); ! renderNode->RenderInternal(); if (mEnablePicking) --- 277,287 ---- glMultMatrixf(node->GetWorldTransform().m); ! renderNode->RenderInternal(); ! ! if (mEnablePicking) ! { ! // pop name from OpenGL name stack ! glPopName(); ! } if (mEnablePicking) *************** *** 266,278 **** // traverse the the hierarchy for (TLeafList::iterator i = node->begin(); i!= node->end(); ++i) { ! shared_ptr<BaseNode> node = shared_dynamic_cast<BaseNode>(*i); ! if (node.get() == 0) ! { ! continue; ! } ! ! RenderScene(node); } } --- 296,308 ---- // traverse the the hierarchy for (TLeafList::iterator i = node->begin(); i!= node->end(); ++i) + { + shared_ptr<BaseNode> node = shared_dynamic_cast<BaseNode>(*i); + if (node.get() == 0) { ! continue; } + + RenderScene(node); + } } *************** *** 324,328 **** } ! void RenderServer::SetAmbientColor(const RGBA& ambient) { mAmbientColor = ambient; --- 354,359 ---- } ! void ! RenderServer::SetAmbientColor(const RGBA& ambient) { mAmbientColor = ambient; --- NEW FILE: baserenderserver_c.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of simspark Tue May 9 2006 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2007 RoboCup Soccer Server 3D Maintenance Group $Id: baserenderserver_c.cpp,v 1.2 2007/06/17 13:38:31 fruit Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "baserenderserver.h" #include <oxygen/sceneserver/sceneserver.h> using namespace boost; using namespace kerosin; using namespace zeitgeist; void CLASS(BaseRenderServer)::DefineClass() { DEFINE_BASECLASS(zeitgeist/Leaf); } Index: rendercontrol.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/kerosin/renderserver/rendercontrol.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** rendercontrol.cpp 15 Mar 2007 07:26:26 -0000 1.2 --- rendercontrol.cpp 17 Jun 2007 13:38:31 -0000 1.3 *************** *** 21,24 **** --- 21,25 ---- #include "customrender.h" #include <zeitgeist/logserver/logserver.h> + #include <oxygen/sceneserver/sceneserver.h> using namespace kerosin; *************** *** 56,60 **** } ! void RenderControl::RenderCustom() { // get list of registered CustomMonitor objects --- 57,62 ---- } ! void ! RenderControl::RenderCustom() { // get list of registered CustomMonitor objects *************** *** 67,74 **** ++iter ) ! { ! shared_static_cast<CustomRender>((*iter)) ! ->Render(); ! } } --- 69,75 ---- ++iter ) ! { ! shared_static_cast<CustomRender>((*iter))->Render(); ! } } *************** *** 79,85 **** (mRenderServer.expired()) ) ! { ! return; ! } // update the window (pumps event loop, etc..) and render the --- 80,86 ---- (mRenderServer.expired()) ) ! { ! return; ! } // update the window (pumps event loop, etc..) and render the *************** *** 92,96 **** } ! int RenderControl::GetFramesRendered() { return mFramesRendered; --- 93,98 ---- } ! int ! RenderControl::GetFramesRendered() const { return mFramesRendered; Index: rendercontrol.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/kerosin/renderserver/rendercontrol.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** rendercontrol.h 15 Mar 2007 07:26:26 -0000 1.2 --- rendercontrol.h 17 Jun 2007 13:38:31 -0000 1.3 *************** *** 22,26 **** #include <oxygen/simulationserver/simcontrolnode.h> ! #include <kerosin/renderserver/renderserver.h> #include <kerosin/openglserver/openglserver.h> --- 22,26 ---- #include <oxygen/simulationserver/simcontrolnode.h> ! #include <kerosin/renderserver/baserenderserver.h> #include <kerosin/openglserver/openglserver.h> *************** *** 38,42 **** /** returns the total number of rendered frames */ ! int GetFramesRendered(); /** renders the scene at the end of each simulation cycle */ --- 38,42 ---- /** returns the total number of rendered frames */ ! int GetFramesRendered() const; /** renders the scene at the end of each simulation cycle */ *************** *** 49,53 **** protected: /** cached reference to the RenderServer */ ! CachedPath<kerosin::RenderServer> mRenderServer; /** cached reference to the OpenGLServer */ --- 49,53 ---- protected: /** cached reference to the RenderServer */ ! CachedPath<kerosin::BaseRenderServer> mRenderServer; /** cached reference to the OpenGLServer */ Index: renderserver.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/kerosin/renderserver/renderserver.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** renderserver.h 9 Apr 2007 17:02:25 -0000 1.4 --- renderserver.h 17 Jun 2007 13:38:31 -0000 1.5 *************** *** 20,27 **** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - RenderServer --- 20,23 ---- *************** *** 39,57 **** #define KEROSIN_RENDERSERVER_H #include <salt/frustum.h> - #include <zeitgeist/class.h> - #include <zeitgeist/leaf.h> #include <oxygen/sceneserver/sceneserver.h> #include <kerosin/openglserver/glbase.h> #include <kerosin/openglserver/openglwrapper.h> - namespace oxygen - { - class Scene; - class SceneServer; - class Camera; - class BaseNode; - } - namespace kerosin { --- 35,45 ---- #define KEROSIN_RENDERSERVER_H + #include "baserenderserver.h" + #include <salt/frustum.h> #include <oxygen/sceneserver/sceneserver.h> #include <kerosin/openglserver/glbase.h> #include <kerosin/openglserver/openglwrapper.h> namespace kerosin { *************** *** 59,63 **** class RenderNode; ! class RenderServer : public zeitgeist::Leaf { // --- 47,51 ---- class RenderNode; ! class RenderServer : public BaseRenderServer { // *************** *** 69,76 **** public: RenderServer(); ! ~RenderServer(); //! display the current active scene ! void Render(); //! render the scene with fancy lighting --- 57,71 ---- public: RenderServer(); ! virtual ~RenderServer() {} //! display the current active scene ! virtual void Render(); ! ! //! @return the width of the current view ! virtual int Width() const; ! //! @return the width of the height view ! virtual int Height() const; ! //! Read the current screen content into a buffer ! bool CopyFrame(char* buffer) const; //! render the scene with fancy lighting *************** *** 96,108 **** protected: - /** get the active scene node from the sceneServer */ - bool RenderServer::GetActiveScene(); - - /** set up SceneServer reference */ - virtual void OnLink(); - - /** reset SceneServer reference */ - virtual void OnUnlink(); - /** render a scene recursively. \param node the scene base node --- 91,94 ---- *************** *** 126,132 **** // protected: - /** reference to the current active scene */ - boost::shared_ptr<oxygen::Scene> mActiveScene; - /** reference to the SceneServer */ CachedPath<oxygen::SceneServer> mSceneServer; --- 112,115 ---- *************** *** 146,153 **** /** the picking position in OpenGL window coordinates */ salt::Vector2f mPickAt; - /** the pick radius around mPickAt */ double mPickRange; - /** the picked result node */ boost::weak_ptr<RenderNode> mPickedNode; --- 129,134 ---- Index: rendercontrol_c.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/kerosin/renderserver/rendercontrol_c.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** rendercontrol_c.cpp 5 Dec 2005 21:38:23 -0000 1.1 --- rendercontrol_c.cpp 17 Jun 2007 13:38:31 -0000 1.2 *************** *** 19,22 **** --- 19,23 ---- */ #include "rendercontrol.h" + #include <oxygen/sceneserver/sceneserver.h> using namespace kerosin; |