Get all the tests linking with shared-simgear, and duplicate the awkward core functions into a new file, pending a proper cleanup.
This commit is contained in:
@@ -69,7 +69,8 @@ if(SIMGEAR_SHARED)
|
||||
ENDIF(APPLE)
|
||||
endif(LIBSVN_FOUND)
|
||||
|
||||
|
||||
list(APPEND sceneSources scene/util/SGCoreOSGDependant.cxx)
|
||||
|
||||
add_library(SimGearScene SHARED ${sceneSources})
|
||||
# set_property(TARGET SimGearScene PROPERTY FRAMEWORK 1)
|
||||
# set_property(TARGET SimGearScene PROPERTY PUBLIC_HEADER "${publicHeaders}")
|
||||
|
||||
@@ -8,5 +8,11 @@ simgear_component(magvar magvar "${SOURCES}" "${HEADERS}")
|
||||
|
||||
if(ENABLE_TESTS)
|
||||
add_executable(test_magvar testmagvar.cxx )
|
||||
target_link_libraries(test_magvar sgmagvar)
|
||||
|
||||
if (SIMGEAR_SHARED)
|
||||
target_link_libraries(test_magvar SimGearCore)
|
||||
else()
|
||||
target_link_libraries(test_magvar sgmagvar)
|
||||
endif()
|
||||
|
||||
endif(ENABLE_TESTS)
|
||||
|
||||
@@ -46,11 +46,19 @@ set(SOURCES
|
||||
simgear_component(math math "${SOURCES}" "${HEADERS}")
|
||||
|
||||
if(ENABLE_TESTS)
|
||||
|
||||
if (SIMGEAR_SHARED)
|
||||
set(TEST_LIBS SimGearCore)
|
||||
else()
|
||||
set(TEST_LIBS sgmath sgstructure sgdebug)
|
||||
endif()
|
||||
|
||||
|
||||
add_executable(math_test SGMathTest.cxx)
|
||||
target_link_libraries(math_test sgmath sgstructure sgdebug)
|
||||
target_link_libraries(math_test ${TEST_LIBS})
|
||||
add_test(math ${EXECUTABLE_OUTPUT_PATH}/math_test)
|
||||
|
||||
add_executable(geometry_test SGGeometryTest.cxx)
|
||||
target_link_libraries(geometry_test sgmath sgstructure sgdebug)
|
||||
target_link_libraries(geometry_test ${TEST_LIBS})
|
||||
add_test(geometry ${EXECUTABLE_OUTPUT_PATH}/geometry_test)
|
||||
endif(ENABLE_TESTS)
|
||||
|
||||
@@ -33,15 +33,22 @@ set(SOURCES
|
||||
simgear_component(misc misc "${SOURCES}" "${HEADERS}")
|
||||
|
||||
if(ENABLE_TESTS)
|
||||
|
||||
if (SIMGEAR_SHARED)
|
||||
set(TEST_LIBS SimGearCore)
|
||||
else()
|
||||
set(TEST_LIBS sgmisc sgdebug)
|
||||
endif()
|
||||
|
||||
add_executable(test_tabbed_values tabbed_values_test.cxx)
|
||||
add_test(tabbed_values ${EXECUTABLE_OUTPUT_PATH}/test_tabbed_values)
|
||||
target_link_libraries(test_tabbed_values sgmisc)
|
||||
target_link_libraries(test_tabbed_values ${TEST_LIBS})
|
||||
|
||||
add_executable(test_strings strutils_test.cxx )
|
||||
add_test(test_strings ${EXECUTABLE_OUTPUT_PATH}/test_strings)
|
||||
target_link_libraries(test_strings sgmisc)
|
||||
target_link_libraries(test_strings ${TEST_LIBS})
|
||||
|
||||
add_executable(test_path path_test.cxx )
|
||||
add_test(test_path ${EXECUTABLE_OUTPUT_PATH}/test_path)
|
||||
target_link_libraries(test_path sgmisc sgdebug)
|
||||
target_link_libraries(test_path ${TEST_LIBS})
|
||||
endif(ENABLE_TESTS)
|
||||
|
||||
@@ -23,11 +23,19 @@ set(SOURCES
|
||||
simgear_component(props props "${SOURCES}" "${HEADERS}")
|
||||
|
||||
if(ENABLE_TESTS)
|
||||
|
||||
if (SIMGEAR_SHARED)
|
||||
set(TEST_LIBS SimGearCore)
|
||||
else()
|
||||
set(TEST_LIBS sgprops sgxml sgstructure sgmisc sgdebug)
|
||||
endif()
|
||||
|
||||
|
||||
add_executable(test_props props_test.cxx)
|
||||
target_link_libraries(test_props sgprops sgxml sgstructure sgmisc sgdebug)
|
||||
target_link_libraries(test_props ${TEST_LIBS})
|
||||
add_test(test_props ${EXECUTABLE_OUTPUT_PATH}/test_props)
|
||||
|
||||
add_executable(test_propertyObject propertyObject_test.cxx)
|
||||
target_link_libraries(test_propertyObject sgprops sgstructure sgdebug)
|
||||
target_link_libraries(test_propertyObject ${TEST_LIBS})
|
||||
add_test(test_propertyObject ${EXECUTABLE_OUTPUT_PATH}/test_propertyObject)
|
||||
endif(ENABLE_TESTS)
|
||||
|
||||
96
simgear/scene/util/SGCoreOSGDependant.cxx
Normal file
96
simgear/scene/util/SGCoreOSGDependant.cxx
Normal file
@@ -0,0 +1,96 @@
|
||||
|
||||
|
||||
// Copyright (C) 2011 Curtis L Olson <curt@flightgear.org>
|
||||
//
|
||||
// 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 <simgear_config.h>
|
||||
#endif
|
||||
|
||||
#include <simgear/math/project.hxx>
|
||||
#include <simgear/misc/PathOptions.hxx>
|
||||
#include <simgear/math/SGMath.hxx>
|
||||
|
||||
#include <osg/Math>
|
||||
#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
|
||||
{
|
||||
SGQuatd hlOr = SGQuatd::fromLonLat(*this);
|
||||
return osg::Matrix(toOsg(hlOr));
|
||||
}
|
||||
|
||||
osg::Matrix SGGeod::makeSimulationFrame() const
|
||||
{
|
||||
osg::Matrix result(makeSimulationFrameRelative());
|
||||
SGVec3d coord;
|
||||
SGGeodesy::SGGeodToCart(*this, coord);
|
||||
result.setTrans(toOsg(coord));
|
||||
return result;
|
||||
}
|
||||
|
||||
osg::Matrix SGGeod::makeZUpFrameRelative() const
|
||||
{
|
||||
osg::Matrix result(makeSimulationFrameRelative());
|
||||
// 180 degree rotation around Y axis
|
||||
osg::Quat flip(0.0, 1.0, 0.0, 0.0);
|
||||
result.preMult(osg::Matrix(flip));
|
||||
return result;
|
||||
}
|
||||
|
||||
osg::Matrix SGGeod::makeZUpFrame() const
|
||||
{
|
||||
osg::Matrix result(makeZUpFrameRelative());
|
||||
SGVec3d coord;
|
||||
SGGeodesy::SGGeodToCart(*this, coord);
|
||||
result.setTrans(toOsg(coord));
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user