diff --git a/code/ColladaExporter.cpp b/code/ColladaExporter.cpp
index 982c7c489..03e59b8ad 100644
--- a/code/ColladaExporter.cpp
+++ b/code/ColladaExporter.cpp
@@ -122,7 +122,9 @@ void ColladaExporter::WriteHeader()
mOutput << startstr << "Assimp Collada Exporter" << endstr;
PopTag();
mOutput << startstr << "" << endstr;
- mOutput << startstr << "" << endstr;
+ mOutput << startstr << "2000-01-01T23:59:59" << endstr;
+ mOutput << startstr << "2000-01-01T23:59:59" << endstr;
+ mOutput << startstr << "" << endstr;
mOutput << startstr << "Y_UP" << endstr;
PopTag();
mOutput << startstr << "" << endstr;
@@ -152,7 +154,7 @@ void ColladaExporter::WriteImageEntry( const Surface& pSurface, const std::strin
{
if( !pSurface.texture.empty() )
{
- mOutput << startstr << "" << endstr;
+ mOutput << startstr << "" << endstr;
PushTag();
mOutput << startstr << "" << pSurface.texture << "" << endstr;
PopTag();
@@ -177,6 +179,35 @@ void ColladaExporter::WriteTextureColorEntry( const Surface& pSurface, const std
mOutput << startstr << "" << pTypeName << ">" << endstr;
}
+// ------------------------------------------------------------------------------------------------
+// Writes the two parameters necessary for referencing a texture in an effect entry
+void ColladaExporter::WriteTextureParamEntry( const Surface& pSurface, const std::string& pTypeName, const std::string& pMatName)
+{
+ // if surface is a texture, write out the sampler and the surface parameters necessary to reference the texture
+ if( !pSurface.texture.empty() )
+ {
+ mOutput << startstr << "" << endstr;
+ PushTag();
+ mOutput << startstr << "" << endstr;
+ PushTag();
+ mOutput << startstr << "" << pMatName << "-" << pTypeName << "-image" << endstr;
+ PopTag();
+ mOutput << startstr << "" << endstr;
+ PopTag();
+ mOutput << startstr << "" << endstr;
+
+ mOutput << startstr << "" << endstr;
+ PushTag();
+ mOutput << startstr << "" << endstr;
+ PushTag();
+ mOutput << startstr << "" << endstr;
+ PopTag();
+ mOutput << startstr << "" << endstr;
+ PopTag();
+ mOutput << startstr << "" << endstr;
+ }
+}
+
// ------------------------------------------------------------------------------------------------
// Writes the material setup
void ColladaExporter::WriteMaterials()
@@ -191,7 +222,10 @@ void ColladaExporter::WriteMaterials()
aiString name;
if( mat->Get( AI_MATKEY_NAME, name) != aiReturn_SUCCESS )
name = "mat";
- materials[a].name = boost::lexical_cast (a) + name.C_Str();
+ materials[a].name = std::string( "m") + boost::lexical_cast (a) + name.C_Str();
+ size_t pos;
+ while( (pos = materials[a].name.find( '#')) != std::string::npos )
+ materials[a].name[pos] = 'x';
ReadMaterialSurface( materials[a].ambient, mat, aiTextureType_AMBIENT, AI_MATKEY_COLOR_AMBIENT);
ReadMaterialSurface( materials[a].diffuse, mat, aiTextureType_DIFFUSE, AI_MATKEY_COLOR_DIFFUSE);
@@ -209,12 +243,12 @@ void ColladaExporter::WriteMaterials()
for( std::vector::const_iterator it = materials.begin(); it != materials.end(); ++it )
{
const Material& mat = *it;
- WriteImageEntry( mat.ambient, mat.name + "_ambient_image");
- WriteImageEntry( mat.diffuse, mat.name + "_diffuse_image");
- WriteImageEntry( mat.specular, mat.name + "_specular_image");
- WriteImageEntry( mat.emissive, mat.name + "_emissive_image");
- WriteImageEntry( mat.reflective, mat.name + "_reflective_image");
- WriteImageEntry( mat.normal, mat.name + "_normal_image");
+ WriteImageEntry( mat.ambient, mat.name + "-ambient-image");
+ WriteImageEntry( mat.diffuse, mat.name + "-diffuse-image");
+ WriteImageEntry( mat.specular, mat.name + "-specular-image");
+ WriteImageEntry( mat.emissive, mat.name + "-emissive-image");
+ WriteImageEntry( mat.reflective, mat.name + "-reflective-image");
+ WriteImageEntry( mat.normal, mat.name + "-normal-image");
}
PopTag();
mOutput << startstr << "" << endstr;
@@ -230,18 +264,23 @@ void ColladaExporter::WriteMaterials()
PushTag();
mOutput << startstr << "" << endstr;
PushTag();
+
+ // write sampler- and surface params for the texture entries
+ WriteTextureParamEntry( mat.emissive, "emissive", mat.name);
+ WriteTextureParamEntry( mat.ambient, "ambient", mat.name);
+ WriteTextureParamEntry( mat.diffuse, "diffuse", mat.name);
+ WriteTextureParamEntry( mat.specular, "specular", mat.name);
+ WriteTextureParamEntry( mat.reflective, "reflective", mat.name);
+
mOutput << startstr << "" << endstr;
PushTag();
mOutput << startstr << "" << endstr;
PushTag();
- WriteTextureColorEntry( mat.ambient, "ambient", mat.name + "_ambient_image");
- WriteTextureColorEntry( mat.diffuse, "diffuse", mat.name + "_diffuse_image");
- WriteTextureColorEntry( mat.specular, "specular", mat.name + "_specular_image");
- WriteTextureColorEntry( mat.emissive, "emission", mat.name + "_emissive_image");
- WriteTextureColorEntry( mat.reflective, "reflective", mat.name + "_reflective_image");
- if( !mat.normal.texture.empty() )
- WriteTextureColorEntry( mat.normal, "bump", mat.name + "_normal_image");
+ WriteTextureColorEntry( mat.emissive, "emission", mat.name + "-emissive-sampler");
+ WriteTextureColorEntry( mat.ambient, "ambient", mat.name + "-ambient-sampler");
+ WriteTextureColorEntry( mat.diffuse, "diffuse", mat.name + "-diffuse-sampler");
+ WriteTextureColorEntry( mat.specular, "specular", mat.name + "-specular-sampler");
mOutput << startstr << "" << endstr;
PushTag();
@@ -249,6 +288,13 @@ void ColladaExporter::WriteMaterials()
PopTag();
mOutput << startstr << "" << endstr;
+ WriteTextureColorEntry( mat.reflective, "reflective", mat.name + "-reflective-sampler");
+
+// deactivated because the Collada spec PHONG model does not allow other textures.
+// if( !mat.normal.texture.empty() )
+// WriteTextureColorEntry( mat.normal, "bump", mat.name + "-normal-sampler");
+
+
PopTag();
mOutput << startstr << "" << endstr;
PopTag();
@@ -340,12 +386,12 @@ void ColladaExporter::WriteGeometry( size_t pIndex)
for( size_t a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a )
{
if( mesh->HasTextureCoords( a) )
- mOutput << startstr << "" << endstr;
+ mOutput << startstr << "" << endstr;
}
for( size_t a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; ++a )
{
if( mesh->HasVertexColors( a) )
- mOutput << startstr << "" << endstr;
+ mOutput << startstr << "" << endstr;
}
PopTag();
diff --git a/code/ColladaExporter.h b/code/ColladaExporter.h
index cfe5a8db7..198e42591 100644
--- a/code/ColladaExporter.h
+++ b/code/ColladaExporter.h
@@ -136,6 +136,8 @@ protected:
void ReadMaterialSurface( Surface& poSurface, const aiMaterial* pSrcMat, aiTextureType pTexture, const char* pKey, size_t pType, size_t pIndex);
/// Writes an image entry for the given surface
void WriteImageEntry( const Surface& pSurface, const std::string& pNameAdd);
+ /// Writes the two parameters necessary for referencing a texture in an effect entry
+ void WriteTextureParamEntry( const Surface& pSurface, const std::string& pTypeName, const std::string& pMatName);
/// Writes a color-or-texture entry into an effect definition
void WriteTextureColorEntry( const Surface& pSurface, const std::string& pTypeName, const std::string& pImageName);
};