Triangulation:

- FEATURE: Concave polygons are now triangulated correctly.
 - internal face order is ccw now, flipwinding part of converttolh flag
 - added test files for the various formats supporting such polygons

FindDegenerates: 
 - improved behaviour when processing polygons, more tolerant.

Obj: 
 - material files are now properly read using the given IOSystem 
 - redirecting some std::cerr calls to our logger 
 - spaces and tabs are now allowed at the beginning of a line 

Viewer: 
 - max smoothing angle for normals is set to 90 deg now

vc9-workspace 
 - added assimp_cmd, renamed some virtual folders to be sexier.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@374 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/1/head
aramis_acg 2009-04-02 15:16:01 +00:00
parent c89944b2af
commit 29c33760e4
33 changed files with 2343 additions and 275 deletions

View File

@ -131,6 +131,9 @@ void B3DImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOS
// convert to RH
MakeLeftHandedProcess monster_maker;
monster_maker.Execute(pScene);
FlipWindingOrderProcess flipper;
flipper.Execute(pScene);
}
// ------------------------------------------------------------------------------------------------

View File

@ -698,8 +698,8 @@ void ColladaLoader::StoreSceneMeshes( aiScene* pScene)
{
pScene->mMeshes = new aiMesh*[mMeshes.size()];
std::copy( mMeshes.begin(), mMeshes.end(), pScene->mMeshes);
mMeshes.clear();
}
mMeshes.clear();
}
// ------------------------------------------------------------------------------------------------
@ -711,8 +711,8 @@ void ColladaLoader::StoreSceneCameras( aiScene* pScene)
{
pScene->mCameras = new aiCamera*[mCameras.size()];
std::copy( mCameras.begin(), mCameras.end(), pScene->mCameras);
mCameras.clear();
}
mCameras.clear();
}
// ------------------------------------------------------------------------------------------------
@ -724,8 +724,8 @@ void ColladaLoader::StoreSceneLights( aiScene* pScene)
{
pScene->mLights = new aiLight*[mLights.size()];
std::copy( mLights.begin(), mLights.end(), pScene->mLights);
mLights.clear();
}
mLights.clear();
}
// ------------------------------------------------------------------------------------------------
@ -737,8 +737,8 @@ void ColladaLoader::StoreSceneTextures( aiScene* pScene)
{
pScene->mTextures = new aiTexture*[mTextures.size()];
std::copy( mTextures.begin(), mTextures.end(), pScene->mTextures);
mTextures.clear();
}
mTextures.clear();
}
// ------------------------------------------------------------------------------------------------
@ -746,12 +746,14 @@ void ColladaLoader::StoreSceneTextures( aiScene* pScene)
void ColladaLoader::StoreSceneMaterials( aiScene* pScene)
{
pScene->mNumMaterials = newMats.size();
pScene->mMaterials = new aiMaterial*[newMats.size()];
for (unsigned int i = 0; i < newMats.size();++i)
pScene->mMaterials[i] = newMats[i].second;
newMats.clear();
if (newMats.size() > 0) {
pScene->mMaterials = new aiMaterial*[newMats.size()];
for (unsigned int i = 0; i < newMats.size();++i)
pScene->mMaterials[i] = newMats[i].second;
newMats.clear();
}
}
// ------------------------------------------------------------------------------------------------
@ -935,8 +937,10 @@ void ColladaLoader::BuildMaterials( const ColladaParser& pParser, aiScene* pScen
mMaterialIndexByName[matIt->first] = newMats.size();
newMats.push_back( std::pair<Collada::Effect*, aiMaterial*>(const_cast<Collada::Effect*>(&effect),mat) );
}
// store a dummy material if none were given
// ScenePreprocessor generates a default material automatically if none is there.
// All further code here in this loader works well without a valid material so
// we can safely let it to ScenePreprocessor.
#if 0
if( newMats.size() == 0)
{
Assimp::MaterialHelper* mat = new Assimp::MaterialHelper;
@ -952,6 +956,7 @@ void ColladaLoader::BuildMaterials( const ColladaParser& pParser, aiScene* pScen
const float specExp = 5.0f;
mat->AddProperty( &specExp, 1, AI_MATKEY_SHININESS);
}
#endif
}
// ------------------------------------------------------------------------------------------------

View File

@ -100,11 +100,6 @@ void MakeLeftHandedProcess::Execute( aiScene* pScene)
ProcessAnimation( nodeAnim);
}
}
// flipping a single vector component means inverting face order ...
FlipWindingOrderProcess flipper;
flipper.Execute(pScene);
DefaultLogger::get()->debug("MakeLeftHandedProcess finished");
}

View File

@ -48,6 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "DXFLoader.h"
#include "ParsingUtils.h"
#include "ConvertToLHProcess.h"
#include "fast_atof.h"
using namespace Assimp;
@ -307,6 +308,10 @@ void DXFImporter::InternReadFile( const std::string& pFile,
pScene->mMaterials = new aiMaterial*[1];
pScene->mMaterials[0] = pcMat;
// flip winding order to be ccw
FlipWindingOrderProcess flipper;
flipper.Execute(pScene);
// --- everything destructs automatically ---
}

View File

@ -100,7 +100,7 @@ void FindDegeneratesProcess::ExecuteOnMesh( aiMesh* mesh)
if (configRemoveDegenerates)
remove_me.resize(mesh->mNumFaces,false);
unsigned int deg = 0;
unsigned int deg = 0, limit;
for (unsigned int a = 0; a < mesh->mNumFaces; ++a)
{
aiFace& face = mesh->mFaces[a];
@ -109,13 +109,20 @@ void FindDegeneratesProcess::ExecuteOnMesh( aiMesh* mesh)
// check whether the face contains degenerated entries
for (register unsigned int i = 0; i < face.mNumIndices; ++i)
{
for (register unsigned int t = i+1; t < face.mNumIndices; ++t)
// Polygons with more than 4 points are allowed to have double points, that is
// simulating polygons with holes just with concave polygons. However,
// double points may not come directly after another.
limit = face.mNumIndices;
if (face.mNumIndices > 4)
limit = std::min(limit,i+2);
for (register unsigned int t = i+1; t < limit; ++t)
{
if (mesh->mVertices[face.mIndices[i]] == mesh->mVertices[face.mIndices[t]])
{
// we have found a matching vertex position
// remove the corresponding index from the array
--face.mNumIndices;
--face.mNumIndices;--limit;
for (unsigned int m = t; m < face.mNumIndices; ++m)
{
face.mIndices[m] = face.mIndices[m+1];

View File

@ -401,7 +401,6 @@ void LWOImporter::InternReadFile( const std::string& pFile,
pScene->mMeshes = new aiMesh*[ pScene->mNumMeshes = (unsigned int)apcMeshes.size() ];
::memcpy(pScene->mMeshes,&apcMeshes[0],pScene->mNumMeshes*sizeof(void*));
// generate the final node graph
GenerateNodeGraph(apcNodes);
}
@ -434,7 +433,7 @@ void LWOImporter::ComputeNormals(aiMesh* mesh, const std::vector<unsigned int>&
aiVector3D* pV2 = mesh->mVertices + face.mIndices[1];
aiVector3D* pV3 = mesh->mVertices + face.mIndices[face.mNumIndices-1];
aiVector3D vNor = ((*pV2 - *pV1) ^ (*pV3 - *pV1)).Normalize();
aiVector3D vNor = ((*pV2 - *pV1) ^(*pV3 - *pV1)).Normalize();
for (unsigned int i = 0; i < face.mNumIndices;++i)
out[face.mIndices[i]] = vNor;
}
@ -596,9 +595,12 @@ void LWOImporter::GenerateNodeGraph(std::vector<aiNode*>& apcNodes)
pScene->mRootNode = pc;
}
// convert the whole stuff to RH
// convert the whole stuff to RH with CCW winding
MakeLeftHandedProcess maker;
maker.Execute(pScene);
FlipWindingOrderProcess flipper;
flipper.Execute(pScene);
}
// ------------------------------------------------------------------------------------------------

View File

@ -370,7 +370,7 @@ void LWSImporter::BuildGraph(aiNode* nd, LWS::NodeDesc& src, std::vector<Attachm
// .. and construct animation channels
aiNodeAnim* anim = NULL;
#if 0 /* not yet */
#if 1 /* not yet */
if (first != last) {
resolver.SetAnimationRange(first,last);
resolver.ExtractAnimChannel(&anim,AI_LWO_ANIM_FLAG_SAMPLE_ANIMS|AI_LWO_ANIM_FLAG_START_AT_ZERO);
@ -863,6 +863,10 @@ void LWSImporter::InternReadFile( const std::string& pFile, aiScene* pScene,
MakeLeftHandedProcess monster_cheat;
monster_cheat.Execute(master);
// .. ccw
FlipWindingOrderProcess flipper;
flipper.Execute(pScene);
// OK ... finally build the output graph
SceneCombiner::MergeScenes(&pScene,master,attach,
AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES | (!configSpeedFlag ? (

View File

@ -119,7 +119,7 @@ void ObjFileImporter::InternReadFile( const std::string& pFile, aiScene* pScene,
}
// parse the file into a temporary representation
ObjFileParser parser(m_Buffer, strDirectory, strModelName);
ObjFileParser parser(m_Buffer, strDirectory, strModelName, pIOHandler);
// And create the proper return structures out of it
CreateDataFromImport(parser.GetModel(), pScene);

View File

@ -59,12 +59,13 @@ const std::string ObjFileParser::DEFAULT_MATERIAL = AI_DEFAULT_MATERIAL_NAME;
// Constructor with loaded data and directories.
ObjFileParser::ObjFileParser(std::vector<char> &Data,
const std::string &strAbsPath,
const std::string &strModelName) :
const std::string &strModelName, IOSystem* _io) :
m_strAbsPath(strAbsPath),
m_DataIt(Data.begin()),
m_DataItEnd(Data.end()),
m_pModel(NULL),
m_uiLine(0)
m_uiLine(0),
io(_io)
{
// Create the model instance to store all the data
m_pModel = new ObjFile::Model();
@ -436,44 +437,27 @@ void ObjFileParser::getMaterialLib()
char *pStart = &(*m_DataIt);
while (!isNewLine(*m_DataIt))
m_DataIt++;
// TODO: fix path construction
// CLEANUP ... who is resposible for *two* identical DefaultIOSystems
// where the IOSystem passed to ReadFile() should be used???
// Check for existence
DefaultIOSystem IOSystem;
std::string strMatName(pStart, &(*m_DataIt));
std::string absName = m_strAbsPath + IOSystem.getOsSeparator() + strMatName;
if ( !IOSystem.Exists( absName.c_str()) )
std::string absName = m_strAbsPath + io->getOsSeparator() + strMatName;
IOStream *pFile = io->Open(absName.c_str());
if (!pFile )
{
DefaultLogger::get()->error("OBJ: Unable to locate material file " + absName);
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
return;
}
// Extract the extention
std::string strExt("");
extractExtension( strMatName, strExt );
static const std::string mat = "mtl";
// Import material library data from file
size_t size = pFile->FileSize();
std::vector<char> buffer(size);
pFile->Read( &buffer[ 0 ], sizeof( char ), size );
io->Close( pFile );
// Load the material library
DefaultIOSystem FileSystem;
IOStream *pFile = FileSystem.Open(absName.c_str());
if (0L != pFile)
{
// Import material library data from file
size_t size = pFile->FileSize();
std::vector<char> buffer;
buffer.resize( size );
pFile->Read( &buffer[ 0 ], sizeof( char ), size );
FileSystem.Close( pFile );
// Importing the material library
ObjFileMtlImporter mtlImporter( buffer, absName, m_pModel );
}
// Skip rest of line
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
// Importing the material library
ObjFileMtlImporter mtlImporter( buffer, absName, m_pModel );
}
// -------------------------------------------------------------------
@ -493,9 +477,7 @@ void ObjFileParser::getNewMaterial()
if (it == m_pModel->m_MaterialMap.end())
{
// Show a warning, if material was not found
std::string strWarn ("Unsupported material requested: ");
strWarn += strMat;
std::cerr << "Warning : " << strWarn << std::endl;
DefaultLogger::get()->warn("OBJ: Unsupported material requested: " + strMat);
m_pModel->m_pCurrentMaterial = m_pModel->m_pDefaultMaterial;
}
else
@ -630,27 +612,8 @@ void ObjFileParser::createObject(const std::string &strObjectName)
// Shows an error in parsing process.
void ObjFileParser::reportErrorTokenInFace()
{
std::string strErr("");
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
std::cerr << "Not supported token in face desc. detected : " << strErr << std::endl;
}
// -------------------------------------------------------------------
// Extracts the extention from a filename
void ObjFileParser::extractExtension(const std::string &strFile,
std::string &strExt)
{
strExt = "";
if (strFile.empty())
return;
// Search for extention delimiter
std::string::size_type pos = strFile.find_last_of(".");
if ( pos == std::string::npos )
return;
strExt = strFile.substr(pos, strFile.size() - pos);
DefaultLogger::get()->error("OBJ: Not supported token in face description detected");
}
// -------------------------------------------------------------------

View File

@ -75,7 +75,7 @@ public:
public:
/// \brief Constructor with data array.
ObjFileParser(std::vector<char> &Data, const std::string &strAbsPath, const std::string &strModelName);
ObjFileParser(std::vector<char> &Data, const std::string &strAbsPath, const std::string &strModelName, IOSystem* io);
/// \brief Destructor
~ObjFileParser();
/// \brief Model getter.
@ -113,8 +113,6 @@ private:
void createObject(const std::string &strObjectName);
/// Error report in token
void reportErrorTokenInFace();
/// Extractor for extention
void extractExtension(const std::string &strFile, std::string &strExt);
private:
/// Default material name
@ -131,6 +129,8 @@ private:
unsigned int m_uiLine;
//! Helper buffer
char m_buffer[BUFFERSIZE];
IOSystem* io;
};
} // Namespace Assimp

View File

@ -121,6 +121,9 @@ inline char_t skipLine( char_t it, char_t end, unsigned int &uiLine )
++it;
++uiLine;
}
/* fix .. from time to time there are spaces at the beginning of a material line */
while ( it != end && (*it == '\t' || *it == ' ') )
++it;
return it;
}
@ -187,7 +190,7 @@ inline char_t getFloat( char_t it, char_t end, float &value )
{
static const size_t BUFFERSIZE = 1024;
char buffer[ BUFFERSIZE ];
memset( buffer, '\0', BUFFERSIZE );
//memset( buffer, '\0', BUFFERSIZE );
it = CopyNextWord<char_t>( it, end, buffer, BUFFERSIZE );
value = (float) fast_atof( buffer );

View File

@ -174,7 +174,12 @@ template <> struct MinMaxChooser<aiVertexWeight> {
}};
// -------------------------------------------------------------------------------
// Find the min/max values of an array of Ts
/** @brief Find the min/max values of an array of Ts
* @param in Input array
* @param size Numebr of elements to process
* @param[out] min minimum value
* @param[out] max maximum value
*/
template <typename T>
inline void ArrayBounds(const T* in, unsigned int size, T& min, T& max)
{
@ -185,6 +190,72 @@ inline void ArrayBounds(const T* in, unsigned int size, T& min, T& max)
}
}
// -------------------------------------------------------------------------------
/** @brief Compute the newell normal of a polygon regardless of its shape
*
* @param out Receives the output normal
* @param num Number of input vertices
* @param x X data source. x[ofs_x*n] is the n'th element.
* @param y Y data source. y[ofs_y*n] is the y'th element
* @param z Z data source. z[ofs_z*n] is the z'th element
*
* @note The data arrays must have storage for at least num+2 elements. Using
* this method is much faster than the 'other' NewellNormal()
*/
template <int ofs_x, int ofs_y, int ofs_z>
inline void NewellNormal (aiVector3D& out, int num, float* x, float* y, float* z)
{
// Duplicate the first two vertices at the end
x[(num+0)*ofs_x] = x[0];
x[(num+1)*ofs_x] = x[ofs_x];
y[(num+0)*ofs_y] = y[0];
y[(num+1)*ofs_y] = y[ofs_y];
z[(num+0)*ofs_z] = z[0];
z[(num+1)*ofs_z] = z[ofs_z];
float sum_xy = 0.0, sum_yz = 0.0, sum_zx = 0.0;
float *xptr = x +ofs_x, *xlow = x, *xhigh = x + ofs_x*2;
float *yptr = y +ofs_y, *ylow = y, *yhigh = y + ofs_y*2;
float *zptr = z +ofs_z, *zlow = z, *zhigh = z + ofs_z*2;
for (int tmp=0; tmp < num; tmp++) {
sum_xy += (*xptr) * ( (*yhigh) - (*ylow) );
sum_yz += (*yptr) * ( (*zhigh) - (*zlow) );
sum_zx += (*zptr) * ( (*xhigh) - (*xlow) );
xptr += ofs_x;
xlow += ofs_x;
xhigh += ofs_x;
yptr += ofs_y;
ylow += ofs_y;
yhigh += ofs_y;
zptr += ofs_z;
zlow += ofs_z;
zhigh += ofs_z;
}
out = aiVector3D(sum_yz,sum_zx,sum_xy);
}
#if 0
// -------------------------------------------------------------------------------
/** @brief Compute newell normal of a polgon regardless of its shape
*
* @param out Receives the output normal
* @param data Input vertices
* @param idx Index buffer
* @param num Number of indices
*/
inline void NewellNormal (aiVector3D& out, const aiVector3D* data, unsigned int* idx, unsigned int num )
{
// TODO: intended to be used in GenNormals.
}
#endif
// -------------------------------------------------------------------------------
/** Little helper function to calculate the quadratic difference
* of two colours.
@ -201,7 +272,12 @@ inline float GetColorDifference( const aiColor4D& pColor1, const aiColor4D& pCol
}
// -------------------------------------------------------------------------------
// Compute the AABB of a mesh after applying a given transform
/** @brief Compute the AABB of a mesh after applying a given transform
* @param mesh Input mesh
* @param[out] min Receives minimum transformed vertex
* @param[out] max Receives maximum transformed vertex
* @param m Transformation matrix to be applied
*/
inline void FindAABBTransformed (const aiMesh* mesh, aiVector3D& min, aiVector3D& max,
const aiMatrix4x4& m)
{
@ -216,7 +292,14 @@ inline void FindAABBTransformed (const aiMesh* mesh, aiVector3D& min, aiVector3D
}
// -------------------------------------------------------------------------------
// Helper function to determine the 'real' center of a mesh
/** @brief Helper function to determine the 'real' center of a mesh
*
* That is the center of its axis-aligned bounding box.
* @param mesh Input mesh
* @param[out] min Minimum vertex of the mesh
* @param[out] max maximum vertex of the mesh
* @param[out] out Center point
*/
inline void FindMeshCenter (aiMesh* mesh, aiVector3D& out, aiVector3D& min, aiVector3D& max)
{
ArrayBounds(mesh->mVertices,mesh->mNumVertices, min,max);

View File

@ -3,7 +3,7 @@
Open Asset Import Library (ASSIMP)
---------------------------------------------------------------------------
Copyright (c) 2006-2008, ASSIMP Development Team
Copyright (c) 2006-2009, ASSIMP Development Team
All rights reserved.
@ -39,13 +39,27 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
/** @file Implementation of the post processing step to split up
* all faces with more than three indices into triangles.
/** @file TriangulateProcess.cpp
* @brief Implementation of the post processing step to split up
* all faces with more than three indices into triangles.
*
*
* The triangulation algorithm will handle concave or convex polygons.
* Self-intersecting or non-planar polygons are not rejected, but
* they're probably not triangulated correctly.
*
* AI_BUILD_TRIANGULATE_COLOR_FACE_WINDING
* - generates vertex colors to represent the face winding order.
* the first vertex of a polygon becomes red, the last blue.
*/
#include "AssimpPCH.h"
#include "TriangulateProcess.h"
#ifndef ASSIMP_BUILD_NO_TRIANGULATE_PROCESS
#include "TriangulateProcess.h"
#include "ProcessHelper.h"
//#define AI_BUILD_TRIANGULATE_COLOR_FACE_WINDING
using namespace Assimp;
// ------------------------------------------------------------------------------------------------
@ -81,55 +95,116 @@ void TriangulateProcess::Execute( aiScene* pScene)
if( TriangulateMesh( pScene->mMeshes[a]))
bHas = true;
}
if (bHas)DefaultLogger::get()->info ("TriangulateProcess finished. All polygons have been triangulated");
else DefaultLogger::get()->debug("TriangulateProcess finished. There was nothing to do.");
if (bHas)DefaultLogger::get()->info ("TriangulateProcess finished. All polygons have been triangulated.");
else DefaultLogger::get()->debug("TriangulateProcess finished. There was nothing to be done.");
}
// ------------------------------------------------------------------------------------------------
// Test whether a point p2 is on the left side of the line formed by p0-p1
inline bool OnLeftSideOfLine(const aiVector2D& p0, const aiVector2D& p1,const aiVector2D& p2)
{
return ( (p1.x - p0.x) * (p2.y - p0.y) - (p2.x - p0.x) * (p1.y - p0.y) ) > 0;
}
// ------------------------------------------------------------------------------------------------
// Test whether a point is inside a given triangle in R2
inline bool PointInTriangle2D(const aiVector2D& p0, const aiVector2D& p1,const aiVector2D& p2, const aiVector2D& pp)
{
// Point in triangle test using baryzentric coordinates
const aiVector2D v0 = p1 - p0;
const aiVector2D v1 = p2 - p0;
const aiVector2D v2 = pp - p0;
float dot00 = v0 * v0;
float dot01 = v0 * v1;
float dot02 = v0 * v2;
float dot11 = v1 * v1;
float dot12 = v1 * v2;
const float invDenom = 1 / (dot00 * dot11 - dot01 * dot01);
dot11 = (dot11 * dot02 - dot01 * dot12) * invDenom;
dot00 = (dot00 * dot12 - dot01 * dot02) * invDenom;
return (dot11 > 0) && (dot00 > 0) && (dot11 + dot00 < 1);
}
// ------------------------------------------------------------------------------------------------
// Triangulates the given mesh.
bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh)
{
// check whether we will need to do something ...
// FIX: now we have aiMesh::mPrimitiveTypes, so this is only here for test cases
if (!pMesh->mPrimitiveTypes)
{
// Now we have aiMesh::mPrimitiveTypes, so this is only here for test cases
if (!pMesh->mPrimitiveTypes) {
bool bNeed = false;
for( unsigned int a = 0; a < pMesh->mNumFaces; a++)
{
for( unsigned int a = 0; a < pMesh->mNumFaces; a++) {
const aiFace& face = pMesh->mFaces[a];
if( face.mNumIndices != 3)
{
if( face.mNumIndices != 3) {
bNeed = true;
}
}
if (!bNeed)return false;
if (!bNeed)
return false;
}
else if (!(pMesh->mPrimitiveTypes & aiPrimitiveType_POLYGON))
else if (!(pMesh->mPrimitiveTypes & aiPrimitiveType_POLYGON)) {
return false;
}
// the output mesh will contain triangles, but no polys anymore
pMesh->mPrimitiveTypes |= aiPrimitiveType_TRIANGLE;
pMesh->mPrimitiveTypes &= ~aiPrimitiveType_POLYGON;
// Find out how many output faces we'll have
unsigned int numOut = 0;
for( unsigned int a = 0; a < pMesh->mNumFaces; a++)
{
// Find out how many output faces we'll get
unsigned int numOut = 0, max_out = 0;
for( unsigned int a = 0; a < pMesh->mNumFaces; a++) {
aiFace& face = pMesh->mFaces[a];
if( face.mNumIndices <= 3)
numOut++;
else numOut += face.mNumIndices-2;
else {
numOut += face.mNumIndices-2;
max_out = std::max(max_out,face.mNumIndices);
}
}
// Just another check whether aiMesh::mPrimitiveTypes is correct
assert(numOut != pMesh->mNumFaces);
aiVector3D* nor_out = NULL;
if (!pMesh->mNormals && pMesh->mPrimitiveTypes == aiPrimitiveType_POLYGON) {
nor_out = pMesh->mNormals = new aiVector3D[pMesh->mNumVertices];
}
aiFace* out = new aiFace[numOut], *curOut = out;
for( unsigned int a = 0; a < pMesh->mNumFaces; a++)
{
std::vector<aiVector3D> temp_verts(max_out+2); /* temporary storage for vertices */
// Apply vertex colors to represent the face winding?
#ifdef AI_BUILD_TRIANGULATE_COLOR_FACE_WINDING
if (!pMesh->mColors[0])
pMesh->mColors[0] = new aiColor4D[pMesh->mNumVertices];
else
new(pMesh->mColors[0]) aiColor4D[pMesh->mNumVertices];
aiColor4D* clr = pMesh->mColors[0];
#endif
// use boost::scoped_array to avoid slow std::vector<bool> specialiations
boost::scoped_array<bool> done(new bool[max_out]);
for( unsigned int a = 0; a < pMesh->mNumFaces; a++) {
aiFace& face = pMesh->mFaces[a];
unsigned int* idx = face.mIndices;
int num = (int)face.mNumIndices, ear = 0, tmp, prev = num-1, next = 0, max = num;
// Apply vertex colors to represent the face winding?
#ifdef AI_BUILD_TRIANGULATE_COLOR_FACE_WINDING
for (unsigned int i = 0; i < face.mNumIndices; ++i) {
aiColor4D& c = clr[idx[i]];
c.r = (i+1) / (float)max;
c.b = 1.f - c.r;
}
#endif
// if it's a simple primitive, just copy it
if( face.mNumIndices <= 3)
{
@ -139,25 +214,160 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh)
}
else
{
for( unsigned int b = 0, end = face.mNumIndices - 2; b < end; b++)
{
aiFace& nface = *curOut++;
nface.mNumIndices = 3;
// A polygon with more than 3 vertices can be either concave or convex.
// Usually everything we're getting is convex and we could easily
// triangulate by trifanning. However, LightWave is probably the only
// modeller making extensive use of highly concave monster polygons ...
// so we need to apply the full 'ear cutting' algorithm.
// RERQUIREMENT: polygon is expected to be simple and *nearly* planar.
// We project it onto a plane to get 2d data. Working in R3 would
// also be possible but it's more difficult to implement.
// Collect all vertices of of the polygon.
aiVector3D* verts = pMesh->mVertices;
for (tmp = 0; tmp < max; ++tmp)
temp_verts[tmp] = verts[idx[tmp]];
// Get newell normal of the polygon. Store it for future use if it's a polygon-only mesh
aiVector3D n;
NewellNormal<3,3,3>(n,max,&temp_verts.front().x,&temp_verts.front().y,&temp_verts.front().z);
if (nor_out) {
for (tmp = 0; tmp < max; ++tmp)
nor_out[idx[tmp]] = n;
}
// Select largest normal coordinate to ignore for projection
const float ax = (n.x>0 ? n.x : -n.x);
const float ay = (n.y>0 ? n.y : -n.y);
const float az = (n.z>0 ? n.z : -n.z);
unsigned int ac = 0, bc = 1; /* no z coord. projection to xy */
float inv = n.z;
if (ax > ay) {
if (ax > az) { /* no x coord. projection to yz */
ac = 1; bc = 2;
inv = n.x;
}
}
else if (ay > az) { /* no y coord. projection to zy */
ac = 2; bc = 0;
inv = n.y;
}
// Swap projection axes to take the negated projection vector into account
if (inv < 0.f) {
std::swap(ac,bc);
}
for (tmp =0; tmp < max; ++tmp) {
temp_verts[tmp].x = verts[idx[tmp]][ac];
temp_verts[tmp].y = verts[idx[tmp]][bc];
done[tmp] = false;
}
//
// FIXME: currently this is the slow O(kn) variant with a worst case
// complexity of O(n^2) (I think). Can be done in O(n).
while (num > 3) {
// Find the next ear of the polygon
int num_found = 0;
for (ear = next;;prev = ear,ear = next) {
// Reuse the buffer for the very last element to save another allocation
if (b == end-1)
nface.mIndices = face.mIndices;
else
{
nface.mIndices = new unsigned int[3];
nface.mIndices[0] = face.mIndices[0];
// break after we looped two times without a positive match
for (next=ear+1;done[(next>max-1?next=0:next)];++next);
if (next < ear) {
if (++num_found == 2)
break;
}
const aiVector2D* pnt1 = (const aiVector2D*)&temp_verts[ear],
*pnt0 = (const aiVector2D*)&temp_verts[prev],
*pnt2 = (const aiVector2D*)&temp_verts[next];
// Must be a convex point. Assuming ccw winding, it must be on the right of the line between p-1 and p+1.
if (OnLeftSideOfLine (*pnt0,*pnt2,*pnt1))
continue;
// and no other point may be contained in this triangle
for ( tmp = 0; tmp < max; ++tmp) {
// We need to compare the actual values because it's possible that multiple indexes in
// the polygon are refering to the same position. concave_polygon.obj is a sample
//
// FIXME: Use 'epsiloned' comparisons instead? Due to numeric inaccuracies in
// PointInTriangle() I'm guessing that it's actually possible to construct
// input data that would cause us to end up with no ears. The problem is,
// which epsilon? If we chose a too large value, we'd get wrong results
const aiVector2D& vtmp = * ((aiVector2D*) &temp_verts[tmp] );
if ( vtmp != *pnt1 && vtmp != *pnt2 && vtmp != *pnt0 && PointInTriangle2D(*pnt0,*pnt1,*pnt2,vtmp))
break;
}
if (tmp != max)
continue;
// this vertex is an ear
break;
}
if (num_found == 2) {
// Due to the 'two ear theorem', every simple polygon with more than three points must
// have 2 'ears'. Here's definitely someting wrong ... but we don't give up yet.
//
// Instead we're continuting with the standard trifanning algorithm which we'd
// use if we had only convex polygons. That's life.
DefaultLogger::get()->error("Failed to triangulate polygon (no ear found). Probably not a simple polygon?");
curOut -= (max-num); /* undo all previous work */
for (tmp = 0; tmp < max-2; ++tmp) {
aiFace& nface = *curOut++;
nface.mNumIndices = 3;
if (!nface.mIndices)
nface.mIndices = new unsigned int[3];
nface.mIndices[0] = idx[0];
nface.mIndices[1] = idx[tmp+1];
nface.mIndices[2] = idx[tmp+2];
}
num = 0;
break;
}
nface.mIndices[1] = face.mIndices[b+1];
nface.mIndices[2] = face.mIndices[b+2];
aiFace& nface = *curOut++;
nface.mNumIndices = 3;
if (!nface.mIndices)
nface.mIndices = new unsigned int[3];
// setup indices for the new triangle ...
nface.mIndices[0] = idx[prev];
nface.mIndices[1] = idx[ear];
nface.mIndices[2] = idx[next];
// exclude the ear from most further processing
done[ear] = true;
--num;
}
if (num > 0) {
// We have three indices forming the last 'ear' remaining. Collect them.
aiFace& nface = *curOut++;
nface.mNumIndices = 3;
nface.mIndices = face.mIndices;
for (tmp = 0; done[tmp]; ++tmp);
idx[0] = idx[tmp];
for (++tmp; done[tmp]; ++tmp);
idx[1] = idx[tmp];
for (++tmp; done[tmp]; ++tmp);
idx[2] = idx[tmp];
}
}
face.mIndices = NULL;
face.mIndices = NULL; /* prevent unintended deletion of our awesome results. would be a pity */
}
// kill the old faces
@ -165,6 +375,8 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh)
// ... and store the new ones
pMesh->mFaces = out;
pMesh->mNumFaces = numOut;
pMesh->mNumFaces = (unsigned int)(curOut-out); /* not necessarily equal to numOut */
return true;
}
#endif // !! ASSIMP_BUILD_NO_TRIANGULATE_PROCESS

View File

@ -419,6 +419,9 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
// convert to RH
MakeLeftHandedProcess hero;
hero.Execute(pScene);
FlipWindingOrderProcess flipper;
flipper.Execute(pScene);
}
#endif // !! AI_BUILD_NO_3D_IMPORTER

View File

@ -144,6 +144,9 @@ void XFileImporter::CreateDataRepresentationFromImport( aiScene* pScene, const X
MakeLeftHandedProcess convertProcess;
convertProcess.Execute( pScene);
FlipWindingOrderProcess flipper;
flipper.Execute(pScene);
// finally: create a dummy material if not material was imported
if( pScene->mNumMaterials == 0)
{

View File

@ -551,14 +551,17 @@ By contrast, some other environments use left-handed coordinate systems, a promi
DirectX. If you need the imported data to be in a left-handed coordinate system, supply the
#aiProcess_MakeLeftHanded flag to the ReadFile() function call.
The output face winding is clockwise. Use #aiProcess_FlipWindingOrder to get CCW data.
The output face winding is counter clockwise. Use #aiProcess_FlipWindingOrder to get CW data.
@code
x0
x2
x1
x2
x0
@endcode
Outputted polygons can be literally everything: they're probably concave, self-intersecting or non-planar,
although our built-in triangulation (#aiProcess_Triangulate postprocessing step) doesn't handle the two latter.
The output UV coordinate system has its origin in the lower-left corner:
@code
0y|1y ---------- 1x|1y

View File

@ -55,20 +55,22 @@ extern "C" {
// ---------------------------------------------------------------------------
/** @brief A single face in a mesh, referring to multiple vertices.
*
* If mNumIndices is 3, the face is called 'triangle', for mNumIndices > 3
* If mNumIndices is 3, we call the face 'triangle', for mNumIndices > 3
* it's called 'polygon' (hey, that's just a definition!).
* <br>
* aiMesh::mPrimitiveTypes can be queried to quickly examine which types of
* primitive are present in a mesh. The aiProcess_SortByPType flag executes
* a special post-processing step which splits meshes with *different*
* primitive types mixed up (e.g. lines and triangles) in several, 'clean'
* submeshes. Furthermore there is a configuration option,
* #AI_CONFIG_PP_SBP_REMOVE, to force #aiProcess_SortByPType to remove
* specific primitive types from the imported scene - completely. In most cases
* you'll probably want to set this setting to
* primitive are actually present in a mesh. The #aiProcess_SortByPType flag
* executes a special post-processing algorithm which splits meshes with
* *different* primitive types mixed up (e.g. lines and triangles) in several
* 'clean' submeshes. Furthermore there is a configuration option (
* #AI_CONFIG_PP_SBP_REMOVE) to force #aiProcess_SortByPType to remove
* specific kinds of primitives from the imported scene, completely and forever.
* In many cases you'll probably want to set this setting to
* @code
* aiPrimitiveType_LINE|aiPrimitiveType_POINT
* @endcode
* Together with the #aiProcess_Triangulate flag you can then be sure that
* #aiFace::mNumIndices is always 3.
* @note Take a look at the @link data Data Structures page @endlink for
* more information on the layout and winding order of a face.
*/

View File

@ -436,15 +436,15 @@ enum aiPostProcessSteps
aiProcess_FlipUVs = 0x80000000, /* don't change */
// -------------------------------------------------------------------------
/** <hr>This step adjusts the output face winding order to be ccw.
/** <hr>This step adjusts the output face winding order to be cw.
*
* The default face winding order is clockwise.
* The default face winding order is counter clockwise.
* <br><b>Output face order:</b>
* @code
* x1
* x2
*
* x0
* x2
* x1
* @endcode
*/
aiProcess_FlipWindingOrder = 0x40000000 /* don't change */
@ -470,6 +470,7 @@ enum aiPostProcessSteps
#define aiProcess_ConvertToLeftHanded ( \
aiProcess_MakeLeftHanded | \
aiProcess_FlipUVs | \
aiProcess_FlipWindingOrder | \
0 )

View File

@ -1 +1 @@
#define SVNRevision 355
#define SVNRevision 369

View File

@ -1,4 +1,3 @@
"MotionCaptureROM.ase" - Recorded using Vicon IQ.
NOTE: The errors in the middle of the animation are there in the
original animation track, too. The captured person lost a marker ...
NOTE: The errors in the middle of the animation are caused by problems during recording.

View File

@ -0,0 +1,138 @@
<?xml version="1.0" encoding="UTF-8"?>
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
<asset>
<contributor>
<authoring_tool>Lightwave 9.5</authoring_tool>
</contributor>
<created>2009-03-27T22:29:42Z</created>
<modified>2009-03-27T22:29:42Z</modified>
<unit meter="1"></unit>
<up_axis>Y_UP</up_axis>
</asset>
<library_animations></library_animations>
<library_cameras></library_cameras>
<library_lights></library_lights>
<library_materials>
<material id="test_Smoothing" name="test_Smoothing">
<instance_effect url="#test_Smoothing-fx"></instance_effect>
</material>
</library_materials>
<library_effects>
<effect id="test_Smoothing-fx">
<profile_COMMON>
<technique sid="common">
<blinn>
<diffuse>
<color>0.141176 0.184314 0.411765 0</color>
</diffuse>
</blinn>
</technique>
</profile_COMMON>
</effect>
</library_effects>
<library_geometries>
<geometry id="Mesh_Object_lib" name="Mesh_Object">
<mesh>
<source id="Mesh_Object_positions" name="position">
<float_array id="Mesh_Object_positions_array" count="192">-1.146 1.6575 2.348
-1.146 1.67177 2.49285
-1.146 1.67177 2.20315
-1.146 1.7125 2.35
-1.146 1.71402 2.63214
-1.146 1.71402 2.06386
-1.146 1.72571 2.48412
-1.146 1.72571 2.21588
-1.146 1.76483 2.61309
-1.146 1.76483 2.08691
-1.146 1.78263 2.76051
-1.146 1.78263 1.93549
-1.146 1.82836 2.73195
-1.146 1.82836 1.96805
-1.146 1.87497 2.87303
-1.146 1.87497 1.82297
-1.146 1.91386 2.83614
-1.146 1.91386 1.86386
-1.146 1.98749 2.96537
-1.146 1.98749 1.73063
-1.146 2.01805 2.92164
-1.146 2.01805 1.77836
-1.146 2.11586 3.03398
-1.146 2.11586 1.66202
-1.146 2.13691 2.98517
-1.146 2.13691 1.71483
-1.146 2.25515 3.07623
-1.146 2.25515 1.61977
-1.146 2.26588 3.02429
-1.146 2.26588 1.67571
-1.146 2.4 3.0905
-1.146 2.4 3.0375
-1.146 2.4 1.6625
-1.146 2.4 1.6055
-1.146 2.53412 3.02429
-1.146 2.53412 1.67571
-1.146 2.54485 3.07623
-1.146 2.54485 1.61977
-1.146 2.66309 2.98517
-1.146 2.66309 1.71483
-1.146 2.68414 3.03398
-1.146 2.68414 1.66202
-1.146 2.78195 2.92164
-1.146 2.78195 1.77836
-1.146 2.81251 2.96537
-1.146 2.81251 1.73063
-1.146 2.88614 2.83614
-1.146 2.88614 1.86386
-1.146 2.92503 2.87303
-1.146 2.92503 1.82297
-1.146 2.97164 2.73195
-1.146 2.97164 1.96805
-1.146 3.01737 2.76051
-1.146 3.01737 1.93549
-1.146 3.03517 2.61309
-1.146 3.03517 2.08691
-1.146 3.07429 2.48412
-1.146 3.07429 2.21588
-1.146 3.08598 2.63214
-1.146 3.08598 2.06386
-1.146 3.0875 2.35
-1.146 3.12823 2.49285
-1.146 3.12823 2.20315
-1.146 3.1425 2.348
</float_array>
<technique_common>
<accessor count="64" offset="0" source="#Mesh_Object_positions_array" stride="3">
<param name="X" type="float"></param>
<param name="Y" type="float"></param>
<param name="Z" type="float"></param>
</accessor>
</technique_common>
</source>
<vertices id="Mesh_Object_vertices">
<input semantic="POSITION" source="#Mesh_Object_positions"></input>
</vertices>
<polylist count="1" material="test_Smoothing">
<input offset="0" semantic="VERTEX" source="#Mesh_Object_vertices"></input>
<vcount>66 </vcount>
<p>26 22 18 14 10 4 1 0 2 5 11 15 19 23 27 33 37 41 45 49 53 59 62 63 61 58 52 48 44 40 36 30 31 34 38 42 46 50 54 56 60 57 55 51 47 43 39 35 32 29 25 21 17 13 9 7 3 6 8 12 16 20 24 28 31 30 </p>
</polylist>
</mesh>
</geometry>
</library_geometries>
<library_controllers></library_controllers>
<library_visual_scenes>
<visual_scene id="VisualSceneNode" name="Scene">
<node id="Mesh_Object" name="Mesh_Object">
<instance_geometry url="#Mesh_Object_lib">
<bind_material>
<technique_common>
<instance_material symbol="test_Smoothing" target="#test_Smoothing"></instance_material>
</technique_common>
</bind_material>
</instance_geometry>
</node>
</visual_scene>
</library_visual_scenes>
<scene>
<instance_visual_scene url="#VisualSceneNode"></instance_visual_scene>
</scene>
</COLLADA>

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,11 @@
newmtl test
Ka 0 0 0
Kd 0.141176 0.184314 0.411765
Ks 0 0 0
Ni 1
Ns 400
Tf 1 1 1
d 1

View File

@ -0,0 +1,77 @@
####
#
# OBJ File Generated by LightWave3D
# LightWave3D OBJ Export v2.3
#
####
o concave_test.obj
mtllib concave_polygon.mtl
g default
v -1.146 1.6575 2.348
v -1.146 1.67177 2.49285
v -1.146 1.67177 2.20315
v -1.146 1.7125 2.35
v -1.146 1.71402 2.63214
v -1.146 1.71402 2.06386
v -1.146 1.72571 2.48412
v -1.146 1.72571 2.21588
v -1.146 1.76483 2.61309
v -1.146 1.76483 2.08691
v -1.146 1.78263 2.76051
v -1.146 1.78263 1.93549
v -1.146 1.82836 2.73195
v -1.146 1.82836 1.96805
v -1.146 1.87497 2.87303
v -1.146 1.87497 1.82297
v -1.146 1.91386 2.83614
v -1.146 1.91386 1.86386
v -1.146 1.98749 2.96537
v -1.146 1.98749 1.73063
v -1.146 2.01805 2.92164
v -1.146 2.01805 1.77836
v -1.146 2.11586 3.03398
v -1.146 2.11586 1.66202
v -1.146 2.13691 2.98517
v -1.146 2.13691 1.71483
v -1.146 2.25515 3.07623
v -1.146 2.25515 1.61977
v -1.146 2.26588 3.02429
v -1.146 2.26588 1.67571
v -1.146 2.4 3.0905
v -1.146 2.4 3.0375
v -1.146 2.4 1.6625
v -1.146 2.4 1.6055
v -1.146 2.53412 3.02429
v -1.146 2.53412 1.67571
v -1.146 2.54485 3.07623
v -1.146 2.54485 1.61977
v -1.146 2.66309 2.98517
v -1.146 2.66309 1.71483
v -1.146 2.68414 3.03398
v -1.146 2.68414 1.66202
v -1.146 2.78195 2.92164
v -1.146 2.78195 1.77836
v -1.146 2.81251 2.96537
v -1.146 2.81251 1.73063
v -1.146 2.88614 2.83614
v -1.146 2.88614 1.86386
v -1.146 2.92503 2.87303
v -1.146 2.92503 1.82297
v -1.146 2.97164 2.73195
v -1.146 2.97164 1.96805
v -1.146 3.01737 2.76051
v -1.146 3.01737 1.93549
v -1.146 3.03517 2.61309
v -1.146 3.03517 2.08691
v -1.146 3.07429 2.48412
v -1.146 3.07429 2.21588
v -1.146 3.08598 2.63214
v -1.146 3.08598 2.06386
v -1.146 3.0875 2.35
v -1.146 3.12823 2.49285
v -1.146 3.12823 2.20315
v -1.146 3.1425 2.348
vn 1 0 -0
usemtl test
s 1
f 27//1 23//1 19//1 15//1 11//1 5//1 2//1 1//1 3//1 6//1 12//1 16//1 20//1 24//1 28//1 34//1 38//1 42//1 46//1 50//1 54//1 60//1 63//1 64//1 62//1 59//1 53//1 49//1 45//1 41//1 37//1 31//1 32//1 35//1 39//1 43//1 47//1 51//1 55//1 57//1 61//1 58//1 56//1 52//1 48//1 44//1 40//1 36//1 33//1 30//1 26//1 22//1 18//1 14//1 10//1 8//1 4//1 7//1 9//1 13//1 17//1 21//1 25//1 29//1 32//1 31//1

View File

@ -13,6 +13,7 @@ void TriangulateProcessTest :: setUp (void)
pcMesh->mNumFaces = 1000;
pcMesh->mFaces = new aiFace[1000];
pcMesh->mVertices = new aiVector3D[10000];
pcMesh->mPrimitiveTypes = aiPrimitiveType_POINT | aiPrimitiveType_LINE |
aiPrimitiveType_LINE | aiPrimitiveType_POLYGON;
@ -32,7 +33,13 @@ void TriangulateProcessTest :: setUp (void)
face.mIndices = new unsigned int[face.mNumIndices];
for (unsigned int p = 0; p < face.mNumIndices; ++p)
{
face.mIndices[p] = pcMesh->mNumVertices++;
face.mIndices[p] = pcMesh->mNumVertices;
// construct fully convex input data in ccw winding, xy plane
aiVector3D& v = pcMesh->mVertices[pcMesh->mNumVertices++];
v.z = 0.f;
v.x = cos (p * AI_MATH_TWO_PI/face.mNumIndices);
v.y = sin (p * AI_MATH_TWO_PI/face.mNumIndices);
}
}
}
@ -86,4 +93,7 @@ void TriangulateProcessTest :: testTriangulation (void)
}
}
}
// we should have no valid normal vectors now necause we aren't a pure polygon mesh
CPPUNIT_ASSERT(pcMesh->mNormals == NULL);
}

View File

@ -970,63 +970,65 @@ int CDisplay::OnSetupTextureView(TextureInfo* pcNew)
// and fill them with data
D3DSURFACE_DESC sDesc;
(*pcNew->piTexture)->GetLevelDesc(0,&sDesc);
char szTemp[128];
if (pcNew->piTexture && *pcNew->piTexture) {
(*pcNew->piTexture)->GetLevelDesc(0,&sDesc);
char szTemp[128];
sprintf(szTemp,"%i",sDesc.Width);
SetWindowText(GetDlgItem(g_hDlg,IDC_EVERT),szTemp);
sprintf(szTemp,"%i",sDesc.Width);
SetWindowText(GetDlgItem(g_hDlg,IDC_EVERT),szTemp);
sprintf(szTemp,"%i",sDesc.Height);
SetWindowText(GetDlgItem(g_hDlg,IDC_ENODEWND),szTemp);
sprintf(szTemp,"%i",sDesc.Height);
SetWindowText(GetDlgItem(g_hDlg,IDC_ENODEWND),szTemp);
sprintf(szTemp,"%i",(*pcNew->piTexture)->GetLevelCount());
SetWindowText(GetDlgItem(g_hDlg,IDC_ESHADER),szTemp);
sprintf(szTemp,"%i",(*pcNew->piTexture)->GetLevelCount());
SetWindowText(GetDlgItem(g_hDlg,IDC_ESHADER),szTemp);
sprintf(szTemp,"%i",pcNew->iUV);
SetWindowText(GetDlgItem(g_hDlg,IDC_EMAT),szTemp);
sprintf(szTemp,"%i",pcNew->iUV);
SetWindowText(GetDlgItem(g_hDlg,IDC_EMAT),szTemp);
sprintf(szTemp,"%f",pcNew->fBlend);
SetWindowText(GetDlgItem(g_hDlg,IDC_EMESH),szTemp);
sprintf(szTemp,"%f",pcNew->fBlend);
SetWindowText(GetDlgItem(g_hDlg,IDC_EMESH),szTemp);
const char* szOp;
switch (pcNew->eOp)
{
case aiTextureOp_Add:
szOp = "add";break;
case aiTextureOp_Subtract:
szOp = "sub";break;
case aiTextureOp_Divide:
szOp = "div";break;
case aiTextureOp_SignedAdd:
szOp = "addsign";break;
case aiTextureOp_SmoothAdd:
szOp = "addsmooth";break;
default: szOp = "mul";
};
SetWindowText(GetDlgItem(g_hDlg,IDC_ELOAD),szOp);
// NOTE: Format is always ARGB8888 since other formats are
// converted to this format ...
SetWindowText(GetDlgItem(g_hDlg,IDC_EFACE),"ARGB8");
// check whether this is the default texture
if (pcNew->piTexture)
{
// {9785DA94-1D96-426b-B3CB-BADC36347F5E}
static const GUID guidPrivateData =
{ 0x9785da94, 0x1d96, 0x426b,
{ 0xb3, 0xcb, 0xba, 0xdc, 0x36, 0x34, 0x7f, 0x5e } };
uint32_t iData = 0;
DWORD dwSize = 4;
(*pcNew->piTexture)->GetPrivateData(guidPrivateData,&iData,&dwSize);
if (0xFFFFFFFF == iData)
const char* szOp;
switch (pcNew->eOp)
{
CLogDisplay::Instance().AddEntry("[ERROR] Texture could not be loaded. "
"The displayed texture is a default texture",
D3DCOLOR_ARGB(0xFF,0xFF,0,0));
return 0;
case aiTextureOp_Add:
szOp = "add";break;
case aiTextureOp_Subtract:
szOp = "sub";break;
case aiTextureOp_Divide:
szOp = "div";break;
case aiTextureOp_SignedAdd:
szOp = "addsign";break;
case aiTextureOp_SmoothAdd:
szOp = "addsmooth";break;
default: szOp = "mul";
};
SetWindowText(GetDlgItem(g_hDlg,IDC_ELOAD),szOp);
// NOTE: Format is always ARGB8888 since other formats are
// converted to this format ...
SetWindowText(GetDlgItem(g_hDlg,IDC_EFACE),"ARGB8");
// check whether this is the default texture
if (pcNew->piTexture)
{
// {9785DA94-1D96-426b-B3CB-BADC36347F5E}
static const GUID guidPrivateData =
{ 0x9785da94, 0x1d96, 0x426b,
{ 0xb3, 0xcb, 0xba, 0xdc, 0x36, 0x34, 0x7f, 0x5e } };
uint32_t iData = 0;
DWORD dwSize = 4;
(*pcNew->piTexture)->GetPrivateData(guidPrivateData,&iData,&dwSize);
if (0xFFFFFFFF == iData)
{
CLogDisplay::Instance().AddEntry("[ERROR] Texture could not be loaded. "
"The displayed texture is a default texture",
D3DCOLOR_ARGB(0xFF,0xFF,0,0));
return 0;
}
}
}
// redraw the color fields in the UI --- their purpose has possibly changed
@ -2181,52 +2183,54 @@ int CDisplay::RenderTextureView()
// build a rectangle which centers the texture
// scaling is OK, but no stretching
D3DSURFACE_DESC sDesc;
(*this->m_pcCurrentTexture->piTexture)->GetLevelDesc(0,&sDesc);
if ( m_pcCurrentTexture->piTexture && *m_pcCurrentTexture->piTexture) { /* just a dirty fix */
(*m_pcCurrentTexture->piTexture)->GetLevelDesc(0,&sDesc);
struct SVertex{float x,y,z,w,u,v;};
SVertex as[4];
struct SVertex{float x,y,z,w,u,v;};
SVertex as[4];
const float nx = (float)sRect.right;
const float ny = (float)sRect.bottom;
const float x = (float)sDesc.Width;
const float y = (float)sDesc.Height;
float f = std::min((nx-30) / x,(ny-30) / y) * (m_fTextureZoom/1000.0f);
float fHalfX = (nx - (f * x)) / 2.0f;
float fHalfY = (ny - (f * y)) / 2.0f;
as[1].x = fHalfX + m_vTextureOffset.x;
as[1].y = fHalfY + m_vTextureOffset.y;
as[1].z = 0.2f;
as[1].w = 1.0f;
as[1].u = 0.0f;
as[1].v = 0.0f;
as[3].x = nx-fHalfX + m_vTextureOffset.x;
as[3].y = fHalfY + m_vTextureOffset.y;
as[3].z = 0.2f;
as[3].w = 1.0f;
as[3].u = 1.0f;
as[3].v = 0.0f;
as[0].x = fHalfX + m_vTextureOffset.x;
as[0].y = ny-fHalfY + m_vTextureOffset.y;
as[0].z = 0.2f;
as[0].w = 1.0f;
as[0].u = 0.0f;
as[0].v = 1.0f;
as[2].x = nx-fHalfX + m_vTextureOffset.x;
as[2].y = ny-fHalfY + m_vTextureOffset.y;
as[2].z = 0.2f;
as[2].w = 1.0f;
as[2].u = 1.0f;
as[2].v = 1.0f;
as[0].x -= 0.5f;as[1].x -= 0.5f;as[2].x -= 0.5f;as[3].x -= 0.5f;
as[0].y -= 0.5f;as[1].y -= 0.5f;as[2].y -= 0.5f;as[3].y -= 0.5f;
const float nx = (float)sRect.right;
const float ny = (float)sRect.bottom;
const float x = (float)sDesc.Width;
const float y = (float)sDesc.Height;
float f = std::min((nx-30) / x,(ny-30) / y) * (m_fTextureZoom/1000.0f);
// draw the rectangle
DWORD dw2;g_piDevice->GetFVF(&dw2);
g_piDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
g_piDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,
&as,sizeof(SVertex));
g_piDevice->SetFVF(dw2);
float fHalfX = (nx - (f * x)) / 2.0f;
float fHalfY = (ny - (f * y)) / 2.0f;
as[1].x = fHalfX + m_vTextureOffset.x;
as[1].y = fHalfY + m_vTextureOffset.y;
as[1].z = 0.2f;
as[1].w = 1.0f;
as[1].u = 0.0f;
as[1].v = 0.0f;
as[3].x = nx-fHalfX + m_vTextureOffset.x;
as[3].y = fHalfY + m_vTextureOffset.y;
as[3].z = 0.2f;
as[3].w = 1.0f;
as[3].u = 1.0f;
as[3].v = 0.0f;
as[0].x = fHalfX + m_vTextureOffset.x;
as[0].y = ny-fHalfY + m_vTextureOffset.y;
as[0].z = 0.2f;
as[0].w = 1.0f;
as[0].u = 0.0f;
as[0].v = 1.0f;
as[2].x = nx-fHalfX + m_vTextureOffset.x;
as[2].y = ny-fHalfY + m_vTextureOffset.y;
as[2].z = 0.2f;
as[2].w = 1.0f;
as[2].u = 1.0f;
as[2].v = 1.0f;
as[0].x -= 0.5f;as[1].x -= 0.5f;as[2].x -= 0.5f;as[3].x -= 0.5f;
as[0].y -= 0.5f;as[1].y -= 0.5f;as[2].y -= 0.5f;as[3].y -= 0.5f;
// draw the rectangle
DWORD dw2;g_piDevice->GetFVF(&dw2);
g_piDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
g_piDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,
&as,sizeof(SVertex));
g_piDevice->SetFVF(dw2);
}
g_piPassThroughEffect->EndPass();
g_piPassThroughEffect->End();

View File

@ -129,6 +129,7 @@ DWORD WINAPI LoadThreadProc(LPVOID lpParameter)
double fCur = (double)timeGetTime();
aiSetImportPropertyInteger(AI_CONFIG_IMPORT_TER_MAKE_UVS,1);
aiSetImportPropertyFloat(AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE,80.f);
//aiSetImportPropertyInteger(AI_CONFIG_PP_FD_REMOVE,1);
//aiSetImportPropertyInteger(AI_CONFIG_PP_PTV_KEEP_HIERARCHY,1);

View File

@ -25,6 +25,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unit", "UnitTest.vcproj", "
Release.AspNetCompiler.Debug = "False"
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "assimpcmd", "assimp_cmd.vcproj", "{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}"
ProjectSection(ProjectDependencies) = postProject
{5691E159-2D9B-407F-971F-EA5C592DC524} = {5691E159-2D9B-407F-971F-EA5C592DC524}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
debug|Win32 = debug|Win32
@ -141,6 +146,30 @@ Global
{9B9D1C90-8A03-409A-B547-AE7B48B90F1A}.release-st|Win32.Build.0 = release-st|Win32
{9B9D1C90-8A03-409A-B547-AE7B48B90F1A}.release-st|x64.ActiveCfg = release-st|x64
{9B9D1C90-8A03-409A-B547-AE7B48B90F1A}.release-st|x64.Build.0 = release-st|x64
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.debug|Win32.ActiveCfg = Debug|Win32
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.debug|Win32.Build.0 = Debug|Win32
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.debug|x64.ActiveCfg = Debug|Win32
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.debug-dll|Win32.ActiveCfg = debug-dll|Win32
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.debug-dll|Win32.Build.0 = debug-dll|Win32
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.debug-dll|x64.ActiveCfg = debug-dll|Win32
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.debug-noboost-st|Win32.ActiveCfg = debug-noboost-st|Win32
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.debug-noboost-st|Win32.Build.0 = debug-noboost-st|Win32
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.debug-noboost-st|x64.ActiveCfg = debug-noboost-st|Win32
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.debug-st|Win32.ActiveCfg = debug-st|Win32
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.debug-st|Win32.Build.0 = debug-st|Win32
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.debug-st|x64.ActiveCfg = debug-st|Win32
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.release|Win32.ActiveCfg = Release|Win32
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.release|Win32.Build.0 = Release|Win32
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.release|x64.ActiveCfg = Release|Win32
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.release-dll|Win32.ActiveCfg = release-dll|Win32
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.release-dll|Win32.Build.0 = release-dll|Win32
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.release-dll|x64.ActiveCfg = release-dll|Win32
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.release-noboost-st|Win32.ActiveCfg = release-noboost-st|Win32
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.release-noboost-st|Win32.Build.0 = release-noboost-st|Win32
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.release-noboost-st|x64.ActiveCfg = release-noboost-st|Win32
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.release-st|Win32.ActiveCfg = release-st|Win32
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.release-st|Win32.Build.0 = release-st|Win32
{7C8F7B44-C990-4EA8-A2A5-9028472E0AD3}.release-st|x64.ActiveCfg = release-st|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -109,6 +109,7 @@
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="0"
OmitFramePointers="true"
WholeProgramOptimization="false"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_SECURE_SCL=0;WIN32"
@ -176,6 +177,7 @@
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="0"
OmitFramePointers="true"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;WIN32;ASSIMP_BUILD_DLL_EXPORT"
StringPooling="true"
@ -225,7 +227,7 @@
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="mkdir $(SolutionDir)..\..\bin\unit_$(ConfigurationName)_$(PlatformName)&#x0D;&#x0A;mkdir $(SolutionDir)..\..\bin\assimpview_$(ConfigurationName)_$(PlatformName)&#x0D;&#x0A;&#x0D;&#x0A;copy &quot;$(OutDir)\$(TargetFileName)&quot; &quot;$(SolutionDir)..\..\bin\unit_$(ConfigurationName)_$(PlatformName)\&quot;&#x0D;&#x0A;copy &quot;$(OutDir)\$(TargetFileName)&quot; &quot;$(SolutionDir)..\..\bin\assimpview_$(ConfigurationName)_$(PlatformName)\&quot;&#x0D;&#x0A;"
CommandLine="mkdir $(SolutionDir)..\..\bin\unit_$(ConfigurationName)_$(PlatformName)&#x0D;&#x0A;mkdir $(SolutionDir)..\..\bin\assimpview_$(ConfigurationName)_$(PlatformName)&#x0D;&#x0A;mkdir $(SolutionDir)..\..\bin\assimpcmd_$(ConfigurationName)_$(PlatformName)&#x0D;&#x0A;&#x0D;&#x0A;copy &quot;$(OutDir)\$(TargetFileName)&quot; &quot;$(SolutionDir)..\..\bin\unit_$(ConfigurationName)_$(PlatformName)\&quot;&#x0D;&#x0A;copy &quot;$(OutDir)\$(TargetFileName)&quot; &quot;$(SolutionDir)..\..\bin\assimpview_$(ConfigurationName)_$(PlatformName)\&quot;&#x0D;&#x0A;copy &quot;$(OutDir)\$(TargetFileName)&quot; &quot;$(SolutionDir)..\..\bin\assimpcmd_$(ConfigurationName)_$(PlatformName)\&quot;&#x0D;&#x0A;"
/>
</Configuration>
<Configuration
@ -301,7 +303,7 @@
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="mkdir $(SolutionDir)..\..\bin\unit_$(ConfigurationName)_$(PlatformName)&#x0D;&#x0A;mkdir $(SolutionDir)..\..\bin\assimpview_$(ConfigurationName)_$(PlatformName)&#x0D;&#x0A;&#x0D;&#x0A;copy &quot;$(OutDir)\$(TargetFileName)&quot; &quot;$(SolutionDir)..\..\bin\unit_$(ConfigurationName)_$(PlatformName)\&quot;&#x0D;&#x0A;copy &quot;$(OutDir)\$(TargetFileName)&quot; &quot;$(SolutionDir)..\..\bin\assimpview_$(ConfigurationName)_$(PlatformName)\&quot;&#x0D;&#x0A;"
CommandLine="mkdir $(SolutionDir)..\..\bin\unit_$(ConfigurationName)_$(PlatformName)&#x0D;&#x0A;mkdir $(SolutionDir)..\..\bin\assimpview_$(ConfigurationName)_$(PlatformName)&#x0D;&#x0A;mkdir $(SolutionDir)..\..\bin\assimpcmd_$(ConfigurationName)_$(PlatformName)&#x0D;&#x0A;&#x0D;&#x0A;copy &quot;$(OutDir)\$(TargetFileName)&quot; &quot;$(SolutionDir)..\..\bin\unit_$(ConfigurationName)_$(PlatformName)\&quot;&#x0D;&#x0A;copy &quot;$(OutDir)\$(TargetFileName)&quot; &quot;$(SolutionDir)..\..\bin\assimpview_$(ConfigurationName)_$(PlatformName)\&quot;&#x0D;&#x0A;copy &quot;$(OutDir)\$(TargetFileName)&quot; &quot;$(SolutionDir)..\..\bin\assimpcmd_$(ConfigurationName)_$(PlatformName)\&quot;&#x0D;&#x0A;"
/>
</Configuration>
<Configuration
@ -330,6 +332,7 @@
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="0"
OmitFramePointers="true"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;WIN32;ASSIMP_BUILD_BOOST_WORKAROUND"
StringPooling="true"
@ -524,6 +527,7 @@
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="0"
OmitFramePointers="true"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;WIN32"
StringPooling="true"
@ -1417,7 +1421,7 @@
>
</File>
<Filter
Name="Extra"
Name="extra"
>
<File
RelativePath="..\..\code\extra\MakeVerboseFormat.cpp"
@ -1521,10 +1525,10 @@
</File>
</Filter>
<Filter
Name="Loaders"
Name="import"
>
<Filter
Name="3DS"
Name="3ds"
>
<File
RelativePath="..\..\code\3DSConverter.cpp"
@ -1544,7 +1548,7 @@
</File>
</Filter>
<Filter
Name="ASE"
Name="ase"
>
<File
RelativePath="..\..\code\ASELoader.cpp"
@ -1564,7 +1568,7 @@
</File>
</Filter>
<Filter
Name="HMP"
Name="hmp"
>
<File
RelativePath="..\..\code\HMPFileData.h"
@ -1580,7 +1584,7 @@
</File>
</Filter>
<Filter
Name="LWO"
Name="lwo"
>
<File
RelativePath="..\..\code\LWOBLoader.cpp"
@ -1604,7 +1608,7 @@
</File>
</Filter>
<Filter
Name="MD2"
Name="md2"
>
<File
RelativePath="..\..\code\MD2FileData.h"
@ -1624,7 +1628,7 @@
</File>
</Filter>
<Filter
Name="MD3"
Name="md3"
>
<File
RelativePath="..\..\code\MD3FileData.h"
@ -1640,7 +1644,7 @@
</File>
</Filter>
<Filter
Name="MD5"
Name="md5"
>
<File
RelativePath="..\..\code\MD5Loader.cpp"
@ -1660,7 +1664,7 @@
</File>
</Filter>
<Filter
Name="MDC"
Name="mdc"
>
<File
RelativePath="..\..\code\MDCFileData.h"
@ -1680,7 +1684,7 @@
</File>
</Filter>
<Filter
Name="MDL"
Name="mdl"
>
<File
RelativePath="..\..\code\HalfLifeFileData.h"
@ -1708,7 +1712,7 @@
</File>
</Filter>
<Filter
Name="Obj"
Name="obj"
>
<File
RelativePath="..\..\code\ObjFileData.h"
@ -1744,7 +1748,7 @@
</File>
</Filter>
<Filter
Name="Ply"
Name="ply"
>
<File
RelativePath="..\..\code\PlyLoader.cpp"
@ -1764,7 +1768,7 @@
</File>
</Filter>
<Filter
Name="SMD"
Name="smd"
>
<File
RelativePath="..\..\code\SMDLoader.cpp"
@ -1776,7 +1780,7 @@
</File>
</Filter>
<Filter
Name="STL"
Name="stl"
>
<File
RelativePath="..\..\code\STLLoader.cpp"
@ -1788,7 +1792,7 @@
</File>
</Filter>
<Filter
Name="X"
Name="x"
>
<File
RelativePath="..\..\code\XFileHelper.h"
@ -1812,7 +1816,7 @@
</File>
</Filter>
<Filter
Name="DXF"
Name="dxf"
>
<File
RelativePath="..\..\code\DXFLoader.cpp"
@ -1824,7 +1828,7 @@
</File>
</Filter>
<Filter
Name="RAW"
Name="raw"
>
<File
RelativePath="..\..\code\RawLoader.cpp"
@ -1836,7 +1840,7 @@
</File>
</Filter>
<Filter
Name="NFF"
Name="nff"
>
<File
RelativePath="..\..\code\NFFLoader.cpp"
@ -1848,11 +1852,11 @@
</File>
</Filter>
<Filter
Name="VRML97"
Name="vrml97"
>
</Filter>
<Filter
Name="OFF"
Name="off"
>
<File
RelativePath="..\..\code\OFFLoader.cpp"
@ -1864,7 +1868,7 @@
</File>
</Filter>
<Filter
Name="AC"
Name="ac"
>
<File
RelativePath="..\..\code\ACLoader.cpp"
@ -1900,7 +1904,7 @@
</File>
</Filter>
<Filter
Name="LWS"
Name="lws"
>
<File
RelativePath="..\..\code\LWOAnimation.cpp"
@ -1920,7 +1924,7 @@
</File>
</Filter>
<Filter
Name="BVH"
Name="bvh"
>
<File
RelativePath="..\..\code\BVHLoader.cpp"
@ -1932,7 +1936,7 @@
</File>
</Filter>
<Filter
Name="IRRMesh"
Name="irrmesh"
>
<File
RelativePath="..\..\code\IRRMeshLoader.cpp"
@ -1944,7 +1948,7 @@
</File>
</Filter>
<Filter
Name="IRR"
Name="irr"
>
<File
RelativePath="..\..\code\IRRLoader.cpp"
@ -1964,7 +1968,7 @@
</File>
</Filter>
<Filter
Name="Q3D"
Name="q3d"
>
<File
RelativePath="..\..\code\Q3DLoader.cpp"
@ -1976,7 +1980,7 @@
</File>
</Filter>
<Filter
Name="B3D"
Name="b3d"
>
<File
RelativePath="..\..\code\B3DImporter.cpp"
@ -1988,7 +1992,7 @@
</File>
</Filter>
<Filter
Name="Collada"
Name="collada"
>
<File
RelativePath="..\..\code\ColladaHelper.h"
@ -2012,7 +2016,7 @@
</File>
</Filter>
<Filter
Name="TER"
Name="ter"
>
<File
RelativePath="..\..\code\TerragenLoader.cpp"
@ -2024,11 +2028,11 @@
</File>
</Filter>
<Filter
Name="CSM"
Name="csm"
>
</Filter>
<Filter
Name="UNREAL"
Name="unreal"
>
<File
RelativePath="..\..\code\UnrealLoader.cpp"
@ -2041,7 +2045,7 @@
</Filter>
</Filter>
<Filter
Name="PostProcess"
Name="process"
>
<File
RelativePath="..\..\code\AssimpPCH.h"
@ -2217,7 +2221,7 @@
</Filter>
</Filter>
<Filter
Name="PCH"
Name="pch"
>
<File
RelativePath="..\..\code\AssimpPCH.cpp"
@ -2321,7 +2325,7 @@
</File>
</Filter>
<Filter
Name="Logging"
Name="logging"
>
<File
RelativePath="..\..\code\DefaultLogger.cpp"
@ -2341,7 +2345,7 @@
</File>
</Filter>
<Filter
Name="FileSystem"
Name="fs"
>
<File
RelativePath="..\..\code\DefaultIOStream.cpp"
@ -2397,7 +2401,7 @@
</File>
</Filter>
<Filter
Name="Extern"
Name="extern"
>
<Filter
Name="irrXML"

File diff suppressed because it is too large Load Diff