- Uv coords are no flipped so that they are correct now

- Custom Materials can be read (see Ogre importer documentation)
- Blender Ogre Exporter Material Template File added

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@477 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/1/head
jonathanklein 2009-09-05 15:49:23 +00:00
parent 8cfb2e26cf
commit 3cb336ff7d
3 changed files with 55 additions and 8 deletions

View File

@ -55,7 +55,7 @@ void OgreImporter::InternReadFile(const std::string &pFile, aiScene *pScene, Ass
throw new ImportErrorException("Failed to create XML Reader for "+pFile); throw new ImportErrorException("Failed to create XML Reader for "+pFile);
DefaultLogger::get()->info("Mesh File opened"); DefaultLogger::get()->debug("Mesh File opened");
//Read root Node: //Read root Node:
if(!(XmlRead(MeshFile) && string(MeshFile->getNodeName())=="mesh")) if(!(XmlRead(MeshFile) && string(MeshFile->getNodeName())=="mesh"))
@ -76,7 +76,7 @@ void OgreImporter::InternReadFile(const std::string &pFile, aiScene *pScene, Ass
{ {
SubMesh NewSubMesh; SubMesh NewSubMesh;
NewSubMesh.MaterialName=GetAttribute<string>(MeshFile, "material"); NewSubMesh.MaterialName=GetAttribute<string>(MeshFile, "material");
DefaultLogger::get()->info("Loading Submehs with Material: "+NewSubMesh.MaterialName); DefaultLogger::get()->debug("Loading Submehs with Material: "+NewSubMesh.MaterialName);
ReadSubMesh(NewSubMesh, MeshFile); ReadSubMesh(NewSubMesh, MeshFile);
} }
//_______________________________________________________________- //_______________________________________________________________-
@ -124,7 +124,7 @@ void OgreImporter::ReadSubMesh(SubMesh &theSubMesh, XmlReader *Reader)
//some info logging: //some info logging:
unsigned int NumFaces=GetAttribute<int>(Reader, "count"); unsigned int NumFaces=GetAttribute<int>(Reader, "count");
stringstream ss; ss <<"Submesh has " << NumFaces << " Faces."; stringstream ss; ss <<"Submesh has " << NumFaces << " Faces.";
DefaultLogger::get()->info(ss.str()); DefaultLogger::get()->debug(ss.str());
while(XmlRead(Reader) && Reader->getNodeName()==string("face")) while(XmlRead(Reader) && Reader->getNodeName()==string("face"))
{ {
@ -145,7 +145,7 @@ void OgreImporter::ReadSubMesh(SubMesh &theSubMesh, XmlReader *Reader)
//some info logging: //some info logging:
unsigned int NumVertices=GetAttribute<int>(Reader, "vertexcount"); unsigned int NumVertices=GetAttribute<int>(Reader, "vertexcount");
stringstream ss; ss<<"VertexCount: "<<NumVertices; stringstream ss; ss<<"VertexCount: "<<NumVertices;
DefaultLogger::get()->info(ss.str()); DefaultLogger::get()->debug(ss.str());
//General Informations about vertices //General Informations about vertices
XmlRead(Reader); XmlRead(Reader);
@ -193,7 +193,7 @@ void OgreImporter::ReadSubMesh(SubMesh &theSubMesh, XmlReader *Reader)
XmlRead(Reader); XmlRead(Reader);
aiVector3D NewUv; aiVector3D NewUv;
NewUv.x=GetAttribute<float>(Reader, "u"); NewUv.x=GetAttribute<float>(Reader, "u");
NewUv.y=GetAttribute<float>(Reader, "v"); NewUv.y=GetAttribute<float>(Reader, "v")*(-1)+1;//flip the uv vertikal, blender exports them so!
Uvs.push_back(NewUv); Uvs.push_back(NewUv);
} }
XmlRead(Reader); XmlRead(Reader);
@ -201,7 +201,7 @@ void OgreImporter::ReadSubMesh(SubMesh &theSubMesh, XmlReader *Reader)
} }
} }
DefaultLogger::get()->info(str(format("Positionen: %1% Normale: %2% TexCoords: %3%") % Positions.size() % Normals.size() % Uvs.size())); DefaultLogger::get()->debug(str(format("Positionen: %1% Normale: %2% TexCoords: %3%") % Positions.size() % Normals.size() % Uvs.size()));
//Make all Vertexes unique: (this is required by assimp) //Make all Vertexes unique: (this is required by assimp)
@ -407,8 +407,36 @@ aiMaterial* OgreImporter::LoadMaterial(std::string MaterialName)
} }
} }
}//end of technique }//end of technique
} }
DefaultLogger::get()->info(Line);
//read informations from a custom material:
if(Line=="set")
{
ss >> Line;
if(Line=="$specular")//todo load this values:
{
}
if(Line=="$diffuse")
{
}
if(Line=="$ambient")
{
}
if(Line=="$colormap")
{
ss >> Line;
NewMaterial->AddProperty(&aiString(Line.c_str()), AI_MATKEY_TEXTURE(aiTextureType_DIFFUSE, 0));
}
if(Line=="$normalmap")
{
ss >> Line;
NewMaterial->AddProperty(&aiString(Line.c_str()), AI_MATKEY_TEXTURE(aiTextureType_NORMALS, 0));
}
}
}//end of material }//end of material
} }
else {} //this is the wrong material, proceed the file until we reach the next material else {} //this is the wrong material, proceed the file until we reach the next material

View File

@ -804,6 +804,9 @@ DefaultLogger::create("AssimpLog.txt",Logger::VERBOSE)
Implement the Assimp::BaseImporter::CanRead(), Assimp::BaseImporter::InternReadFile() and Assimp::BaseImporter::GetExtensionList(). Implement the Assimp::BaseImporter::CanRead(), Assimp::BaseImporter::InternReadFile() and Assimp::BaseImporter::GetExtensionList().
Just copy'n'paste the template from Appendix A and adapt it for your needs. Just copy'n'paste the template from Appendix A and adapt it for your needs.
</li> </li>
<li>For error handling, throw a dynamic allocated ImportErrorException (see Appendix A) for critical errors, and log errors, warnings, infos and debuginfos
with DefaultLogger::get()->[error, warn, debug, info].
</li>
<li> <li>
Make sure the loader compiles against all build configurations on all supported platforms. This includes <i>-noboost</i>! To avoid problems, Make sure the loader compiles against all build configurations on all supported platforms. This includes <i>-noboost</i>! To avoid problems,
see the boost section on this page for a list of all 'allowed' boost classes (again, this grew historically when we had to accept that boost see the boost section on this page for a list of all 'allowed' boost classes (again, this grew historically when we had to accept that boost
@ -1429,12 +1432,18 @@ the name of the material file. This is especially usefull if multiply materials
The importer will first try to load the material with the same name as the mesh and only if this can't be open try The importer will first try to load the material with the same name as the mesh and only if this can't be open try
to load the alternate material file. The default material filename is "Scene.material". to load the alternate material file. The default material filename is "Scene.material".
We suggest that you use custom materials, because they support multiple textures (like colormap and normalmap). First of all you
should read the custom material sektion in the Ogre Blender exporter Help File, and than use the assimp.tlp template, which you
can find in scripts/OgreImpoter/Assimp.tlp. If you don't set all values, don't worry, they will be ignored during import.
If you want more propertiesin custom materials, you can easily expand the ogre material loader, it will be just a few lines for each property.
What will be loaded? What will be loaded?
Mesh: Faces, Positions, Normals and one Uv pair. The Materialname will be used to load the material Mesh: Faces, Positions, Normals and one Uv pair. The Materialname will be used to load the material
Material: The right material in the file will be searched, the importer should work with materials who Material: The right material in the file will be searched, the importer should work with materials who
have 1 technique and 1 pass in this technique. From there, the texturename will be loaded. Also, the have 1 technique and 1 pass in this technique. From there, the texturename (for 1 color- and 1 normalmap) will be loaded. Also, the
materialname will be set. materialname will be set.
Skeleton: Nothing, yet. Skeleton: Nothing, yet.

View File

@ -0,0 +1,10 @@
material %_materialName
{
set $specular %_specular
set $diffuse %_diffuse
set $ambient %_ambient
set $colormap %color._texture
set $normalmap %normal._texture
}