- Major update to the viewer. A little bit buggy now, but I'll fix that

- 2/3 of the viewer code are no wrapped in helper classes
- ByteSwap.h header added 
- Bugfix in the 3DS loader: Texture blend mode was read incorrectly
- Bugfix in the X-Loader. Assets with specular_exp == 0 use gouraud lighting now
- Added new helper functions to MaterialHelper 
- Added aiMaterialGetTexture() function to allow easy access to all properties of a texture

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@16 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
This commit is contained in:
aramis_acg
2008-05-13 23:26:52 +00:00
parent 7144737824
commit 2eb6fca408
60 changed files with 7502 additions and 2613 deletions

View File

@@ -44,6 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "GenVertexNormalsProcess.h"
#include "SpatialSort.h"
#include "DefaultLogger.h"
#include "../include/aiPostProcess.h"
#include "../include/aiMesh.h"
#include "../include/aiScene.h"
@@ -72,22 +73,35 @@ bool GenVertexNormalsProcess::IsActive( unsigned int pFlags) const
// Executes the post processing step on the given imported data.
void GenVertexNormalsProcess::Execute( aiScene* pScene)
{
DefaultLogger::get()->debug("GenVertexNormalsProcess begin");
bool bHas = false;
for( unsigned int a = 0; a < pScene->mNumMeshes; a++)
this->GenMeshVertexNormals( pScene->mMeshes[a]);
{
if(this->GenMeshVertexNormals( pScene->mMeshes[a]))
bHas = true;
}
if (bHas)
{
DefaultLogger::get()->info("GenVertexNormalsProcess finished. "
"Vertex normals have been calculated");
}
else DefaultLogger::get()->debug("GenVertexNormalsProcess finished. "
"There was nothing to do");
}
// -------------------------------------------------------------------
// Executes the post processing step on the given imported data.
void GenVertexNormalsProcess::GenMeshVertexNormals (aiMesh* pMesh)
bool GenVertexNormalsProcess::GenMeshVertexNormals (aiMesh* pMesh)
{
if (NULL != pMesh->mNormals)return;
if (NULL != pMesh->mNormals)return false;
pMesh->mNormals = new aiVector3D[pMesh->mNumVertices];
for( unsigned int a = 0; a < pMesh->mNumFaces; a++)
{
const aiFace& face = pMesh->mFaces[a];
// assume it is a triangle
aiVector3D* pV1 = &pMesh->mVertices[face.mIndices[0]];
aiVector3D* pV2 = &pMesh->mVertices[face.mIndices[1]];
aiVector3D* pV3 = &pMesh->mVertices[face.mIndices[2]];
@@ -95,12 +109,11 @@ void GenVertexNormalsProcess::GenMeshVertexNormals (aiMesh* pMesh)
aiVector3D pDelta1 = *pV2 - *pV1;
aiVector3D pDelta2 = *pV3 - *pV1;
aiVector3D vNor = pDelta1 ^ pDelta2;
float fLength = vNor.Length();
if (0.0f != fLength)vNor /= fLength;
pMesh->mNormals[face.mIndices[0]] = vNor;
pMesh->mNormals[face.mIndices[1]] = vNor;
pMesh->mNormals[face.mIndices[2]] = vNor;
for (unsigned int i = 0;i < face.mNumIndices;++i)
{
pMesh->mNormals[face.mIndices[i]] = vNor;
}
}
// calculate the position bounds so we have a reliable epsilon to
@@ -141,5 +154,5 @@ void GenVertexNormalsProcess::GenMeshVertexNormals (aiMesh* pMesh)
delete pMesh->mNormals;
pMesh->mNormals = pcNew;
return;
return true;
}