]> git.mxchange.org Git - simgear.git/commitdiff
Get all the tests linking with shared-simgear, and duplicate the awkward core functio...
authorJames Turner <zakalawe@mac.com>
Mon, 28 Nov 2011 23:22:43 +0000 (23:22 +0000)
committerJames Turner <zakalawe@mac.com>
Mon, 28 Nov 2011 23:22:43 +0000 (23:22 +0000)
simgear/CMakeLists.txt
simgear/magvar/CMakeLists.txt
simgear/math/CMakeLists.txt
simgear/misc/CMakeLists.txt
simgear/props/CMakeLists.txt
simgear/scene/util/SGCoreOSGDependant.cxx [new file with mode: 0644]

index cde6efa4b2247b1b3089b546e436480330948876..f85ccc3f18908e23d9c176f675e5f340bedc2548 100644 (file)
@@ -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}")
index 08ce1e8ae4c0d08afca65065e45e33452cdb7b95..2e6cd342bca0710cd6ee41e398565368783399cf 100644 (file)
@@ -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)
index 49e1b7852190eaf84b4840b8e2e6bfae2eaee719..91f01dbe2dd5d6f11c06c584a9d34a805072b132 100644 (file)
@@ -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)
index 597e80facf117f824e408e451091754179bde9fd..582f29ec5291111e03a06a525b39d25a7e68bce1 100644 (file)
@@ -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)
index dfd1916094222ed410dd6582deee3bc28a402848..f0dcbed8a9597d0bd28f6b9ae83e4705297905da 100644 (file)
@@ -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)
diff --git a/simgear/scene/util/SGCoreOSGDependant.cxx b/simgear/scene/util/SGCoreOSGDependant.cxx
new file mode 100644 (file)
index 0000000..1585370
--- /dev/null
@@ -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;
+}
+