You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Version 1.8.1 will fail to parse binary format X file when it use DeclData. In debug mode the engine will report: "No closing brace in DeclData", the reason is the parser forgot read the opening brace when it start parsing the DeclData block.
This bug can be fixed by modifying CXMeshFileLoader.cpp, add readHeadOfDataObject() at the beginning of the if block in CXMeshFileLoader::parseDataObjectMesh
Do you have some example mesh failing here? In case it's not a free mesh, you can send it also by private mail. Just to make sure that we have some mesh in our test repository.
In any way, it sounds as if alo 1.8.0 would fail on such a mesh then, as we have no changes in the .x loader code I suppose.
I was looking over the code which processes the DeclData block and it appears that it doesn't handle tangents or bi-normals. It collects some information and then does nothing with them.
The reason it does this is because the mesh vertices are stored using the irr::video::S3DVertex structure; where there are no fields for this sort of information. There is a better structure S3DVertexTangents which should probably be used in its place.
If you take a look at the SXMesh structure (found in CXMeshLoader.h) you'll see the vertex format is declared as 'core::array<video::S3DVertex> Vertices;'.
I was trying to build a Bi-normal / Tangent / Normal matrix for a NormalMap Shader. Now I am not sure how to proceed; guess I'll have to find a work around.
I am looking into this now too because I am hoping to generate a Binormal/Tangent/Normal matrix. Inspecting the parser
Last edited by rabbit on Fri Jan 23, 2015 9:47 pm, edited 1 time in total.
I fear we are all in the same situation as you - only way to figure it out is understanding what's going on in the .x loader. The original authors are all no longer active.
// Create a mesh
pMesh = pGame->getSceneManager()->getMesh("media/meshes/NormalMapTest.x");
// NOTE: This is 100% necessary without it the normal map screws up
irr::scene::ISkinnedMesh* pSkinnedMesh = (irr::scene::ISkinnedMesh*)pMesh; pSkinnedMesh->convertMeshToTangents();
The tangent comes into the vertex shader in 'gl_MultiTexCoord1' (value passed from COpenGLDriver.cpp) and then to make your uniform TBN Matrix, you need the bi-normal which is the cross product between the normal and the tangent.
Fix probably didn't make much of a difference in most cases. But for his test-case it removes the warning, so I've applied it.
If you have other problems please make a new bugreport and include a test-model with all data.
THANK GOODNESS! this fix has "fixed" the troubles that i had with Irr and the KWX Exporter. The curious part is that other X files were loaded properly.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt