From: James Turner Date: Tue, 29 Nov 2011 10:23:09 +0000 (+0000) Subject: Move some OSG-dependant code into scene/util. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=42b7c486716dbc7c179c5ac57c6b6070fbdcdb9f;p=simgear.git Move some OSG-dependant code into scene/util. --- diff --git a/simgear/math/CMakeLists.txt b/simgear/math/CMakeLists.txt index 91f01dbe..b01f9259 100644 --- a/simgear/math/CMakeLists.txt +++ b/simgear/math/CMakeLists.txt @@ -28,7 +28,6 @@ set(HEADERS beziercurve.hxx interpolater.hxx leastsqs.hxx - project.hxx sg_geodesy.hxx sg_types.hxx sg_random.h @@ -39,7 +38,6 @@ set(SOURCES SGGeodesy.cxx interpolater.cxx leastsqs.cxx - project.cxx sg_random.c ) diff --git a/simgear/math/project.cxx b/simgear/math/project.cxx deleted file mode 100644 index c6a4ef73..00000000 --- a/simgear/math/project.cxx +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2010 Tim Moore moore@bricoworks.com -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This library 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 -// Library 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "project.hxx" - -#ifndef NO_OPENSCENEGRAPH_INTERFACE - -#include -#include - -namespace simgear -{ -GLint project(GLdouble objX, GLdouble objY, GLdouble objZ, - const GLdouble *model, const GLdouble *proj, const GLint *view, - GLdouble* winX, GLdouble* winY, GLdouble* winZ) -{ - using namespace osg; - Vec4d obj(objX, objY, objZ, 1.0); - Matrixd Mmodel(model), Mproj(proj); - Matrixd Mwin = (Matrixd::translate(1.0, 1.0, 1.0) - * Matrixd::scale(0.5 * view[2], 0.5 * view[3], 0.5) - * Matrixd::translate(view[0], view[1], 0.0)); - Vec4d result = obj * Mmodel * Mproj * Mwin; - if (equivalent(result.w(), 0.0)) - return GL_FALSE; - result = result / result.w(); - *winX = result.x(); *winY = result.y(); *winZ = result.z(); - return GL_TRUE; -} - -} - -#endif // of NO_OPENSCENEGRAPH_INTERFACE - diff --git a/simgear/math/project.hxx b/simgear/math/project.hxx deleted file mode 100644 index 07a97d79..00000000 --- a/simgear/math/project.hxx +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2010 Tim Moore moore@bricoworks.com -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This library 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 -// Library 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -#ifndef SIMGEAR_PROJECT_HXX -#define SIMGEAR_PROJECT_HXX 1 - -#ifndef NO_OPENSCENEGRAPH_INTERFACE - -#include - -namespace simgear -{ -// Replacement for gluProject. OSG doesn't link in GLU anymore. -extern GLint project(GLdouble objX, GLdouble objY, GLdouble objZ, - const GLdouble *model, const GLdouble *proj, - const GLint *view, - GLdouble* winX, GLdouble* winY, GLdouble* winZ); -} - -#endif // of NO_OPENSCENEGRAPH_INTERFACE - -#endif - diff --git a/simgear/misc/CMakeLists.txt b/simgear/misc/CMakeLists.txt index 582f29ec..c4ae64df 100644 --- a/simgear/misc/CMakeLists.txt +++ b/simgear/misc/CMakeLists.txt @@ -2,7 +2,6 @@ include (SimGearComponent) set(HEADERS - PathOptions.hxx ResourceManager.hxx interpolator.hxx sg_dir.hxx @@ -18,7 +17,6 @@ set(HEADERS ) set(SOURCES - PathOptions.cxx ResourceManager.cxx interpolator.cxx sg_dir.cxx diff --git a/simgear/misc/PathOptions.cxx b/simgear/misc/PathOptions.cxx deleted file mode 100644 index b81600d8..00000000 --- a/simgear/misc/PathOptions.cxx +++ /dev/null @@ -1,41 +0,0 @@ -// PathOptions.cxx -- make an osgDB Options object from a path -// Copyright (C) 2007 Tim Moore timoore@redhat.com -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This library 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 -// Library 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// $Id$ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#ifndef NO_OPENSCENEGRAPH_INTERFACE - -#include - -#include "PathOptions.hxx" - -using namespace simgear; - -osgDB::ReaderWriter::Options* simgear::makeOptionsFromPath(const SGPath& path) -{ - using namespace osgDB; - ReaderWriter::Options *options - = new ReaderWriter::Options(*(Registry::instance()->getOptions())); - options->setDatabasePath(path.str()); - return options; -} - -#endif // of NO_OPENSCENEGRAPH_INTERFACE diff --git a/simgear/misc/PathOptions.hxx b/simgear/misc/PathOptions.hxx deleted file mode 100644 index 8d4186a7..00000000 --- a/simgear/misc/PathOptions.hxx +++ /dev/null @@ -1,33 +0,0 @@ -// PathOptions.hxx -- make an osgDB Options object from a path -// Copyright (C) 2007 Tim Moore timoore@redhat.com -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This library 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 -// Library 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// $Id$ - -#ifndef PATHOPTIONSHXX -#define PATHOPTIONSHXX 1 - -#ifndef NO_OPENSCENEGRAPH_INTERFACE -#include -#include - -namespace simgear -{ -osgDB::ReaderWriter::Options* makeOptionsFromPath(const SGPath&); -} -#endif - -#endif diff --git a/simgear/scene/sky/cloud.cxx b/simgear/scene/sky/cloud.cxx index a3cf4ffe..228f0a8c 100644 --- a/simgear/scene/sky/cloud.cxx +++ b/simgear/scene/sky/cloud.cxx @@ -48,7 +48,7 @@ #endif #include -#include +#include #include #include #include diff --git a/simgear/scene/sky/moon.cxx b/simgear/scene/sky/moon.cxx index a5366c71..28275e6a 100644 --- a/simgear/scene/sky/moon.cxx +++ b/simgear/scene/sky/moon.cxx @@ -50,7 +50,7 @@ #include #include #include -#include +#include #include "sphere.hxx" #include "moon.hxx" diff --git a/simgear/scene/sky/newcloud.cxx b/simgear/scene/sky/newcloud.cxx index e05301af..d78380d2 100644 --- a/simgear/scene/sky/newcloud.cxx +++ b/simgear/scene/sky/newcloud.cxx @@ -42,7 +42,7 @@ #include #include -#include +#include #include #include #include diff --git a/simgear/scene/sky/oursun.cxx b/simgear/scene/sky/oursun.cxx index db7e7319..59db466c 100644 --- a/simgear/scene/sky/oursun.cxx +++ b/simgear/scene/sky/oursun.cxx @@ -42,7 +42,7 @@ #include #include -#include +#include #include #include #include "oursun.hxx" diff --git a/simgear/scene/util/CMakeLists.txt b/simgear/scene/util/CMakeLists.txt index d312dfae..f04b77c4 100644 --- a/simgear/scene/util/CMakeLists.txt +++ b/simgear/scene/util/CMakeLists.txt @@ -20,6 +20,8 @@ set(HEADERS StateAttributeFactory.hxx UpdateOnceCallback.hxx VectorArrayAdapter.hxx + PathOptions.hxx + project.hxx ) set(SOURCES @@ -35,6 +37,8 @@ set(SOURCES SplicingVisitor.cxx StateAttributeFactory.cxx UpdateOnceCallback.cxx + PathOptions.cxx + project.cxx ) simgear_scene_component(util scene/util "${SOURCES}" "${HEADERS}") diff --git a/simgear/scene/util/PathOptions.cxx b/simgear/scene/util/PathOptions.cxx new file mode 100644 index 00000000..203247b7 --- /dev/null +++ b/simgear/scene/util/PathOptions.cxx @@ -0,0 +1,37 @@ +// PathOptions.cxx -- make an osgDB Options object from a path +// Copyright (C) 2007 Tim Moore timoore@redhat.com +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library 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 +// Library 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// $Id$ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include + +#include "PathOptions.hxx" + +using namespace simgear; + +osgDB::ReaderWriter::Options* simgear::makeOptionsFromPath(const SGPath& path) +{ + using namespace osgDB; + ReaderWriter::Options *options + = new ReaderWriter::Options(*(Registry::instance()->getOptions())); + options->setDatabasePath(path.str()); + return options; +} diff --git a/simgear/scene/util/PathOptions.hxx b/simgear/scene/util/PathOptions.hxx new file mode 100644 index 00000000..5bf3a4b7 --- /dev/null +++ b/simgear/scene/util/PathOptions.hxx @@ -0,0 +1,31 @@ +// PathOptions.hxx -- make an osgDB Options object from a path +// Copyright (C) 2007 Tim Moore timoore@redhat.com +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library 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 +// Library 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// $Id$ + +#ifndef PATHOPTIONSHXX +#define PATHOPTIONSHXX 1 + +#include +#include + +namespace simgear +{ +osgDB::ReaderWriter::Options* makeOptionsFromPath(const SGPath&); +} + +#endif diff --git a/simgear/scene/util/SGCoreOSGDependant.cxx b/simgear/scene/util/SGCoreOSGDependant.cxx index 15853700..b46064e9 100644 --- a/simgear/scene/util/SGCoreOSGDependant.cxx +++ b/simgear/scene/util/SGCoreOSGDependant.cxx @@ -21,45 +21,10 @@ # include #endif -#include -#include #include #include #include -#include - -namespace simgear -{ -GLint project(GLdouble objX, GLdouble objY, GLdouble objZ, - const GLdouble *model, const GLdouble *proj, const GLint *view, - GLdouble* winX, GLdouble* winY, GLdouble* winZ) -{ - using namespace osg; - Vec4d obj(objX, objY, objZ, 1.0); - Matrixd Mmodel(model), Mproj(proj); - Matrixd Mwin = (Matrixd::translate(1.0, 1.0, 1.0) - * Matrixd::scale(0.5 * view[2], 0.5 * view[3], 0.5) - * Matrixd::translate(view[0], view[1], 0.0)); - Vec4d result = obj * Mmodel * Mproj * Mwin; - if (equivalent(result.w(), 0.0)) - return GL_FALSE; - result = result / result.w(); - *winX = result.x(); *winY = result.y(); *winZ = result.z(); - return GL_TRUE; -} - -osgDB::ReaderWriter::Options* makeOptionsFromPath(const SGPath& path) -{ - using namespace osgDB; - ReaderWriter::Options *options - = new ReaderWriter::Options(*(Registry::instance()->getOptions())); - options->setDatabasePath(path.str()); - return options; -} - - -} osg::Matrix SGGeod::makeSimulationFrameRelative() const { diff --git a/simgear/scene/util/project.cxx b/simgear/scene/util/project.cxx new file mode 100644 index 00000000..aff7f0a6 --- /dev/null +++ b/simgear/scene/util/project.cxx @@ -0,0 +1,48 @@ +// Copyright (C) 2010 Tim Moore moore@bricoworks.com +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library 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 +// Library 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "project.hxx" + +#include +#include + +namespace simgear +{ +GLint project(GLdouble objX, GLdouble objY, GLdouble objZ, + const GLdouble *model, const GLdouble *proj, const GLint *view, + GLdouble* winX, GLdouble* winY, GLdouble* winZ) +{ + using namespace osg; + Vec4d obj(objX, objY, objZ, 1.0); + Matrixd Mmodel(model), Mproj(proj); + Matrixd Mwin = (Matrixd::translate(1.0, 1.0, 1.0) + * Matrixd::scale(0.5 * view[2], 0.5 * view[3], 0.5) + * Matrixd::translate(view[0], view[1], 0.0)); + Vec4d result = obj * Mmodel * Mproj * Mwin; + if (equivalent(result.w(), 0.0)) + return GL_FALSE; + result = result / result.w(); + *winX = result.x(); *winY = result.y(); *winZ = result.z(); + return GL_TRUE; +} + +} // of namespace simgear + diff --git a/simgear/scene/util/project.hxx b/simgear/scene/util/project.hxx new file mode 100644 index 00000000..92506156 --- /dev/null +++ b/simgear/scene/util/project.hxx @@ -0,0 +1,32 @@ +// Copyright (C) 2010 Tim Moore moore@bricoworks.com +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library 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 +// Library 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +#ifndef SIMGEAR_PROJECT_HXX +#define SIMGEAR_PROJECT_HXX 1 + +#include + +namespace simgear +{ +// Replacement for gluProject. OSG doesn't link in GLU anymore. +extern GLint project(GLdouble objX, GLdouble objY, GLdouble objZ, + const GLdouble *model, const GLdouble *proj, + const GLint *view, + GLdouble* winX, GLdouble* winY, GLdouble* winZ); +} + +#endif + diff --git a/simgear/screen/tr.cxx b/simgear/screen/tr.cxx index f1ff29df..fd64d7cb 100644 --- a/simgear/screen/tr.cxx +++ b/simgear/screen/tr.cxx @@ -144,7 +144,7 @@ #include #endif -#include +#include #include "tr.h"