...
 
Commits (5)
......@@ -35,6 +35,8 @@ Build-Depends: debhelper (>= 9),
librsvg2-dev,
libpoppler-glib-dev,
liblua5.2-dev,
libcollada-dom2.4-dp-dev,
libboost-filesystem-dev,
libopenthreads-dev
Standards-Version: 4.1.3
Vcs-Browser: https://salsa.debian.org/openscenegraph-team/openscenegraph-3.4
......
diff --git a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/CMakeLists.txt b/src/osgPlugins/dae/CMakeLists.txt
index a82481994..af03fb866 100644
--- a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/CMakeLists.txt
+++ b/src/osgPlugins/dae/CMakeLists.txt
@@ -1,5 +1,19 @@
INCLUDE_DIRECTORIES( ${COLLADA_INCLUDE_DIR} ${COLLADA_INCLUDE_DIR}/1.4)
+
+################################################################################
+## Quieten warnings that a due to dae headers
+
+IF(CMAKE_COMPILER_IS_GNUCXX)
+ # Remove -Wextra flag as it barfs on ffmoeg headers
+ STRING(REGEX REPLACE "-Wextra" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+ENDIF()
+
+IF(CMAKE_COMPILER_IS_GNUCXX OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
+ENDIF()
+
+
SET(TARGET_SRC
daeReader.cpp
daeRAnimations.cpp
@@ -76,5 +90,10 @@ ENDIF()
SET(TARGET_ADDED_LIBRARIES osgSim osgAnimation)
+IF(CMAKE_COMPILER_IS_GNUCXX)
+ # Remove -Wshadow flag as it barfs on ffmoeg headers
+ STRING(REGEX REPLACE "-Wshadow" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+ENDIF()
+
#### end var setup ###
SETUP_PLUGIN(dae dae)
diff --git a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/ReaderWriterDAE.cpp b/src/osgPlugins/dae/ReaderWriterDAE.cpp
index 87cd9db9d..de86b92b3 100644
--- a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/ReaderWriterDAE.cpp
+++ b/src/osgPlugins/dae/ReaderWriterDAE.cpp
@@ -32,6 +32,12 @@
#define SERIALIZER() OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> lock(_serializerMutex)
+#if __cplusplus > 199711L
+ #define smart_ptr std::unique_ptr
+#else
+ #define smart_ptr std::auto_ptr
+#endif
+
osgDB::ReaderWriter::ReadResult
ReaderWriterDAE::readNode(std::istream& fin,
const osgDB::ReaderWriter::Options* options) const
@@ -65,10 +71,14 @@ ReaderWriterDAE::readNode(std::istream& fin,
if (NULL == pDAE)
{
bOwnDAE = true;
+#ifdef COLLADA_DOM_2_4_OR_LATER
+ pDAE = new DAE(NULL,NULL,_specversion);
+#else
pDAE = new DAE;
+#endif
}
- std::auto_ptr<DAE> scopedDae(bOwnDAE ? pDAE : NULL); // Deallocates locally created structure at scope exit
+ smart_ptr<DAE> scopedDae(bOwnDAE ? pDAE : NULL); // Deallocates locally created structure at scope exit
osgDAE::daeReader daeReader(pDAE, &pluginOptions);
@@ -139,9 +149,14 @@ ReaderWriterDAE::readNode(const std::string& fname,
if (NULL == pDAE)
{
bOwnDAE = true;
+#ifdef COLLADA_DOM_2_4_OR_LATER
+ pDAE = new DAE(NULL,NULL,_specversion);
+#else
pDAE = new DAE;
+#endif
}
- std::auto_ptr<DAE> scopedDae(bOwnDAE ? pDAE : NULL); // Deallocates locally created structure at scope exit
+
+ smart_ptr<DAE> scopedDae(bOwnDAE ? pDAE : NULL); // Deallocates locally created structure at scope exit
osgDAE::daeReader daeReader(pDAE, &pluginOptions);
@@ -221,6 +236,7 @@ ReaderWriterDAE::writeNode( const osg::Node& node,
else if (opt == "daeLinkOriginalTexturesNoForce") { pluginOptions.linkOrignialTextures = true; pluginOptions.forceTexture = false; }
else if (opt == "daeLinkOriginalTexturesForce") { pluginOptions.linkOrignialTextures = true; pluginOptions.forceTexture = true; }
else if (opt == "daeNamesUseCodepage") pluginOptions.namesUseCodepage = true;
+ else if (opt == "daeRenameIds") pluginOptions.renameIds = true;
else if (!opt.empty())
{
OSG_NOTICE << std::endl << "COLLADA dae plugin: unrecognized option \"" << opt << std::endl;
@@ -231,9 +247,13 @@ ReaderWriterDAE::writeNode( const osg::Node& node,
if (NULL == pDAE)
{
bOwnDAE = true;
+#ifdef COLLADA_DOM_2_4_OR_LATER
+ pDAE = new DAE(NULL,NULL,_specversion);
+#else
pDAE = new DAE;
+#endif
}
- std::auto_ptr<DAE> scopedDae(bOwnDAE ? pDAE : NULL); // Deallocates locally created structure at scope exit
+ smart_ptr<DAE> scopedDae(bOwnDAE ? pDAE : NULL); // Deallocates locally created structure at scope exit
// Convert file name to URI
std::string fileURI = ConvertFilePathToColladaCompatibleURI(fname);
diff --git a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/ReaderWriterDAE.h b/src/osgPlugins/dae/ReaderWriterDAE.h
index 63ee6bd00..2bea1bcf2 100644
--- a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/ReaderWriterDAE.h
+++ b/src/osgPlugins/dae/ReaderWriterDAE.h
@@ -13,6 +13,8 @@ class ReaderWriterDAE : public osgDB::ReaderWriter
public:
ReaderWriterDAE()
{
+ _specversion = "1.4.1";
+
// Collada document
supportsExtension("dae","COLLADA 1.4.x DAE format");
// Collada zip archive (contains one or more dae files and a manifest.xml)
@@ -26,13 +28,14 @@ public:
supportsOption("daeLinkOriginalTexturesNoForce", "(Write option) Writes reference to the original image if found, instead of writing the image in memory");
supportsOption("daeLinkOriginalTexturesForce", "(Write option) Writes reference to the original image even if not found, instead of writing the image in memory");
supportsOption("daeNamesUseCodepage", "(Write option) All names except filenames (materials, animation, geometries...) should be considered as encoded using current codepage (UTF8 if not). Filenames follow OSG_USE_UTF8_FILENAME.");
+ supportsOption("daeRenameIds", "(Write option) Rename all IDs (geometries, materials, etc.) to remove characters which may be interpreted as an URI. Useful if you want to ensure names having spaces or slashes behave correctly. This may be undesired if original naming must be somewhat kept.");
supportsOption("StrictTransparency", "(Read option) Undocumented");
supportsOption("daeTessellateNone", "(Read option) Do not tessellate at all (Polygons are stored as GL_POLYGON - not suitable for concave polygons)");
supportsOption("daeTessellatePolygonsAsTriFans", "(Read option) Tessellate the old way (default), interpreting polygons as triangle fans (faster, but does not work for concave polygons)");
supportsOption("daeTessellatePolygons", "(Read option) Use full tessellation of polygons (slower, works for concave polygons)");
supportsOption("daeUsePredefinedTextureUnits", "(Read option) Texture units have fixed uses (0: ambient occlusion, 1: main texture...). May create non contiguous units (default).");
- supportsOption("daeUsePredefinedTextureUnits", "(Read option) Texture units are created in sequence (contiguous units).");
+ supportsOption("daeUseSequencedTextureUnits", "(Read option) Texture units are created in sequence (contiguous units).");
}
const char* className() const { return "COLLADA 1.4.x DAE reader/writer"; }
@@ -47,6 +50,7 @@ public:
private:
mutable OpenThreads::ReentrantMutex _serializerMutex;
+ const char* _specversion;
};
///////////////////////////////////////////////////////////////////////////
diff --git a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeRAnimations.cpp b/src/osgPlugins/dae/daeRAnimations.cpp
index 63ef93382..cda238b84 100644
--- a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeRAnimations.cpp
+++ b/src/osgPlugins/dae/daeRAnimations.cpp
@@ -467,14 +467,14 @@ void daeReader::processAnimationMap(const TargetChannelPartMap& tcm, osgAnimatio
else if (MatrixCubicBezierKeyframeContainer* cbkfCntr =
dynamic_cast<MatrixCubicBezierKeyframeContainer*>(channelPart->keyframes.get()))
{
- osgAnimation::MatrixKeyframeContainer* kfCntr = new osgAnimation::MatrixKeyframeContainer;
+ osgAnimation::MatrixKeyframeContainer* cbCntr = new osgAnimation::MatrixKeyframeContainer;
for (size_t i = 0; i < cbkfCntr->size(); ++i)
{
const MatrixCubicBezierKeyframe& cbkf = cbkfCntr->at(i);
- kfCntr->push_back(osgAnimation::MatrixKeyframe(cbkf.getTime(), cbkf.getValue().getPosition()));
+ cbCntr->push_back(osgAnimation::MatrixKeyframe(cbkf.getTime(), cbkf.getValue().getPosition()));
}
osgAnimation::MatrixLinearChannel* channel = new osgAnimation::MatrixLinearChannel;
- channel->getOrCreateSampler()->setKeyframeContainer(kfCntr);
+ channel->getOrCreateSampler()->setKeyframeContainer(cbCntr);
pOsgAnimationChannel = channel;
}
}
diff --git a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeRGeometry.cpp b/src/osgPlugins/dae/daeRGeometry.cpp
index 3258f83a6..088105db7 100644
--- a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeRGeometry.cpp
+++ b/src/osgPlugins/dae/daeRGeometry.cpp
@@ -224,10 +224,10 @@ osg::Node* daeReader::processMorph(domMorph* pDomMorph, domBind_material* pDomBi
osg::Geode* targetgeode = getOrCreateGeometry(pDomGeometry, NULL);
// Expects a single geometry inside the geode, should change this
- osg::Geometry* pOsgGeometry = dynamic_cast<osg::Geometry*>(targetgeode->getDrawable(0));
- if (pOsgGeometry)
+ osg::Geometry* geometry = dynamic_cast<osg::Geometry*>(targetgeode->getDrawable(0));
+ if (geometry)
{
- pOsgMorphGeometry->addMorphTarget(pOsgGeometry);
+ pOsgMorphGeometry->addMorphTarget(geometry);
}
}
else
@@ -248,10 +248,10 @@ osg::Node* daeReader::processMorph(domMorph* pDomMorph, domBind_material* pDomBi
osg::Geode* targetgeode = getOrCreateGeometry(pDomGeometry, NULL);
// Expects a single geometry inside the geode, should change this
- osg::Geometry* pOsgGeometry = dynamic_cast<osg::Geometry*>(targetgeode->getDrawable(0));
- if (pOsgGeometry)
+ osg::Geometry* geometry = dynamic_cast<osg::Geometry*>(targetgeode->getDrawable(0));
+ if (geometry)
{
- pOsgMorphGeometry->addMorphTarget(pOsgGeometry);
+ pOsgMorphGeometry->addMorphTarget(geometry);
}
}
else
@@ -596,10 +596,6 @@ void daeReader::processPolygons(osg::Geode* geode,
osg::DrawElementsUInt* pDrawElements = new osg::DrawElementsUInt(GL_TRIANGLES);
geometry->addPrimitiveSet(pDrawElements);
- std::vector<std::vector<GLuint> > indexLists;
- resolveMeshArrays(group->getP_array(), group->getInput_array(), pDomMesh,
- geometry, sources, indexLists);
-
for ( size_t i = 0; i < indexLists.size(); ++i)
{
const std::vector<GLuint>& indices = indexLists[i];
@@ -960,18 +956,18 @@ void daeReader::resolveMeshArrays(const domP_Array& domPArray,
//We keep somewhere the mapping between daeElement id and created arrays
_texCoordIdMap.insert(std::pair<std::string,size_t>(id,texcoord_set));
// 2D Texcoords
- osg::ref_ptr<osg::Array> array( createGeometryArray<osg::Vec2Array, osg::Vec2dArray, VertexIndices::TEXCOORD>(sources[texcoord_source], vertexIndicesIndexMap, readDoubleTexcoords, texcoord_set) );
- if (array.valid())
+ osg::ref_ptr<osg::Array> array2d( createGeometryArray<osg::Vec2Array, osg::Vec2dArray, VertexIndices::TEXCOORD>(sources[texcoord_source], vertexIndicesIndexMap, readDoubleTexcoords, texcoord_set) );
+ if (array2d.valid())
{
- geometry->setTexCoordArray(texcoord_set, array.get());
+ geometry->setTexCoordArray(texcoord_set, array2d.get());
}
else
{
// 3D Textcoords
- osg::ref_ptr<osg::Array> array( createGeometryArray<osg::Vec3Array, osg::Vec3dArray, VertexIndices::TEXCOORD>(sources[texcoord_source], vertexIndicesIndexMap, readDoubleTexcoords, texcoord_set) );
- if (array.valid())
+ osg::ref_ptr<osg::Array> array3d( createGeometryArray<osg::Vec3Array, osg::Vec3dArray, VertexIndices::TEXCOORD>(sources[texcoord_source], vertexIndicesIndexMap, readDoubleTexcoords, texcoord_set) );
+ if (array3d.valid())
{
- geometry->setTexCoordArray(texcoord_set, array.get());
+ geometry->setTexCoordArray(texcoord_set, array3d.get());
}
}
}
diff --git a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeRMaterials.cpp b/src/osgPlugins/dae/daeRMaterials.cpp
index 158ca35ef..d4c2703b2 100644
--- a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeRMaterials.cpp
+++ b/src/osgPlugins/dae/daeRMaterials.cpp
@@ -589,8 +589,6 @@ bool daeReader::processColorOrTextureType(const osg::StateSet* ss,
}
bool retVal = false;
- std::string texCoordSet;
-
//osg::StateAttribute *sa = NULL;
//TODO: Make all channels process <param ref=""> type of value
if (channel == osg::Material::EMISSION )
@@ -1017,6 +1015,11 @@ osg::Texture2D* daeReader::processTexture(
domFx_surface_common *surface = NULL;
domImage *dImg = NULL;
+ if(tex->getTexture() == NULL)
+ {
+ return NULL;
+ }
+
std::string target = std::string("./") + std::string(tex->getTexture());
OSG_INFO<<"processTexture("<<target<<")"<<std::endl;
@@ -1159,7 +1162,10 @@ osg::Texture2D* daeReader::processTexture(
_textureParamMap[parameters] = t2D;
}
- _texCoordSetMap[TextureToCoordSetMap::key_type(ss, tuu)] = tex->getTexcoord();
+ if(tex->getTexcoord() != NULL)
+ {
+ _texCoordSetMap[TextureToCoordSetMap::key_type(ss, tuu)] = tex->getTexcoord();
+ }
return t2D;
}
diff --git a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeRSceneObjects.cpp b/src/osgPlugins/dae/daeRSceneObjects.cpp
index 9874ed315..9096345a4 100644
--- a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeRSceneObjects.cpp
+++ b/src/osgPlugins/dae/daeRSceneObjects.cpp
@@ -361,7 +361,7 @@ osg::Node* daeReader::processLight( domLight *dlight )
lightmodel->setAmbientIntensity(osg::Vec4(0.0f,0.0f,0.0f,1.0f));
_rootStateSet->setAttributeAndModes(lightmodel, osg::StateAttribute::ON);
- osg::LightSource* lightsource = new osg::LightSource();
+ osg::ref_ptr<osg::LightSource> lightsource = new osg::LightSource();
lightsource->setLight(light);
std::string name = dlight->getId() ? dlight->getId() : "";
if (dlight->getName())
@@ -520,7 +520,7 @@ osg::Node* daeReader::processLight( domLight *dlight )
light->setDirection(osg::Vec3(0, 0, -1));
}
- return lightsource;
+ return lightsource.release();
}
// <camera>
diff --git a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeRTransforms.cpp b/src/osgPlugins/dae/daeRTransforms.cpp
index 9100b8d0b..be182f854 100644
--- a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeRTransforms.cpp
+++ b/src/osgPlugins/dae/daeRTransforms.cpp
@@ -33,7 +33,7 @@ using namespace osgDAE;
// Note <lookat>, <matrix>, <rotate>, <scale>, <skew> and <translate> may appear in any order
// These transformations can be combined in any number and ordering to produce the desired
-// coordinate system for the parent <node> element. The COLLADA specificatin requires that the
+// coordinate system for the parent <node> element. The COLLADA specification requires that the
// transformation elements are processed in order and accumulate the result as if they were
// converted to column-order matrices and concatenated using matrix post-multiplication.
osg::Transform* daeReader::processOsgMatrixTransform(domNode *node, bool isBone)
diff --git a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeReader.cpp b/src/osgPlugins/dae/daeReader.cpp
index e7dbe956e..282389fd0 100644
--- a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeReader.cpp
+++ b/src/osgPlugins/dae/daeReader.cpp
@@ -185,9 +185,9 @@ bool daeReader::processDocument( const std::string& fileURI)
// identify every node as a joint, making it meaningless.
std::vector<domInstance_controller*> instanceControllers;
database->typeLookup(instanceControllers);
- for (size_t i = 0; i < instanceControllers.size(); ++i)
+ for (size_t controller = 0; controller < instanceControllers.size(); ++controller)
{
- domInstance_controller* pInstanceController = instanceControllers[i];
+ domInstance_controller* pInstanceController = instanceControllers[controller];
domController *pDomController = daeSafeCast<domController>(getElementFromURI(pInstanceController->getUrl()));
if (!pDomController)
diff --git a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeWAnimations.cpp b/src/osgPlugins/dae/daeWAnimations.cpp
index 7bb793125..6927a4afe 100644
--- a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeWAnimations.cpp
+++ b/src/osgPlugins/dae/daeWAnimations.cpp
@@ -35,10 +35,10 @@
using namespace osgDAE;
-void daeWriter::writeAnimations( osg::Node &node )
+void daeWriter::writeAnimations( osg::Node &wnode )
{
- const std::string nodeNameUTF( _pluginOptions.namesUseCodepage ? osgDB::convertStringFromCurrentCodePageToUTF8(node.getName()) : node.getName() );
- osg::Callback* ncb = node.getUpdateCallback();
+ const std::string nodeNameUTF( _pluginOptions.namesUseCodepage ? osgDB::convertStringFromCurrentCodePageToUTF8(wnode.getName()) : wnode.getName() );
+ osg::Callback* ncb = wnode.getUpdateCallback();
if (ncb)
{
osgAnimation::AnimationManagerBase* am = dynamic_cast<osgAnimation::AnimationManagerBase*>(ncb);
@@ -51,12 +51,12 @@ void daeWriter::writeAnimations( osg::Node &node )
}
osgAnimation::AnimationList animationList = am->getAnimationList();
- for (size_t i = 0; i < animationList.size(); i++)
+ for (size_t ai = 0; ai < animationList.size(); ai++)
{
domAnimation* pDomAnimation = daeSafeCast< domAnimation >( _domLibraryAnimations->add( COLLADA_ELEMENT_ANIMATION ) );
domAnimation* pMainDomAnimation = pDomAnimation;
- osg::ref_ptr<osgAnimation::Animation> animation = animationList[i];
+ osg::ref_ptr<osgAnimation::Animation> animation = animationList[ai];
std::string animationName( animation->getName() );
if (animationName.empty())
animationName = "animation";
@@ -264,7 +264,7 @@ void daeWriter::writeAnimations( osg::Node &node )
{
domInputLocal* pDomInput = daeSafeCast< domInputLocal >(pDomSampler->add(COLLADA_ELEMENT_INPUT));
pDomInput->setSemantic(COMMON_PROFILE_INPUT_INPUT);
- std::string url = "#" + inputSourceName;
+ url = "#" + inputSourceName;
pDomInput->setSource(url.c_str());
pDomInput = daeSafeCast< domInputLocal >(pDomSampler->add(COLLADA_ELEMENT_INPUT));
@@ -280,7 +280,7 @@ void daeWriter::writeAnimations( osg::Node &node )
// Set sampler as source
domChannel* pDomChannel = daeSafeCast< domChannel >(pDomAnimation->add(COLLADA_ELEMENT_CHANNEL));
- std::string url = "#" + sourceNameX;
+ url = "#" + sourceNameX;
pDomChannel->setSource(url.c_str());
// targetName contains the name of the updateCallback
@@ -308,7 +308,7 @@ void daeWriter::writeAnimations( osg::Node &node )
{
domInputLocal* pDomInput = daeSafeCast< domInputLocal >(pDomSampler->add(COLLADA_ELEMENT_INPUT));
pDomInput->setSemantic(COMMON_PROFILE_INPUT_INPUT);
- std::string url = "#" + inputSourceName;
+ url = "#" + inputSourceName;
pDomInput->setSource(url.c_str());
pDomInput = daeSafeCast< domInputLocal >(pDomSampler->add(COLLADA_ELEMENT_INPUT));
@@ -324,7 +324,7 @@ void daeWriter::writeAnimations( osg::Node &node )
// Set sampler as source
domChannel* pDomChannel = daeSafeCast< domChannel >(pDomAnimation->add(COLLADA_ELEMENT_CHANNEL));
- std::string url = "#" + sourceNameY;
+ url = "#" + sourceNameY;
pDomChannel->setSource(url.c_str());
// targetName contains the name of the updateCallback
@@ -352,7 +352,7 @@ void daeWriter::writeAnimations( osg::Node &node )
{
domInputLocal* pDomInput = daeSafeCast< domInputLocal >(pDomSampler->add(COLLADA_ELEMENT_INPUT));
pDomInput->setSemantic(COMMON_PROFILE_INPUT_INPUT);
- std::string url = "#" + inputSourceName;
+ url = "#" + inputSourceName;
pDomInput->setSource(url.c_str());
pDomInput = daeSafeCast< domInputLocal >(pDomSampler->add(COLLADA_ELEMENT_INPUT));
@@ -368,7 +368,7 @@ void daeWriter::writeAnimations( osg::Node &node )
// Set sampler as source
domChannel* pDomChannel = daeSafeCast< domChannel >(pDomAnimation->add(COLLADA_ELEMENT_CHANNEL));
- std::string url = "#" + sourceNameZ;
+ url = "#" + sourceNameZ;
pDomChannel->setSource(url.c_str());
// targetName contains the name of the updateCallback
@@ -438,7 +438,7 @@ void daeWriter::writeAnimations( osg::Node &node )
{
domInputLocal* pDomInput = daeSafeCast< domInputLocal >(pDomSampler->add(COLLADA_ELEMENT_INPUT));
pDomInput->setSemantic(COMMON_PROFILE_INPUT_INPUT);
- std::string url = "#" + inputSourceName;
+ url = "#" + inputSourceName;
pDomInput->setSource(url.c_str());
pDomInput = daeSafeCast< domInputLocal >(pDomSampler->add(COLLADA_ELEMENT_INPUT));
@@ -454,7 +454,7 @@ void daeWriter::writeAnimations( osg::Node &node )
// Set sampler as source
domChannel* pDomChannel = daeSafeCast< domChannel >(pDomAnimation->add(COLLADA_ELEMENT_CHANNEL));
- std::string url = "#" + sourceName;
+ url = "#" + sourceName;
pDomChannel->setSource(url.c_str());
// targetName contains the name of the updateCallback
diff --git a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeWGeometry.cpp b/src/osgPlugins/dae/daeWGeometry.cpp
index 6eff94141..e7a8788ea 100644
--- a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeWGeometry.cpp
+++ b/src/osgPlugins/dae/daeWGeometry.cpp
@@ -175,12 +175,12 @@ void daeWriter::writeRigGeometry(osgAnimation::RigGeometry *pOsgRigGeometry)
int size = 0; // TODO number of animated joints
osgAnimation::VertexInfluenceMap* vim = pOsgRigGeometry->getInfluenceMap();
- osgAnimation::VertexInfluenceMap::iterator iter = vim->begin();
- while (iter != vim->end())
+ osgAnimation::VertexInfluenceMap::iterator vim_iter = vim->begin();
+ while (vim_iter != vim->end())
{
- jointNames.append(iter->first.c_str());
- //iter->second.getn
- ++iter;
+ jointNames.append(vim_iter->first.c_str());
+ //vim_iter->second.getn
+ ++vim_iter;
}
domName_array* pDomJointsNameArray = daeSafeCast< domName_array >(pDomJointsSource->add(COLLADA_ELEMENT_NAME_ARRAY));
@@ -192,7 +192,7 @@ void daeWriter::writeRigGeometry(osgAnimation::RigGeometry *pOsgRigGeometry)
domSource::domTechnique_common* pDomSourceTechniqueCommon = daeSafeCast< domSource::domTechnique_common >(pDomJointsSource->add(COLLADA_ELEMENT_TECHNIQUE_COMMON));
domAccessor* pDomAccessor = daeSafeCast< domAccessor >(pDomSourceTechniqueCommon->add(COLLADA_ELEMENT_ACCESSOR));
- std::string url = "#" + jointsNameArrayName;
+ url = "#" + jointsNameArrayName;
pDomAccessor->setSource(url.c_str());
pDomAccessor->setCount(size);
@@ -215,7 +215,7 @@ void daeWriter::writeRigGeometry(osgAnimation::RigGeometry *pOsgRigGeometry)
domSource::domTechnique_common* pDomSourceTechniqueCommon = daeSafeCast< domSource::domTechnique_common >(pDomSkinBindPoseSource->add(COLLADA_ELEMENT_TECHNIQUE_COMMON));
domAccessor* pDomAccessor = daeSafeCast< domAccessor >(pDomSourceTechniqueCommon->add(COLLADA_ELEMENT_ACCESSOR));
- std::string url = "#" + matricesArrayName;
+ url = "#" + matricesArrayName;
pDomAccessor->setSource(url.c_str());
pDomAccessor->setCount(size);
pDomAccessor->setStride(16);
@@ -239,7 +239,7 @@ void daeWriter::writeRigGeometry(osgAnimation::RigGeometry *pOsgRigGeometry)
domSource::domTechnique_common* pDomSourceTechniqueCommon = daeSafeCast< domSource::domTechnique_common >(pDomSkinWeightsSource->add(COLLADA_ELEMENT_TECHNIQUE_COMMON));
domAccessor* pDomAccessor = daeSafeCast< domAccessor >(pDomSourceTechniqueCommon->add(COLLADA_ELEMENT_ACCESSOR));
- std::string url = "#" + weightsArrayName;
+ url = "#" + weightsArrayName;
pDomAccessor->setSource(url.c_str());
pDomAccessor->setCount(size);
@@ -345,8 +345,8 @@ void daeWriter::writeMorphGeometry(osgAnimation::MorphGeometry *pOsgMorphGeometr
osgAnimation::MorphGeometry::MorphTargetList morphTargetList = pOsgMorphGeometry->getMorphTargetList();
for (unsigned int i=0; i < morphTargetList.size(); i++)
{
- domGeometry* pDomGeometry = getOrCreateDomGeometry(morphTargetList[i].getGeometry());
- idrefs.append(pDomGeometry->getId());
+ domGeometry* pRefDomGeometry = getOrCreateDomGeometry(morphTargetList[i].getGeometry());
+ idrefs.append(pRefDomGeometry->getId());
}
pDomIDREFArray->setValue(idrefs);
std::string targetsArrayName = targetsName + "_array";
diff --git a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeWSceneObjects.cpp b/src/osgPlugins/dae/daeWSceneObjects.cpp
index cadb65c98..72dab08c8 100644
--- a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeWSceneObjects.cpp
+++ b/src/osgPlugins/dae/daeWSceneObjects.cpp
@@ -436,7 +436,7 @@ void daeWriter::apply( osg::LightSource &node )
if ((ambientColor.r() != 0) || (ambientColor.g() != 0) || (ambientColor.b() != 0))
{
domInstance_light *ambientDomInstanceLight = daeSafeCast< domInstance_light >(currentNode->add( COLLADA_ELEMENT_INSTANCE_LIGHT ));
- std::string name = node.getName();
+ name = node.getName();
if (name.empty())
{
name = uniquify( "light-ambient" );
@@ -445,7 +445,7 @@ void daeWriter::apply( osg::LightSource &node )
{
name += "-ambient";
}
- std::string url = "#" + name;
+ url = "#" + name;
ambientDomInstanceLight->setUrl( url.c_str() );
domLight *ambientDomLight = daeSafeCast< domLight >( lib_lights->add( COLLADA_ELEMENT_LIGHT ) );
diff --git a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeWTransforms.cpp b/src/osgPlugins/dae/daeWTransforms.cpp
index 79d408c4e..a51d9b608 100644
--- a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeWTransforms.cpp
+++ b/src/osgPlugins/dae/daeWTransforms.cpp
@@ -39,7 +39,7 @@ void daeWriter::writeUpdateTransformElements(const osg::Vec3 &pos, const osg::Qu
// Make a three rotate place elements for the euler angles
// TODO decompose quaternion into three euler angles
- double angle;
+ osg::Quat::value_type angle;
osg::Vec3 axis;
q.getRotate( angle, axis );
@@ -154,7 +154,7 @@ void daeWriter::apply( osg::PositionAttitudeTransform &node )
scale->getValue().append3( s.x(), s.y(), s.z() );
}
- double angle;
+ osg::Quat::value_type angle;
osg::Vec3 axis;
q.getRotate( angle, axis );
if ( angle != 0 )
diff --git a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeWriter.cpp b/src/osgPlugins/dae/daeWriter.cpp
index c9089bd54..acd40e96e 100644
--- a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeWriter.cpp
+++ b/src/osgPlugins/dae/daeWriter.cpp
@@ -19,16 +19,17 @@
#include <dom/domConstants.h>
#include <sstream>
+#include <stdexcept>
#include <osgDB/ConvertUTF>
-
+#include <limits>
namespace osgDAE {
-daeWriter::ArrayNIndices::ArrayNIndices( osg::Array* valArray, osg::IndexArray* ind ) :
+daeWriter::ArrayNIndices::ArrayNIndices( osg::Array* vArray, osg::IndexArray* ind ) :
vec2(0), vec3(0), vec4(0),
vec2d(0), vec3d(0), vec4d(0),
vec4ub(0),
- valArray(valArray),
+ valArray(vArray),
inds( ind ), mode(NONE)
{
if ( valArray != NULL )
@@ -71,6 +72,20 @@ daeWriter::ArrayNIndices::ArrayNIndices( osg::Array* valArray, osg::IndexArray*
}
+std::string toString(const osg::Vec2f& value)
+{
+ std::stringstream str;
+ str << value.x() << " " << value.y();
+ return str.str();
+}
+
+std::string toString(const osg::Vec2d& value)
+{
+ std::stringstream str;
+ str << value.x() << " " << value.y();
+ return str.str();
+}
+
std::string toString(const osg::Vec3f& value)
{
std::stringstream str;
@@ -85,7 +100,22 @@ std::string toString(const osg::Vec3d& value)
return str.str();
}
-std::string toString(const osg::Matrix& value)
+std::string toString(const osg::Vec4f& value)
+{
+ std::stringstream str;
+ str << value.x() << " " << value.y() << " " << value.z() << " " << value.w();
+ return str.str();
+}
+
+std::string toString(const osg::Vec4d& value)
+{
+ std::stringstream str;
+ str << value.x() << " " << value.y() << " " << value.z() << " " << value.w();
+ return str.str();
+}
+
+template <typename T>
+std::string matrixToString(T value)
{
std::stringstream str;
str << value(0,0) << " " << value(1,0) << " " << value(2,0) << " " << value(3,0) << " "
@@ -95,6 +125,15 @@ std::string toString(const osg::Matrix& value)
return str.str();
}
+std::string toString(const osg::Matrixf& value)
+{
+ return matrixToString<osg::Matrixf>(value);
+}
+
+std::string toString(const osg::Matrixd& value)
+{
+ return matrixToString<osg::Matrixd>(value);
+}
daeWriter::Options::Options()
: usePolygons(false),
@@ -104,7 +143,8 @@ daeWriter::Options::Options()
linkOrignialTextures(false),
forceTexture(false),
namesUseCodepage(false),
- relativiseImagesPathNbUpDirs(0)
+ relativiseImagesPathNbUpDirs(0),
+ renameIds(false)
{}
daeWriter::daeWriter( DAE *dae_, const std::string & fileURI, const std::string & directory, const std::string & srcDirectory, const osgDB::ReaderWriter::Options * options, TraversalMode tm, const Options * pluginOptions) : osg::NodeVisitor( tm ),
@@ -209,22 +249,31 @@ void daeWriter::updateCurrentDaeNode()
}
}
-std::string daeWriter::uniquify( const std::string &_name )
+std::string daeWriter::uniquify( const std::string & uname )
{
- const std::string name( _pluginOptions.namesUseCodepage ? osgDB::convertStringFromCurrentCodePageToUTF8(_name) : _name );
- std::map< std::string, int >::iterator iter = uniqueNames.find( name );
- if ( iter != uniqueNames.end() )
+ const std::string baseName( _pluginOptions.namesUseCodepage ? osgDB::convertStringFromCurrentCodePageToUTF8(uname) : uname );
+ std::string newName( baseName );
+ if (_pluginOptions.renameIds)
{
- iter->second++;
- std::ostringstream num;
- num << std::dec << iter->second;
- return name + "_" + num.str();
+ // Turn 'newName' into a simple ID
+ // Note: ConvertFilePathToColladaCompatibleURI(newName) did not the job: names such as "C:\somedir\somefile" become "/C:/somedir/somefile" and are not interpreted as a simple ID within Google Earth.
+ static const char * const REPLACE_CHARS = " /\\:#?=%&*";
+ for(std::size_t found = newName.find_first_of(REPLACE_CHARS); found != std::string::npos; found = newName.find_first_of(REPLACE_CHARS)) newName[found] = '_';
}
- else
+
+ // Loop while newName is in use
+ UniqueNames::iterator iter;
+ for (iter = uniqueNames.find(newName); iter != uniqueNames.end(); iter = uniqueNames.find(newName))
{
- uniqueNames.insert( std::make_pair( name, 0 ) );
- return name;
+ if (iter->second == std::numeric_limits<UniqueNames::mapped_type>::max()) throw std::runtime_error("Not implemented: renaming DAE name above given limit.");
+ iter->second++; // Increment usage count
+ std::ostringstream num;
+ num << std::dec << iter->second;
+ newName = baseName + "_" + num.str();
}
+
+ uniqueNames.insert( std::make_pair( newName, 0 ) );
+ return newName;
}
void daeWriter::createAssetTag( bool isZUpAxis )
diff --git a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeWriter.h b/src/osgPlugins/dae/daeWriter.h
index a2f18d874..5a74132d9 100644
--- a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeWriter.h
+++ b/src/osgPlugins/dae/daeWriter.h
@@ -89,9 +89,14 @@ std::string toString(T value)
return str.str();
}
+std::string toString(const osg::Vec2f& value);
+std::string toString(const osg::Vec2d& value);
std::string toString(const osg::Vec3f& value);
std::string toString(const osg::Vec3d& value);
-std::string toString(const osg::Matrix& value);
+std::string toString(const osg::Vec4f& value);
+std::string toString(const osg::Vec4d& value);
+std::string toString(const osg::Matrixf& value);
+std::string toString(const osg::Matrixd& value);
// Collects all nodes that are targeted by an animation
class FindAnimatedNodeVisitor : public osg::NodeVisitor
@@ -164,6 +169,8 @@ public:
bool forceTexture;
bool namesUseCodepage;
unsigned int relativiseImagesPathNbUpDirs;
+ /** Rename all IDs (geometries, materials, etc.) to remove characters which may be interpreted as an URI. */
+ bool renameIds;
};
daeWriter(DAE *dae_, const std::string &fileURI, const std::string & directory, const std::string & srcDirectory, const osgDB::ReaderWriter::Options * options, TraversalMode tm=TRAVERSE_ALL_CHILDREN, const Options * pluginOptions=NULL);
virtual ~daeWriter();
@@ -264,7 +271,8 @@ protected: //members
typedef std::map< osgAnimation::RigGeometry*, domController *> OsgRigGeometryDomControllerMap;
typedef std::map< osgAnimation::MorphGeometry*, domController *> OsgMorphGeometryDomControllerMap;
- std::map< std::string, int > uniqueNames;
+ typedef std::map< std::string, int > UniqueNames;
+ UniqueNames uniqueNames;
OsgGeometryDomGeometryMap geometryMap;
OsgRigGeometryDomControllerMap _osgRigGeometryDomControllerMap;
OsgMorphGeometryDomControllerMap _osgMorphGeometryDomControllerMap;
......@@ -2,3 +2,4 @@ disable-zip-plugin-with-embedded-zlib.patch
no-xine-malloc-aligned.diff
0006-Occlusion-Queries-Stuttering-fix-from-upstream.patch
0007-Explicit-signed-char-type-for-portability-base64.patch
collada.patch