From Sukender, "Here are two sumbissions for DAE.

1. daeRGeometry.cpp (rev 12132). A tiny sumbission which fixes a quite important bug: a parameter was forgotten in Collada ReaderWriter, and texture coordinates could not be loaded properly. So:
"
Added missing paramter when calling createGeometryData(). Fixes missing texture coordinates (in "bind_vertex_input").
"

2. ReaderWriterDAE.cpp (rev 12132):
"
Added "baseImageDir" as a plugin string data, in order to manually specify base directory to use when relativising image file names. This is used to properly write files, when images are not located in a subdirectory (like "../images" for some software).
"
This commit is contained in:
Robert Osfield
2011-02-14 14:16:58 +00:00
parent b5a14f8d68
commit 3128c8063e
2 changed files with 8 additions and 3 deletions

View File

@@ -115,9 +115,14 @@ ReaderWriterDAE::writeNode( const osg::Node& node,
bool linkOrignialTextures(false);
bool forceTexture(false);
bool namesUseCodepage(false);
std::string srcDirectory( osgDB::getFilePath(node.getName().empty() ? fname : node.getName()) ); // Base dir when relativising images paths
if( options )
{
pDAE = (DAE*)options->getPluginData("DAE");
const std::string & baseDir = options->getPluginStringData("baseImageDir"); // Rename "srcModelPath" (and call getFilePath() on it)?
if (!baseDir.empty()) srcDirectory = baseDir;
// Sukender's note: I don't know why DAE seems to accept comma-sparated options instead of space-separated options as other ReaderWriters. However, to avoid breaking compatibility, here's a workaround:
std::string optString( options->getOptionString() );
for(std::string::iterator it=optString.begin(); it!=optString.end(); ++it) {
@@ -155,7 +160,7 @@ ReaderWriterDAE::writeNode( const osg::Node& node,
osg::NodeVisitor::TraversalMode traversalMode = writeExtras ? osg::NodeVisitor::TRAVERSE_ALL_CHILDREN : osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN;
osgDAE::daeWriter daeWriter(pDAE, fileURI, osgDB::getFilePath(fname), osgDB::getFilePath(node.getName().empty() ? fname : node.getName()), options, usePolygon, googleMode, traversalMode, writeExtras, earthTex, zUpAxis, linkOrignialTextures, forceTexture, namesUseCodepage);
osgDAE::daeWriter daeWriter(pDAE, fileURI, osgDB::getFilePath(fname), srcDirectory, options, usePolygon, googleMode, traversalMode, writeExtras, earthTex, zUpAxis, linkOrignialTextures, forceTexture, namesUseCodepage);
daeWriter.setRootNode( node );
const_cast<osg::Node*>(&node)->accept( daeWriter );

View File

@@ -746,8 +746,8 @@ osg::Geometry::ArrayData createGeometryData(domSourceReader & sourceReader, cons
template <class ArrayTypeSingle, class ArrayTypeDouble, int Value>
inline osg::Geometry::ArrayData createGeometryData(domSourceReader & sourceReader, const VertexIndicesIndexMap & vertexIndicesIndexMap, bool useDoublePrecision, int texcoordNum=-1) {
if (useDoublePrecision) return createGeometryData<ArrayTypeDouble, Value>(sourceReader, vertexIndicesIndexMap);
else return createGeometryData<ArrayTypeSingle, Value>(sourceReader, vertexIndicesIndexMap);
if (useDoublePrecision) return createGeometryData<ArrayTypeDouble, Value>(sourceReader, vertexIndicesIndexMap, texcoordNum);
else return createGeometryData<ArrayTypeSingle, Value>(sourceReader, vertexIndicesIndexMap, texcoordNum);
}