From: <sv...@ww...> - 2008-01-21 19:48:32
|
Author: nsmoooose Date: 2008-01-21 11:48:24 -0800 (Mon, 21 Jan 2008) New Revision: 2210 Added: branches/layout_tool_improvements/csp/tools/layout2/cpp/CspLayoutApplication.cpp branches/layout_tool_improvements/csp/tools/layout2/cpp/CspLayoutApplication.h Modified: branches/layout_tool_improvements/csp/tools/layout2/SConscript branches/layout_tool_improvements/csp/tools/layout2/cpp/ModelLoader.cpp branches/layout_tool_improvements/csp/tools/layout2/cpp/ModelLoader.h branches/layout_tool_improvements/csp/tools/layout2/cpp/Scene.cpp branches/layout_tool_improvements/csp/tools/layout2/layout.i branches/layout_tool_improvements/csp/tools/layout2/scripts/ui/LayoutApplication.py Log: Added CspLayoutApplication. It works like a facade to all C++ setup operations for the layout application. These setup operations is needed in order for CSP to find models, shaders and textures etc. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=2210 Modified: branches/layout_tool_improvements/csp/tools/layout2/SConscript =================================================================== --- branches/layout_tool_improvements/csp/tools/layout2/SConscript 2008-01-21 18:23:23 UTC (rev 2209) +++ branches/layout_tool_improvements/csp/tools/layout2/SConscript 2008-01-21 19:48:24 UTC (rev 2210) @@ -22,6 +22,8 @@ name = 'layout_module', sources = [ 'layout.i', + 'cpp/CspLayoutApplication.cpp', + 'cpp/CspLayoutApplication.h', 'cpp/DynamicGrid.cpp', 'cpp/DynamicGrid.h', 'cpp/FeatureGraph.cpp', Added: branches/layout_tool_improvements/csp/tools/layout2/cpp/CspLayoutApplication.cpp =================================================================== --- branches/layout_tool_improvements/csp/tools/layout2/cpp/CspLayoutApplication.cpp (rev 0) +++ branches/layout_tool_improvements/csp/tools/layout2/cpp/CspLayoutApplication.cpp 2008-01-21 19:48:24 UTC (rev 2210) @@ -0,0 +1,31 @@ +// CSPLayout +// Copyright 2003-2005 Mark Rose <mk...@us...> +// +// Based in part on osgpick sample code +// OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield +// +// 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; either version 2 +// of the License, or (at your option) any later version. +// +// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US + +#include <csp/cspsim/ObjectModel.h> +#include <csp/cspsim/Shader.h> +#include <csp/tools/layout2/cpp/CspLayoutApplication.h> + +void csp::layout::CspLayoutApplication::setOpenSceneGraphPathList(const std::string &pathlist) { + csp::ObjectModel::setDataFilePathList(pathlist); +} + +void csp::layout::CspLayoutApplication::setShaderPath(const std::string &path) { + Shader::instance()->setShaderPath(path); +} \ No newline at end of file Added: branches/layout_tool_improvements/csp/tools/layout2/cpp/CspLayoutApplication.h =================================================================== --- branches/layout_tool_improvements/csp/tools/layout2/cpp/CspLayoutApplication.h (rev 0) +++ branches/layout_tool_improvements/csp/tools/layout2/cpp/CspLayoutApplication.h 2008-01-21 19:48:24 UTC (rev 2210) @@ -0,0 +1,43 @@ +// CSPLayout +// Copyright 2003-2005 Mark Rose <mk...@us...> +// +// Based in part on osgpick sample code +// OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield +// +// 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; either version 2 +// of the License, or (at your option) any later version. +// +// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US + + +#ifndef __CSP_LAYOUT_CSPLAYOUTAPPLICATION_H__ +#define __CSP_LAYOUT_CSPLAYOUTAPPLICATION_H__ + +#include <csp/csplib/util/Referenced.h> + +namespace csp { +namespace layout { + +class CspLayoutApplication { +public: + // Set the pathlist (':' separated) for loading images, models, and fonts + // when creating ObjectModels. + static void setOpenSceneGraphPathList(const std::string &pathlist); + + static void setShaderPath(const std::string &path); +}; + +} // namespace layout +} // namespace csp + + +#endif // __CSP_LAYOUT_CSPLAYOUTAPPLICATION_H__ Modified: branches/layout_tool_improvements/csp/tools/layout2/cpp/ModelLoader.cpp =================================================================== --- branches/layout_tool_improvements/csp/tools/layout2/cpp/ModelLoader.cpp 2008-01-21 18:23:23 UTC (rev 2209) +++ branches/layout_tool_improvements/csp/tools/layout2/cpp/ModelLoader.cpp 2008-01-21 19:48:24 UTC (rev 2210) @@ -58,8 +58,3 @@ assert(model.valid()); return model->getModel(); } - -void csp::layout::setOpenSceneGraphPathList(std::string const &pathlist) { - csp::ObjectModel::setDataFilePathList(pathlist); -} - Modified: branches/layout_tool_improvements/csp/tools/layout2/cpp/ModelLoader.h =================================================================== --- branches/layout_tool_improvements/csp/tools/layout2/cpp/ModelLoader.h 2008-01-21 18:23:23 UTC (rev 2209) +++ branches/layout_tool_improvements/csp/tools/layout2/cpp/ModelLoader.h 2008-01-21 19:48:24 UTC (rev 2210) @@ -37,10 +37,6 @@ // Retrieve the scene graph for an FeatureModel osg::ref_ptr<osg::Node> getFeatureModel(csp::Object *object); -// Set the pathlist (':' separated) for loading images, models, and fonts -// when creating ObjectModels. -void setOpenSceneGraphPathList(std::string const &pathlist); - } // End namespace layout } // End namespace csp Modified: branches/layout_tool_improvements/csp/tools/layout2/cpp/Scene.cpp =================================================================== --- branches/layout_tool_improvements/csp/tools/layout2/cpp/Scene.cpp 2008-01-21 18:23:23 UTC (rev 2209) +++ branches/layout_tool_improvements/csp/tools/layout2/cpp/Scene.cpp 2008-01-21 19:48:24 UTC (rev 2210) @@ -22,6 +22,7 @@ #include <csp/tools/layout2/cpp/FeatureGraph.h> #include <csp/tools/layout2/cpp/Scene.h> #include <osg/Group> +// #include <osg/LightSource> class csp::layout::Scene::Implementation { public: @@ -31,8 +32,21 @@ Implementation() : m_FeatureGraph(new FeatureGraph) { m_RootNode = new osg::Group; + + /* + osg::ref_ptr<osg::LightSource> light = new osg::LightSource(); + light->setLight(new osg::Light()); + light->getLight()->setDiffuse(osg::Vec4(1,1,1,1)); + light->getLight()->setPosition(osg::Vec4(0,0,1,0)); + light->getLight()->setDirection(osg::Vec3(0,0,-1)); + light->getLight()->setLightNum(3); + light->setLocalStateSetModes(osg::StateAttribute::ON); + m_RootNode->addChild(light.get()); + */ + m_RootNode->addChild(m_FeatureGraph->getScene().get()); + m_DynamicGrid = new DynamicGrid; m_RootNode->addChild(m_DynamicGrid.get()); } Modified: branches/layout_tool_improvements/csp/tools/layout2/layout.i =================================================================== --- branches/layout_tool_improvements/csp/tools/layout2/layout.i 2008-01-21 18:23:23 UTC (rev 2209) +++ branches/layout_tool_improvements/csp/tools/layout2/layout.i 2008-01-21 19:48:24 UTC (rev 2210) @@ -20,6 +20,7 @@ %{ #include <csp/csplib/data/Object.h> #include <csp/csplib/util/PythonSignals.h> +#include "csp/tools/layout2/cpp/CspLayoutApplication.h" #include <csp/tools/layout2/cpp/FeatureGraph.h> #include <csp/tools/layout2/cpp/LayoutNodes.h> #include <csp/tools/layout2/cpp/ModelLoader.h> @@ -93,6 +94,7 @@ TYPEMAP_PYSLOT_IN(void) +%include "csp/tools/layout2/cpp/CspLayoutApplication.h" %include "csp/tools/layout2/cpp/LayoutNodes.h" %include "csp/tools/layout2/cpp/FeatureGraph.h" %include "csp/tools/layout2/cpp/ModelLoader.h" Modified: branches/layout_tool_improvements/csp/tools/layout2/scripts/ui/LayoutApplication.py =================================================================== --- branches/layout_tool_improvements/csp/tools/layout2/scripts/ui/LayoutApplication.py 2008-01-21 18:23:23 UTC (rev 2209) +++ branches/layout_tool_improvements/csp/tools/layout2/scripts/ui/LayoutApplication.py 2008-01-21 19:48:24 UTC (rev 2210) @@ -21,7 +21,11 @@ datadirs = ('images', 'models', 'fonts', 'sounds') pathlist = os.pathsep.join([os.path.join(dataDirectory, subdir) for subdir in datadirs]) - setOpenSceneGraphPathList(pathlist.encode('utf8')) + CspLayoutApplication.setOpenSceneGraphPathList(pathlist.encode('utf8')) + shaderPath = os.path.join(dataDirectory, 'shaders').encode('utf8') + print(shaderPath) + print(dir(shaderPath)) + CspLayoutApplication.setShaderPath(shaderPath) # Create an instance of our customized Frame class |