Move some OSG-dependant code into scene/util.

This commit is contained in:
James Turner 2011-11-29 10:23:09 +00:00
parent 75afee59c3
commit 42b7c48671
13 changed files with 10 additions and 59 deletions

View File

@ -28,7 +28,6 @@ set(HEADERS
beziercurve.hxx beziercurve.hxx
interpolater.hxx interpolater.hxx
leastsqs.hxx leastsqs.hxx
project.hxx
sg_geodesy.hxx sg_geodesy.hxx
sg_types.hxx sg_types.hxx
sg_random.h sg_random.h
@ -39,7 +38,6 @@ set(SOURCES
SGGeodesy.cxx SGGeodesy.cxx
interpolater.cxx interpolater.cxx
leastsqs.cxx leastsqs.cxx
project.cxx
sg_random.c sg_random.c
) )

View File

@ -2,7 +2,6 @@
include (SimGearComponent) include (SimGearComponent)
set(HEADERS set(HEADERS
PathOptions.hxx
ResourceManager.hxx ResourceManager.hxx
interpolator.hxx interpolator.hxx
sg_dir.hxx sg_dir.hxx
@ -18,7 +17,6 @@ set(HEADERS
) )
set(SOURCES set(SOURCES
PathOptions.cxx
ResourceManager.cxx ResourceManager.cxx
interpolator.cxx interpolator.cxx
sg_dir.cxx sg_dir.cxx

View File

@ -48,7 +48,7 @@
#endif #endif
#include <simgear/math/sg_random.h> #include <simgear/math/sg_random.h>
#include <simgear/misc/PathOptions.hxx> #include <simgear/scene/util/PathOptions.hxx>
#include <simgear/debug/logstream.hxx> #include <simgear/debug/logstream.hxx>
#include <simgear/scene/model/model.hxx> #include <simgear/scene/model/model.hxx>
#include <simgear/scene/util/RenderConstants.hxx> #include <simgear/scene/util/RenderConstants.hxx>

View File

@ -50,7 +50,7 @@
#include <simgear/constants.h> #include <simgear/constants.h>
#include <simgear/screen/colors.hxx> #include <simgear/screen/colors.hxx>
#include <simgear/scene/model/model.hxx> #include <simgear/scene/model/model.hxx>
#include <simgear/misc/PathOptions.hxx> #include <simgear/scene/util/PathOptions.hxx>
#include "sphere.hxx" #include "sphere.hxx"
#include "moon.hxx" #include "moon.hxx"

View File

@ -42,7 +42,7 @@
#include <simgear/math/sg_random.h> #include <simgear/math/sg_random.h>
#include <simgear/misc/sg_path.hxx> #include <simgear/misc/sg_path.hxx>
#include <simgear/misc/PathOptions.hxx> #include <simgear/scene/util/PathOptions.hxx>
#include <simgear/props/props.hxx> #include <simgear/props/props.hxx>
#include <simgear/scene/model/model.hxx> #include <simgear/scene/model/model.hxx>
#include <simgear/scene/util/SGReaderWriterOptions.hxx> #include <simgear/scene/util/SGReaderWriterOptions.hxx>

View File

@ -42,7 +42,7 @@
#include <osgDB/ReadFile> #include <osgDB/ReadFile>
#include <simgear/math/SGMath.hxx> #include <simgear/math/SGMath.hxx>
#include <simgear/misc/PathOptions.hxx> #include <simgear/scene/util/PathOptions.hxx>
#include <simgear/screen/colors.hxx> #include <simgear/screen/colors.hxx>
#include <simgear/scene/model/model.hxx> #include <simgear/scene/model/model.hxx>
#include "oursun.hxx" #include "oursun.hxx"

View File

@ -20,6 +20,8 @@ set(HEADERS
StateAttributeFactory.hxx StateAttributeFactory.hxx
UpdateOnceCallback.hxx UpdateOnceCallback.hxx
VectorArrayAdapter.hxx VectorArrayAdapter.hxx
PathOptions.hxx
project.hxx
) )
set(SOURCES set(SOURCES
@ -35,6 +37,8 @@ set(SOURCES
SplicingVisitor.cxx SplicingVisitor.cxx
StateAttributeFactory.cxx StateAttributeFactory.cxx
UpdateOnceCallback.cxx UpdateOnceCallback.cxx
PathOptions.cxx
project.cxx
) )
simgear_scene_component(util scene/util "${SOURCES}" "${HEADERS}") simgear_scene_component(util scene/util "${SOURCES}" "${HEADERS}")

View File

@ -21,8 +21,6 @@
# include <simgear_config.h> # include <simgear_config.h>
#endif #endif
#ifndef NO_OPENSCENEGRAPH_INTERFACE
#include <osgDB/Registry> #include <osgDB/Registry>
#include "PathOptions.hxx" #include "PathOptions.hxx"
@ -37,5 +35,3 @@ osgDB::ReaderWriter::Options* simgear::makeOptionsFromPath(const SGPath& path)
options->setDatabasePath(path.str()); options->setDatabasePath(path.str());
return options; return options;
} }
#endif // of NO_OPENSCENEGRAPH_INTERFACE

View File

@ -20,7 +20,6 @@
#ifndef PATHOPTIONSHXX #ifndef PATHOPTIONSHXX
#define PATHOPTIONSHXX 1 #define PATHOPTIONSHXX 1
#ifndef NO_OPENSCENEGRAPH_INTERFACE
#include <osgDB/ReaderWriter> #include <osgDB/ReaderWriter>
#include <simgear/misc/sg_path.hxx> #include <simgear/misc/sg_path.hxx>
@ -28,6 +27,5 @@ namespace simgear
{ {
osgDB::ReaderWriter::Options* makeOptionsFromPath(const SGPath&); osgDB::ReaderWriter::Options* makeOptionsFromPath(const SGPath&);
} }
#endif
#endif #endif

View File

@ -21,45 +21,10 @@
# include <simgear_config.h> # include <simgear_config.h>
#endif #endif
#include <simgear/math/project.hxx>
#include <simgear/misc/PathOptions.hxx>
#include <simgear/math/SGMath.hxx> #include <simgear/math/SGMath.hxx>
#include <osg/Math> #include <osg/Math>
#include <osg/Matrixd> #include <osg/Matrixd>
#include <osgDB/Registry>
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 osg::Matrix SGGeod::makeSimulationFrameRelative() const
{ {

View File

@ -21,8 +21,6 @@
#include "project.hxx" #include "project.hxx"
#ifndef NO_OPENSCENEGRAPH_INTERFACE
#include <osg/Math> #include <osg/Math>
#include <osg/Matrixd> #include <osg/Matrixd>
@ -46,7 +44,5 @@ GLint project(GLdouble objX, GLdouble objY, GLdouble objZ,
return GL_TRUE; return GL_TRUE;
} }
} } // of namespace simgear
#endif // of NO_OPENSCENEGRAPH_INTERFACE

View File

@ -17,8 +17,6 @@
#ifndef SIMGEAR_PROJECT_HXX #ifndef SIMGEAR_PROJECT_HXX
#define SIMGEAR_PROJECT_HXX 1 #define SIMGEAR_PROJECT_HXX 1
#ifndef NO_OPENSCENEGRAPH_INTERFACE
#include <osg/GL> #include <osg/GL>
namespace simgear namespace simgear
@ -30,7 +28,5 @@ extern GLint project(GLdouble objX, GLdouble objY, GLdouble objZ,
GLdouble* winX, GLdouble* winY, GLdouble* winZ); GLdouble* winX, GLdouble* winY, GLdouble* winZ);
} }
#endif // of NO_OPENSCENEGRAPH_INTERFACE
#endif #endif

View File

@ -144,7 +144,7 @@
#include <windows.h> #include <windows.h>
#endif #endif
#include <simgear/math/project.hxx> #include <simgear/scene/util/project.hxx>
#include "tr.h" #include "tr.h"