Changes to allow the COLLADA plugin to compile against the latest COLLADA DOM version 2.4 as well as retaining compatibility with the old 2.2 DOM.

git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14633 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
Robert Osfield 2014-12-23 12:10:03 +00:00
parent dd650921b1
commit 5a4f962013
13 changed files with 110 additions and 23 deletions

View File

@ -11,16 +11,16 @@
# $COLLADA_DIR is an environment variable that would
# correspond to the ./configure --prefix=$COLLADA_DIR
#
# Created by Robert Osfield.
# Created by Robert Osfield.
# Check if COLLADA_DIR is set, otherwise use ACTUAL_3DPARTY_DIR:
SET( COLLADA_ENV_VAR_AVAILABLE $ENV{COLLADA_DIR} )
IF ( COLLADA_ENV_VAR_AVAILABLE )
SET(COLLADA_DOM_ROOT "$ENV{COLLADA_DIR}/dom" CACHE PATH "Location of Collada DOM directory" FORCE)
ELSE ( COLLADA_ENV_VAR_AVAILABLE )
ELSE ()
SET(COLLADA_DOM_ROOT "${ACTUAL_3DPARTY_DIR}/include/1.4/dom" CACHE PATH "Location of Collada DOM directory" FORCE)
ENDIF( COLLADA_ENV_VAR_AVAILABLE )
ENDIF()
@ -65,16 +65,17 @@ FIND_PATH(COLLADA_INCLUDE_DIR dae.h
${ACTUAL_3DPARTY_DIR}/include
)
FIND_LIBRARY(COLLADA_DYNAMIC_LIBRARY
NAMES collada_dom collada14dom Collada14Dom libcollada14dom21 libcollada14dom22
FIND_LIBRARY(COLLADA_DYNAMIC_LIBRARY
NAMES collada_dom collada14dom Collada14Dom libcollada14dom21 libcollada14dom22 collada-dom2.4-dp
PATHS
${COLLADA_DOM_ROOT}/build/${COLLADA_BUILDNAME}-1.4
${COLLADA_DOM_ROOT}
$ENV{COLLADA_DIR}/build/${COLLADA_BUILDNAME}-1.4
$ENV{COLLADA_DIR}/lib
$ENV{COLLADA_DIR}/lib-dbg
$ENV{COLLADA_DIR}
~/Library/Frameworks
/Library/Frameworks
/Library/Frameworks
/opt/local/Library/Frameworks #macports
/usr/local/lib
/usr/local/lib64
@ -88,10 +89,11 @@ FIND_LIBRARY(COLLADA_DYNAMIC_LIBRARY
${ACTUAL_3DPARTY_DIR}/lib
)
FIND_LIBRARY(COLLADA_DYNAMIC_LIBRARY_DEBUG
NAMES collada_dom-d collada14dom-d Collada14Dom-d libcollada14dom21-d libcollada14dom22-d
FIND_LIBRARY(COLLADA_DYNAMIC_LIBRARY_DEBUG
NAMES collada_dom-d collada14dom-d Collada14Dom-d libcollada14dom21-d libcollada14dom22-d collada-dom2.4-dp-d
PATHS
${COLLADA_DOM_ROOT}/build/${COLLADA_BUILDNAME}-1.4-d
${COLLADA_DOM_ROOT}
$ENV{COLLADA_DIR}/build/${COLLADA_BUILDNAME}-1.4-d
$ENV{COLLADA_DIR}/lib
$ENV{COLLADA_DIR}/lib-dbg
@ -111,7 +113,7 @@ FIND_LIBRARY(COLLADA_DYNAMIC_LIBRARY_DEBUG
${ACTUAL_3DPARTY_DIR}/lib
)
FIND_LIBRARY(COLLADA_STATIC_LIBRARY
FIND_LIBRARY(COLLADA_STATIC_LIBRARY
NAMES libcollada14dom21-s libcollada14dom22-s libcollada14dom.a
PATHS
${COLLADA_DOM_ROOT}/build/${COLLADA_BUILDNAME}-1.4
@ -134,7 +136,7 @@ FIND_LIBRARY(COLLADA_STATIC_LIBRARY
${ACTUAL_3DPARTY_DIR}/lib
)
FIND_LIBRARY(COLLADA_STATIC_LIBRARY_DEBUG
FIND_LIBRARY(COLLADA_STATIC_LIBRARY_DEBUG
NAMES collada_dom-sd collada14dom-sd libcollada14dom21-sd libcollada14dom22-sd libcollada14dom-d.a
PATHS
${COLLADA_DOM_ROOT}/build/${COLLADA_BUILDNAME}-1.4-d
@ -173,7 +175,7 @@ FIND_LIBRARY(COLLADA_STATIC_LIBRARY_DEBUG
)
ENDIF(WIN32)
ENDIF(LIBXML2_FOUND)
FIND_PACKAGE(ZLIB)
IF (ZLIB_FOUND)
SET(COLLADA_ZLIB_LIBRARY "${ZLIB_LIBRARY}" CACHE FILEPATH "" FORCE)
@ -242,7 +244,7 @@ FIND_LIBRARY(COLLADA_STATIC_LIBRARY_DEBUG
)
FIND_LIBRARY(COLLADA_BOOST_FILESYSTEM_LIBRARY
NAMES libboost_filesystem boost_filesystem boost_filesystem-mt libboost_filesystem-${COLLADA_BUILDNAME}0-mt libboost_filesystem-${COLLADA_BUILDNAME}0-mt-1_54 libboost_filesystem-${COLLADA_BUILDNAME}0-mt-1_55
NAMES libboost_filesystem boost_filesystem boost_filesystem-mt libboost_filesystem-${COLLADA_BUILDNAME}0-mt libboost_filesystem-${COLLADA_BUILDNAME}0-mt-1_54 libboost_filesystem-${COLLADA_BUILDNAME}0-mt-1_55
PATHS
${COLLADA_DOM_ROOT}/external-libs/boost/lib/${COLLADA_BUILDNAME}
${COLLADA_DOM_ROOT}/external-libs/boost/lib/mingw
@ -250,7 +252,7 @@ FIND_LIBRARY(COLLADA_STATIC_LIBRARY_DEBUG
)
FIND_LIBRARY(COLLADA_BOOST_FILESYSTEM_LIBRARY_DEBUG
NAMES libboost_filesystem-d boost_filesystem-d boost_filesystem-mt-d libboost_filesystem-${COLLADA_BUILDNAME}0-mt-gd libboost_filesystem-${COLLADA_BUILDNAME}0-mt-gd-1_54 libboost_filesystem-${COLLADA_BUILDNAME}0-mt-gd-1_55
NAMES libboost_filesystem-d boost_filesystem-d boost_filesystem-mt-d libboost_filesystem-${COLLADA_BUILDNAME}0-mt-gd libboost_filesystem-${COLLADA_BUILDNAME}0-mt-gd-1_54 libboost_filesystem-${COLLADA_BUILDNAME}0-mt-gd-1_55
PATHS
${COLLADA_DOM_ROOT}/external-libs/boost/lib/${COLLADA_BUILDNAME}
${COLLADA_DOM_ROOT}/external-libs/boost/lib/mingw
@ -258,7 +260,7 @@ FIND_LIBRARY(COLLADA_STATIC_LIBRARY_DEBUG
)
FIND_LIBRARY(COLLADA_BOOST_SYSTEM_LIBRARY
NAMES libboost_system boost_system boost_system-mt libboost_system-${COLLADA_BUILDNAME}0-mt libboost_system-${COLLADA_BUILDNAME}0-mt-1_54 libboost_system-${COLLADA_BUILDNAME}0-mt-1_55
NAMES libboost_system boost_system boost_system-mt libboost_system-${COLLADA_BUILDNAME}0-mt libboost_system-${COLLADA_BUILDNAME}0-mt-1_54 libboost_system-${COLLADA_BUILDNAME}0-mt-1_55
PATHS
${COLLADA_DOM_ROOT}/external-libs/boost/lib/${COLLADA_BUILDNAME}
${COLLADA_DOM_ROOT}/external-libs/boost/lib/mingw
@ -266,7 +268,7 @@ FIND_LIBRARY(COLLADA_STATIC_LIBRARY_DEBUG
)
FIND_LIBRARY(COLLADA_BOOST_SYSTEM_LIBRARY_DEBUG
NAMES libboost_system-d boost_system-d boost_system-mt-d libboost_system-${COLLADA_BUILDNAME}0-mt-gd libboost_system-${COLLADA_BUILDNAME}0-mt-gd-1_54 libboost_system-${COLLADA_BUILDNAME}0-mt-gd-1_55
NAMES libboost_system-d boost_system-d boost_system-mt-d libboost_system-${COLLADA_BUILDNAME}0-mt-gd libboost_system-${COLLADA_BUILDNAME}0-mt-gd-1_54 libboost_system-${COLLADA_BUILDNAME}0-mt-gd-1_55
PATHS
${COLLADA_DOM_ROOT}/external-libs/boost/lib/${COLLADA_BUILDNAME}
${COLLADA_DOM_ROOT}/external-libs/boost/lib/mingw
@ -277,6 +279,23 @@ FIND_LIBRARY(COLLADA_STATIC_LIBRARY_DEBUG
SET(COLLADA_FOUND "NO")
IF(COLLADA_DYNAMIC_LIBRARY OR COLLADA_STATIC_LIBRARY)
IF (COLLADA_INCLUDE_DIR)
SET(COLLADA_FOUND "YES")
ENDIF(COLLADA_INCLUDE_DIR)
ENDIF(COLLADA_DYNAMIC_LIBRARY OR COLLADA_STATIC_LIBRARY)
FIND_PATH(COLLADA_INCLUDE_DOMANY_DIR 1.4/dom/domAny.h
${COLLADA_INCLUDE_DIR}
)
IF (COLLADA_INCLUDE_DOMANY_DIR)
SET(COLLADA_DOM_2_4_OR_LATER TRUE)
ELSEIF()
SET(COLLADA_DOM_2_4_OR_LATER FALSE)
ENDIF()
MESSAGE("\n\n COLLADA_DOM_2_4_OR_LATER=" ${COLLADA_DOM_2_4_OR_LATER})
ENDIF()
ENDIF()

View File

@ -18,7 +18,7 @@ SET(TARGET_SRC
ReaderWriterDAE.cpp
)
SET(TARGET_H
SET(TARGET_H
daeReader.h
daeWriter.h
domSourceReader.h
@ -35,6 +35,11 @@ ELSE()
ENDIF()
ADD_DEFINITIONS(-DNO_BOOST)
ADD_DEFINITIONS(-DCOLLADA_DOM_SUPPORT141)
IF (COLLADA_DOM_2_4_OR_LATER)
ADD_DEFINITIONS(-DCOLLADA_DOM_2_4_OR_LATER)
ENDIF()
IF(COLLADA_USE_STATIC)
IF(WIN32)
@ -68,8 +73,8 @@ ELSE()
ENDIF()
ENDIF()
SET(TARGET_ADDED_LIBRARIES osgSim osgAnimation)
SET(TARGET_ADDED_LIBRARIES osgSim osgAnimation)
#### end var setup ###
SETUP_PLUGIN(dae dae)

View File

@ -33,6 +33,11 @@
using namespace osgDAE;
#ifdef COLLADA_DOM_2_4_OR_LATER
#include <dom/domAny.h>
using namespace ColladaDOM141;
#endif
template <typename T>
void daeReader::getTransparencyCounts(daeDatabase* database, int& zero, int& one) const
{

View File

@ -29,6 +29,11 @@
using namespace osgDAE;
#ifdef COLLADA_DOM_2_4_OR_LATER
#include <dom/domAny.h>
using namespace ColladaDOM141;
#endif
osg::Group* daeReader::processOsgMultiSwitch(domTechnique* teq)
{
osgSim::MultiSwitch* msw = new osgSim::MultiSwitch;

View File

@ -24,6 +24,11 @@
#include <osg/MatrixTransform>
#include <osgSim/DOFTransform>
#ifdef COLLADA_DOM_2_4_OR_LATER
#include <dom/domAny.h>
using namespace ColladaDOM141;
#endif
using namespace osgDAE;
// Note <lookat>, <matrix>, <rotate>, <scale>, <skew> and <translate> may appear in any order

View File

@ -23,6 +23,11 @@
using namespace osgDAE;
#ifdef COLLADA_DOM_2_4_OR_LATER
#include <dom/domAny.h>
using namespace ColladaDOM141;
#endif
daeReader::Options::Options() :
strictTransparency(false),
precisionHint(0),
@ -296,7 +301,8 @@ bool daeReader::convert( std::istream& fin )
std::vector<char> buffer(length);
fin.read(&buffer[0], length);
_document = _dae->openFromMemory(fileURI, &buffer[0]);
domElement* loaded_element = _dae->openFromMemory(fileURI, &buffer[0]);
_document = dynamic_cast<domCOLLADA*>(loaded_element);
return processDocument (fileURI);
}
@ -305,7 +311,8 @@ bool daeReader::convert( const std::string &fileURI )
{
clearCaches();
_document = _dae->open(fileURI);
domElement* loaded_element = _dae->open(fileURI);
_document = dynamic_cast<domCOLLADA*>(loaded_element);
return processDocument (fileURI);
}

View File

@ -35,6 +35,10 @@
#include <osgAnimation/Bone>
#include <osgAnimation/Skeleton>
#ifdef COLLADA_DOM_2_4_OR_LATER
namespace ColladaDOM141
{
#endif
class domBind_material;
class domCamera;
//class domCommon_color_or_texture_type;
@ -55,6 +59,12 @@ class domTranslate;
class domRotate;
class domVisual_scene;
#ifdef COLLADA_DOM_2_4_OR_LATER
}
using namespace ColladaDOM141;
#endif
namespace osgDAE
{
@ -380,6 +390,7 @@ private:
osg::Node* _rootNode;
osg::ref_ptr<osg::StateSet> _rootStateSet;
domCOLLADA* _document;
domVisual_scene* _visualScene;
std::map<std::string,bool> _targetMap;

View File

@ -31,6 +31,7 @@
#include <osg/CameraView>
#include <osgDB/ConvertUTF>
using namespace osgDAE;

View File

@ -31,6 +31,11 @@
#include "windows.h"
#endif
#ifdef COLLADA_DOM_2_4_OR_LATER
#include <dom/domAny.h>
using namespace ColladaDOM141;
#endif
using namespace osgDAE;

View File

@ -28,6 +28,11 @@
#include <osg/Billboard>
#include <osg/CameraView>
#ifdef COLLADA_DOM_2_4_OR_LATER
#include <dom/domAny.h>
using namespace ColladaDOM141;
#endif
using namespace osgDAE;
// Write non-standard node data as extra of type "Node" with "OpenSceneGraph" technique

View File

@ -22,6 +22,11 @@
#include <osgAnimation/Bone>
#include <osgSim/DOFTransform>
#ifdef COLLADA_DOM_2_4_OR_LATER
#include <dom/domAny.h>
using namespace ColladaDOM141;
#endif
using namespace osgDAE;

View File

@ -50,6 +50,10 @@
#include <dae/daeDocument.h>
#include <dom/domChannel.h>
#ifdef COLLADA_DOM_2_4_OR_LATER
namespace ColladaDOM141
{
#endif
class domCOLLADA;
class domGeometry;
@ -68,6 +72,12 @@ class domSource;
class domVisual_scene;
class domP;
#ifdef COLLADA_DOM_2_4_OR_LATER
}
using namespace ColladaDOM141;
#endif
namespace osgDAE {
/// Convert value to string using it's stream operator

View File

@ -17,7 +17,11 @@
#include <osg/Array>
#include <osg/Notify>
class domSource;
#include <dom/domSource.h>
#ifdef COLLADA_DOM_2_4_OR_LATER
using namespace ColladaDOM141;
#endif
namespace osgDAE {