Added temporary boost workaround - some assimp features work with reduced functionality in this case.
Added AC-loader, WIP version. PLY loader is now able to load models from blender, test model added. Refactoring. Added FindInvalidData step. Added support for precompiled headers, the release builds in VC8 are configued to use PCH now. Added separate makefile for mingw, no -FPic warning anymore, -clear works now. git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@176 67173fc5-114c-0410-ac8e-9d2fd5bffc1fpull/1/head
parent
f204ff0d45
commit
1db46c242f
|
@ -41,6 +41,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/** @file Implementation of the 3ds importer class */
|
||||
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
// internal headers
|
||||
#include "3DSLoader.h"
|
||||
#include "MaterialSystem.h"
|
||||
|
@ -48,15 +51,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "StringComparison.h"
|
||||
#include "qnan.h"
|
||||
|
||||
// public ASSIMP headers
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/IOStream.h"
|
||||
#include "../include/IOSystem.h"
|
||||
#include "../include/aiMesh.h"
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/aiAssert.h"
|
||||
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -41,6 +41,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/** @file Implementation of the 3ds importer class */
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
// internal headers
|
||||
#include "3DSLoader.h"
|
||||
#include "MaterialSystem.h"
|
||||
|
@ -48,17 +50,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "StringComparison.h"
|
||||
#include "qnan.h"
|
||||
|
||||
// public ASSIMP headers
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/aiAssert.h"
|
||||
#include "../include/IOStream.h"
|
||||
#include "../include/IOSystem.h"
|
||||
#include "../include/assimp.hpp"
|
||||
|
||||
// boost headers
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,673 @@
|
|||
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (ASSIMP)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the following
|
||||
conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the ASSIMP team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the ASSIMP Development Team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file Implementation of the AC3D importer class */
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
#ifndef AI_BUILD_NO_AC_IMPORTER
|
||||
|
||||
// internal headers
|
||||
#include "ACLoader.h"
|
||||
#include "ParsingUtils.h"
|
||||
#include "fast_atof.h"
|
||||
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// skip to the next token
|
||||
#define AI_AC_SKIP_TO_NEXT_TOKEN() \
|
||||
if (!SkipSpaces(&buffer)) \
|
||||
{ \
|
||||
DefaultLogger::get()->error("AC3D: Unexpected EOF/EOL"); \
|
||||
continue; \
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// read a string enclosed in double quotation marks. buffer must point to "
|
||||
#define AI_AC_GET_STRING(out) \
|
||||
++buffer; \
|
||||
const char* sz = buffer; \
|
||||
while ('\"' != *buffer) \
|
||||
{ \
|
||||
if (IsLineEnd( *buffer )) \
|
||||
{ \
|
||||
DefaultLogger::get()->error("AC3D: Unexpected EOF/EOL in string"); \
|
||||
out = "ERROR"; \
|
||||
break; \
|
||||
} \
|
||||
++buffer; \
|
||||
} \
|
||||
if (IsLineEnd( *buffer ))continue; \
|
||||
out = std::string(sz,(unsigned int)(buffer-sz)); \
|
||||
++buffer;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// read 1 to n floats prefixed with an optional predefined identifier
|
||||
#define AI_AC_CHECKED_LOAD_FLOAT_ARRAY(name,name_length,num,out) \
|
||||
AI_AC_SKIP_TO_NEXT_TOKEN(); \
|
||||
if (name_length) \
|
||||
{ \
|
||||
if (strncmp(buffer,name,name_length) || !IsSpace(buffer[name_length])) \
|
||||
{ \
|
||||
DefaultLogger::get()->error("AC3D: Unexpexted token. " name " was expected."); \
|
||||
continue; \
|
||||
} \
|
||||
buffer += name_length+1; \
|
||||
} \
|
||||
for (unsigned int i = 0; i < num;++i) \
|
||||
{ \
|
||||
AI_AC_SKIP_TO_NEXT_TOKEN(); \
|
||||
buffer = fast_atof_move(buffer,((float*)out)[i]); \
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor to be privately used by Importer
|
||||
AC3DImporter::AC3DImporter()
|
||||
{
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Destructor, private as well
|
||||
AC3DImporter::~AC3DImporter()
|
||||
{
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Returns whether the class can handle the format of the given file.
|
||||
bool AC3DImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler) const
|
||||
{
|
||||
// simple check of file extension is enough for the moment
|
||||
std::string::size_type pos = pFile.find_last_of('.');
|
||||
// no file extension - can't read
|
||||
if( pos == std::string::npos)return false;
|
||||
std::string extension = pFile.substr( pos);
|
||||
|
||||
return !(extension.length() != 3 || extension[0] != '.' ||
|
||||
extension[1] != 'a' && extension[1] != 'A' ||
|
||||
extension[2] != 'c' && extension[2] != 'C');
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Get a pointer to the next line from the file
|
||||
bool AC3DImporter::GetNextLine( )
|
||||
{
|
||||
SkipLine(&buffer);
|
||||
return SkipSpaces(&buffer);
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Parse an object section in an AC file
|
||||
void AC3DImporter::LoadObjectSection(std::vector<Object>& objects)
|
||||
{
|
||||
if (!TokenMatch(buffer,"OBJECT",6))
|
||||
return;
|
||||
|
||||
++mNumMeshes;
|
||||
|
||||
objects.push_back(Object());
|
||||
Object& obj = objects.back();
|
||||
|
||||
while (GetNextLine())
|
||||
{
|
||||
if (TokenMatch(buffer,"kids",4))
|
||||
{
|
||||
SkipSpaces(&buffer);
|
||||
unsigned int num = strtol10(buffer,&buffer);
|
||||
GetNextLine();
|
||||
if (num)
|
||||
{
|
||||
// load the children of this object recursively
|
||||
obj.children.reserve(num);
|
||||
LoadObjectSection(obj.children);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (TokenMatch(buffer,"name",4))
|
||||
{
|
||||
SkipSpaces(&buffer);
|
||||
AI_AC_GET_STRING(obj.name);
|
||||
}
|
||||
else if (TokenMatch(buffer,"texture",7))
|
||||
{
|
||||
SkipSpaces(&buffer);
|
||||
AI_AC_GET_STRING(obj.texture);
|
||||
}
|
||||
else if (TokenMatch(buffer,"texrep",6))
|
||||
{
|
||||
SkipSpaces(&buffer);
|
||||
AI_AC_CHECKED_LOAD_FLOAT_ARRAY("",0,2,&obj.texRepeat);
|
||||
}
|
||||
else if (TokenMatch(buffer,"rot",3))
|
||||
{
|
||||
SkipSpaces(&buffer);
|
||||
AI_AC_CHECKED_LOAD_FLOAT_ARRAY("",0,9,&obj.rotation);
|
||||
}
|
||||
else if (TokenMatch(buffer,"loc",3))
|
||||
{
|
||||
SkipSpaces(&buffer);
|
||||
AI_AC_CHECKED_LOAD_FLOAT_ARRAY("",0,3,&obj.translation);
|
||||
}
|
||||
else if (TokenMatch(buffer,"numvert",7))
|
||||
{
|
||||
SkipSpaces(&buffer);
|
||||
|
||||
unsigned int t = strtol10(buffer,&buffer);
|
||||
obj.vertices.reserve(t);
|
||||
for (unsigned int i = 0; i < t;++i)
|
||||
{
|
||||
if (!GetNextLine())
|
||||
{
|
||||
DefaultLogger::get()->error("AC3D: Unexpected EOF: not all vertices have been parsed yet");
|
||||
break;
|
||||
}
|
||||
else if (!IsNumeric(*buffer))
|
||||
{
|
||||
DefaultLogger::get()->error("AC3D: Unexpected token: not all vertices have been parsed yet");
|
||||
--buffer; // make sure the line is processed a second time
|
||||
break;
|
||||
}
|
||||
obj.vertices.push_back(aiVector3D());
|
||||
aiVector3D& v = obj.vertices.back();
|
||||
AI_AC_CHECKED_LOAD_FLOAT_ARRAY("",0,3,&v.x);
|
||||
}
|
||||
}
|
||||
else if (TokenMatch(buffer,"numsurf",7))
|
||||
{
|
||||
SkipSpaces(&buffer);
|
||||
|
||||
const unsigned int t = strtol10(buffer,&buffer);
|
||||
obj.surfaces.reserve(t);
|
||||
for (unsigned int i = 0; i < t;++i)
|
||||
{
|
||||
GetNextLine();
|
||||
if (!TokenMatch(buffer,"SURF",4))
|
||||
{
|
||||
DefaultLogger::get()->error("AC3D: SURF token was expected");
|
||||
--buffer; // make sure the line is processed a second time
|
||||
break;
|
||||
}
|
||||
SkipSpaces(&buffer);
|
||||
obj.surfaces.push_back(Surface());
|
||||
Surface& surf = obj.surfaces.back();
|
||||
surf.flags = strtol_cppstyle(buffer);
|
||||
|
||||
while (1)
|
||||
{
|
||||
if(!GetNextLine())
|
||||
{
|
||||
DefaultLogger::get()->error("AC3D: Unexpected EOF: surface is incomplete");
|
||||
break;
|
||||
}
|
||||
if (TokenMatch(buffer,"mat",3))
|
||||
{
|
||||
SkipSpaces(&buffer);
|
||||
surf.mat = strtol10(buffer);
|
||||
}
|
||||
else if (TokenMatch(buffer,"refs",4))
|
||||
{
|
||||
SkipSpaces(&buffer);
|
||||
const unsigned int m = strtol10(buffer);
|
||||
surf.entries.reserve(m);
|
||||
|
||||
obj.numRefs += m;
|
||||
|
||||
for (unsigned int k = 0; k < m; ++k)
|
||||
{
|
||||
if(!GetNextLine())
|
||||
{
|
||||
DefaultLogger::get()->error("AC3D: Unexpected EOF: surface references are incomplete");
|
||||
break;
|
||||
}
|
||||
surf.entries.push_back(Surface::SurfaceEntry());
|
||||
Surface::SurfaceEntry& entry = surf.entries.back();
|
||||
|
||||
entry.first = strtol10(buffer,&buffer);
|
||||
SkipSpaces(&buffer);
|
||||
AI_AC_CHECKED_LOAD_FLOAT_ARRAY("",0,2,&entry.second);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
--buffer; // make sure the line is processed a second time
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
DefaultLogger::get()->error("AC3D: Unexpected EOF: \'kids\' line was expected");
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Convert a material from AC3DImporter::Material to aiMaterial
|
||||
void AC3DImporter::ConvertMaterial(const Object& object,
|
||||
const Material& matSrc,
|
||||
MaterialHelper& matDest)
|
||||
{
|
||||
aiString s;
|
||||
|
||||
if (matSrc.name.length())
|
||||
{
|
||||
s.Set(matSrc.name);
|
||||
matDest.AddProperty(&s,AI_MATKEY_NAME);
|
||||
}
|
||||
if (object.texture.length())
|
||||
{
|
||||
s.Set(object.texture);
|
||||
matDest.AddProperty(&s,AI_MATKEY_TEXTURE_DIFFUSE(0));
|
||||
}
|
||||
|
||||
matDest.AddProperty<aiColor3D>(&matSrc.rgb,1, AI_MATKEY_COLOR_DIFFUSE);
|
||||
matDest.AddProperty<aiColor3D>(&matSrc.amb,1, AI_MATKEY_COLOR_AMBIENT);
|
||||
matDest.AddProperty<aiColor3D>(&matSrc.emis,1,AI_MATKEY_COLOR_EMISSIVE);
|
||||
matDest.AddProperty<aiColor3D>(&matSrc.spec,1,AI_MATKEY_COLOR_SPECULAR);
|
||||
|
||||
float f = 1.f - matSrc.trans;
|
||||
|
||||
matDest.AddProperty<float>(&matSrc.shin,1,AI_MATKEY_SHININESS);
|
||||
matDest.AddProperty<float>(&f,1,AI_MATKEY_OPACITY);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Converts the loaded data to the internal verbose representation
|
||||
aiNode* AC3DImporter::ConvertObjectSection(Object& object,
|
||||
std::vector<aiMesh*>& meshes,
|
||||
std::vector<MaterialHelper*>& outMaterials,
|
||||
const std::vector<Material>& materials)
|
||||
{
|
||||
aiNode* node = new aiNode();
|
||||
if (object.vertices.size())
|
||||
{
|
||||
if (!object.surfaces.size() || !object.numRefs)
|
||||
{
|
||||
/* " An object with 7 vertices (no surfaces, no materials defined).
|
||||
This is a good way of getting point data into AC3D.
|
||||
The Vertex->create convex-surface/object can be used on these
|
||||
vertices to 'wrap' a 3d shape around them "
|
||||
(http://www.opencity.info/html/ac3dfileformat.html)
|
||||
|
||||
therefore: if no surfaces are defined return point data only
|
||||
*/
|
||||
|
||||
DefaultLogger::get()->info("AC3D: No surfaces defined in object definition, "
|
||||
"a point list is returned");
|
||||
|
||||
meshes.push_back(new aiMesh());
|
||||
aiMesh* mesh = meshes.back();
|
||||
|
||||
mesh->mNumFaces = mesh->mNumVertices = (unsigned int)object.vertices.size();
|
||||
aiFace* faces = mesh->mFaces = new aiFace[mesh->mNumFaces];
|
||||
aiVector3D* verts = mesh->mVertices = new aiVector3D[mesh->mNumVertices];
|
||||
|
||||
for (unsigned int i = 0; i < mesh->mNumVertices;++i,++faces,++verts)
|
||||
{
|
||||
*verts = object.vertices[i];
|
||||
faces->mNumIndices = 1;
|
||||
faces->mIndices = new unsigned int[1];
|
||||
faces->mIndices[0] = i;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// need to generate one or more meshes for this object.
|
||||
// find out how many different materials we have
|
||||
typedef std::pair< unsigned int, unsigned int > IntPair;
|
||||
typedef std::vector< IntPair > MatTable;
|
||||
MatTable needMat(materials.size(),IntPair(0,0));
|
||||
|
||||
std::vector<Surface>::iterator it,end = object.surfaces.end();
|
||||
std::vector<Surface::SurfaceEntry>::iterator it2,end2;
|
||||
|
||||
for (it = object.surfaces.begin(); it != end; ++it)
|
||||
{
|
||||
register unsigned int idx = (*it).mat;
|
||||
if (idx >= needMat.size())
|
||||
{
|
||||
DefaultLogger::get()->error("AC3D: material index os out of range");
|
||||
idx = 0;
|
||||
}
|
||||
if ((*it).entries.empty())
|
||||
{
|
||||
DefaultLogger::get()->warn("AC3D: surface her zero vertex references");
|
||||
}
|
||||
|
||||
// validate all vertex indices to make sure we won't crash here
|
||||
for (it2 = (*it).entries.begin(),
|
||||
end2 = (*it).entries.end(); it2 != end2; ++it2)
|
||||
{
|
||||
if ((*it2).first >= object.vertices.size())
|
||||
{
|
||||
DefaultLogger::get()->warn("AC3D: Invalid vertex reference");
|
||||
(*it2).first = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!needMat[idx].first)++node->mNumMeshes;
|
||||
|
||||
switch ((*it).flags & 0xf)
|
||||
{
|
||||
// closed line
|
||||
case 0x1:
|
||||
|
||||
needMat[idx].first += (unsigned int)(*it).entries.size();
|
||||
needMat[idx].second += (unsigned int)(*it).entries.size()<<1u;
|
||||
break;
|
||||
|
||||
// unclosed line
|
||||
case 0x2:
|
||||
|
||||
needMat[idx].first += (unsigned int)(*it).entries.size()-1;
|
||||
needMat[idx].second += ((unsigned int)(*it).entries.size()-1)<<1u;
|
||||
break;
|
||||
|
||||
// 0 == polygon, else unknown
|
||||
default:
|
||||
|
||||
if ((*it).flags & 0xf)
|
||||
{
|
||||
DefaultLogger::get()->warn("AC3D: The type flag of a surface is unknown");
|
||||
(*it).flags &= ~(0xf);
|
||||
}
|
||||
|
||||
// the number of faces increments by one, the number
|
||||
// of vertices by surface.numref.
|
||||
needMat[idx].first++;
|
||||
needMat[idx].second += (unsigned int)(*it).entries.size();
|
||||
};
|
||||
}
|
||||
unsigned int* pip = node->mMeshes = new unsigned int[node->mNumMeshes];
|
||||
unsigned int mat = 0;
|
||||
for (MatTable::const_iterator cit = needMat.begin(), cend = needMat.end();
|
||||
cit != cend; ++cit, ++mat)
|
||||
{
|
||||
if (!(*cit).first)continue;
|
||||
|
||||
// allocate a new aiMesh object
|
||||
*pip++ = (unsigned int)meshes.size();
|
||||
aiMesh* mesh = new aiMesh();
|
||||
meshes.push_back(mesh);
|
||||
|
||||
mesh->mMaterialIndex = (unsigned int)outMaterials.size();
|
||||
outMaterials.push_back(new MaterialHelper());
|
||||
ConvertMaterial(object, materials[mat], *outMaterials.back());
|
||||
|
||||
// allocate storage for vertices and normals
|
||||
mesh->mNumFaces = (*cit).first;
|
||||
aiFace* faces = mesh->mFaces = new aiFace[mesh->mNumFaces];
|
||||
|
||||
mesh->mNumVertices = (*cit).second;
|
||||
aiVector3D* vertices = mesh->mVertices = new aiVector3D[mesh->mNumVertices];
|
||||
unsigned int cur = 0;
|
||||
|
||||
// allocate UV coordinates, but only if the texture name for the
|
||||
// surface is not empty
|
||||
aiVector3D* uv = NULL;
|
||||
if(object.texture.length())
|
||||
{
|
||||
uv = mesh->mTextureCoords[0] = new aiVector3D[mesh->mNumVertices];
|
||||
mesh->mNumUVComponents[0] = 2;
|
||||
}
|
||||
|
||||
for (it = object.surfaces.begin(); it != end; ++it)
|
||||
{
|
||||
if (mat == (*it).mat)
|
||||
{
|
||||
const Surface& src = *it;
|
||||
|
||||
// closed polygon
|
||||
unsigned int type = (*it).flags & 0xf;
|
||||
if (!type)
|
||||
{
|
||||
aiFace& face = *faces++;
|
||||
if((face.mNumIndices = (unsigned int)src.entries.size()))
|
||||
{
|
||||
face.mIndices = new unsigned int[face.mNumIndices];
|
||||
for (unsigned int i = 0; i < face.mNumIndices;++i,++vertices)
|
||||
{
|
||||
const Surface::SurfaceEntry& entry = src.entries[i];
|
||||
face.mIndices[i] = cur++;
|
||||
|
||||
// copy vertex positions
|
||||
*vertices = object.vertices[entry.first];
|
||||
|
||||
// copy texture coordinates (apply the UV offset)
|
||||
if (uv)
|
||||
{
|
||||
uv->x = entry.second.x * object.texRepeat.x;
|
||||
uv->y = entry.second.y * object.texRepeat.y;
|
||||
++uv;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
it2 = (*it).entries.begin();
|
||||
|
||||
// either a closed or an unclosed line
|
||||
register unsigned int tmp = (unsigned int)(*it).entries.size();
|
||||
if (0x2 == type)--tmp;
|
||||
for (unsigned int m = 0; m < tmp;++m)
|
||||
{
|
||||
aiFace& face = *faces++;
|
||||
|
||||
face.mNumIndices = 2;
|
||||
face.mIndices = new unsigned int[2];
|
||||
face.mIndices[0] = cur++;
|
||||
face.mIndices[1] = cur;
|
||||
|
||||
// copy vertex positions
|
||||
*vertices++ = object.vertices[(*it2).first];
|
||||
|
||||
// copy texture coordinates (apply the UV offset)
|
||||
if (uv)
|
||||
{
|
||||
uv->x = (*it2).second.x * object.texRepeat.x;
|
||||
uv->y = (*it2).second.y * object.texRepeat.y;
|
||||
++uv;
|
||||
}
|
||||
|
||||
if (0x1 == type && tmp-1 == m)
|
||||
{
|
||||
// if this is a closed line repeat its beginning now
|
||||
it2 = (*it).entries.begin();
|
||||
}
|
||||
else ++it2;
|
||||
|
||||
// second point
|
||||
*vertices++ = object.vertices[(*it2).first];
|
||||
|
||||
if (uv)
|
||||
{
|
||||
uv->x = (*it2).second.x * object.texRepeat.x;
|
||||
uv->y = (*it2).second.y * object.texRepeat.y;
|
||||
++uv;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add children to the object
|
||||
if (object.children.size())
|
||||
{
|
||||
node->mNumChildren = (unsigned int)object.children.size();
|
||||
node->mChildren = new aiNode*[node->mNumChildren];
|
||||
for (unsigned int i = 0; i < node->mNumChildren;++i)
|
||||
{
|
||||
node->mChildren[i] = ConvertObjectSection(object.children[i],meshes,outMaterials,materials);
|
||||
node->mChildren[i]->mParent = node;
|
||||
}
|
||||
}
|
||||
|
||||
node->mName.Set(object.name);
|
||||
|
||||
// setup the local transformation matrix of the object
|
||||
node->mTransformation = aiMatrix4x4 ( object.rotation );
|
||||
|
||||
node->mTransformation.a4 = object.translation.x;
|
||||
node->mTransformation.b4 = object.translation.y;
|
||||
node->mTransformation.c4 = object.translation.z;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void AC3DImporter::SetupProperties(const Importer* pImp)
|
||||
{
|
||||
configSplitBFCull = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_AC_SEPARATE_BFCULL,1) ? true : false;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Imports the given file into the given scene structure.
|
||||
void AC3DImporter::InternReadFile( const std::string& pFile,
|
||||
aiScene* pScene, IOSystem* pIOHandler)
|
||||
{
|
||||
boost::scoped_ptr<IOStream> file( pIOHandler->Open( pFile, "rb"));
|
||||
|
||||
// Check whether we can read from the file
|
||||
if( file.get() == NULL)
|
||||
throw new ImportErrorException( "Failed to open AC3D file " + pFile + ".");
|
||||
|
||||
const unsigned int fileSize = (unsigned int)file->FileSize();
|
||||
|
||||
// allocate storage and copy the contents of the file to a memory buffer
|
||||
std::vector<char> mBuffer2(fileSize+1);
|
||||
file->Read(&mBuffer2[0], 1, fileSize);
|
||||
mBuffer2[fileSize] = '\0';
|
||||
buffer = &mBuffer2[0];
|
||||
mNumMeshes = 0;
|
||||
|
||||
if (::strncmp(buffer,"AC3D",4))
|
||||
throw new ImportErrorException("AC3D: No valid AC3D file, magic sequence not found");
|
||||
|
||||
// print the file format version to the console
|
||||
unsigned int version = HexDigitToDecimal( buffer[4] );
|
||||
char msg[3];::_itoa(version,msg,10);
|
||||
DefaultLogger::get()->info(std::string("AC3D file format version: ") + msg);
|
||||
|
||||
std::vector<Material> materials;
|
||||
materials.reserve(5);
|
||||
|
||||
std::vector<Object> rootObjects;
|
||||
rootObjects.reserve(5);
|
||||
|
||||
while (GetNextLine())
|
||||
{
|
||||
if (TokenMatch(buffer,"MATERIAL",8))
|
||||
{
|
||||
materials.push_back(Material());
|
||||
Material& mat = materials.back();
|
||||
|
||||
// manually parse the material ... sscanf would use the buldin atof ...
|
||||
// Format: (name) rgb %f %f %f amb %f %f %f emis %f %f %f spec %f %f %f shi %d trans %f
|
||||
|
||||
AI_AC_SKIP_TO_NEXT_TOKEN();
|
||||
if ('\"' == *buffer)
|
||||
{
|
||||
AI_AC_GET_STRING(mat.name);
|
||||
AI_AC_SKIP_TO_NEXT_TOKEN();
|
||||
}
|
||||
|
||||
AI_AC_CHECKED_LOAD_FLOAT_ARRAY("rgb",3,3,&mat.rgb);
|
||||
AI_AC_CHECKED_LOAD_FLOAT_ARRAY("amb",3,3,&mat.rgb);
|
||||
AI_AC_CHECKED_LOAD_FLOAT_ARRAY("emis",4,3,&mat.rgb);
|
||||
AI_AC_CHECKED_LOAD_FLOAT_ARRAY("spec",4,3,&mat.rgb);
|
||||
AI_AC_CHECKED_LOAD_FLOAT_ARRAY("shi",3,1,&mat.shin);
|
||||
AI_AC_CHECKED_LOAD_FLOAT_ARRAY("trans",5,1,&mat.trans);
|
||||
}
|
||||
LoadObjectSection(rootObjects);
|
||||
}
|
||||
|
||||
if (rootObjects.empty() || !mNumMeshes)
|
||||
{
|
||||
throw new ImportErrorException("AC3D: No meshes have been loaded");
|
||||
}
|
||||
if (materials.empty())
|
||||
{
|
||||
DefaultLogger::get()->warn("AC3D: No material has been found");
|
||||
materials.push_back(Material());
|
||||
}
|
||||
|
||||
mNumMeshes += (mNumMeshes>>2u) + 1;
|
||||
std::vector<aiMesh*> meshes;
|
||||
meshes.reserve(mNumMeshes);
|
||||
|
||||
std::vector<MaterialHelper*> omaterials;
|
||||
materials.reserve(mNumMeshes);
|
||||
|
||||
// generate a dummy root if there are multiple objects on the top layer
|
||||
Object* root;
|
||||
if (1 == rootObjects.size())
|
||||
root = &rootObjects[0];
|
||||
else
|
||||
{
|
||||
root = new Object();
|
||||
}
|
||||
|
||||
// now convert the imported stuff to our output data structure
|
||||
pScene->mRootNode = ConvertObjectSection(*root,meshes,omaterials,materials);
|
||||
if (1 != rootObjects.size())delete root;
|
||||
|
||||
// build output arrays
|
||||
pScene->mNumMeshes = (unsigned int)meshes.size();
|
||||
pScene->mMeshes = new aiMesh*[pScene->mNumMeshes];
|
||||
::memcpy(pScene->mMeshes,&meshes[0],pScene->mNumMeshes*sizeof(void*));
|
||||
|
||||
// build output arrays
|
||||
pScene->mNumMaterials = (unsigned int)omaterials.size();
|
||||
pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials];
|
||||
::memcpy(pScene->mMaterials,&omaterials[0],pScene->mNumMaterials*sizeof(void*));
|
||||
}
|
||||
|
||||
#endif //!defined AI_BUILD_NO_AC_IMPORTER
|
|
@ -0,0 +1,243 @@
|
|||
/*
|
||||
Open Asset Import Library (ASSIMP)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the ASSIMP team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the ASSIMP Development Team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file Declaration of the .ac importer class. */
|
||||
#ifndef AI_AC3DLOADER_H_INCLUDED
|
||||
#define AI_AC3DLOADER_H_INCLUDED
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "BaseImporter.h"
|
||||
#include "../include/aiTypes.h"
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** AC3D (*.ac) importer class
|
||||
*/
|
||||
class AC3DImporter : public BaseImporter
|
||||
{
|
||||
friend class Importer;
|
||||
|
||||
protected:
|
||||
/** Constructor to be privately used by Importer */
|
||||
AC3DImporter();
|
||||
|
||||
/** Destructor, private as well */
|
||||
~AC3DImporter();
|
||||
|
||||
|
||||
// Represents an AC3D material
|
||||
struct Material
|
||||
{
|
||||
Material()
|
||||
: rgb (0.6f,0.6f,0.6f)
|
||||
, spec (1.f,1.f,1.f)
|
||||
, shin (0.f)
|
||||
, trans (0.f)
|
||||
{}
|
||||
|
||||
// base color of the material
|
||||
aiColor3D rgb;
|
||||
|
||||
// ambient color of the material
|
||||
aiColor3D amb;
|
||||
|
||||
// emissive color of the material
|
||||
aiColor3D emis;
|
||||
|
||||
// specular color of the material
|
||||
aiColor3D spec;
|
||||
|
||||
// shininess exponent
|
||||
float shin;
|
||||
|
||||
// transparency. 0 == opaque
|
||||
float trans;
|
||||
|
||||
// name of the material. optional.
|
||||
std::string name;
|
||||
};
|
||||
|
||||
// Represents an AC3D surface
|
||||
struct Surface
|
||||
{
|
||||
Surface()
|
||||
: mat (0)
|
||||
, flags (0)
|
||||
{}
|
||||
|
||||
unsigned int mat,flags;
|
||||
|
||||
typedef std::pair<unsigned int, aiVector2D > SurfaceEntry;
|
||||
std::vector< SurfaceEntry > entries;
|
||||
};
|
||||
|
||||
// Represents an AC3D object
|
||||
struct Object
|
||||
{
|
||||
Object()
|
||||
: texRepeat(1.f,1.f)
|
||||
, numRefs (0)
|
||||
{}
|
||||
|
||||
// name of the object
|
||||
std::string name;
|
||||
|
||||
// object children
|
||||
std::vector<Object> children;
|
||||
|
||||
// texture to be assigned to all surfaces of the object
|
||||
std::string texture;
|
||||
|
||||
// texture repat factors (scaling for all coordinates)
|
||||
aiVector2D texRepeat;
|
||||
|
||||
// rotation matrix
|
||||
aiMatrix3x3 rotation;
|
||||
|
||||
// translation vector
|
||||
aiVector3D translation;
|
||||
|
||||
// vertices
|
||||
std::vector<aiVector3D> vertices;
|
||||
|
||||
// surfaces
|
||||
std::vector<Surface> surfaces;
|
||||
|
||||
// number of indices (= num verts in verbose format)
|
||||
unsigned int numRefs;
|
||||
};
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Returns whether the class can handle the format of the given file.
|
||||
* See BaseImporter::CanRead() for details. */
|
||||
bool CanRead( const std::string& pFile, IOSystem* pIOHandler) const;
|
||||
|
||||
protected:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Called by Importer::GetExtensionList() for each loaded importer.
|
||||
* See BaseImporter::GetExtensionList() for details
|
||||
*/
|
||||
void GetExtensionList(std::string& append)
|
||||
{
|
||||
append.append("*.ac");
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Imports the given file into the given scene structure.
|
||||
* See BaseImporter::InternReadFile() for details
|
||||
*/
|
||||
void InternReadFile( const std::string& pFile, aiScene* pScene,
|
||||
IOSystem* pIOHandler);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Called prior to ReadFile().
|
||||
* The function is a request to the importer to update its configuration
|
||||
* basing on the Importer's configuration property list.
|
||||
*/
|
||||
void SetupProperties(const Importer* pImp);
|
||||
|
||||
private:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Get the next line from the file.
|
||||
* @return false if the end of the file was reached
|
||||
*/
|
||||
bool GetNextLine();
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Load the object section. This method is called recursively to
|
||||
* load subobjects, the method returns after a 'kids 0' was
|
||||
* encountered.
|
||||
* @objects List of output objects
|
||||
*/
|
||||
void LoadObjectSection(std::vector<Object>& objects);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Convert all objects into meshes and nodes.
|
||||
* @param object Current object to work on
|
||||
* @param meshes Pointer to the list of output meshes
|
||||
* @param outMaterials List of output materials
|
||||
* @param materials Material list
|
||||
* @param Scenegraph node for the object
|
||||
*/
|
||||
aiNode* ConvertObjectSection(Object& object,
|
||||
std::vector<aiMesh*>& meshes,
|
||||
std::vector<MaterialHelper*>& outMaterials,
|
||||
const std::vector<Material>& materials);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Convert a material
|
||||
* @param object Current object
|
||||
* @param matSrc Source material description
|
||||
* @param matDest Destination material to be filled
|
||||
*/
|
||||
void ConvertMaterial(const Object& object,
|
||||
const Material& matSrc,
|
||||
MaterialHelper& matDest);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
// points to the next data line
|
||||
const char* buffer;
|
||||
|
||||
// Configuration option: if enabled, up to two meshes
|
||||
// are generated per material: those faces who have
|
||||
// their bf cull flags set are separated.
|
||||
bool configSplitBFCull;
|
||||
|
||||
// counts how many objects we have in the tree.
|
||||
// basing on this information we can find a
|
||||
// good estimate how many meshes we'll have in the final scene.
|
||||
unsigned int mNumMeshes;
|
||||
};
|
||||
|
||||
} // end of namespace Assimp
|
||||
|
||||
#endif // AI_AC3DIMPORTER_H_INC
|
|
@ -41,6 +41,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/** @file Implementation of the ASE importer class */
|
||||
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
// internal headers
|
||||
#include "ASELoader.h"
|
||||
#include "MaterialSystem.h"
|
||||
|
@ -51,16 +54,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "fast_atof.h"
|
||||
#include "qnan.h"
|
||||
|
||||
// ASSIMP public headers
|
||||
#include "../include/IOStream.h"
|
||||
#include "../include/IOSystem.h"
|
||||
#include "../include/aiMesh.h"
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/aiAssert.h"
|
||||
#include "../include/DefaultLogger.h"
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
using namespace Assimp;
|
||||
using namespace Assimp::ASE;
|
||||
|
||||
|
|
|
@ -41,20 +41,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/** @file Implementation of the ASE parser class */
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
// internal headers
|
||||
#include "TextureTransform.h"
|
||||
#include "ASELoader.h"
|
||||
#include "MaterialSystem.h"
|
||||
#include "fast_atof.h"
|
||||
|
||||
// public ASSIMP headers
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/IOStream.h"
|
||||
#include "../include/IOSystem.h"
|
||||
#include "../include/aiMesh.h"
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/aiAssert.h"
|
||||
|
||||
using namespace Assimp;
|
||||
using namespace Assimp::ASE;
|
||||
|
||||
|
|
|
@ -41,19 +41,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
/** @file Implementation of the Plain-C API */
|
||||
|
||||
|
||||
// public ASSIMP headers
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
#include "../include/assimp.h"
|
||||
|
||||
// public ASSIMP headers
|
||||
#include "../include/aiFileIO.h"
|
||||
#include "../include/assimp.hpp"
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/aiAssert.h"
|
||||
#include "../include/IOStream.h"
|
||||
#include "../include/IOSystem.h"
|
||||
|
||||
#include "GenericProperty.h"
|
||||
|
||||
// boost headers
|
||||
//#define AI_C_THREADSAFE
|
||||
|
||||
#if (defined AI_C_THREADSAFE)
|
||||
# include <boost/thread/thread.hpp>
|
||||
# include <boost/thread/mutex.hpp>
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
|
||||
|
||||
|
||||
// this is a dummy - it is used to generate the precompiled header file.
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
|
||||
|
||||
|
||||
static const char* LEGAL_INFORMATION =
|
||||
|
||||
"Open Asset Import Library (ASSIMP).\n\n"
|
||||
|
||||
"Licensed under a modified BSD license (http://assimp.sourceforge.net/main_license.html)\n"
|
||||
"(c) ASSIMP Development Team, 2008\n"
|
||||
"Hosted at SourceForge, http://assimp.sourceforge.net\n"
|
||||
;
|
|
@ -0,0 +1,46 @@
|
|||
|
||||
|
||||
#ifndef ASSIMP_PCH_INCLUDED
|
||||
#define ASSIMP_PCH_INCLUDED
|
||||
|
||||
// STL headers
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <cassert>
|
||||
#include <stack>
|
||||
#include <queue>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
// public ASSIMP headers
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/IOStream.h"
|
||||
#include "../include/IOSystem.h"
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/aiPostProcess.h"
|
||||
#include "../include/assimp.hpp"
|
||||
|
||||
// internal headers that are nearly always required
|
||||
#include "MaterialSystem.h"
|
||||
#include "StringComparison.h"
|
||||
#include "ByteSwap.h"
|
||||
#include "qnan.h"
|
||||
|
||||
// boost headers - take them from the workaround dir if possible
|
||||
#ifdef ASSIMP_BUILD_BOOST_WORKAROUND
|
||||
|
||||
# include "../include/BoostWorkaround/boost/scoped_ptr.hpp"
|
||||
# include "../include/BoostWorkaround/boost/format.hpp"
|
||||
#else
|
||||
|
||||
# include <boost/scoped_ptr.hpp>
|
||||
# include <boost/format.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
#endif // !! ASSIMP_PCH_INCLUDED
|
||||
|
|
@ -40,12 +40,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
*/
|
||||
|
||||
/** @file Implementation of BaseImporter */
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
#include "BaseImporter.h"
|
||||
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/aiAssert.h"
|
||||
#include "../include/assimp.hpp"
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
||||
|
|
|
@ -143,8 +143,13 @@ public:
|
|||
/** Called prior to ReadFile().
|
||||
* The function is a request to the importer to update its configuration
|
||||
* basing on the Importer's configuration property list.
|
||||
* @param pImp Importer instance
|
||||
* @param ppFlags Post-processing steps to be executed on the data
|
||||
* returned by the loaders. This value is provided to allow some
|
||||
* internal optimizations.
|
||||
*/
|
||||
virtual void SetupProperties(const Importer* pImp);
|
||||
virtual void SetupProperties(const Importer* pImp /*,
|
||||
unsigned int ppFlags*/);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -40,13 +40,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
*/
|
||||
|
||||
/** @file Implementation of BaseProcess */
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
#include "BaseImporter.h"
|
||||
#include "BaseProcess.h"
|
||||
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/aiAssert.h"
|
||||
#include "../include/assimp.hpp"
|
||||
using namespace Assimp;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -42,12 +42,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef AI_BASEPROCESS_H_INC
|
||||
#define AI_BASEPROCESS_H_INC
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "../include/aiTypes.h"
|
||||
#include "GenericProperty.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
struct aiScene;
|
||||
|
||||
namespace Assimp {
|
||||
|
|
|
@ -73,6 +73,8 @@ public:
|
|||
//! \param szOut Buffer to be swapped
|
||||
static inline void Swap4(void* _szOut)
|
||||
{
|
||||
ai_assert(NULL != _szOut);
|
||||
|
||||
#if _MSC_VER >= 1400 && (defined _M_X86)
|
||||
__asm
|
||||
{
|
||||
|
@ -82,7 +84,6 @@ public:
|
|||
mov dword_ptr[edi], eax
|
||||
};
|
||||
#else
|
||||
ai_assert(NULL != _szOut);
|
||||
int8_t* szOut = (int8_t*)_szOut;
|
||||
std::swap(szOut[0],szOut[3]);
|
||||
std::swap(szOut[1],szOut[2]);
|
||||
|
|
|
@ -43,16 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
* tangents and bitangents for all imported meshes
|
||||
*/
|
||||
|
||||
// STL headers
|
||||
#include <vector>
|
||||
#include <assert.h>
|
||||
|
||||
// public ASSIMP headers
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/aiPostProcess.h"
|
||||
#include "../include/aiMesh.h"
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/assimp.hpp"
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
// internal headers
|
||||
#include "CalcTangentsProcess.h"
|
||||
|
|
|
@ -1,12 +1,50 @@
|
|||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (ASSIMP)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the following
|
||||
conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the ASSIMP team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the ASSIMP Development Team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file Implementation of the post processing step to convert all imported data
|
||||
* to a left-handed coordinate system.
|
||||
*/
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
#include "ConvertToLHProcess.h"
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/aiPostProcess.h"
|
||||
#include "../include/aiMesh.h"
|
||||
#include "../include/aiAnim.h"
|
||||
#include "../include/aiScene.h"
|
||||
|
||||
|
||||
using namespace Assimp;
|
||||
|
|
|
@ -40,21 +40,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
*/
|
||||
|
||||
/** @file Implementation of the DXF importer class */
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
|
||||
#include "DXFLoader.h"
|
||||
#include "ParsingUtils.h"
|
||||
#include "fast_atof.h"
|
||||
#include "MaterialSystem.h"
|
||||
|
||||
// public ASSIMP headers
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/aiAssert.h"
|
||||
#include "../include/IOStream.h"
|
||||
#include "../include/IOSystem.h"
|
||||
|
||||
#include "../include/DefaultLogger.h"
|
||||
|
||||
// boost headers
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
|
|
@ -40,6 +40,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
*/
|
||||
/** @file Default File I/O implementation for #Importer */
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
#include "DefaultIOStream.h"
|
||||
#include "../include/aiAssert.h"
|
||||
#include <sys/types.h>
|
||||
|
|
|
@ -39,9 +39,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
---------------------------------------------------------------------------
|
||||
*/
|
||||
/** @file Default implementation of IOSystem using the standard C file functions */
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "DefaultIOSystem.h"
|
||||
#include "DefaultIOStream.h"
|
||||
|
||||
|
|
|
@ -39,16 +39,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/aiAssert.h"
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
#include "DefaultIOSystem.h"
|
||||
#include "Win32DebugLogStream.h"
|
||||
#include "../include/IOStream.h"
|
||||
#include "FileLogStream.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
namespace Assimp
|
||||
{
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
|
@ -0,0 +1,277 @@
|
|||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (ASSIMP)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the following
|
||||
conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the ASSIMP team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the ASSIMP Development Team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file Defines a post processing step to search an importer's output
|
||||
for data that is obviously invalid */
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
#ifndef AI_BUILD_NO_FINDINVALIDDATA_PROCESS
|
||||
|
||||
// internal headers
|
||||
#include "FindInvalidDataProcess.h"
|
||||
#include "ProcessHelper.h"
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor to be privately used by Importer
|
||||
FindInvalidDataProcess::FindInvalidDataProcess()
|
||||
{
|
||||
// nothing to do here
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Destructor, private as well
|
||||
FindInvalidDataProcess::~FindInvalidDataProcess()
|
||||
{
|
||||
// nothing to do here
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Returns whether the processing step is present in the given flag field.
|
||||
bool FindInvalidDataProcess::IsActive( unsigned int pFlags) const
|
||||
{
|
||||
// this step is always active
|
||||
return true;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Update mesh references in the node graph
|
||||
void UpdateMeshReferences(aiNode* node, const std::vector<unsigned int>& meshMapping)
|
||||
{
|
||||
if (node->mNumMeshes)
|
||||
{
|
||||
unsigned int out = 0;
|
||||
for (unsigned int a = 0; a < node->mNumMeshes;++a)
|
||||
{
|
||||
register unsigned int ref = node->mMeshes[a];
|
||||
if (0xffffffff != (ref = meshMapping[ref]))
|
||||
{
|
||||
node->mMeshes[out++] = ref;
|
||||
}
|
||||
}
|
||||
// just let the members that are unused, that's much cheaper
|
||||
// than a full array realloc'n'copy party ...
|
||||
node->mNumMeshes = out;
|
||||
}
|
||||
// recursively update all children
|
||||
for (unsigned int i = 0; i < node->mNumChildren;++i)
|
||||
UpdateMeshReferences(node->mChildren[i],meshMapping);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Executes the post processing step on the given imported data.
|
||||
void FindInvalidDataProcess::Execute( aiScene* pScene)
|
||||
{
|
||||
DefaultLogger::get()->debug("FindInvalidDataProcess begin");
|
||||
|
||||
bool out = false;
|
||||
std::vector<unsigned int> meshMapping(pScene->mNumMeshes);
|
||||
unsigned int real = 0;
|
||||
|
||||
for( unsigned int a = 0; a < pScene->mNumMeshes; a++)
|
||||
{
|
||||
int result;
|
||||
if ((result = ProcessMesh( pScene->mMeshes[a])))
|
||||
{
|
||||
out = true;
|
||||
if (2 == result)
|
||||
{
|
||||
// remove this mesh
|
||||
delete pScene->mMeshes[a];
|
||||
AI_DEBUG_INVALIDATE_PTR(pScene->mMeshes[a]);
|
||||
|
||||
meshMapping[a] = 0xffffffff;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
pScene->mMeshes[real] = pScene->mMeshes[a];
|
||||
meshMapping[a] = real++;
|
||||
}
|
||||
|
||||
if (out)
|
||||
{
|
||||
if ( real != pScene->mNumMeshes)
|
||||
{
|
||||
if (!real)
|
||||
throw new ImportErrorException("No meshes remaining");
|
||||
|
||||
|
||||
// we need to remove some meshes.
|
||||
// therefore we'll also need to remove all references
|
||||
// to them from the scenegraph
|
||||
UpdateMeshReferences(pScene->mRootNode,meshMapping);
|
||||
pScene->mNumMeshes = real;
|
||||
}
|
||||
|
||||
DefaultLogger::get()->info("FindInvalidDataProcess finished. Found issues ...");
|
||||
}
|
||||
else DefaultLogger::get()->debug("FindInvalidDataProcess finished. Everything seems to be OK.");
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
inline const char* ValidateArrayContents(const T* arr, unsigned int size,
|
||||
const std::vector<bool>& dirtyMask)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <>
|
||||
inline const char* ValidateArrayContents<aiVector3D>(const aiVector3D* arr, unsigned int size,
|
||||
const std::vector<bool>& dirtyMask)
|
||||
{
|
||||
bool b = false;
|
||||
for (unsigned int i = 0; i < size;++i)
|
||||
{
|
||||
if (dirtyMask.size() && dirtyMask[i])continue;
|
||||
|
||||
const aiVector3D& v = arr[i];
|
||||
if (is_special_float(v.x) || is_special_float(v.y) || is_special_float(v.z))
|
||||
{
|
||||
return "INF/NAN was found in a vector component";
|
||||
}
|
||||
if (i && v != arr[i-1])b = true;
|
||||
}
|
||||
if (!b)return "All vectors are identical";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
inline bool ProcessArray(T*& in, unsigned int num,const char* name,
|
||||
const std::vector<bool>& dirtyMask)
|
||||
{
|
||||
const char* err = ValidateArrayContents(in,num,dirtyMask);
|
||||
if (err)
|
||||
{
|
||||
DefaultLogger::get()->error(std::string("FindInvalidDataProcess fails on mesh ") + name + ": " + err);
|
||||
|
||||
delete[] in;
|
||||
in = NULL;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Executes the post processing step on the given imported data.
|
||||
int FindInvalidDataProcess::ProcessMesh (aiMesh* pMesh)
|
||||
{
|
||||
bool ret = false;
|
||||
std::vector<bool> dirtyMask;
|
||||
|
||||
// process vertex positions
|
||||
if(pMesh->mVertices && ProcessArray(pMesh->mVertices,pMesh->mNumVertices,"positions",dirtyMask))
|
||||
{
|
||||
DefaultLogger::get()->error("Deleting mesh: Unable to continue without vertex positions");
|
||||
return 2;
|
||||
}
|
||||
|
||||
// process texture coordinates
|
||||
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS;++i)
|
||||
{
|
||||
if (!pMesh->mTextureCoords[i])break;
|
||||
if (ProcessArray(pMesh->mTextureCoords[i],pMesh->mNumVertices,"uvcoords",dirtyMask))
|
||||
{
|
||||
// delete all subsequent texture coordinate sets.
|
||||
for (unsigned int a = i+1; a < AI_MAX_NUMBER_OF_TEXTURECOORDS;++a)
|
||||
{
|
||||
delete[] pMesh->mTextureCoords[a]; pMesh->mTextureCoords[a] = NULL;
|
||||
}
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
|
||||
// -- we don't validate vertex colors, it's difficult to say whether
|
||||
// they are invalid or not.
|
||||
|
||||
// normals and tangents are undefined for point and line faces.
|
||||
// we generate a small lookup table in which we mark all
|
||||
// indices into the normals/tangents array that MAY be invalid
|
||||
if (pMesh->mNormals || pMesh->mTangents)
|
||||
{
|
||||
if (aiPrimitiveType_POINT & pMesh->mPrimitiveTypes ||
|
||||
aiPrimitiveType_LINE & pMesh->mPrimitiveTypes)
|
||||
{
|
||||
if (aiPrimitiveType_TRIANGLE & pMesh->mPrimitiveTypes ||
|
||||
aiPrimitiveType_POLYGON & pMesh->mPrimitiveTypes)
|
||||
{
|
||||
// we need the lookup table
|
||||
dirtyMask.resize(pMesh->mNumVertices,false);
|
||||
for (unsigned int m = 0; m < pMesh->mNumFaces;++m)
|
||||
{
|
||||
const aiFace& f = pMesh->mFaces[m];
|
||||
if (2 == f.mNumIndices)
|
||||
{
|
||||
dirtyMask[f.mIndices[0]] = dirtyMask[f.mIndices[1]] = true;
|
||||
}
|
||||
else if (1 == f.mNumIndices)dirtyMask[f.mIndices[0]] = true;
|
||||
}
|
||||
}
|
||||
else return ret;
|
||||
}
|
||||
|
||||
// process mesh normals
|
||||
if (pMesh->mNormals && ProcessArray(pMesh->mNormals,pMesh->mNumVertices,"normals",dirtyMask))
|
||||
ret = true;
|
||||
|
||||
// process mesh tangents
|
||||
if (pMesh->mTangents && ProcessArray(pMesh->mTangents,pMesh->mNumVertices,"tangents",dirtyMask))
|
||||
{
|
||||
delete[] pMesh->mBitangents; pMesh->mBitangents = NULL;
|
||||
ret = true;
|
||||
}
|
||||
|
||||
// process mesh bitangents
|
||||
if (pMesh->mBitangents && ProcessArray(pMesh->mBitangents,pMesh->mNumVertices,"bitangents",dirtyMask))
|
||||
{
|
||||
delete[] pMesh->mTangents; pMesh->mTangents = NULL;
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
return ret ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
#endif // !! AI_BUILD_NO_FINDINVALIDDATA_PROCESS
|
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
Open Asset Import Library (ASSIMP)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the ASSIMP team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the ASSIMP Development Team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file Defines a post processing step to search an importer's output
|
||||
for data that is obviously invalid */
|
||||
#ifndef AI_FINDINVALIDDATA_H_INC
|
||||
#define AI_FINDINVALIDDATA_H_INC
|
||||
|
||||
#include "BaseProcess.h"
|
||||
#include "../include/aiTypes.h"
|
||||
|
||||
struct aiMesh;
|
||||
class FindInvalidDataProcessTest;
|
||||
|
||||
namespace Assimp
|
||||
{
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** The FindInvalidData postprocessing step is always active, there is
|
||||
* no corresponding aiPostProcess flag. It searches the mesh data
|
||||
* for parts that are obviously invalid and removes them.
|
||||
*
|
||||
* Originally this was a workaround for some models written by Blender
|
||||
* which have zero normal vectors.
|
||||
*/
|
||||
class ASSIMP_API FindInvalidDataProcess : public BaseProcess
|
||||
{
|
||||
friend class Importer;
|
||||
friend class ::FindInvalidDataProcessTest;
|
||||
|
||||
protected:
|
||||
|
||||
/** Constructor to be privately used by Importer */
|
||||
FindInvalidDataProcess();
|
||||
|
||||
/** Destructor, private as well */
|
||||
~FindInvalidDataProcess();
|
||||
|
||||
public:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/**
|
||||
*/
|
||||
bool IsActive( unsigned int pFlags) const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/**
|
||||
*/
|
||||
void Execute( aiScene* pScene);
|
||||
|
||||
protected:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Executes the postprocessing step on the given mesh
|
||||
* @param pMesh The mesh to process.
|
||||
* @return 0 - nothing, 1 - removed sth, 2 - please delete me
|
||||
*/
|
||||
int ProcessMesh( aiMesh* pMesh);
|
||||
};
|
||||
|
||||
} // end of namespace Assimp
|
||||
|
||||
#endif // AI_AI_FINDINVALIDDATA_H_INC
|
|
@ -43,19 +43,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
* all normals in meshes with infacing normals.
|
||||
*/
|
||||
|
||||
// CRT includes
|
||||
#include <vector>
|
||||
#include <assert.h>
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
// internal headers
|
||||
#include "FixNormalsStep.h"
|
||||
#include "SpatialSort.h"
|
||||
|
||||
// public ASSIMP headers
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/aiPostProcess.h"
|
||||
#include "../include/aiMesh.h"
|
||||
#include "../include/aiScene.h"
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
|
|
@ -42,11 +42,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
/** @file Implementation of the post processing step to generate face
|
||||
* normals for all imported faces.
|
||||
*/
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
#include "GenFaceNormalsProcess.h"
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/aiPostProcess.h"
|
||||
#include "../include/aiMesh.h"
|
||||
#include "../include/aiScene.h"
|
||||
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
|
|
@ -43,11 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
* normals for all imported faces.
|
||||
*/
|
||||
|
||||
// public ASSIMP headers
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/aiPostProcess.h"
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/assimp.hpp"
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
// internal headers
|
||||
#include "GenVertexNormalsProcess.h"
|
||||
|
@ -75,6 +71,7 @@ bool GenVertexNormalsProcess::IsActive( unsigned int pFlags) const
|
|||
{
|
||||
return (pFlags & aiProcess_GenSmoothNormals) != 0;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Executes the post processing step on the given imported data.
|
||||
void GenVertexNormalsProcess::SetupProperties(const Importer* pImp)
|
||||
|
@ -84,6 +81,7 @@ void GenVertexNormalsProcess::SetupProperties(const Importer* pImp)
|
|||
this->configMaxAngle = std::max(std::min(this->configMaxAngle,175.0f),0.0f);
|
||||
this->configMaxAngle = AI_DEG_TO_RAD(this->configMaxAngle);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Executes the post processing step on the given imported data.
|
||||
void GenVertexNormalsProcess::Execute( aiScene* pScene)
|
||||
|
@ -93,7 +91,7 @@ void GenVertexNormalsProcess::Execute( aiScene* pScene)
|
|||
bool bHas = false;
|
||||
for( unsigned int a = 0; a < pScene->mNumMeshes; a++)
|
||||
{
|
||||
if(this->GenMeshVertexNormals( pScene->mMeshes[a],a))
|
||||
if(GenMeshVertexNormals( pScene->mMeshes[a],a))
|
||||
bHas = true;
|
||||
}
|
||||
|
||||
|
@ -120,7 +118,7 @@ bool GenVertexNormalsProcess::GenMeshVertexNormals (aiMesh* pMesh, unsigned int
|
|||
aiVector3D* pV1 = &pMesh->mVertices[face.mIndices[0]];
|
||||
aiVector3D* pV2 = &pMesh->mVertices[face.mIndices[1]];
|
||||
aiVector3D* pV3 = &pMesh->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)
|
||||
pMesh->mNormals[face.mIndices[i]] = vNor;
|
||||
|
|
|
@ -41,20 +41,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/** @file Implementation of the MDL importer class */
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
// internal headers
|
||||
#include "MaterialSystem.h"
|
||||
#include "HMPLoader.h"
|
||||
#include "MD2FileData.h"
|
||||
|
||||
// public ASSIMP headers
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/IOStream.h"
|
||||
#include "../include/IOSystem.h"
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/aiAssert.h"
|
||||
|
||||
// boost headers
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
|
|
@ -41,16 +41,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/** @file Implementation of the CPP-API class #Importer */
|
||||
|
||||
// STL/CSL heades
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
// public Assimp API
|
||||
#include "../include/assimp.hpp"
|
||||
#include "../include/aiAssert.h"
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/aiPostProcess.h"
|
||||
#include "../include/DefaultLogger.h"
|
||||
|
||||
// internal headers
|
||||
#include "BaseImporter.h"
|
||||
|
@ -61,115 +53,126 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "ProcessHelper.h"
|
||||
|
||||
// Importers
|
||||
#if (!defined AI_BUILD_NO_X_IMPORTER)
|
||||
#ifndef AI_BUILD_NO_X_IMPORTER
|
||||
# include "XFileImporter.h"
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_3DS_IMPORTER)
|
||||
#ifndef AI_BUILD_NO_3DS_IMPORTER
|
||||
# include "3DSLoader.h"
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_MD3_IMPORTER)
|
||||
#ifndef AI_BUILD_NO_MD3_IMPORTER
|
||||
# include "MD3Loader.h"
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_MDL_IMPORTER)
|
||||
#ifndef AI_BUILD_NO_MDL_IMPORTER
|
||||
# include "MDLLoader.h"
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_MD2_IMPORTER)
|
||||
#ifndef AI_BUILD_NO_MD2_IMPORTER
|
||||
# include "MD2Loader.h"
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_PLY_IMPORTER)
|
||||
#ifndef AI_BUILD_NO_PLY_IMPORTER
|
||||
# include "PlyLoader.h"
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_ASE_IMPORTER)
|
||||
#ifndef AI_BUILD_NO_ASE_IMPORTER
|
||||
# include "ASELoader.h"
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_OBJ_IMPORTER)
|
||||
#ifndef AI_BUILD_NO_OBJ_IMPORTER
|
||||
# include "ObjFileImporter.h"
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_HMP_IMPORTER)
|
||||
#ifndef AI_BUILD_NO_HMP_IMPORTER
|
||||
# include "HMPLoader.h"
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_SMD_IMPORTER)
|
||||
#ifndef AI_BUILD_NO_SMD_IMPORTER
|
||||
# include "SMDLoader.h"
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_MDR_IMPORTER)
|
||||
#ifndef AI_BUILD_NO_MDR_IMPORTER
|
||||
# include "MDRLoader.h"
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_MDC_IMPORTER)
|
||||
#ifndef AI_BUILD_NO_MDC_IMPORTER
|
||||
# include "MDCLoader.h"
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_MD5_IMPORTER)
|
||||
#ifndef AI_BUILD_NO_MD5_IMPORTER
|
||||
# include "MD5Loader.h"
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_STL_IMPORTER)
|
||||
#ifndef AI_BUILD_NO_STL_IMPORTER
|
||||
# include "STLLoader.h"
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_LWO_IMPORTER)
|
||||
#ifndef AI_BUILD_NO_LWO_IMPORTER
|
||||
# include "LWOLoader.h"
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_DXF_IMPORTER)
|
||||
#ifndef AI_BUILD_NO_DXF_IMPORTER
|
||||
# include "DXFLoader.h"
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_NFF_IMPORTER)
|
||||
#ifndef AI_BUILD_NO_NFF_IMPORTER
|
||||
# include "NFFLoader.h"
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_RAW_IMPORTER)
|
||||
#ifndef AI_BUILD_NO_RAW_IMPORTER
|
||||
# include "RAWLoader.h"
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_OFF_IMPORTER)
|
||||
#ifndef AI_BUILD_NO_OFF_IMPORTER
|
||||
# include "OffLoader.h"
|
||||
#endif
|
||||
#ifndef AI_BUILD_NO_AC_IMPORTER
|
||||
# include "ACLoader.h"
|
||||
#endif
|
||||
|
||||
|
||||
// PostProcess-Steps
|
||||
#if (!defined AI_BUILD_NO_CALCTANGENTS_PROCESS)
|
||||
#ifndef AI_BUILD_NO_CALCTANGENTS_PROCESS
|
||||
# include "CalcTangentsProcess.h"
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_JOINVERTICES_PROCESS)
|
||||
#ifndef AI_BUILD_NO_JOINVERTICES_PROCESS
|
||||
# include "JoinVerticesProcess.h"
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_CONVERTTOLH_PROCESS)
|
||||
#ifndef AI_BUILD_NO_CONVERTTOLH_PROCESS
|
||||
# include "ConvertToLHProcess.h"
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_TRIANGULATE_PROCESS)
|
||||
#ifndef AI_BUILD_NO_TRIANGULATE_PROCESS
|
||||
# include "TriangulateProcess.h"
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_GENFACENORMALS_PROCESS)
|
||||
#ifndef AI_BUILD_NO_GENFACENORMALS_PROCESS
|
||||
# include "GenFaceNormalsProcess.h"
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_GENVERTEXNORMALS_PROCESS)
|
||||
#ifndef AI_BUILD_NO_GENVERTEXNORMALS_PROCESS
|
||||
# include "GenVertexNormalsProcess.h"
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_KILLNORMALS_PROCESS)
|
||||
#ifndef AI_BUILD_NO_REMOVEVC_PROCESS
|
||||
# include "RemoveVCProcess.h"
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_SPLITLARGEMESHES_PROCESS)
|
||||
#ifndef AI_BUILD_NO_SPLITLARGEMESHES_PROCESS
|
||||
# include "SplitLargeMeshes.h"
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_PRETRANSFORMVERTICES_PROCESS)
|
||||
#ifndef AI_BUILD_NO_PRETRANSFORMVERTICES_PROCESS
|
||||
# include "PretransformVertices.h"
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_LIMITBONEWEIGHTS_PROCESS)
|
||||
#ifndef AI_BUILD_NO_LIMITBONEWEIGHTS_PROCESS
|
||||
# include "LimitBoneWeightsProcess.h"
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_VALIDATEDS_PROCESS)
|
||||
#ifndef AI_BUILD_NO_VALIDATEDS_PROCESS
|
||||
# include "ValidateDataStructure.h"
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_IMPROVECACHELOCALITY_PROCESS)
|
||||
#ifndef AI_BUILD_NO_IMPROVECACHELOCALITY_PROCESS
|
||||
# include "ImproveCacheLocality.h"
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_FIXINFACINGNORMALS_PROCESS)
|
||||
#ifndef AI_BUILD_NO_FIXINFACINGNORMALS_PROCESS
|
||||
# include "FixNormalsStep.h"
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_REMOVE_REDUNDANTMATERIALS_PROCESS)
|
||||
#ifndef AI_BUILD_NO_REMOVE_REDUNDANTMATERIALS_PROCESS
|
||||
# include "RemoveRedundantMaterials.h"
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_OPTIMIZEGRAPH_PROCESS)
|
||||
#ifndef AI_BUILD_NO_OPTIMIZEGRAPH_PROCESS
|
||||
# include "OptimizeGraphProcess.h"
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_SORTBYPTYPE_PROCESS)
|
||||
# include "SortByPTypeProcess.h"
|
||||
#ifndef AI_BUILD_NO_FINDINVALIDDATA_PROCESS
|
||||
# include "FindInvalidDataProcess.h"
|
||||
#endif
|
||||
|
||||
// NOTE: the preprocessor code has been moved to the header as
|
||||
// we've also declared the DeterminePType process in it, which
|
||||
// can't be removed.
|
||||
|
||||
//#ifndef AI_BUILD_NO_SORTBYPTYPE_PROCESS
|
||||
# include "SortByPTypeProcess.h"
|
||||
//#endif
|
||||
|
||||
|
||||
|
||||
using namespace Assimp;
|
||||
|
@ -221,11 +224,9 @@ Importer::Importer() :
|
|||
#if (!defined AI_BUILD_NO_SMD_IMPORTER)
|
||||
mImporter.push_back( new SMDImporter());
|
||||
#endif
|
||||
/*
|
||||
#if (!defined AI_BUILD_NO_MDR_IMPORTER)
|
||||
mImporter.push_back( new MDRImporter());
|
||||
#endif
|
||||
*/
|
||||
#if (!defined AI_BUILD_NO_MDC_IMPORTER)
|
||||
mImporter.push_back( new MDCImporter());
|
||||
#endif
|
||||
|
@ -250,6 +251,9 @@ Importer::Importer() :
|
|||
#if (!defined AI_BUILD_NO_OFF_IMPORTER)
|
||||
mImporter.push_back( new OFFImporter());
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_AC_IMPORTER)
|
||||
mImporter.push_back( new AC3DImporter());
|
||||
#endif
|
||||
|
||||
// add an instance of each post processing step here in the order
|
||||
// of sequence it is executed. steps that are added here are not validated -
|
||||
|
@ -262,18 +266,28 @@ Importer::Importer() :
|
|||
|
||||
mPostProcessingSteps.push_back( new DeterminePTypeHelperProcess());
|
||||
|
||||
#if (!defined AI_BUILD_NO_REMOVE_REDUNDANTMATERIALS_PROCESS)
|
||||
mPostProcessingSteps.push_back( new RemoveRedundantMatsProcess());
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_OPTIMIZEGRAPH_PROCESS)
|
||||
mPostProcessingSteps.push_back( new OptimizeGraphProcess());
|
||||
#if (!defined AI_BUILD_NO_REMOVEVC_PROCESS)
|
||||
mPostProcessingSteps.push_back( new RemoveVCProcess());
|
||||
#endif
|
||||
|
||||
#if (!defined AI_BUILD_NO_TRIANGULATE_PROCESS)
|
||||
mPostProcessingSteps.push_back( new TriangulateProcess());
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_SORTBYPTYPE_PROCESS)
|
||||
mPostProcessingSteps.push_back( new SortByPTypeProcess());
|
||||
#endif
|
||||
|
||||
#if (!defined AI_BUILD_NO_FINDINVALIDDATA_PROCESS)
|
||||
mPostProcessingSteps.push_back( new FindInvalidDataProcess());
|
||||
#endif
|
||||
|
||||
|
||||
#if (!defined AI_BUILD_NO_REMOVE_REDUNDANTMATERIALS_PROCESS)
|
||||
mPostProcessingSteps.push_back( new RemoveRedundantMatsProcess());
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_OPTIMIZEGRAPH_PROCESS)
|
||||
mPostProcessingSteps.push_back( new OptimizeGraphProcess());
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_PRETRANSFORMVERTICES_PROCESS)
|
||||
mPostProcessingSteps.push_back( new PretransformVertices());
|
||||
#endif
|
||||
|
@ -283,9 +297,6 @@ Importer::Importer() :
|
|||
#if (!defined AI_BUILD_NO_SPLITLARGEMESHES_PROCESS)
|
||||
mPostProcessingSteps.push_back( new SplitLargeMeshesProcess_Triangle());
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_REMOVEVC_PROCESS)
|
||||
mPostProcessingSteps.push_back( new RemoveVCProcess());
|
||||
#endif
|
||||
#if (!defined AI_BUILD_NO_GENFACENORMALS_PROCESS)
|
||||
mPostProcessingSteps.push_back( new GenFaceNormalsProcess());
|
||||
#endif
|
||||
|
|
|
@ -46,16 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
* http://www.cs.princeton.edu/gfx/pubs/Sander_2007_%3ETR/tipsy.pdf
|
||||
*/
|
||||
|
||||
// STL headers
|
||||
#include <vector>
|
||||
#include <stack>
|
||||
#include <queue>
|
||||
|
||||
// public ASSIMP headers
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/aiPostProcess.h"
|
||||
#include "../include/aiMesh.h"
|
||||
#include "../include/aiScene.h"
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
// internal headers
|
||||
#include "ImproveCacheLocality.h"
|
||||
|
|
|
@ -43,12 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
* for all imported meshes
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/aiPostProcess.h"
|
||||
#include "../include/aiMesh.h"
|
||||
#include "../include/aiScene.h"
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
// internal headers
|
||||
#include "JoinVerticesProcess.h"
|
||||
|
|
|
@ -42,17 +42,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
/** @file Implementation of the LWO importer class for the older LWOB
|
||||
file formats, including materials */
|
||||
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
// internal headers
|
||||
#include "LWOLoader.h"
|
||||
#include "MaterialSystem.h"
|
||||
#include "ByteSwap.h"
|
||||
|
||||
// public assimp headers
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/aiAssert.h"
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/assimp.hpp"
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
||||
|
|
|
@ -41,13 +41,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/** @file Implementation of the LWO importer class */
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
// public assimp headers
|
||||
#include "../include/IOStream.h"
|
||||
#include "../include/IOSystem.h"
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/aiAssert.h"
|
||||
#include "../include/assimp.hpp"
|
||||
|
||||
// internal headers
|
||||
#include "LWOLoader.h"
|
||||
|
@ -57,11 +52,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "ByteSwap.h"
|
||||
#include "ProcessHelper.h"
|
||||
|
||||
// boost headers
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -100,7 +90,7 @@ bool LWOImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler) const
|
|||
// Setup configuration properties
|
||||
void LWOImporter::SetupProperties(const Importer* pImp)
|
||||
{
|
||||
// -- no configuration options at the moment
|
||||
configSpeedFlag = ( 0 != pImp->GetPropertyInteger(AI_CONFIG_FAVOUR_SPEED,0) ? true : false);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -437,7 +427,7 @@ void LWOImporter::ComputeNormals(aiMesh* mesh, const std::vector<unsigned int>&
|
|||
|
||||
// generate vertex normals. We have O(logn) for the binary lookup, which we need
|
||||
// for n elements, thus the EXPECTED complexity is O(nlogn)
|
||||
if (surface.mMaximumSmoothAngle < 3.f)
|
||||
if (surface.mMaximumSmoothAngle < 3.f && !configSpeedFlag)
|
||||
{
|
||||
const float fLimit = cos(surface.mMaximumSmoothAngle);
|
||||
|
||||
|
|
|
@ -382,6 +382,8 @@ protected:
|
|||
|
||||
/** Output scene */
|
||||
aiScene* pScene;
|
||||
|
||||
bool configSpeedFlag;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -41,21 +41,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/** @file Implementation of the material oart of the LWO importer class */
|
||||
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
// internal headers
|
||||
#include "LWOLoader.h"
|
||||
#include "MaterialSystem.h"
|
||||
#include "ByteSwap.h"
|
||||
|
||||
// public assimp headers
|
||||
#include "../include/IOStream.h"
|
||||
#include "../include/IOSystem.h"
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/aiAssert.h"
|
||||
#include "../include/DefaultLogger.h"
|
||||
|
||||
// boost headers
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
#include "AssimpPCH.h"
|
|
@ -40,17 +40,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/** Implementation of the LimitBoneWeightsProcess post processing step */
|
||||
|
||||
#include <vector>
|
||||
#include <assert.h>
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
#include "LimitBoneWeightsProcess.h"
|
||||
|
||||
#include "../include/aiPostProcess.h"
|
||||
#include "../include/aiMesh.h"
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/aiAssert.h"
|
||||
#include "../include/assimp.hpp"
|
||||
#include "../include/DefaultLogger.h"
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
|
|
@ -39,22 +39,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
/** @file Implementation of the MD2 importer class */
|
||||
#include "MD2Loader.h"
|
||||
#include "MaterialSystem.h"
|
||||
#include "ByteSwap.h"
|
||||
#include "MD2NormalTable.h" // shouldn't be included by other units
|
||||
|
||||
// public ASSIMP headers
|
||||
#include "../include/assimp.hpp"
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/aiAssert.h"
|
||||
#include "../include/IOStream.h"
|
||||
#include "../include/IOSystem.h"
|
||||
#include "../include/DefaultLogger.h"
|
||||
|
||||
// boost headers
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
using namespace Assimp;
|
||||
using namespace Assimp::MD2;
|
||||
|
@ -118,10 +110,10 @@ void MD2Importer::SetupProperties(const Importer* pImp)
|
|||
{
|
||||
// The AI_CONFIG_IMPORT_MD2_KEYFRAME option overrides the
|
||||
// AI_CONFIG_IMPORT_GLOBAL_KEYFRAME option.
|
||||
if(0xffffffff == (this->configFrameID = pImp->GetPropertyInteger(
|
||||
if(0xffffffff == (configFrameID = pImp->GetPropertyInteger(
|
||||
AI_CONFIG_IMPORT_MD2_KEYFRAME,0xffffffff)))
|
||||
{
|
||||
this->configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_GLOBAL_KEYFRAME,0);
|
||||
configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_GLOBAL_KEYFRAME,0);
|
||||
}
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -129,14 +121,14 @@ void MD2Importer::SetupProperties(const Importer* pImp)
|
|||
void MD2Importer::ValidateHeader( )
|
||||
{
|
||||
// check magic number
|
||||
if (this->m_pcHeader->magic != AI_MD2_MAGIC_NUMBER_BE &&
|
||||
this->m_pcHeader->magic != AI_MD2_MAGIC_NUMBER_LE)
|
||||
if (m_pcHeader->magic != AI_MD2_MAGIC_NUMBER_BE &&
|
||||
m_pcHeader->magic != AI_MD2_MAGIC_NUMBER_LE)
|
||||
{
|
||||
char szBuffer[5];
|
||||
szBuffer[0] = ((char*)&this->m_pcHeader->magic)[0];
|
||||
szBuffer[1] = ((char*)&this->m_pcHeader->magic)[1];
|
||||
szBuffer[2] = ((char*)&this->m_pcHeader->magic)[2];
|
||||
szBuffer[3] = ((char*)&this->m_pcHeader->magic)[3];
|
||||
szBuffer[0] = ((char*)&m_pcHeader->magic)[0];
|
||||
szBuffer[1] = ((char*)&m_pcHeader->magic)[1];
|
||||
szBuffer[2] = ((char*)&m_pcHeader->magic)[2];
|
||||
szBuffer[3] = ((char*)&m_pcHeader->magic)[3];
|
||||
szBuffer[4] = '\0';
|
||||
|
||||
throw new ImportErrorException("Invalid MD2 magic word: should be IDP2, the "
|
||||
|
@ -144,33 +136,33 @@ void MD2Importer::ValidateHeader( )
|
|||
}
|
||||
|
||||
// check file format version
|
||||
if (this->m_pcHeader->version != 8)
|
||||
if (m_pcHeader->version != 8)
|
||||
DefaultLogger::get()->warn( "Unsupported md2 file version. Continuing happily ...");
|
||||
|
||||
// check some values whether they are valid
|
||||
if (0 == this->m_pcHeader->numFrames)
|
||||
if (0 == m_pcHeader->numFrames)
|
||||
throw new ImportErrorException( "Invalid md2 file: NUM_FRAMES is 0");
|
||||
|
||||
if (this->m_pcHeader->offsetEnd > (uint32_t)fileSize)
|
||||
if (m_pcHeader->offsetEnd > (uint32_t)fileSize)
|
||||
throw new ImportErrorException( "Invalid md2 file: File is too small");
|
||||
|
||||
if (this->m_pcHeader->offsetSkins + this->m_pcHeader->numSkins * sizeof (MD2::Skin) >= this->fileSize ||
|
||||
this->m_pcHeader->offsetTexCoords + this->m_pcHeader->numTexCoords * sizeof (MD2::TexCoord) >= this->fileSize ||
|
||||
this->m_pcHeader->offsetTriangles + this->m_pcHeader->numTriangles * sizeof (MD2::Triangle) >= this->fileSize ||
|
||||
this->m_pcHeader->offsetFrames + this->m_pcHeader->numFrames * sizeof (MD2::Frame) >= this->fileSize ||
|
||||
this->m_pcHeader->offsetEnd > this->fileSize)
|
||||
if (m_pcHeader->offsetSkins + m_pcHeader->numSkins * sizeof (MD2::Skin) >= fileSize ||
|
||||
m_pcHeader->offsetTexCoords + m_pcHeader->numTexCoords * sizeof (MD2::TexCoord) >= fileSize ||
|
||||
m_pcHeader->offsetTriangles + m_pcHeader->numTriangles * sizeof (MD2::Triangle) >= fileSize ||
|
||||
m_pcHeader->offsetFrames + m_pcHeader->numFrames * sizeof (MD2::Frame) >= fileSize ||
|
||||
m_pcHeader->offsetEnd > fileSize)
|
||||
{
|
||||
throw new ImportErrorException("Invalid MD2 header: some offsets are outside the file");
|
||||
}
|
||||
|
||||
if (this->m_pcHeader->numSkins > AI_MD2_MAX_SKINS)
|
||||
if (m_pcHeader->numSkins > AI_MD2_MAX_SKINS)
|
||||
DefaultLogger::get()->warn("The model contains more skins than Quake 2 supports");
|
||||
if ( this->m_pcHeader->numFrames > AI_MD2_MAX_FRAMES)
|
||||
if ( m_pcHeader->numFrames > AI_MD2_MAX_FRAMES)
|
||||
DefaultLogger::get()->warn("The model contains more frames than Quake 2 supports");
|
||||
if (this->m_pcHeader->numVertices > AI_MD2_MAX_VERTS)
|
||||
if (m_pcHeader->numVertices > AI_MD2_MAX_VERTS)
|
||||
DefaultLogger::get()->warn("The model contains more vertices than Quake 2 supports");
|
||||
|
||||
if (this->m_pcHeader->numFrames <= this->configFrameID )
|
||||
if (m_pcHeader->numFrames <= configFrameID )
|
||||
throw new ImportErrorException("The requested frame is not existing the file");
|
||||
|
||||
}
|
||||
|
@ -193,10 +185,10 @@ void MD2Importer::InternReadFile( const std::string& pFile,
|
|||
|
||||
std::vector<unsigned char> mBuffer2(fileSize);
|
||||
file->Read(&mBuffer2[0], 1, fileSize);
|
||||
this->mBuffer = &mBuffer2[0];
|
||||
mBuffer = &mBuffer2[0];
|
||||
|
||||
|
||||
this->m_pcHeader = (const MD2::Header*)this->mBuffer;
|
||||
m_pcHeader = (const MD2::Header*)mBuffer;
|
||||
|
||||
#ifdef AI_BUILD_BIG_ENDIAN
|
||||
|
||||
|
@ -220,7 +212,7 @@ void MD2Importer::InternReadFile( const std::string& pFile,
|
|||
|
||||
#endif
|
||||
|
||||
this->ValidateHeader();
|
||||
ValidateHeader();
|
||||
|
||||
// there won't be more than one mesh inside the file
|
||||
pScene->mNumMaterials = 1;
|
||||
|
@ -238,17 +230,17 @@ void MD2Importer::InternReadFile( const std::string& pFile,
|
|||
|
||||
// navigate to the begin of the frame data
|
||||
const MD2::Frame* pcFrame = (const MD2::Frame*) ((uint8_t*)
|
||||
this->m_pcHeader + this->m_pcHeader->offsetFrames);
|
||||
m_pcHeader + m_pcHeader->offsetFrames);
|
||||
|
||||
pcFrame += this->configFrameID;
|
||||
pcFrame += configFrameID;
|
||||
|
||||
// navigate to the begin of the triangle data
|
||||
MD2::Triangle* pcTriangles = (MD2::Triangle*) ((uint8_t*)
|
||||
this->m_pcHeader + this->m_pcHeader->offsetTriangles);
|
||||
m_pcHeader + m_pcHeader->offsetTriangles);
|
||||
|
||||
// navigate to the begin of the tex coords data
|
||||
const MD2::TexCoord* pcTexCoords = (const MD2::TexCoord*) ((uint8_t*)
|
||||
this->m_pcHeader + this->m_pcHeader->offsetTexCoords);
|
||||
m_pcHeader + m_pcHeader->offsetTexCoords);
|
||||
|
||||
// navigate to the begin of the vertex data
|
||||
const MD2::Vertex* pcVerts = (const MD2::Vertex*) (pcFrame->vertices);
|
||||
|
@ -275,8 +267,8 @@ void MD2Importer::InternReadFile( const std::string& pFile,
|
|||
ByteSwap::Swap4( & pcFrame->translate[2] );
|
||||
#endif
|
||||
|
||||
pcMesh->mNumFaces = this->m_pcHeader->numTriangles;
|
||||
pcMesh->mFaces = new aiFace[this->m_pcHeader->numTriangles];
|
||||
pcMesh->mNumFaces = m_pcHeader->numTriangles;
|
||||
pcMesh->mFaces = new aiFace[m_pcHeader->numTriangles];
|
||||
|
||||
// allocate output storage
|
||||
pcMesh->mNumVertices = (unsigned int)pcMesh->mNumFaces*3;
|
||||
|
@ -286,11 +278,11 @@ void MD2Importer::InternReadFile( const std::string& pFile,
|
|||
// not sure whether there are MD2 files without texture coordinates
|
||||
// NOTE: texture coordinates can be there without a texture,
|
||||
// but a texture can't be there without a valid UV channel
|
||||
if (this->m_pcHeader->numTexCoords && this->m_pcHeader->numSkins)
|
||||
if (m_pcHeader->numTexCoords && m_pcHeader->numSkins)
|
||||
{
|
||||
// navigate to the first texture associated with the mesh
|
||||
const MD2::Skin* pcSkins = (const MD2::Skin*) ((unsigned char*)this->m_pcHeader +
|
||||
this->m_pcHeader->offsetSkins);
|
||||
const MD2::Skin* pcSkins = (const MD2::Skin*) ((unsigned char*)m_pcHeader +
|
||||
m_pcHeader->offsetSkins);
|
||||
|
||||
const int iMode = (int)aiShadingMode_Gouraud;
|
||||
MaterialHelper* pcHelper = (MaterialHelper*)pScene->mMaterials[0];
|
||||
|
@ -344,7 +336,7 @@ void MD2Importer::InternReadFile( const std::string& pFile,
|
|||
unsigned int iCurrent = 0;
|
||||
|
||||
float fDivisorU,fDivisorV;
|
||||
if (this->m_pcHeader->numTexCoords)
|
||||
if (m_pcHeader->numTexCoords)
|
||||
{
|
||||
// allocate storage for texture coordinates, too
|
||||
pcMesh->mTextureCoords[0] = new aiVector3D[pcMesh->mNumVertices];
|
||||
|
@ -352,23 +344,23 @@ void MD2Importer::InternReadFile( const std::string& pFile,
|
|||
|
||||
// check whether the skin width or height are zero (this would
|
||||
// cause a division through zero)
|
||||
if (!this->m_pcHeader->skinWidth)
|
||||
if (!m_pcHeader->skinWidth)
|
||||
{
|
||||
DefaultLogger::get()->error("Skin width is zero but there are "
|
||||
"valid absolute texture coordinates");
|
||||
fDivisorU = 1.0f;
|
||||
}
|
||||
else fDivisorU = (float)this->m_pcHeader->skinWidth;
|
||||
if (!this->m_pcHeader->skinHeight)
|
||||
else fDivisorU = (float)m_pcHeader->skinWidth;
|
||||
if (!m_pcHeader->skinHeight)
|
||||
{
|
||||
DefaultLogger::get()->error("Skin height is zero but there are "
|
||||
"valid absolute texture coordinates ");
|
||||
fDivisorV = 1.0f;
|
||||
}
|
||||
else fDivisorV = (float)this->m_pcHeader->skinHeight;
|
||||
else fDivisorV = (float)m_pcHeader->skinHeight;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < (unsigned int)this->m_pcHeader->numTriangles;++i)
|
||||
for (unsigned int i = 0; i < (unsigned int)m_pcHeader->numTriangles;++i)
|
||||
{
|
||||
// allocate the face
|
||||
pScene->mMeshes[0]->mFaces[i].mIndices = new unsigned int[3];
|
||||
|
@ -381,23 +373,20 @@ void MD2Importer::InternReadFile( const std::string& pFile,
|
|||
for (unsigned int c = 0; c < 3;++c,++iCurrent)
|
||||
{
|
||||
// validate vertex indices
|
||||
if (pcTriangles[i].vertexIndices[c] >= this->m_pcHeader->numVertices)
|
||||
register unsigned int iIndex = (unsigned int)pcTriangles[i].vertexIndices[c];
|
||||
if (iIndex >= m_pcHeader->numVertices)
|
||||
{
|
||||
DefaultLogger::get()->error("Vertex index is outside the allowed range");
|
||||
pcTriangles[i].vertexIndices[c] = this->m_pcHeader->numVertices-1;
|
||||
DefaultLogger::get()->error("MD2: Vertex index is outside the allowed range");
|
||||
iIndex = m_pcHeader->numVertices-1;
|
||||
}
|
||||
|
||||
// copy face indices
|
||||
unsigned int iIndex = (unsigned int)pcTriangles[i].vertexIndices[c];
|
||||
|
||||
// read x,y, and z component of the vertex
|
||||
aiVector3D& vec = pcMesh->mVertices[iCurrent];
|
||||
|
||||
vec.x = (float)pcVerts[iIndex].vertex[0] * pcFrame->scale[0];
|
||||
vec.x += pcFrame->translate[0];
|
||||
|
||||
// (flip z and y component)
|
||||
// FIX: no .... invert y instead
|
||||
// invert y
|
||||
vec.y = (float)pcVerts[iIndex].vertex[1] * pcFrame->scale[1];
|
||||
vec.y += pcFrame->translate[1];
|
||||
vec.y *= -1.0f;
|
||||
|
@ -410,13 +399,14 @@ void MD2Importer::InternReadFile( const std::string& pFile,
|
|||
LookupNormalIndex(pcVerts[iIndex].lightNormalIndex,vNormal);
|
||||
vNormal.y *= -1.0f;
|
||||
|
||||
if (this->m_pcHeader->numTexCoords)
|
||||
if (m_pcHeader->numTexCoords)
|
||||
{
|
||||
// validate texture coordinates
|
||||
if (pcTriangles[iIndex].textureIndices[c] >= this->m_pcHeader->numTexCoords)
|
||||
iIndex = pcTriangles[iIndex].textureIndices[c];
|
||||
if (iIndex >= m_pcHeader->numTexCoords)
|
||||
{
|
||||
DefaultLogger::get()->error("UV index is outside the allowed range");
|
||||
pcTriangles[iIndex].textureIndices[c] = this->m_pcHeader->numTexCoords-1;
|
||||
DefaultLogger::get()->error("MD2: UV index is outside the allowed range");
|
||||
iIndex = m_pcHeader->numTexCoords-1;
|
||||
}
|
||||
|
||||
aiVector3D& pcOut = pcMesh->mTextureCoords[0][iCurrent];
|
||||
|
@ -424,8 +414,8 @@ void MD2Importer::InternReadFile( const std::string& pFile,
|
|||
|
||||
// the texture coordinates are absolute values but we
|
||||
// need relative values between 0 and 1
|
||||
u = (float)pcTexCoords[pcTriangles[i].textureIndices[c]].s / fDivisorU;
|
||||
v = (float)pcTexCoords[pcTriangles[i].textureIndices[c]].t / fDivisorV;
|
||||
u = pcTexCoords[iIndex].s / fDivisorU;
|
||||
v = pcTexCoords[iIndex].t / fDivisorV;
|
||||
pcOut.x = u;
|
||||
pcOut.y = 1.0f - v; // FIXME: Is this correct for MD2?
|
||||
}
|
||||
|
|
|
@ -40,21 +40,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
*/
|
||||
|
||||
/** @file Implementation of the MD3 importer class */
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
|
||||
#include "MD3Loader.h"
|
||||
#include "MaterialSystem.h"
|
||||
#include "StringComparison.h"
|
||||
#include "ByteSwap.h"
|
||||
|
||||
#include "../include/IOStream.h"
|
||||
#include "../include/IOSystem.h"
|
||||
#include "../include/aiMesh.h"
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/aiAssert.h"
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/assimp.hpp"
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
||||
|
|
|
@ -41,6 +41,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/** @file Implementation of the MD5 importer class */
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
// internal headers
|
||||
#include "MaterialSystem.h"
|
||||
#include "RemoveComments.h"
|
||||
|
@ -48,17 +50,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "StringComparison.h"
|
||||
#include "fast_atof.h"
|
||||
|
||||
// public headers
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/IOStream.h"
|
||||
#include "../include/IOSystem.h"
|
||||
#include "../include/aiMesh.h"
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/aiAssert.h"
|
||||
|
||||
// boost headers
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -84,7 +84,7 @@ protected:
|
|||
*/
|
||||
void GetExtensionList(std::string& append)
|
||||
{
|
||||
append.append("*.md5");
|
||||
append.append("*.md5mesh;*.md5anim");
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
|
|
@ -41,6 +41,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/** @file Implementation of the MD5 parser class */
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
// internal headers
|
||||
#include "MD5Loader.h"
|
||||
#include "MaterialSystem.h"
|
||||
|
@ -48,13 +50,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "ParsingUtils.h"
|
||||
#include "StringComparison.h"
|
||||
|
||||
// public ASSIMP headers
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/IOStream.h"
|
||||
#include "../include/IOSystem.h"
|
||||
#include "../include/aiMesh.h"
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/aiAssert.h"
|
||||
|
||||
using namespace Assimp;
|
||||
using namespace Assimp::MD5;
|
||||
|
|
|
@ -41,24 +41,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/** @file Implementation of the MDC importer class */
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
// internal headers
|
||||
#include "MDCLoader.h"
|
||||
#include "MD3FileData.h"
|
||||
#include "MaterialSystem.h"
|
||||
#include "StringComparison.h"
|
||||
#include "MDCNormalTable.h" // shouldn't be included by other units
|
||||
#include "ByteSwap.h"
|
||||
|
||||
// public ASSIMP headers
|
||||
#include "../include/IOStream.h"
|
||||
#include "../include/IOSystem.h"
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/aiAssert.h"
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/assimp.hpp"
|
||||
|
||||
// boost headers
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
using namespace Assimp;
|
||||
using namespace Assimp::MDC;
|
||||
|
|
|
@ -42,23 +42,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
/** @file Implementation of the main parts of the MDL importer class */
|
||||
|
||||
// internal headers
|
||||
#include "MaterialSystem.h"
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
#include "MDLLoader.h"
|
||||
#include "MDLDefaultColorMap.h"
|
||||
#include "MD2FileData.h"
|
||||
#include "qnan.h"
|
||||
#include "ByteSwap.h"
|
||||
|
||||
// public ASSIMP headers
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/aiAssert.h"
|
||||
#include "../include/IOStream.h"
|
||||
#include "../include/IOSystem.h"
|
||||
#include "../include/assimp.hpp"
|
||||
|
||||
// boost headers
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
@ -1712,7 +1701,7 @@ void MDLImporter::AddBonesToNodeGraph_3DGS_MDL7(const MDL::IntBone_MDL7** apcBon
|
|||
aiNode* pcNode = pcParent->mChildren[qq++] = new aiNode();
|
||||
pcNode->mName = aiString( pcBone->mName );
|
||||
|
||||
this->AddBonesToNodeGraph_3DGS_MDL7(apcBones,pcNode,i);
|
||||
this->AddBonesToNodeGraph_3DGS_MDL7(apcBones,pcNode,(uint16_t)i);
|
||||
}
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -41,19 +41,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/** @file Implementation of the material part of the MDL importer class */
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
// internal headers
|
||||
#include "MaterialSystem.h"
|
||||
#include "MDLLoader.h"
|
||||
#include "MDLDefaultColorMap.h"
|
||||
#include "qnan.h"
|
||||
|
||||
// public ASSIMP headers
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/IOStream.h"
|
||||
#include "../include/IOSystem.h"
|
||||
#include "../include/aiMesh.h"
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/aiAssert.h"
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
|
|
@ -41,22 +41,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/** @file Implementation of the MDR importer class */
|
||||
|
||||
// internal headers
|
||||
#include "AssimpPCH.h"
|
||||
#include "MDRLoader.h"
|
||||
#include "MaterialSystem.h"
|
||||
#include "StringComparison.h"
|
||||
#include "ByteSwap.h"
|
||||
|
||||
// public ASSIMP headers
|
||||
#include "../include/IOStream.h"
|
||||
#include "../include/IOSystem.h"
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/aiAssert.h"
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/assimp.hpp"
|
||||
|
||||
// boost headers
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
using namespace Assimp;
|
||||
using namespace Assimp::MDR;
|
||||
|
|
|
@ -38,13 +38,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "MaterialSystem.h"
|
||||
#include "StringComparison.h"
|
||||
#include "AssimpPCH.h"
|
||||
#include "Hash.h"
|
||||
|
||||
#include "../include/aiMaterial.h"
|
||||
#include "../include/aiAssert.h"
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
// we are using sprintf only on fixed-size buffers, so the
|
||||
|
|
|
@ -41,23 +41,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/** @file Implementation of the STL importer class */
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
// internal headers
|
||||
#include "NFFLoader.h"
|
||||
#include "MaterialSystem.h"
|
||||
#include "ParsingUtils.h"
|
||||
#include "StandardShapes.h"
|
||||
#include "fast_atof.h"
|
||||
#include "qnan.h"
|
||||
|
||||
// public assimp headers
|
||||
#include "../include/IOStream.h"
|
||||
#include "../include/IOSystem.h"
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/aiAssert.h"
|
||||
#include "../include/DefaultLogger.h"
|
||||
|
||||
// boost headers
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
|
|
@ -41,21 +41,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/** @file Implementation of the OFF importer class */
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
// internal headers
|
||||
#include "OFFLoader.h"
|
||||
#include "MaterialSystem.h"
|
||||
#include "ParsingUtils.h"
|
||||
#include "fast_atof.h"
|
||||
|
||||
// public assimp headers
|
||||
#include "../include/IOStream.h"
|
||||
#include "../include/IOSystem.h"
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/aiAssert.h"
|
||||
#include "../include/DefaultLogger.h"
|
||||
|
||||
// boost headers
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
@ -81,8 +73,6 @@ bool OFFImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler) const
|
|||
if( pos == std::string::npos)return false;
|
||||
std::string extension = pFile.substr( pos);
|
||||
|
||||
if (extension.length() < 4)return false;
|
||||
if (extension[0] != '.')return false;
|
||||
|
||||
return !(extension.length() != 4 || extension[0] != '.' ||
|
||||
extension[1] != 'o' && extension[1] != 'R' ||
|
||||
|
|
|
@ -38,19 +38,12 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
#include "ObjFileImporter.h"
|
||||
#include "ObjFileParser.h"
|
||||
#include "ObjFileData.h"
|
||||
#include "MaterialSystem.h"
|
||||
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/aiAssert.h"
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/IOStream.h"
|
||||
#include "../include/IOSystem.h"
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <boost/format.hpp>
|
||||
|
||||
namespace Assimp
|
||||
{
|
||||
|
|
|
@ -38,9 +38,10 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
#include "ObjFileMtlImporter.h"
|
||||
#include "../include/aiTypes.h"
|
||||
#include "../include/aiAssert.h"
|
||||
#include "ObjTools.h"
|
||||
#include "ObjFileData.h"
|
||||
#include "fast_atof.h"
|
||||
|
|
|
@ -1,16 +1,53 @@
|
|||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (ASSIMP)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the following
|
||||
conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the ASSIMP team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the ASSIMP Development Team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
#include "ObjFileParser.h"
|
||||
#include "ObjFileMtlImporter.h"
|
||||
#include "ObjTools.h"
|
||||
#include "ObjFileData.h"
|
||||
#include "DefaultIOSystem.h"
|
||||
#include "../include/IOStream.h"
|
||||
#include "../include/aiTypes.h"
|
||||
#include "../include/aiAssert.h"
|
||||
#include "fast_atof.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
#include "DefaultIOSystem.h"
|
||||
|
||||
namespace Assimp
|
||||
{
|
||||
|
|
|
@ -40,17 +40,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/** Implementation of the OptimizeGraphProcess post-processing step*/
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
#include "OptimizeGraphProcess.h"
|
||||
#include "Hash.h"
|
||||
|
||||
#include "../include/aiPostProcess.h"
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/aiAssert.h"
|
||||
#include "../include/assimp.hpp"
|
||||
#include "../include/DefaultLogger.h"
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
@ -72,7 +66,6 @@ using namespace Assimp;
|
|||
// Constructor to be privately used by Importer
|
||||
OptimizeGraphProcess::OptimizeGraphProcess()
|
||||
{
|
||||
configRemoveAnimations = AI_OG_REMOVE_ANIMATIONS;
|
||||
configMinNumFaces = AI_OG_MIN_NUM_FACES;
|
||||
configJoinInequalTransforms = AI_OG_JOIN_INEQUAL_TRANSFORMS;
|
||||
}
|
||||
|
@ -95,12 +88,8 @@ bool OptimizeGraphProcess::IsActive( unsigned int pFlags) const
|
|||
// Setup properties of the step
|
||||
void OptimizeGraphProcess::SetupProperties(const Importer* pImp)
|
||||
{
|
||||
// remove animation nodes?
|
||||
configRemoveAnimations = pImp->GetPropertyInteger(AI_CONFIG_PP_OG_REMOVE_ANIMATIONS,
|
||||
AI_OG_REMOVE_ANIMATIONS) != 0 ? true : false;
|
||||
|
||||
// join nods with inequal transformations?
|
||||
configRemoveAnimations = pImp->GetPropertyInteger(AI_CONFIG_PP_OG_JOIN_INEQUAL_TRANSFORMS,
|
||||
configJoinInequalTransforms = pImp->GetPropertyInteger(AI_CONFIG_PP_OG_JOIN_INEQUAL_TRANSFORMS,
|
||||
AI_OG_JOIN_INEQUAL_TRANSFORMS) != 0 ? true : false;
|
||||
|
||||
// minimum face number per node
|
||||
|
@ -108,66 +97,6 @@ void OptimizeGraphProcess::SetupProperties(const Importer* pImp)
|
|||
AI_OG_MIN_NUM_FACES);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
aiNode* OptimizeGraphProcess::RemoveAnimationNodes (aiNode* node)
|
||||
{
|
||||
ai_assert(NULL != node);
|
||||
|
||||
std::vector<aiNode*> out;
|
||||
RemoveAnimationNodes(node,out);
|
||||
if (out.empty())
|
||||
throw new ImportErrorException("OptimizeGraphProcess: no nodes are remaining.");
|
||||
if (1 == out.size())
|
||||
return out[0];
|
||||
aiNode* p = new aiNode();
|
||||
p->mName.Set("<dummy_root>");
|
||||
p->mNumChildren = (unsigned int)out.size();
|
||||
p->mChildren = new aiNode*[p->mNumChildren];
|
||||
::memcpy(p->mChildren,&out[0],p->mNumChildren*sizeof(void*));
|
||||
return p;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void OptimizeGraphProcess::RemoveAnimationNodes (aiNode* node,std::vector<aiNode*>& out)
|
||||
{
|
||||
ai_assert(NULL != node);
|
||||
|
||||
// if this is an animation node: shift all children on this layer
|
||||
if (!node->mNumMeshes)
|
||||
{
|
||||
unsigned int old = (unsigned int)out.size();
|
||||
for (unsigned int i = 0; i < node->mNumChildren;++i)
|
||||
{
|
||||
RemoveAnimationNodes(node->mChildren[i],out);
|
||||
}
|
||||
// update the transformations of all shifted childs
|
||||
std::vector<aiNode*>::iterator it2 = out.end(),it = out.begin()+old;
|
||||
for (; it != it2; ++it)
|
||||
(*it)->mTransformation = node->mTransformation * (*it)->mTransformation;
|
||||
|
||||
delete[] node->mChildren;node->mChildren = NULL;
|
||||
delete node;
|
||||
}
|
||||
else
|
||||
{
|
||||
// *this* node remains on this layer, and the children, too
|
||||
out.push_back(node);
|
||||
|
||||
std::vector<aiNode*> outNew;
|
||||
for (unsigned int i = 0; i < node->mNumChildren;++i)
|
||||
{
|
||||
RemoveAnimationNodes(node->mChildren[i],outNew);
|
||||
}
|
||||
if (outNew.size() > node->mNumChildren)
|
||||
{
|
||||
delete[] node->mChildren;
|
||||
node->mChildren = new aiNode*[outNew.size()];
|
||||
}
|
||||
node->mNumChildren = (unsigned int)outNew.size();
|
||||
::memcpy(node->mChildren,&outNew[0],node->mNumChildren*sizeof(void*));
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void OptimizeGraphProcess::FindLockedNodes(aiNode* node)
|
||||
{
|
||||
|
@ -893,22 +822,18 @@ void OptimizeGraphProcess::Execute( aiScene* pScene)
|
|||
ComputeMeshHashes();
|
||||
|
||||
// STEP 2
|
||||
if (configRemoveAnimations)
|
||||
pScene->mRootNode = RemoveAnimationNodes(pScene->mRootNode);
|
||||
FindLockedNodes(pScene->mRootNode);
|
||||
|
||||
// STEP 3
|
||||
else FindLockedNodes(pScene->mRootNode);
|
||||
|
||||
// STEP 4
|
||||
FindLockedMeshes(pScene->mRootNode);
|
||||
|
||||
// STEP 5
|
||||
// STEP 4
|
||||
ApplyOptimizations(pScene->mRootNode);
|
||||
|
||||
// STEP 6
|
||||
// STEP 5
|
||||
BuildOutputMeshList();
|
||||
|
||||
// STEP 7
|
||||
// STEP 6
|
||||
UnlockNodes(pScene->mRootNode);
|
||||
UnlockMeshes();
|
||||
}
|
||||
|
|
|
@ -57,7 +57,6 @@ namespace Assimp {
|
|||
|
||||
// **********************************************************
|
||||
// Java: ConfigProperty.java,
|
||||
// ConfigProperty.OG_MAX_HIERARCHY_DEPTH
|
||||
// ConfigProperty.OG_MIN_NUM_FACES
|
||||
// ConfigProperty.JOIN_INEQUAL_TRANSFORMS
|
||||
// **********************************************************
|
||||
|
@ -70,10 +69,6 @@ namespace Assimp {
|
|||
# define AI_OG_MIN_NUM_FACES 0xffffffff
|
||||
#endif // !! AI_LMW_MAX_WEIGHTS
|
||||
|
||||
#if (!defined AI_OG_REMOVE_ANIMATIONS)
|
||||
# define AI_OG_REMOVE_ANIMATIONS false
|
||||
#endif // !! AI_LMW_MAX_WEIGHTS
|
||||
|
||||
#if (!defined AI_OG_JOIN_INEQUAL_TRANSFORMS)
|
||||
# define AI_OG_JOIN_INEQUAL_TRANSFORMS false
|
||||
#endif // !! AI_LMW_MAX_WEIGHTS
|
||||
|
@ -152,12 +147,6 @@ public:
|
|||
configMinNumFaces = n;
|
||||
}
|
||||
|
||||
// set the configRemoveAnimations property
|
||||
inline void SetRemoveAnimations(bool b)
|
||||
{
|
||||
configRemoveAnimations = b;
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -178,14 +167,6 @@ protected:
|
|||
void RemoveAnimationNodes (aiNode* node,std::vector<aiNode*>& out);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Entry point to the RemoveAnimationNodes algorithm.
|
||||
* @param node Root node to start with
|
||||
* @return New root node
|
||||
*/
|
||||
aiNode* RemoveAnimationNodes (aiNode* node);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Finds and marks all locked nodes in the tree.
|
||||
* A node is locked if it is referenced by animations.
|
||||
|
@ -309,12 +290,6 @@ private:
|
|||
unsigned int configMinNumFaces;
|
||||
|
||||
|
||||
/** Configuration option: specifies whether animations are removed
|
||||
from the node graph. If animations aren't needed by the caller,
|
||||
this allows for further optimization.
|
||||
*/
|
||||
bool configRemoveAnimations;
|
||||
|
||||
/** Configuration option: specifies whether nodes with inequal
|
||||
world matrices are joined if they are on the same hierarchy
|
||||
level and if it seems to make sense.
|
||||
|
|
|
@ -122,6 +122,30 @@ bool GetNextLine(const char_t*& buffer, char_t out[4096])
|
|||
while (IsLineEnd( *buffer ) && '\0' != *buffer)++buffer;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
template <class char_t>
|
||||
inline bool IsNumeric( char_t in)
|
||||
{
|
||||
return in >= '0' && in <= '9' || '-' == in || '+' == in;
|
||||
}
|
||||
// ---------------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE bool TokenMatch(const char*& in, const char* token, unsigned int len)
|
||||
{
|
||||
if (!::strncmp(token,in,len) && IsSpaceOrNewLine(in[len]))
|
||||
{
|
||||
in += len+1;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// ---------------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE bool TokenMatch(char*& in, const char* token, unsigned int len)
|
||||
{
|
||||
if (!::strncmp(token,in,len) && IsSpaceOrNewLine(in[len]))
|
||||
{
|
||||
in += len+1;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif // ! AI_PARSING_UTILS_H_INC
|
||||
|
|
|
@ -41,21 +41,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/** @file Implementation of the PLY importer class */
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
// internal headers
|
||||
#include "PlyLoader.h"
|
||||
#include "MaterialSystem.h"
|
||||
#include "StringComparison.h"
|
||||
|
||||
// public ASSIMP headers
|
||||
#include "../include/IOStream.h"
|
||||
#include "../include/IOSystem.h"
|
||||
#include "../include/aiMesh.h"
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/aiAssert.h"
|
||||
#include "../include/DefaultLogger.h"
|
||||
|
||||
// boost headeers
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
@ -127,23 +119,21 @@ void PLYImporter::InternReadFile(
|
|||
|
||||
// determine the format of the file data
|
||||
PLY::DOM sPlyDom;
|
||||
if (0 == ASSIMP_strincmp(szMe,"format",6) && IsSpace(*(szMe+6)))
|
||||
if (TokenMatch(szMe,"format",6))
|
||||
{
|
||||
szMe += 7;
|
||||
if (0 == ASSIMP_strincmp(szMe,"ascii",5) && IsSpace(*(szMe+5)))
|
||||
if (TokenMatch(szMe,"ascii",5))
|
||||
{
|
||||
szMe += 6;
|
||||
SkipLine(szMe,(const char**)&szMe);
|
||||
if(!PLY::DOM::ParseInstance(szMe,&sPlyDom))
|
||||
throw new ImportErrorException( "Invalid .ply file: Unable to build DOM (#1)");
|
||||
}
|
||||
else if (0 == ASSIMP_strincmp(szMe,"binary_",7))
|
||||
else if (!::strncmp(szMe,"binary_",7))
|
||||
{
|
||||
bool bIsBE = false;
|
||||
szMe+=7;
|
||||
|
||||
// binary_little_endian
|
||||
// binary_big_endian
|
||||
szMe += 7;
|
||||
#if (defined AI_BUILD_BIG_ENDIAN)
|
||||
if ('l' == *szMe || 'L' == *szMe)bIsBE = true;
|
||||
#else
|
||||
|
@ -394,32 +384,32 @@ void PLYImporter::LoadTextureCoordinates(std::vector<aiVector2D>* pvOut)
|
|||
|
||||
// serach in the DOM for a vertex entry
|
||||
unsigned int _i = 0;
|
||||
for (std::vector<PLY::Element*>::const_iterator
|
||||
for (std::vector<PLY::Element>::const_iterator
|
||||
i = this->pcDOM->alElements.begin();
|
||||
i != this->pcDOM->alElements.end();++i,++_i)
|
||||
{
|
||||
if (PLY::EEST_Vertex == (*i)->eSemantic)
|
||||
if (PLY::EEST_Vertex == (*i).eSemantic)
|
||||
{
|
||||
pcList = this->pcDOM->alElementData[_i];
|
||||
pcList = &this->pcDOM->alElementData[_i];
|
||||
|
||||
// now check whether which normal components are available
|
||||
unsigned int _a = 0;
|
||||
for (std::vector<PLY::Property*>::const_iterator
|
||||
a = (*i)->alProperties.begin();
|
||||
a != (*i)->alProperties.end();++a,++_a)
|
||||
for (std::vector<PLY::Property>::const_iterator
|
||||
a = (*i).alProperties.begin();
|
||||
a != (*i).alProperties.end();++a,++_a)
|
||||
{
|
||||
if ((*a)->bIsList)continue;
|
||||
if (PLY::EST_UTextureCoord == (*a)->Semantic)
|
||||
if ((*a).bIsList)continue;
|
||||
if (PLY::EST_UTextureCoord == (*a).Semantic)
|
||||
{
|
||||
cnt++;
|
||||
aiPositions[0] = _a;
|
||||
aiTypes[0] = (*a)->eType;
|
||||
aiTypes[0] = (*a).eType;
|
||||
}
|
||||
else if (PLY::EST_VTextureCoord == (*a)->Semantic)
|
||||
else if (PLY::EST_VTextureCoord == (*a).Semantic)
|
||||
{
|
||||
cnt++;
|
||||
aiPositions[1] = _a;
|
||||
aiTypes[1] = (*a)->eType;
|
||||
aiTypes[1] = (*a).eType;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -428,7 +418,7 @@ void PLYImporter::LoadTextureCoordinates(std::vector<aiVector2D>* pvOut)
|
|||
if (NULL != pcList && 0 != cnt)
|
||||
{
|
||||
pvOut->reserve(pcList->alInstances.size());
|
||||
for (std::vector<ElementInstance*>::const_iterator
|
||||
for (std::vector<ElementInstance>::const_iterator
|
||||
i = pcList->alInstances.begin();
|
||||
i != pcList->alInstances.end();++i)
|
||||
{
|
||||
|
@ -438,13 +428,13 @@ void PLYImporter::LoadTextureCoordinates(std::vector<aiVector2D>* pvOut)
|
|||
if (0xFFFFFFFF != aiPositions[0])
|
||||
{
|
||||
vOut.x = PLY::PropertyInstance::ConvertTo<float>(
|
||||
(*i)->alProperties[aiPositions[0]].avList.front(),aiTypes[0]);
|
||||
(*i).alProperties[aiPositions[0]].avList.front(),aiTypes[0]);
|
||||
}
|
||||
|
||||
if (0xFFFFFFFF != aiPositions[1])
|
||||
{
|
||||
vOut.y = PLY::PropertyInstance::ConvertTo<float>(
|
||||
(*i)->alProperties[aiPositions[1]].avList.front(),aiTypes[1]);
|
||||
(*i).alProperties[aiPositions[1]].avList.front(),aiTypes[1]);
|
||||
}
|
||||
// and add them to our nice list
|
||||
pvOut->push_back(vOut);
|
||||
|
@ -463,41 +453,41 @@ void PLYImporter::LoadVertices(std::vector<aiVector3D>* pvOut, bool p_bNormals)
|
|||
|
||||
// serach in the DOM for a vertex entry
|
||||
unsigned int _i = 0;
|
||||
for (std::vector<PLY::Element*>::const_iterator
|
||||
for (std::vector<PLY::Element>::const_iterator
|
||||
i = this->pcDOM->alElements.begin();
|
||||
i != this->pcDOM->alElements.end();++i,++_i)
|
||||
{
|
||||
if (PLY::EEST_Vertex == (*i)->eSemantic)
|
||||
if (PLY::EEST_Vertex == (*i).eSemantic)
|
||||
{
|
||||
pcList = this->pcDOM->alElementData[_i];
|
||||
pcList = &this->pcDOM->alElementData[_i];
|
||||
|
||||
// load normal vectors?
|
||||
if (p_bNormals)
|
||||
{
|
||||
// now check whether which normal components are available
|
||||
unsigned int _a = 0;
|
||||
for (std::vector<PLY::Property*>::const_iterator
|
||||
a = (*i)->alProperties.begin();
|
||||
a != (*i)->alProperties.end();++a,++_a)
|
||||
for (std::vector<PLY::Property>::const_iterator
|
||||
a = (*i).alProperties.begin();
|
||||
a != (*i).alProperties.end();++a,++_a)
|
||||
{
|
||||
if ((*a)->bIsList)continue;
|
||||
if (PLY::EST_XNormal == (*a)->Semantic)
|
||||
if ((*a).bIsList)continue;
|
||||
if (PLY::EST_XNormal == (*a).Semantic)
|
||||
{
|
||||
cnt++;
|
||||
aiPositions[0] = _a;
|
||||
aiTypes[0] = (*a)->eType;
|
||||
aiTypes[0] = (*a).eType;
|
||||
}
|
||||
else if (PLY::EST_YNormal == (*a)->Semantic)
|
||||
else if (PLY::EST_YNormal == (*a).Semantic)
|
||||
{
|
||||
cnt++;
|
||||
aiPositions[1] = _a;
|
||||
aiTypes[1] = (*a)->eType;
|
||||
aiTypes[1] = (*a).eType;
|
||||
}
|
||||
else if (PLY::EST_ZNormal == (*a)->Semantic)
|
||||
else if (PLY::EST_ZNormal == (*a).Semantic)
|
||||
{
|
||||
cnt++;
|
||||
aiPositions[2] = _a;
|
||||
aiTypes[2] = (*a)->eType;
|
||||
aiTypes[2] = (*a).eType;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -506,28 +496,28 @@ void PLYImporter::LoadVertices(std::vector<aiVector3D>* pvOut, bool p_bNormals)
|
|||
{
|
||||
// now check whether which coordinate sets are available
|
||||
unsigned int _a = 0;
|
||||
for (std::vector<PLY::Property*>::const_iterator
|
||||
a = (*i)->alProperties.begin();
|
||||
a != (*i)->alProperties.end();++a,++_a)
|
||||
for (std::vector<PLY::Property>::const_iterator
|
||||
a = (*i).alProperties.begin();
|
||||
a != (*i).alProperties.end();++a,++_a)
|
||||
{
|
||||
if ((*a)->bIsList)continue;
|
||||
if (PLY::EST_XCoord == (*a)->Semantic)
|
||||
if ((*a).bIsList)continue;
|
||||
if (PLY::EST_XCoord == (*a).Semantic)
|
||||
{
|
||||
cnt++;
|
||||
aiPositions[0] = _a;
|
||||
aiTypes[0] = (*a)->eType;
|
||||
aiTypes[0] = (*a).eType;
|
||||
}
|
||||
else if (PLY::EST_YCoord == (*a)->Semantic)
|
||||
else if (PLY::EST_YCoord == (*a).Semantic)
|
||||
{
|
||||
cnt++;
|
||||
aiPositions[1] = _a;
|
||||
aiTypes[1] = (*a)->eType;
|
||||
aiTypes[1] = (*a).eType;
|
||||
}
|
||||
else if (PLY::EST_ZCoord == (*a)->Semantic)
|
||||
else if (PLY::EST_ZCoord == (*a).Semantic)
|
||||
{
|
||||
cnt++;
|
||||
aiPositions[2] = _a;
|
||||
aiTypes[2] = (*a)->eType;
|
||||
aiTypes[2] = (*a).eType;
|
||||
}
|
||||
if (3 == cnt)break;
|
||||
}
|
||||
|
@ -539,7 +529,7 @@ void PLYImporter::LoadVertices(std::vector<aiVector3D>* pvOut, bool p_bNormals)
|
|||
if (NULL != pcList && 0 != cnt)
|
||||
{
|
||||
pvOut->reserve(pcList->alInstances.size());
|
||||
for (std::vector<ElementInstance*>::const_iterator
|
||||
for (std::vector<ElementInstance>::const_iterator
|
||||
i = pcList->alInstances.begin();
|
||||
i != pcList->alInstances.end();++i)
|
||||
{
|
||||
|
@ -549,19 +539,19 @@ void PLYImporter::LoadVertices(std::vector<aiVector3D>* pvOut, bool p_bNormals)
|
|||
if (0xFFFFFFFF != aiPositions[0])
|
||||
{
|
||||
vOut.x = PLY::PropertyInstance::ConvertTo<float>(
|
||||
(*i)->alProperties[aiPositions[0]].avList.front(),aiTypes[0]);
|
||||
(*i).alProperties[aiPositions[0]].avList.front(),aiTypes[0]);
|
||||
}
|
||||
|
||||
if (0xFFFFFFFF != aiPositions[1])
|
||||
{
|
||||
vOut.y = PLY::PropertyInstance::ConvertTo<float>(
|
||||
(*i)->alProperties[aiPositions[1]].avList.front(),aiTypes[1]);
|
||||
(*i).alProperties[aiPositions[1]].avList.front(),aiTypes[1]);
|
||||
}
|
||||
|
||||
if (0xFFFFFFFF != aiPositions[2])
|
||||
{
|
||||
vOut.z = PLY::PropertyInstance::ConvertTo<float>(
|
||||
(*i)->alProperties[aiPositions[2]].avList.front(),aiTypes[2]);
|
||||
(*i).alProperties[aiPositions[2]].avList.front(),aiTypes[2]);
|
||||
}
|
||||
|
||||
// and add them to our nice list
|
||||
|
@ -609,44 +599,44 @@ void PLYImporter::LoadVertexColor(std::vector<aiColor4D>* pvOut)
|
|||
|
||||
// serach in the DOM for a vertex entry
|
||||
unsigned int _i = 0;
|
||||
for (std::vector<PLY::Element*>::const_iterator
|
||||
for (std::vector<PLY::Element>::const_iterator
|
||||
i = this->pcDOM->alElements.begin();
|
||||
i != this->pcDOM->alElements.end();++i,++_i)
|
||||
{
|
||||
if (PLY::EEST_Vertex == (*i)->eSemantic)
|
||||
if (PLY::EEST_Vertex == (*i).eSemantic)
|
||||
{
|
||||
pcList = this->pcDOM->alElementData[_i];
|
||||
pcList = &this->pcDOM->alElementData[_i];
|
||||
|
||||
// now check whether which coordinate sets are available
|
||||
unsigned int _a = 0;
|
||||
for (std::vector<PLY::Property*>::const_iterator
|
||||
a = (*i)->alProperties.begin();
|
||||
a != (*i)->alProperties.end();++a,++_a)
|
||||
for (std::vector<PLY::Property>::const_iterator
|
||||
a = (*i).alProperties.begin();
|
||||
a != (*i).alProperties.end();++a,++_a)
|
||||
{
|
||||
if ((*a)->bIsList)continue;
|
||||
if (PLY::EST_Red == (*a)->Semantic)
|
||||
if ((*a).bIsList)continue;
|
||||
if (PLY::EST_Red == (*a).Semantic)
|
||||
{
|
||||
cnt++;
|
||||
aiPositions[0] = _a;
|
||||
aiTypes[0] = (*a)->eType;
|
||||
aiTypes[0] = (*a).eType;
|
||||
}
|
||||
else if (PLY::EST_Green == (*a)->Semantic)
|
||||
else if (PLY::EST_Green == (*a).Semantic)
|
||||
{
|
||||
cnt++;
|
||||
aiPositions[1] = _a;
|
||||
aiTypes[1] = (*a)->eType;
|
||||
aiTypes[1] = (*a).eType;
|
||||
}
|
||||
else if (PLY::EST_Blue == (*a)->Semantic)
|
||||
else if (PLY::EST_Blue == (*a).Semantic)
|
||||
{
|
||||
cnt++;
|
||||
aiPositions[2] = _a;
|
||||
aiTypes[2] = (*a)->eType;
|
||||
aiTypes[2] = (*a).eType;
|
||||
}
|
||||
else if (PLY::EST_Alpha == (*a)->Semantic)
|
||||
else if (PLY::EST_Alpha == (*a).Semantic)
|
||||
{
|
||||
cnt++;
|
||||
aiPositions[3] = _a;
|
||||
aiTypes[3] = (*a)->eType;
|
||||
aiTypes[3] = (*a).eType;
|
||||
}
|
||||
if (4 == cnt)break;
|
||||
}
|
||||
|
@ -657,7 +647,7 @@ void PLYImporter::LoadVertexColor(std::vector<aiColor4D>* pvOut)
|
|||
if (NULL != pcList && 0 != cnt)
|
||||
{
|
||||
pvOut->reserve(pcList->alInstances.size());
|
||||
for (std::vector<ElementInstance*>::const_iterator
|
||||
for (std::vector<ElementInstance>::const_iterator
|
||||
i = pcList->alInstances.begin();
|
||||
i != pcList->alInstances.end();++i)
|
||||
{
|
||||
|
@ -666,19 +656,19 @@ void PLYImporter::LoadVertexColor(std::vector<aiColor4D>* pvOut)
|
|||
|
||||
if (0xFFFFFFFF != aiPositions[0])
|
||||
{
|
||||
vOut.r = NormalizeColorValue((*i)->alProperties[
|
||||
vOut.r = NormalizeColorValue((*i).alProperties[
|
||||
aiPositions[0]].avList.front(),aiTypes[0]);
|
||||
}
|
||||
|
||||
if (0xFFFFFFFF != aiPositions[1])
|
||||
{
|
||||
vOut.g = NormalizeColorValue((*i)->alProperties[
|
||||
vOut.g = NormalizeColorValue((*i).alProperties[
|
||||
aiPositions[1]].avList.front(),aiTypes[1]);
|
||||
}
|
||||
|
||||
if (0xFFFFFFFF != aiPositions[2])
|
||||
{
|
||||
vOut.b = NormalizeColorValue((*i)->alProperties[
|
||||
vOut.b = NormalizeColorValue((*i).alProperties[
|
||||
aiPositions[2]].avList.front(),aiTypes[2]);
|
||||
}
|
||||
|
||||
|
@ -686,7 +676,7 @@ void PLYImporter::LoadVertexColor(std::vector<aiColor4D>* pvOut)
|
|||
if (0xFFFFFFFF == aiPositions[3])vOut.a = 1.0f;
|
||||
else
|
||||
{
|
||||
vOut.a = NormalizeColorValue((*i)->alProperties[
|
||||
vOut.a = NormalizeColorValue((*i).alProperties[
|
||||
aiPositions[3]].avList.front(),aiTypes[3]);
|
||||
}
|
||||
|
||||
|
@ -716,54 +706,54 @@ void PLYImporter::LoadFaces(std::vector<PLY::Face>* pvOut)
|
|||
|
||||
// serach in the DOM for a face entry
|
||||
unsigned int _i = 0;
|
||||
for (std::vector<PLY::Element*>::const_iterator
|
||||
for (std::vector<PLY::Element>::const_iterator
|
||||
i = this->pcDOM->alElements.begin();
|
||||
i != this->pcDOM->alElements.end();++i,++_i)
|
||||
{
|
||||
// face = unique number of vertex indices
|
||||
if (PLY::EEST_Face == (*i)->eSemantic)
|
||||
if (PLY::EEST_Face == (*i).eSemantic)
|
||||
{
|
||||
pcList = this->pcDOM->alElementData[_i];
|
||||
pcList = &this->pcDOM->alElementData[_i];
|
||||
unsigned int _a = 0;
|
||||
for (std::vector<PLY::Property*>::const_iterator
|
||||
a = (*i)->alProperties.begin();
|
||||
a != (*i)->alProperties.end();++a,++_a)
|
||||
for (std::vector<PLY::Property>::const_iterator
|
||||
a = (*i).alProperties.begin();
|
||||
a != (*i).alProperties.end();++a,++_a)
|
||||
{
|
||||
if (PLY::EST_VertexIndex == (*a)->Semantic)
|
||||
if (PLY::EST_VertexIndex == (*a).Semantic)
|
||||
{
|
||||
// must be a dynamic list!
|
||||
if (!(*a)->bIsList)continue;
|
||||
if (!(*a).bIsList)continue;
|
||||
iProperty = _a;
|
||||
bOne = true;
|
||||
eType = (*a)->eType;
|
||||
eType = (*a).eType;
|
||||
}
|
||||
else if (PLY::EST_MaterialIndex == (*a)->Semantic)
|
||||
else if (PLY::EST_MaterialIndex == (*a).Semantic)
|
||||
{
|
||||
if ((*a)->bIsList)continue;
|
||||
if ((*a).bIsList)continue;
|
||||
iMaterialIndex = _a;
|
||||
bOne = true;
|
||||
eType2 = (*a)->eType;
|
||||
eType2 = (*a).eType;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
// triangle strip
|
||||
// TODO: triangle strip and material index support???
|
||||
else if (PLY::EEST_TriStrip == (*i)->eSemantic)
|
||||
else if (PLY::EEST_TriStrip == (*i).eSemantic)
|
||||
{
|
||||
// find a list property in this ...
|
||||
pcList = this->pcDOM->alElementData[_i];
|
||||
pcList = &this->pcDOM->alElementData[_i];
|
||||
unsigned int _a = 0;
|
||||
for (std::vector<PLY::Property*>::const_iterator
|
||||
a = (*i)->alProperties.begin();
|
||||
a != (*i)->alProperties.end();++a,++_a)
|
||||
for (std::vector<PLY::Property>::const_iterator
|
||||
a = (*i).alProperties.begin();
|
||||
a != (*i).alProperties.end();++a,++_a)
|
||||
{
|
||||
// must be a dynamic list!
|
||||
if (!(*a)->bIsList)continue;
|
||||
if (!(*a).bIsList)continue;
|
||||
iProperty = _a;
|
||||
bOne = true;
|
||||
bIsTristrip = true;
|
||||
eType = (*a)->eType;
|
||||
eType = (*a).eType;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -775,7 +765,7 @@ void PLYImporter::LoadFaces(std::vector<PLY::Face>* pvOut)
|
|||
if (!bIsTristrip)
|
||||
{
|
||||
pvOut->reserve(pcList->alInstances.size());
|
||||
for (std::vector<ElementInstance*>::const_iterator
|
||||
for (std::vector<ElementInstance>::const_iterator
|
||||
i = pcList->alInstances.begin();
|
||||
i != pcList->alInstances.end();++i)
|
||||
{
|
||||
|
@ -784,11 +774,11 @@ void PLYImporter::LoadFaces(std::vector<PLY::Face>* pvOut)
|
|||
// parse the list of vertex indices
|
||||
if (0xFFFFFFFF != iProperty)
|
||||
{
|
||||
const unsigned int iNum = (unsigned int)(*i)->alProperties[iProperty].avList.size();
|
||||
const unsigned int iNum = (unsigned int)(*i).alProperties[iProperty].avList.size();
|
||||
sFace.mIndices.resize(iNum);
|
||||
|
||||
std::list<PLY::PropertyInstance::ValueUnion>::const_iterator p =
|
||||
(*i)->alProperties[iProperty].avList.begin();
|
||||
std::vector<PLY::PropertyInstance::ValueUnion>::const_iterator p =
|
||||
(*i).alProperties[iProperty].avList.begin();
|
||||
|
||||
for (unsigned int a = 0; a < iNum;++a,++p)
|
||||
{
|
||||
|
@ -800,7 +790,7 @@ void PLYImporter::LoadFaces(std::vector<PLY::Face>* pvOut)
|
|||
if (0xFFFFFFFF != iMaterialIndex)
|
||||
{
|
||||
sFace.iMaterialIndex = PLY::PropertyInstance::ConvertTo<unsigned int>(
|
||||
(*i)->alProperties[iMaterialIndex].avList.front(),eType2);
|
||||
(*i).alProperties[iMaterialIndex].avList.front(),eType2);
|
||||
}
|
||||
pvOut->push_back(sFace);
|
||||
}
|
||||
|
@ -809,14 +799,14 @@ void PLYImporter::LoadFaces(std::vector<PLY::Face>* pvOut)
|
|||
{
|
||||
// normally we have only one triangle strip instance where
|
||||
// a value of -1 indicates a restart of the strip
|
||||
for (std::vector<ElementInstance*>::const_iterator
|
||||
for (std::vector<ElementInstance>::const_iterator
|
||||
i = pcList->alInstances.begin();
|
||||
i != pcList->alInstances.end();++i)
|
||||
{
|
||||
int aiTable[2] = {-1,-1};
|
||||
for (std::list<PLY::PropertyInstance::ValueUnion>::const_iterator
|
||||
a = (*i)->alProperties[iProperty].avList.begin();
|
||||
a != (*i)->alProperties[iProperty].avList.end();++a)
|
||||
for (std::vector<PLY::PropertyInstance::ValueUnion>::const_iterator
|
||||
a = (*i).alProperties[iProperty].avList.begin();
|
||||
a != (*i).alProperties[iProperty].avList.end();++a)
|
||||
{
|
||||
int p = PLY::PropertyInstance::ConvertTo<int>(*a,eType);
|
||||
if (-1 == p)
|
||||
|
@ -915,98 +905,98 @@ void PLYImporter::LoadMaterial(std::vector<MaterialHelper*>* pvOut)
|
|||
|
||||
// serach in the DOM for a vertex entry
|
||||
unsigned int _i = 0;
|
||||
for (std::vector<PLY::Element*>::const_iterator
|
||||
for (std::vector<PLY::Element>::const_iterator
|
||||
i = this->pcDOM->alElements.begin();
|
||||
i != this->pcDOM->alElements.end();++i,++_i)
|
||||
{
|
||||
if (PLY::EEST_Material == (*i)->eSemantic)
|
||||
if (PLY::EEST_Material == (*i).eSemantic)
|
||||
{
|
||||
pcList = this->pcDOM->alElementData[_i];
|
||||
pcList = &this->pcDOM->alElementData[_i];
|
||||
|
||||
// now check whether which coordinate sets are available
|
||||
unsigned int _a = 0;
|
||||
for (std::vector<PLY::Property*>::const_iterator
|
||||
a = (*i)->alProperties.begin();
|
||||
a != (*i)->alProperties.end();++a,++_a)
|
||||
for (std::vector<PLY::Property>::const_iterator
|
||||
a = (*i).alProperties.begin();
|
||||
a != (*i).alProperties.end();++a,++_a)
|
||||
{
|
||||
if ((*a)->bIsList)continue;
|
||||
if ((*a).bIsList)continue;
|
||||
|
||||
// pohng specularity -----------------------------------
|
||||
if (PLY::EST_PhongPower == (*a)->Semantic)
|
||||
if (PLY::EST_PhongPower == (*a).Semantic)
|
||||
{
|
||||
iPhong = _a;
|
||||
ePhong = (*a)->eType;
|
||||
ePhong = (*a).eType;
|
||||
}
|
||||
|
||||
// general opacity -----------------------------------
|
||||
if (PLY::EST_Opacity == (*a)->Semantic)
|
||||
if (PLY::EST_Opacity == (*a).Semantic)
|
||||
{
|
||||
iOpacity = _a;
|
||||
eOpacity = (*a)->eType;
|
||||
eOpacity = (*a).eType;
|
||||
}
|
||||
|
||||
// diffuse color channels -----------------------------------
|
||||
if (PLY::EST_DiffuseRed == (*a)->Semantic)
|
||||
if (PLY::EST_DiffuseRed == (*a).Semantic)
|
||||
{
|
||||
aaiPositions[0][0] = _a;
|
||||
aaiTypes[0][0] = (*a)->eType;
|
||||
aaiTypes[0][0] = (*a).eType;
|
||||
}
|
||||
else if (PLY::EST_DiffuseGreen == (*a)->Semantic)
|
||||
else if (PLY::EST_DiffuseGreen == (*a).Semantic)
|
||||
{
|
||||
aaiPositions[0][1] = _a;
|
||||
aaiTypes[0][1] = (*a)->eType;
|
||||
aaiTypes[0][1] = (*a).eType;
|
||||
}
|
||||
else if (PLY::EST_DiffuseBlue == (*a)->Semantic)
|
||||
else if (PLY::EST_DiffuseBlue == (*a).Semantic)
|
||||
{
|
||||
aaiPositions[0][2] = _a;
|
||||
aaiTypes[0][2] = (*a)->eType;
|
||||
aaiTypes[0][2] = (*a).eType;
|
||||
}
|
||||
else if (PLY::EST_DiffuseAlpha == (*a)->Semantic)
|
||||
else if (PLY::EST_DiffuseAlpha == (*a).Semantic)
|
||||
{
|
||||
aaiPositions[0][3] = _a;
|
||||
aaiTypes[0][3] = (*a)->eType;
|
||||
aaiTypes[0][3] = (*a).eType;
|
||||
}
|
||||
// specular color channels -----------------------------------
|
||||
else if (PLY::EST_SpecularRed == (*a)->Semantic)
|
||||
else if (PLY::EST_SpecularRed == (*a).Semantic)
|
||||
{
|
||||
aaiPositions[1][0] = _a;
|
||||
aaiTypes[1][0] = (*a)->eType;
|
||||
aaiTypes[1][0] = (*a).eType;
|
||||
}
|
||||
else if (PLY::EST_SpecularGreen == (*a)->Semantic)
|
||||
else if (PLY::EST_SpecularGreen == (*a).Semantic)
|
||||
{
|
||||
aaiPositions[1][1] = _a;
|
||||
aaiTypes[1][1] = (*a)->eType;
|
||||
aaiTypes[1][1] = (*a).eType;
|
||||
}
|
||||
else if (PLY::EST_SpecularBlue == (*a)->Semantic)
|
||||
else if (PLY::EST_SpecularBlue == (*a).Semantic)
|
||||
{
|
||||
aaiPositions[1][2] = _a;
|
||||
aaiTypes[1][2] = (*a)->eType;
|
||||
aaiTypes[1][2] = (*a).eType;
|
||||
}
|
||||
else if (PLY::EST_SpecularAlpha == (*a)->Semantic)
|
||||
else if (PLY::EST_SpecularAlpha == (*a).Semantic)
|
||||
{
|
||||
aaiPositions[1][3] = _a;
|
||||
aaiTypes[1][3] = (*a)->eType;
|
||||
aaiTypes[1][3] = (*a).eType;
|
||||
}
|
||||
// ambient color channels -----------------------------------
|
||||
else if (PLY::EST_AmbientRed == (*a)->Semantic)
|
||||
else if (PLY::EST_AmbientRed == (*a).Semantic)
|
||||
{
|
||||
aaiPositions[2][0] = _a;
|
||||
aaiTypes[2][0] = (*a)->eType;
|
||||
aaiTypes[2][0] = (*a).eType;
|
||||
}
|
||||
else if (PLY::EST_AmbientGreen == (*a)->Semantic)
|
||||
else if (PLY::EST_AmbientGreen == (*a).Semantic)
|
||||
{
|
||||
aaiPositions[2][1] = _a;
|
||||
aaiTypes[2][1] = (*a)->eType;
|
||||
aaiTypes[2][1] = (*a).eType;
|
||||
}
|
||||
else if (PLY::EST_AmbientBlue == (*a)->Semantic)
|
||||
else if (PLY::EST_AmbientBlue == (*a).Semantic)
|
||||
{
|
||||
aaiPositions[22][2] = _a;
|
||||
aaiTypes[2][2] = (*a)->eType;
|
||||
aaiTypes[2][2] = (*a).eType;
|
||||
}
|
||||
else if (PLY::EST_AmbientAlpha == (*a)->Semantic)
|
||||
else if (PLY::EST_AmbientAlpha == (*a).Semantic)
|
||||
{
|
||||
aaiPositions[2][3] = _a;
|
||||
aaiTypes[2][3] = (*a)->eType;
|
||||
aaiTypes[2][3] = (*a).eType;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1015,7 +1005,7 @@ void PLYImporter::LoadMaterial(std::vector<MaterialHelper*>* pvOut)
|
|||
// check whether we have a valid source for the material data
|
||||
if (NULL != pcList)
|
||||
{
|
||||
for (std::vector<ElementInstance*>::const_iterator
|
||||
for (std::vector<ElementInstance>::const_iterator
|
||||
i = pcList->alInstances.begin();
|
||||
i != pcList->alInstances.end();++i)
|
||||
{
|
||||
|
@ -1023,15 +1013,15 @@ void PLYImporter::LoadMaterial(std::vector<MaterialHelper*>* pvOut)
|
|||
MaterialHelper* pcHelper = new MaterialHelper();
|
||||
|
||||
// build the diffuse material color
|
||||
GetMaterialColor((*i)->alProperties,aaiPositions[0],aaiTypes[0],&clrOut);
|
||||
GetMaterialColor((*i).alProperties,aaiPositions[0],aaiTypes[0],&clrOut);
|
||||
pcHelper->AddProperty<aiColor4D>(&clrOut,1,AI_MATKEY_COLOR_DIFFUSE);
|
||||
|
||||
// build the specular material color
|
||||
GetMaterialColor((*i)->alProperties,aaiPositions[1],aaiTypes[1],&clrOut);
|
||||
GetMaterialColor((*i).alProperties,aaiPositions[1],aaiTypes[1],&clrOut);
|
||||
pcHelper->AddProperty<aiColor4D>(&clrOut,1,AI_MATKEY_COLOR_SPECULAR);
|
||||
|
||||
// build the ambient material color
|
||||
GetMaterialColor((*i)->alProperties,aaiPositions[2],aaiTypes[2],&clrOut);
|
||||
GetMaterialColor((*i).alProperties,aaiPositions[2],aaiTypes[2],&clrOut);
|
||||
pcHelper->AddProperty<aiColor4D>(&clrOut,1,AI_MATKEY_COLOR_AMBIENT);
|
||||
|
||||
// handle phong power and shading mode
|
||||
|
@ -1039,7 +1029,7 @@ void PLYImporter::LoadMaterial(std::vector<MaterialHelper*>* pvOut)
|
|||
if (0xFFFFFFFF != iPhong)
|
||||
{
|
||||
float fSpec = PLY::PropertyInstance::ConvertTo<float>(
|
||||
(*i)->alProperties[iPhong].avList.front(),ePhong);
|
||||
(*i).alProperties[iPhong].avList.front(),ePhong);
|
||||
|
||||
// if shininess is 0 (and the pow() calculation would therefore always
|
||||
// become 1, not depending on the angle) use gouraud lighting
|
||||
|
@ -1061,7 +1051,7 @@ void PLYImporter::LoadMaterial(std::vector<MaterialHelper*>* pvOut)
|
|||
if (0xFFFFFFFF != iOpacity)
|
||||
{
|
||||
float fOpacity = PLY::PropertyInstance::ConvertTo<float>(
|
||||
(*i)->alProperties[iPhong].avList.front(),eOpacity);
|
||||
(*i).alProperties[iPhong].avList.front(),eOpacity);
|
||||
|
||||
pcHelper->AddProperty<float>(&fOpacity, 1, AI_MATKEY_OPACITY);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
115
code/PlyParser.h
115
code/PlyParser.h
|
@ -43,16 +43,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef AI_PLYFILEHELPER_H_INC
|
||||
#define AI_PLYFILEHELPER_H_INC
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <sstream>
|
||||
|
||||
#include "ParsingUtils.h"
|
||||
|
||||
#include "../include/aiTypes.h"
|
||||
#include "../include/aiMesh.h"
|
||||
#include "../include/aiAnim.h"
|
||||
|
||||
namespace Assimp
|
||||
{
|
||||
|
@ -240,16 +233,16 @@ public:
|
|||
//! string is either '\n', '\r' or '\0'. Return valie is false
|
||||
//! if the input string is NOT a valid property (E.g. does
|
||||
//! not start with the "property" keyword)
|
||||
static bool ParseProperty (const char* p_szIn, const char** p_szOut,
|
||||
static bool ParseProperty (const char* pCur, const char** pCurOut,
|
||||
Property* pOut);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
//! Parse a data type from a string
|
||||
static EDataType ParseDataType(const char* p_szIn,const char** p_szOut);
|
||||
static EDataType ParseDataType(const char* pCur,const char** pCurOut);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
//! Parse a semantic from a string
|
||||
static ESemantic ParseSemantic(const char* p_szIn,const char** p_szOut);
|
||||
static ESemantic ParseSemantic(const char* pCur,const char** pCurOut);
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
@ -268,22 +261,9 @@ public:
|
|||
, NumOccur(0)
|
||||
{}
|
||||
|
||||
//! Destructor. Dallocates all storage
|
||||
~Element()
|
||||
{
|
||||
// delete all elements
|
||||
for (std::vector<Property*>::const_iterator
|
||||
i = this->alProperties.begin();
|
||||
i != this->alProperties.end();++i)
|
||||
{
|
||||
delete (*i);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//! List of properties assigned to the element
|
||||
//! std::vector to support operator[]
|
||||
std::vector<Property*> alProperties;
|
||||
std::vector<Property> alProperties;
|
||||
|
||||
//! Semantic of the element
|
||||
EElementSemantic eSemantic;
|
||||
|
@ -300,13 +280,13 @@ public:
|
|||
//! Parse an element from a string.
|
||||
//! The function will parse all properties contained in the
|
||||
//! element, too.
|
||||
static bool ParseElement (const char* p_szIn, const char** p_szOut,
|
||||
static bool ParseElement (const char* pCur, const char** pCurOut,
|
||||
Element* pOut);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
//! Parse a semantic from a string
|
||||
static EElementSemantic ParseSemantic(const char* p_szIn,
|
||||
const char** p_szOut);
|
||||
static EElementSemantic ParseSemantic(const char* pCur,
|
||||
const char** pCurOut);
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
@ -341,17 +321,17 @@ public:
|
|||
|
||||
// -------------------------------------------------------------------
|
||||
//! List of all values parsed. Contains only one value
|
||||
// for non-list propertys
|
||||
std::list<ValueUnion> avList;
|
||||
// for non-list properties
|
||||
std::vector<ValueUnion> avList;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
//! Parse a property instance
|
||||
static bool ParseInstance (const char* p_szIn,const char** p_szOut,
|
||||
static bool ParseInstance (const char* pCur,const char** pCurOut,
|
||||
const Property* prop, PropertyInstance* p_pcOut);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
//! Parse a property instance in binary format
|
||||
static bool ParseInstanceBinary (const char* p_szIn,const char** p_szOut,
|
||||
static bool ParseInstanceBinary (const char* pCur,const char** pCurOut,
|
||||
const Property* prop, PropertyInstance* p_pcOut,bool p_bBE);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
@ -360,12 +340,12 @@ public:
|
|||
|
||||
// -------------------------------------------------------------------
|
||||
//! Parse a value
|
||||
static bool ParseValue(const char* p_szIn,const char** p_szOut,
|
||||
static bool ParseValue(const char* pCur,const char** pCurOut,
|
||||
EDataType eType,ValueUnion* out);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
//! Parse a binary value
|
||||
static bool ParseValueBinary(const char* p_szIn,const char** p_szOut,
|
||||
static bool ParseValueBinary(const char* pCur,const char** pCurOut,
|
||||
EDataType eType,ValueUnion* out,bool p_bBE);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
@ -390,12 +370,12 @@ public:
|
|||
|
||||
// -------------------------------------------------------------------
|
||||
//! Parse an element instance
|
||||
static bool ParseInstance (const char* p_szIn,const char** p_szOut,
|
||||
static bool ParseInstance (const char* pCur,const char** pCurOut,
|
||||
const Element* pcElement, ElementInstance* p_pcOut);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
//! Parse a binary element instance
|
||||
static bool ParseInstanceBinary (const char* p_szIn,const char** p_szOut,
|
||||
static bool ParseInstanceBinary (const char* pCur,const char** pCurOut,
|
||||
const Element* pcElement, ElementInstance* p_pcOut,bool p_bBE);
|
||||
};
|
||||
|
||||
|
@ -410,37 +390,17 @@ public:
|
|||
ElementInstanceList ()
|
||||
{}
|
||||
|
||||
//! Construction from a given element description
|
||||
ElementInstanceList (const Element* pc)
|
||||
{
|
||||
// reserve enough storage to speedup the process
|
||||
alInstances.resize(pc->NumOccur);
|
||||
}
|
||||
|
||||
//! Destructor. Dallocates all storage
|
||||
~ElementInstanceList()
|
||||
{
|
||||
// delete all elements
|
||||
for (std::vector<ElementInstance*>::const_iterator
|
||||
i = this->alInstances.begin();
|
||||
i != this->alInstances.end();++i)
|
||||
{
|
||||
delete (*i);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//! List of all element instances
|
||||
std::vector< ElementInstance* > alInstances;
|
||||
std::vector< ElementInstance > alInstances;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
//! Parse an element instance list
|
||||
static bool ParseInstanceList (const char* p_szIn,const char** p_szOut,
|
||||
static bool ParseInstanceList (const char* pCur,const char** pCurOut,
|
||||
const Element* pcElement, ElementInstanceList* p_pcOut);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
//! Parse a binary element instance list
|
||||
static bool ParseInstanceListBinary (const char* p_szIn,const char** p_szOut,
|
||||
static bool ParseInstanceListBinary (const char* pCur,const char** pCurOut,
|
||||
const Element* pcElement, ElementInstanceList* p_pcOut,bool p_bBE);
|
||||
};
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
@ -455,54 +415,35 @@ public:
|
|||
DOM()
|
||||
{}
|
||||
|
||||
//! Destructor. Dallocates all storage
|
||||
~DOM()
|
||||
{
|
||||
// delete all elements
|
||||
for (std::vector<Element*>::const_iterator
|
||||
i = this->alElements.begin();
|
||||
i != this->alElements.end();++i)
|
||||
{
|
||||
delete (*i);
|
||||
}
|
||||
// delete all instance lists
|
||||
for (std::vector<ElementInstanceList*>::const_iterator
|
||||
i = this->alElementData.begin();
|
||||
i != this->alElementData.end();++i)
|
||||
{
|
||||
delete (*i);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//! Contains all elements of the file format
|
||||
std::vector<Element*> alElements;
|
||||
std::vector<Element> alElements;
|
||||
//! Contains the real data of each element's instance list
|
||||
std::vector<ElementInstanceList*> alElementData;
|
||||
std::vector<ElementInstanceList> alElementData;
|
||||
|
||||
//! Parse the DOM for a PLY file. The input string is assumed
|
||||
//! to be terminated with zero
|
||||
static bool ParseInstance (const char* p_szIn,DOM* p_pcOut);
|
||||
static bool ParseInstanceBinary (const char* p_szIn,
|
||||
static bool ParseInstance (const char* pCur,DOM* p_pcOut);
|
||||
static bool ParseInstanceBinary (const char* pCur,
|
||||
DOM* p_pcOut,bool p_bBE);
|
||||
|
||||
//! Skip all comment lines after this
|
||||
static bool SkipComments (const char* p_szIn,const char** p_szOut);
|
||||
static bool SkipComments (const char* pCur,const char** pCurOut);
|
||||
|
||||
private:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
//! Handle the file header and read all element descriptions
|
||||
bool ParseHeader (const char* p_szIn,const char** p_szOut);
|
||||
bool ParseHeader (const char* pCur,const char** pCurOut);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
//! Read in all element instance lists
|
||||
bool ParseElementInstanceLists (const char* p_szIn,const char** p_szOut);
|
||||
bool ParseElementInstanceLists (const char* pCur,const char** pCurOut);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
//! Read in all element instance lists for a binary file format
|
||||
bool ParseElementInstanceListsBinary (const char* p_szIn,
|
||||
const char** p_szOut,bool p_bBE);
|
||||
bool ParseElementInstanceListsBinary (const char* pCur,
|
||||
const char** pCurOut,bool p_bBE);
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
@ -530,7 +471,7 @@ public:
|
|||
|
||||
// ---------------------------------------------------------------------------------
|
||||
template <typename TYPE>
|
||||
TYPE PLY::PropertyInstance::ConvertTo(
|
||||
inline TYPE PLY::PropertyInstance::ConvertTo(
|
||||
PLY::PropertyInstance::ValueUnion v, PLY::EDataType eType)
|
||||
{
|
||||
switch (eType)
|
||||
|
|
|
@ -41,14 +41,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/** @file Implementation of the "PretransformVertices" post processing step
|
||||
*/
|
||||
#include "PretransformVertices.h"
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/aiPostProcess.h"
|
||||
#include "../include/aiMesh.h"
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/aiAssert.h"
|
||||
|
||||
#include <list>
|
||||
#include "AssimpPCH.h"
|
||||
#include "PretransformVertices.h"
|
||||
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
|
|
@ -41,21 +41,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/** @file Implementation of the RAW importer class */
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
// internal headers
|
||||
#include "RawLoader.h"
|
||||
#include "MaterialSystem.h"
|
||||
#include "ParsingUtils.h"
|
||||
#include "fast_atof.h"
|
||||
|
||||
// public assimp headers
|
||||
#include "../include/IOStream.h"
|
||||
#include "../include/IOSystem.h"
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/aiAssert.h"
|
||||
#include "../include/DefaultLogger.h"
|
||||
|
||||
// boost headers
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
@ -91,11 +83,6 @@ bool RAWImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler) const
|
|||
extension[3] != 'w' && extension[3] != 'W');
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
||||
#define AI_RAW_IS_NON_INTEGRAL(sz) \
|
||||
((*sz < '0' || *sz > '9') && *sz != '+' && *sz != '-')
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Imports the given file into the given scene structure.
|
||||
void RAWImporter::InternReadFile( const std::string& pFile,
|
||||
|
@ -129,7 +116,7 @@ void RAWImporter::InternReadFile( const std::string& pFile,
|
|||
// the beginning of a new group
|
||||
const char* sz = line;SkipSpaces(&sz);
|
||||
if (IsLineEnd(*sz))continue;
|
||||
if (AI_RAW_IS_NON_INTEGRAL(sz))
|
||||
if (!IsNumeric(*sz))
|
||||
{
|
||||
const char* sz2 = sz;
|
||||
while (!IsSpaceOrNewLine(*sz2))++sz2;
|
||||
|
@ -158,7 +145,7 @@ void RAWImporter::InternReadFile( const std::string& pFile,
|
|||
unsigned int num;
|
||||
for (num = 0; num < 12;++num)
|
||||
{
|
||||
if(!SkipSpaces(&sz) || AI_RAW_IS_NON_INTEGRAL(sz))break;
|
||||
if(!SkipSpaces(&sz) || !IsNumeric(*sz))break;
|
||||
sz = fast_atof_move(sz,data[num]);
|
||||
}
|
||||
if (num != 12 && num != 9)
|
||||
|
|
|
@ -41,10 +41,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
/** @file Defines a helper class, "CommentRemover", which can be
|
||||
* used to remove comments (single and multi line) from a text file.
|
||||
*/
|
||||
#include "../include/aiTypes.h"
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/aiAssert.h"
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
#include "RemoveComments.h"
|
||||
|
||||
namespace Assimp
|
||||
|
|
|
@ -42,14 +42,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
*/
|
||||
|
||||
// internal headers
|
||||
#include "AssimpPCH.h"
|
||||
#include "RemoveRedundantMaterials.h"
|
||||
#include "MaterialSystem.h"
|
||||
|
||||
// public ASSIMP headers
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/aiPostProcess.h"
|
||||
#include "../include/aiMesh.h"
|
||||
#include "../include/aiScene.h"
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
|
|
@ -41,14 +41,21 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
/** @file Implementation of the post processing step to remove
|
||||
* any parts of the mesh structure from the imported data.
|
||||
*/
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
#include "RemoveVCProcess.h"
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/aiPostProcess.h"
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/aiConfig.h"
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
||||
// MSB for type unsigned int
|
||||
#define AI_RC_UINT_MSB (1u<<((sizeof(unsigned int)<<3u)-1u))
|
||||
#define AI_RC_UINT_MSB_2 (AI_RC_UINT_MSB>>1u)
|
||||
|
||||
// unmask the two upper bits of an unsigned int
|
||||
#define AI_RC_UNMASK(p) (p & (~(AI_RC_UINT_MSB|AI_RC_UINT_MSB_2)))
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor to be privately used by Importer
|
||||
RemoveVCProcess::RemoveVCProcess()
|
||||
|
@ -66,7 +73,94 @@ RemoveVCProcess::~RemoveVCProcess()
|
|||
// Returns whether the processing step is present in the given flag field.
|
||||
bool RemoveVCProcess::IsActive( unsigned int pFlags) const
|
||||
{
|
||||
return (pFlags & aiProcess_RemVertexComponentXYZ) != 0;
|
||||
return (pFlags & aiProcess_RemoveComponent) != 0;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Small helper function to delete all elements in a T** aray using delete
|
||||
template <typename T>
|
||||
inline void ArrayDelete(T**& in, unsigned int num)
|
||||
{
|
||||
for (unsigned int i = 0; i < num; ++i)
|
||||
delete in[i];
|
||||
|
||||
delete[] in;
|
||||
in = NULL;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Small helper function to set a sepcific bit in the aiNode::mNumMeshes member of all nodes
|
||||
// that are referenced by the elements of an array (T::mName must be there)
|
||||
template <typename T>
|
||||
inline void MaskNodes(aiNode* node,T** in, unsigned int num, unsigned int bit)
|
||||
{
|
||||
if (node->mName.length)
|
||||
{
|
||||
for (unsigned int i = 0; i < num;++i)
|
||||
{
|
||||
T* cur = in[i];
|
||||
if (cur->mName == node->mName)
|
||||
{
|
||||
node->mNumMeshes |= bit;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (unsigned int i = 0; i < node->mNumChildren;++i)
|
||||
MaskNodes(node->mChildren[i],in,num,bit);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Updates the node graph - removes all nodes which have the "remove" flag set and the
|
||||
// "don't remove" flag not set. Nodes with meshes are never deleted.
|
||||
bool UpdateNodeGraph(aiNode* node,std::list<aiNode*>& childsOfParent,bool root)
|
||||
{
|
||||
register bool b = false;
|
||||
|
||||
std::list<aiNode*> mine;
|
||||
for (unsigned int i = 0; i < node->mNumChildren;++i)
|
||||
{
|
||||
if(UpdateNodeGraph(node->mChildren[i],mine,false))
|
||||
b = true;
|
||||
}
|
||||
|
||||
if (!root && !node->mNumMeshes && AI_RC_UINT_MSB == (node->mNumMeshes & (AI_RC_UINT_MSB | AI_RC_UINT_MSB_2)))
|
||||
{
|
||||
// this node needs to be removed
|
||||
if(node->mNumChildren)
|
||||
{
|
||||
childsOfParent.insert(childsOfParent.end(),mine.begin(),mine.end());
|
||||
|
||||
// set all children to NULL to make sure they are not deleted when we delete ourself
|
||||
for (unsigned int i = 0; i < node->mNumChildren;++i)
|
||||
node->mChildren[i] = NULL;
|
||||
}
|
||||
b = true;
|
||||
delete node;
|
||||
}
|
||||
else
|
||||
{
|
||||
AI_RC_UNMASK(node->mNumMeshes);
|
||||
childsOfParent.push_back(node);
|
||||
|
||||
if (b)
|
||||
{
|
||||
// reallocate the array of our children here
|
||||
node->mNumChildren = (unsigned int)mine.size();
|
||||
aiNode** const children = new aiNode*[mine.size()];
|
||||
aiNode** ptr = children;
|
||||
|
||||
for (std::list<aiNode*>::iterator it = mine.begin(), end = mine.end();
|
||||
it != end; ++it)
|
||||
{
|
||||
*ptr++ = *it;
|
||||
}
|
||||
delete[] node->mChildren;
|
||||
node->mChildren = children;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -74,16 +168,110 @@ bool RemoveVCProcess::IsActive( unsigned int pFlags) const
|
|||
void RemoveVCProcess::Execute( aiScene* pScene)
|
||||
{
|
||||
DefaultLogger::get()->debug("RemoveVCProcess begin");
|
||||
bool bHas = false,bMasked = false;
|
||||
|
||||
bool bHas = false;
|
||||
for( unsigned int a = 0; a < pScene->mNumMeshes; a++)
|
||||
mScene = pScene;
|
||||
|
||||
// handle animations
|
||||
if ( configDeleteFlags & aiComponent_ANIMATIONS)
|
||||
{
|
||||
if( this->ProcessMesh( pScene->mMeshes[a]))
|
||||
bHas = true;
|
||||
bHas = true;
|
||||
ArrayDelete(pScene->mAnimations,pScene->mNumAnimations);
|
||||
}
|
||||
if (bHas)DefaultLogger::get()->info("RemoveVCProcess finished. The specified vertex components have been removed");
|
||||
else DefaultLogger::get()->debug("RemoveVCProcess finished. There was nothing to do ..");
|
||||
|
||||
// handle textures
|
||||
if ( configDeleteFlags & aiComponent_TEXTURES)
|
||||
{
|
||||
bHas = true;
|
||||
ArrayDelete(pScene->mTextures,pScene->mNumTextures);
|
||||
}
|
||||
#if 0
|
||||
// handle light sources
|
||||
if ( configDeleteFlags & aiComponent_LIGHTS)
|
||||
{
|
||||
// mask nodes for removal
|
||||
MaskNodes(pScene->mRootNode,pScene->mLights,pScene->mNumLights,
|
||||
AI_RC_UINT_MSB);
|
||||
|
||||
bHas = bMasked = true;
|
||||
ArrayDelete(pScene->mLights,pScene->mNumLights);
|
||||
}
|
||||
|
||||
// handle camneras
|
||||
if ( configDeleteFlags & aiComponent_CAMERA)
|
||||
{
|
||||
// mask nodes for removal
|
||||
MaskNodes(pScene->mRootNode,pScene->mLights,pScene->mNumLights,
|
||||
AI_RC_UINT_MSB);
|
||||
|
||||
bHas = true;
|
||||
ArrayDelete(pScene->mCameras,pScene->mNumCameras);
|
||||
}
|
||||
#endif
|
||||
// handle meshes
|
||||
if (configDeleteFlags & aiComponent_MESHES)
|
||||
{
|
||||
bHas = true;
|
||||
ArrayDelete(pScene->mMeshes,pScene->mNumMeshes);
|
||||
pScene->mFlags |= AI_SCENE_FLAGS_ANIM_SKELETON_ONLY;
|
||||
}
|
||||
else
|
||||
{
|
||||
for( unsigned int a = 0; a < pScene->mNumMeshes; a++)
|
||||
{
|
||||
if( this->ProcessMesh( pScene->mMeshes[a]))
|
||||
bHas = true;
|
||||
}
|
||||
if (configDeleteFlags & aiComponent_BONEWEIGHTS && bHas)bMasked = true;
|
||||
}
|
||||
|
||||
// now check which scenegraph nodes are unnecessary now
|
||||
// we use the upper two bits of aiNode::mNumMeshes as
|
||||
// temporary storage.
|
||||
// MSB means: REMOVE ME!
|
||||
// MSB>>1 means: NO, DON'T REMOVE ME (Veto)
|
||||
if (bMasked)
|
||||
{
|
||||
#if 0
|
||||
if (pScene->mNumLights)
|
||||
{
|
||||
MaskNodes(pScene->mRootNode,pScene->mLights,pScene->mNumLights,
|
||||
AI_RC_UINT_MSB_2);
|
||||
}
|
||||
if (pScene->mNumCameras)
|
||||
{
|
||||
MaskNodes(pScene->mRootNode,pScene->mCameras,pScene->mNumCameras,
|
||||
AI_RC_UINT_MSB_2);
|
||||
}
|
||||
#endif
|
||||
if (!(configDeleteFlags & aiComponent_BONEWEIGHTS))
|
||||
{
|
||||
for (unsigned int i = 0; i < pScene->mNumMeshes;++i)
|
||||
{
|
||||
aiMesh* mesh = pScene->mMeshes[i];
|
||||
if (mesh->mNumBones)
|
||||
{
|
||||
MaskNodes(pScene->mRootNode,mesh->mBones,mesh->mNumBones,
|
||||
AI_RC_UINT_MSB_2);
|
||||
}
|
||||
}
|
||||
}
|
||||
std::list<aiNode*> dummy;
|
||||
UpdateNodeGraph(pScene->mRootNode,dummy, true);
|
||||
|
||||
// the root node will neever be deleted
|
||||
}
|
||||
|
||||
// now check whether the result contains
|
||||
// !0 animations (+ the AI_SCENE_FLAGS_ANIM_SKELETON_ONLY flag) OR
|
||||
// !0 meshes
|
||||
if (!pScene->mNumAnimations && !pScene->mNumMeshes)
|
||||
{
|
||||
throw new ImportErrorException("No valid data structure remaining");
|
||||
}
|
||||
|
||||
if (bHas)DefaultLogger::get()->info("RemoveVCProcess finished. Data structure cleanup has been done.");
|
||||
else DefaultLogger::get()->debug("RemoveVCProcess finished. Nothing to be done ...");
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -93,7 +281,7 @@ void RemoveVCProcess::SetupProperties(const Importer* pImp)
|
|||
configDeleteFlags = pImp->GetPropertyInteger(AI_CONFIG_PP_RVC_FLAGS,0x0);
|
||||
if (!configDeleteFlags)
|
||||
{
|
||||
DefaultLogger::get()->warn("RemoveVCProcess: AI_CONFIG_PP_RVC_FLAGS is zero, no streams selected");
|
||||
DefaultLogger::get()->warn("RemoveVCProcess: AI_CONFIG_PP_RVC_FLAGS is zero.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,33 +289,37 @@ void RemoveVCProcess::SetupProperties(const Importer* pImp)
|
|||
// Executes the post processing step on the given imported data.
|
||||
bool RemoveVCProcess::ProcessMesh(aiMesh* pMesh)
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
// handle normals
|
||||
if (configDeleteFlags & aiVertexComponent_NORMALS && pMesh->mNormals)
|
||||
if (configDeleteFlags & aiComponent_NORMALS && pMesh->mNormals)
|
||||
{
|
||||
delete[] pMesh->mNormals;
|
||||
pMesh->mNormals = NULL;
|
||||
ret = true;
|
||||
}
|
||||
|
||||
// handle tangents and bitangents
|
||||
if (configDeleteFlags & aiVertexComponent_TANGENTS_AND_BITANGENTS && pMesh->mTangents)
|
||||
if (configDeleteFlags & aiComponent_TANGENTS_AND_BITANGENTS && pMesh->mTangents)
|
||||
{
|
||||
delete[] pMesh->mTangents;
|
||||
pMesh->mTangents = NULL;
|
||||
|
||||
delete[] pMesh->mBitangents;
|
||||
pMesh->mBitangents = NULL;
|
||||
ret = true;
|
||||
}
|
||||
|
||||
// handle texture coordinates
|
||||
register bool b = (0 != (configDeleteFlags & aiVertexComponent_TEXCOORDS));
|
||||
register bool b = (0 != (configDeleteFlags & aiComponent_TEXCOORDS));
|
||||
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i)
|
||||
{
|
||||
if (!pMesh->mTextureCoords[i])break;
|
||||
if (configDeleteFlags & aiVertexComponent_TEXCOORDSn(i) || b)
|
||||
if (configDeleteFlags & aiComponent_TEXCOORDSn(i) || b)
|
||||
{
|
||||
delete pMesh->mTextureCoords[i];
|
||||
pMesh->mTextureCoords[i] = NULL;
|
||||
ret = true;
|
||||
|
||||
if (!b)
|
||||
{
|
||||
|
@ -143,14 +335,15 @@ bool RemoveVCProcess::ProcessMesh(aiMesh* pMesh)
|
|||
}
|
||||
|
||||
// handle vertex colors
|
||||
b = (0 != (configDeleteFlags & aiVertexComponent_COLORS));
|
||||
b = (0 != (configDeleteFlags & aiComponent_COLORS));
|
||||
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_COLOR_SETS; ++i)
|
||||
{
|
||||
if (!pMesh->mColors[i])break;
|
||||
if (configDeleteFlags & aiVertexComponent_COLORSn(i) || b)
|
||||
if (configDeleteFlags & aiComponent_COLORSn(i) || b)
|
||||
{
|
||||
delete pMesh->mColors[i];
|
||||
pMesh->mColors[i] = NULL;
|
||||
ret = true;
|
||||
|
||||
if (!b)
|
||||
{
|
||||
|
@ -165,5 +358,16 @@ bool RemoveVCProcess::ProcessMesh(aiMesh* pMesh)
|
|||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
// handle bones
|
||||
if (configDeleteFlags & aiComponent_BONEWEIGHTS && pMesh->mBones)
|
||||
{
|
||||
// mask nodes for removal
|
||||
MaskNodes(mScene->mRootNode,pMesh->mBones,pMesh->mNumBones,
|
||||
AI_RC_UINT_MSB);
|
||||
|
||||
ArrayDelete(pMesh->mBones,pMesh->mNumBones);
|
||||
ret = true;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -90,7 +90,13 @@ private:
|
|||
|
||||
bool ProcessMesh (aiMesh* pcMesh);
|
||||
|
||||
/** Configuration
|
||||
*/
|
||||
unsigned int configDeleteFlags;
|
||||
|
||||
/** The scene the instance is currently operating on
|
||||
*/
|
||||
aiScene* mScene;
|
||||
};
|
||||
|
||||
} // end of namespace Assimp
|
||||
|
|
|
@ -43,11 +43,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
vertices close to a given position. Special implementation for
|
||||
the 3ds loader handling smooth groups correctly */
|
||||
|
||||
#include <algorithm>
|
||||
#include "AssimpPCH.h"
|
||||
#include "SGSpatialSort.h"
|
||||
|
||||
#include "../include/aiAssert.h"
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
||||
|
|
|
@ -41,23 +41,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/** @file Implementation of the SMD importer class */
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
// internal headers
|
||||
#include "MaterialSystem.h"
|
||||
#include "SMDLoader.h"
|
||||
#include "StringComparison.h"
|
||||
#include "fast_atof.h"
|
||||
|
||||
// public headers
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/IOStream.h"
|
||||
#include "../include/IOSystem.h"
|
||||
#include "../include/aiMesh.h"
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/aiAssert.h"
|
||||
#include "../include/assimp.hpp"
|
||||
|
||||
// boost headers
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
@ -110,10 +99,10 @@ void SMDImporter::SetupProperties(const Importer* pImp)
|
|||
{
|
||||
// The AI_CONFIG_IMPORT_SMD_KEYFRAME option overrides the
|
||||
// AI_CONFIG_IMPORT_GLOBAL_KEYFRAME option.
|
||||
if(0xffffffff == (this->configFrameID = pImp->GetPropertyInteger(
|
||||
if(0xffffffff == (configFrameID = pImp->GetPropertyInteger(
|
||||
AI_CONFIG_IMPORT_SMD_KEYFRAME,0xffffffff)))
|
||||
{
|
||||
this->configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_GLOBAL_KEYFRAME,0);
|
||||
configFrameID = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_GLOBAL_KEYFRAME,0);
|
||||
}
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -129,92 +118,81 @@ void SMDImporter::InternReadFile(
|
|||
throw new ImportErrorException( "Failed to open SMD/VTA file " + pFile + ".");
|
||||
}
|
||||
|
||||
this->iFileSize = (unsigned int)file->FileSize();
|
||||
iFileSize = (unsigned int)file->FileSize();
|
||||
|
||||
// allocate storage and copy the contents of the file to a memory buffer
|
||||
this->pScene = pScene;
|
||||
this->mBuffer = new char[this->iFileSize+1];
|
||||
file->Read( (void*)mBuffer, 1, this->iFileSize);
|
||||
this->iSmallestFrame = (1 << 31);
|
||||
this->bHasUVs = true;
|
||||
this->iLineNumber = 1;
|
||||
|
||||
// append a terminal 0
|
||||
this->mBuffer[this->iFileSize] = '\0';
|
||||
std::vector<char> buff(iFileSize+1);
|
||||
file->Read( &buff[0], 1, iFileSize);
|
||||
buff[iFileSize] = '\0';
|
||||
mBuffer = &buff[0];
|
||||
|
||||
iSmallestFrame = (1 << 31);
|
||||
bHasUVs = true;
|
||||
iLineNumber = 1;
|
||||
|
||||
// reserve enough space for ... hm ... 10 textures
|
||||
this->aszTextures.reserve(10);
|
||||
aszTextures.reserve(10);
|
||||
|
||||
// reserve enough space for ... hm ... 1000 triangles
|
||||
this->asTriangles.reserve(1000);
|
||||
asTriangles.reserve(1000);
|
||||
|
||||
// reserve enough space for ... hm ... 20 bones
|
||||
this->asBones.reserve(20);
|
||||
asBones.reserve(20);
|
||||
|
||||
try
|
||||
|
||||
// parse the file ...
|
||||
ParseFile();
|
||||
|
||||
// if there are no triangles it seems to be an animation SMD,
|
||||
// containing only the animation skeleton.
|
||||
if (asTriangles.empty())
|
||||
{
|
||||
// parse the file ...
|
||||
this->ParseFile();
|
||||
|
||||
// if there are no triangles it seems to be an animation SMD,
|
||||
// containing only the animation skeleton.
|
||||
if (this->asTriangles.empty())
|
||||
if (asBones.empty())
|
||||
{
|
||||
if (this->asBones.empty())
|
||||
{
|
||||
throw new ImportErrorException("No triangles and no bones have "
|
||||
"been found in the file. This file seems to be invalid.");
|
||||
}
|
||||
// set the flag in the scene structure which indicates
|
||||
// that there is nothing than an animation skeleton
|
||||
pScene->mFlags |= AI_SCENE_FLAGS_ANIM_SKELETON_ONLY;
|
||||
throw new ImportErrorException("SMD: No triangles and no bones have "
|
||||
"been found in the file. This file seems to be invalid.");
|
||||
}
|
||||
|
||||
if (!this->asBones.empty())
|
||||
{
|
||||
// check whether all bones have been initialized
|
||||
for (std::vector<SMD::Bone>::const_iterator
|
||||
i = this->asBones.begin();
|
||||
i != this->asBones.end();++i)
|
||||
{
|
||||
if (!(*i).mName.length())
|
||||
{
|
||||
DefaultLogger::get()->warn("Not all bones have been initialized");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// now fix invalid time values and make sure the animation starts at frame 0
|
||||
this->FixTimeValues();
|
||||
|
||||
// compute absolute bone transformation matrices
|
||||
this->ComputeAbsoluteBoneTransformations();
|
||||
}
|
||||
if (!(pScene->mFlags & AI_SCENE_FLAGS_ANIM_SKELETON_ONLY))
|
||||
{
|
||||
// create output meshes
|
||||
this->CreateOutputMeshes();
|
||||
|
||||
// build an output material list
|
||||
this->CreateOutputMaterials();
|
||||
}
|
||||
|
||||
// build the output animation
|
||||
this->CreateOutputAnimations();
|
||||
|
||||
// build output nodes (bones are added as empty dummy nodes)
|
||||
this->CreateOutputNodes();
|
||||
}
|
||||
catch (ImportErrorException* ex)
|
||||
{
|
||||
delete[] this->mBuffer;
|
||||
AI_DEBUG_INVALIDATE_PTR(this->mBuffer);
|
||||
throw ex;
|
||||
// set the flag in the scene structure which indicates
|
||||
// that there is nothing than an animation skeleton
|
||||
pScene->mFlags |= AI_SCENE_FLAGS_ANIM_SKELETON_ONLY;
|
||||
}
|
||||
|
||||
// delete the file buffer
|
||||
delete[] this->mBuffer;
|
||||
AI_DEBUG_INVALIDATE_PTR(this->mBuffer);
|
||||
if (!asBones.empty())
|
||||
{
|
||||
// check whether all bones have been initialized
|
||||
for (std::vector<SMD::Bone>::const_iterator
|
||||
i = asBones.begin();
|
||||
i != asBones.end();++i)
|
||||
{
|
||||
if (!(*i).mName.length())
|
||||
{
|
||||
DefaultLogger::get()->warn("SMD: Not all bones have been initialized");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// now fix invalid time values and make sure the animation starts at frame 0
|
||||
FixTimeValues();
|
||||
|
||||
// compute absolute bone transformation matrices
|
||||
ComputeAbsoluteBoneTransformations();
|
||||
}
|
||||
if (!(pScene->mFlags & AI_SCENE_FLAGS_ANIM_SKELETON_ONLY))
|
||||
{
|
||||
// create output meshes
|
||||
CreateOutputMeshes();
|
||||
|
||||
// build an output material list
|
||||
CreateOutputMaterials();
|
||||
}
|
||||
|
||||
// build the output animation
|
||||
CreateOutputAnimations();
|
||||
|
||||
// build output nodes (bones are added as empty dummy nodes)
|
||||
CreateOutputNodes();
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Write an error message with line number to the log file
|
||||
|
@ -223,10 +201,10 @@ void SMDImporter::LogErrorNoThrow(const char* msg)
|
|||
char szTemp[1024];
|
||||
|
||||
#if _MSC_VER >= 1400
|
||||
sprintf_s(szTemp,"Line %i: %s",this->iLineNumber,msg);
|
||||
sprintf_s(szTemp,"Line %i: %s",iLineNumber,msg);
|
||||
#else
|
||||
ai_assert(strlen(msg) < 1000);
|
||||
sprintf(szTemp,"Line %i: %s",this->iLineNumber,msg);
|
||||
sprintf(szTemp,"Line %i: %s",iLineNumber,msg);
|
||||
#endif
|
||||
|
||||
DefaultLogger::get()->error(szTemp);
|
||||
|
@ -238,10 +216,10 @@ void SMDImporter::LogWarning(const char* msg)
|
|||
char szTemp[1024];
|
||||
|
||||
#if _MSC_VER >= 1400
|
||||
sprintf_s(szTemp,"Line %i: %s",this->iLineNumber,msg);
|
||||
sprintf_s(szTemp,"Line %i: %s",iLineNumber,msg);
|
||||
#else
|
||||
ai_assert(strlen(msg) < 1000);
|
||||
sprintf(szTemp,"Line %i: %s",this->iLineNumber,msg);
|
||||
sprintf(szTemp,"Line %i: %s",iLineNumber,msg);
|
||||
#endif
|
||||
DefaultLogger::get()->warn(szTemp);
|
||||
}
|
||||
|
@ -249,11 +227,11 @@ void SMDImporter::LogWarning(const char* msg)
|
|||
// Fix invalid time values in the file
|
||||
void SMDImporter::FixTimeValues()
|
||||
{
|
||||
double dDelta = (double)this->iSmallestFrame;
|
||||
double dDelta = (double)iSmallestFrame;
|
||||
double dMax = 0.0f;
|
||||
for (std::vector<SMD::Bone>::iterator
|
||||
iBone = this->asBones.begin();
|
||||
iBone != this->asBones.end();++iBone)
|
||||
iBone = asBones.begin();
|
||||
iBone != asBones.end();++iBone)
|
||||
{
|
||||
for (std::vector<SMD::Bone::Animation::MatrixKey>::iterator
|
||||
iKey = (*iBone).sAnim.asKeys.begin();
|
||||
|
@ -263,7 +241,7 @@ void SMDImporter::FixTimeValues()
|
|||
dMax = std::max(dMax, (*iKey).dTime);
|
||||
}
|
||||
}
|
||||
this->dLengthOfAnim = dMax;
|
||||
dLengthOfAnim = dMax;
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// create output meshes
|
||||
|
@ -272,16 +250,16 @@ void SMDImporter::CreateOutputMeshes()
|
|||
// we need to sort all faces by their material index
|
||||
// in opposition to other loaders we can be sure that each
|
||||
// material is at least used once.
|
||||
this->pScene->mNumMeshes = (unsigned int) this->aszTextures.size();
|
||||
this->pScene->mMeshes = new aiMesh*[this->pScene->mNumMeshes];
|
||||
pScene->mNumMeshes = (unsigned int) aszTextures.size();
|
||||
pScene->mMeshes = new aiMesh*[pScene->mNumMeshes];
|
||||
|
||||
typedef std::vector<unsigned int> FaceList;
|
||||
FaceList* aaiFaces = new FaceList[this->pScene->mNumMeshes];
|
||||
FaceList* aaiFaces = new FaceList[pScene->mNumMeshes];
|
||||
|
||||
// approximate the space that will be required
|
||||
unsigned int iNum = (unsigned int)this->asTriangles.size() / this->pScene->mNumMeshes;
|
||||
unsigned int iNum = (unsigned int)asTriangles.size() / pScene->mNumMeshes;
|
||||
iNum += iNum >> 1;
|
||||
for (unsigned int i = 0; i < this->pScene->mNumMeshes;++i)
|
||||
for (unsigned int i = 0; i < pScene->mNumMeshes;++i)
|
||||
{
|
||||
aaiFaces[i].reserve(iNum);
|
||||
}
|
||||
|
@ -289,22 +267,22 @@ void SMDImporter::CreateOutputMeshes()
|
|||
// collect all faces
|
||||
iNum = 0;
|
||||
for (std::vector<SMD::Face>::const_iterator
|
||||
iFace = this->asTriangles.begin();
|
||||
iFace != this->asTriangles.end();++iFace,++iNum)
|
||||
iFace = asTriangles.begin();
|
||||
iFace != asTriangles.end();++iFace,++iNum)
|
||||
{
|
||||
if (0xffffffff == (*iFace).iTexture)aaiFaces[(*iFace).iTexture].push_back( 0 );
|
||||
else if ((*iFace).iTexture >= this->aszTextures.size())
|
||||
else if ((*iFace).iTexture >= aszTextures.size())
|
||||
{
|
||||
DefaultLogger::get()->error("[SMD/VTA] Material index overflow in face");
|
||||
aaiFaces[(*iFace).iTexture].push_back((unsigned int)this->aszTextures.size()-1);
|
||||
aaiFaces[(*iFace).iTexture].push_back((unsigned int)aszTextures.size()-1);
|
||||
}
|
||||
else aaiFaces[(*iFace).iTexture].push_back(iNum);
|
||||
}
|
||||
|
||||
// now create the output meshes
|
||||
for (unsigned int i = 0; i < this->pScene->mNumMeshes;++i)
|
||||
for (unsigned int i = 0; i < pScene->mNumMeshes;++i)
|
||||
{
|
||||
aiMesh*& pcMesh = this->pScene->mMeshes[i] = new aiMesh();
|
||||
aiMesh*& pcMesh = pScene->mMeshes[i] = new aiMesh();
|
||||
ai_assert(!aaiFaces[i].empty()); // should not be empty ...
|
||||
|
||||
pcMesh->mPrimitiveTypes = aiPrimitiveType_TRIANGLE;
|
||||
|
@ -316,12 +294,12 @@ void SMDImporter::CreateOutputMeshes()
|
|||
typedef std::pair<unsigned int,float> TempWeightListEntry;
|
||||
typedef std::vector< TempWeightListEntry > TempBoneWeightList;
|
||||
|
||||
TempBoneWeightList* aaiBones = new TempBoneWeightList[this->asBones.size()]();
|
||||
TempBoneWeightList* aaiBones = new TempBoneWeightList[asBones.size()]();
|
||||
|
||||
// try to reserve enough memory without wasting too much
|
||||
for (unsigned int iBone = 0; iBone < this->asBones.size();++iBone)
|
||||
for (unsigned int iBone = 0; iBone < asBones.size();++iBone)
|
||||
{
|
||||
aaiBones[iBone].reserve(pcMesh->mNumVertices/this->asBones.size());
|
||||
aaiBones[iBone].reserve(pcMesh->mNumVertices/asBones.size());
|
||||
}
|
||||
|
||||
// allocate storage
|
||||
|
@ -330,7 +308,7 @@ void SMDImporter::CreateOutputMeshes()
|
|||
aiVector3D* pcVerts = pcMesh->mVertices = new aiVector3D[pcMesh->mNumVertices];
|
||||
|
||||
aiVector3D* pcUVs = NULL;
|
||||
if (this->bHasUVs)
|
||||
if (bHasUVs)
|
||||
{
|
||||
pcUVs = pcMesh->mTextureCoords[0] = new aiVector3D[pcMesh->mNumVertices];
|
||||
pcMesh->mNumUVComponents[0] = 2;
|
||||
|
@ -344,7 +322,7 @@ void SMDImporter::CreateOutputMeshes()
|
|||
|
||||
// fill the vertices
|
||||
unsigned int iSrcFace = aaiFaces[i][iFace];
|
||||
SMD::Face& face = this->asTriangles[iSrcFace];
|
||||
SMD::Face& face = asTriangles[iSrcFace];
|
||||
|
||||
*pcVerts++ = face.avVertices[0].pos;
|
||||
*pcVerts++ = face.avVertices[1].pos;
|
||||
|
@ -369,7 +347,7 @@ void SMDImporter::CreateOutputMeshes()
|
|||
for (unsigned int iBone = 0;iBone < face.avVertices[iVert].aiBoneLinks.size();++iBone)
|
||||
{
|
||||
TempWeightListEntry& pairval = face.avVertices[iVert].aiBoneLinks[iBone];
|
||||
if (pairval.first >= this->asBones.size())
|
||||
if (pairval.first >= asBones.size())
|
||||
{
|
||||
DefaultLogger::get()->error("[SMD/VTA] Bone index overflow. "
|
||||
"The bone index will be ignored, the weight will be assigned "
|
||||
|
@ -384,7 +362,7 @@ void SMDImporter::CreateOutputMeshes()
|
|||
// we should ...
|
||||
if (fSum <= 1.0f)
|
||||
{
|
||||
if (face.avVertices[iVert].iParentNode >= this->asBones.size())
|
||||
if (face.avVertices[iVert].iParentNode >= asBones.size())
|
||||
{
|
||||
DefaultLogger::get()->error("[SMD/VTA] Bone index overflow. "
|
||||
"The index of the vertex parent bone is invalid. "
|
||||
|
@ -396,7 +374,7 @@ void SMDImporter::CreateOutputMeshes()
|
|||
for (unsigned int iBone = 0;iBone < face.avVertices[iVert].aiBoneLinks.size();++iBone)
|
||||
{
|
||||
TempWeightListEntry& pairval = face.avVertices[iVert].aiBoneLinks[iBone];
|
||||
if (pairval.first >= this->asBones.size())continue;
|
||||
if (pairval.first >= asBones.size())continue;
|
||||
aaiBones[pairval.first].back().second *= fSum;
|
||||
}
|
||||
}
|
||||
|
@ -414,24 +392,24 @@ void SMDImporter::CreateOutputMeshes()
|
|||
|
||||
// now build all bones of the mesh
|
||||
iNum = 0;
|
||||
for (unsigned int iBone = 0; iBone < this->asBones.size();++iBone)
|
||||
for (unsigned int iBone = 0; iBone < asBones.size();++iBone)
|
||||
{
|
||||
if (!aaiBones[iBone].empty())++iNum;
|
||||
}
|
||||
pcMesh->mNumBones = iNum;
|
||||
pcMesh->mBones = new aiBone*[pcMesh->mNumBones];
|
||||
iNum = 0;
|
||||
for (unsigned int iBone = 0; iBone < this->asBones.size();++iBone)
|
||||
for (unsigned int iBone = 0; iBone < asBones.size();++iBone)
|
||||
{
|
||||
if (aaiBones[iBone].empty())continue;
|
||||
aiBone*& bone = pcMesh->mBones[iNum] = new aiBone();
|
||||
|
||||
bone->mNumWeights = (unsigned int)aaiBones[iBone].size();
|
||||
bone->mWeights = new aiVertexWeight[bone->mNumWeights];
|
||||
bone->mOffsetMatrix = this->asBones[iBone].mOffsetMatrix;
|
||||
bone->mName.Set( this->asBones[iBone].mName );
|
||||
bone->mOffsetMatrix = asBones[iBone].mOffsetMatrix;
|
||||
bone->mName.Set( asBones[iBone].mName );
|
||||
|
||||
this->asBones[iBone].bIsUsed = true;
|
||||
asBones[iBone].bIsUsed = true;
|
||||
|
||||
for (unsigned int iWeight = 0; iWeight < bone->mNumWeights;++iWeight)
|
||||
{
|
||||
|
@ -452,9 +430,9 @@ void SMDImporter::AddBoneChildren(aiNode* pcNode, uint32_t iParent)
|
|||
ai_assert(NULL != pcNode && 0 == pcNode->mNumChildren && NULL == pcNode->mChildren);
|
||||
|
||||
// first count ...
|
||||
for (unsigned int i = 0; i < this->asBones.size();++i)
|
||||
for (unsigned int i = 0; i < asBones.size();++i)
|
||||
{
|
||||
SMD::Bone& bone = this->asBones[i];
|
||||
SMD::Bone& bone = asBones[i];
|
||||
if (bone.iParent == iParent)++pcNode->mNumChildren;
|
||||
}
|
||||
|
||||
|
@ -463,9 +441,9 @@ void SMDImporter::AddBoneChildren(aiNode* pcNode, uint32_t iParent)
|
|||
|
||||
// and fill all subnodes
|
||||
unsigned int qq = 0;
|
||||
for (unsigned int i = 0; i < this->asBones.size();++i)
|
||||
for (unsigned int i = 0; i < asBones.size();++i)
|
||||
{
|
||||
SMD::Bone& bone = this->asBones[i];
|
||||
SMD::Bone& bone = asBones[i];
|
||||
if (bone.iParent != iParent)continue;
|
||||
|
||||
aiNode* pc = pcNode->mChildren[qq++] = new aiNode();
|
||||
|
@ -483,34 +461,34 @@ void SMDImporter::AddBoneChildren(aiNode* pcNode, uint32_t iParent)
|
|||
// create output nodes
|
||||
void SMDImporter::CreateOutputNodes()
|
||||
{
|
||||
this->pScene->mRootNode = new aiNode();
|
||||
if (!(this->pScene->mFlags & AI_SCENE_FLAGS_ANIM_SKELETON_ONLY))
|
||||
pScene->mRootNode = new aiNode();
|
||||
if (!(pScene->mFlags & AI_SCENE_FLAGS_ANIM_SKELETON_ONLY))
|
||||
{
|
||||
// create one root node that renders all meshes
|
||||
this->pScene->mRootNode->mNumMeshes = this->pScene->mNumMeshes;
|
||||
this->pScene->mRootNode->mMeshes = new unsigned int[this->pScene->mNumMeshes];
|
||||
for (unsigned int i = 0; i < this->pScene->mNumMeshes;++i)
|
||||
this->pScene->mRootNode->mMeshes[i] = i;
|
||||
pScene->mRootNode->mNumMeshes = pScene->mNumMeshes;
|
||||
pScene->mRootNode->mMeshes = new unsigned int[pScene->mNumMeshes];
|
||||
for (unsigned int i = 0; i < pScene->mNumMeshes;++i)
|
||||
pScene->mRootNode->mMeshes[i] = i;
|
||||
}
|
||||
|
||||
// now add all bones as dummy sub nodes to the graph
|
||||
this->AddBoneChildren(this->pScene->mRootNode,(uint32_t)-1);
|
||||
AddBoneChildren(pScene->mRootNode,(uint32_t)-1);
|
||||
|
||||
// if we have only one bone we can even remove the root node
|
||||
if (this->pScene->mFlags & AI_SCENE_FLAGS_ANIM_SKELETON_ONLY &&
|
||||
1 == this->pScene->mRootNode->mNumChildren)
|
||||
if (pScene->mFlags & AI_SCENE_FLAGS_ANIM_SKELETON_ONLY &&
|
||||
1 == pScene->mRootNode->mNumChildren)
|
||||
{
|
||||
aiNode* pcOldRoot = this->pScene->mRootNode;
|
||||
this->pScene->mRootNode = pcOldRoot->mChildren[0];
|
||||
aiNode* pcOldRoot = pScene->mRootNode;
|
||||
pScene->mRootNode = pcOldRoot->mChildren[0];
|
||||
pcOldRoot->mChildren[0] = NULL;
|
||||
delete pcOldRoot;
|
||||
|
||||
this->pScene->mRootNode->mParent = NULL;
|
||||
pScene->mRootNode->mParent = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
::strcpy(this->pScene->mRootNode->mName.data, "<SMD_root>");
|
||||
this->pScene->mRootNode->mName.length = 10;
|
||||
::strcpy(pScene->mRootNode->mName.data, "<SMD_root>");
|
||||
pScene->mRootNode->mName.length = 10;
|
||||
}
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -519,8 +497,8 @@ void SMDImporter::CreateOutputAnimations()
|
|||
{
|
||||
unsigned int iNumBones = 0;
|
||||
for (std::vector<SMD::Bone>::const_iterator
|
||||
i = this->asBones.begin();
|
||||
i != this->asBones.end();++i)
|
||||
i = asBones.begin();
|
||||
i != asBones.end();++i)
|
||||
{
|
||||
if ((*i).bIsUsed)++iNumBones;
|
||||
}
|
||||
|
@ -531,11 +509,11 @@ void SMDImporter::CreateOutputAnimations()
|
|||
return;
|
||||
}
|
||||
|
||||
this->pScene->mNumAnimations = 1;
|
||||
this->pScene->mAnimations = new aiAnimation*[1];
|
||||
aiAnimation*& anim = this->pScene->mAnimations[0] = new aiAnimation();
|
||||
pScene->mNumAnimations = 1;
|
||||
pScene->mAnimations = new aiAnimation*[1];
|
||||
aiAnimation*& anim = pScene->mAnimations[0] = new aiAnimation();
|
||||
|
||||
anim->mDuration = this->dLengthOfAnim;
|
||||
anim->mDuration = dLengthOfAnim;
|
||||
anim->mNumChannels = iNumBones;
|
||||
anim->mTicksPerSecond = 25.0; // FIXME: is this correct?
|
||||
|
||||
|
@ -544,8 +522,8 @@ void SMDImporter::CreateOutputAnimations()
|
|||
// now build valid keys
|
||||
unsigned int a = 0;
|
||||
for (std::vector<SMD::Bone>::const_iterator
|
||||
i = this->asBones.begin();
|
||||
i != this->asBones.end();++i)
|
||||
i = asBones.begin();
|
||||
i != asBones.end();++i)
|
||||
{
|
||||
if (!(*i).bIsUsed)continue;
|
||||
|
||||
|
@ -585,9 +563,9 @@ void SMDImporter::ComputeAbsoluteBoneTransformations()
|
|||
// for each bone: determine the key with the lowest time value
|
||||
// theoretically the SMD format should have all keyframes
|
||||
// in order. However, I've seen a file where this wasn't true.
|
||||
for (unsigned int i = 0; i < this->asBones.size();++i)
|
||||
for (unsigned int i = 0; i < asBones.size();++i)
|
||||
{
|
||||
SMD::Bone& bone = this->asBones[i];
|
||||
SMD::Bone& bone = asBones[i];
|
||||
|
||||
uint32_t iIndex = 0;
|
||||
double dMin = 10e10;
|
||||
|
@ -604,15 +582,15 @@ void SMDImporter::ComputeAbsoluteBoneTransformations()
|
|||
}
|
||||
|
||||
unsigned int iParent = 0;
|
||||
while (iParent < this->asBones.size())
|
||||
while (iParent < asBones.size())
|
||||
{
|
||||
for (unsigned int iBone = 0; iBone < this->asBones.size();++iBone)
|
||||
for (unsigned int iBone = 0; iBone < asBones.size();++iBone)
|
||||
{
|
||||
SMD::Bone& bone = this->asBones[iBone];
|
||||
SMD::Bone& bone = asBones[iBone];
|
||||
|
||||
if (iParent == bone.iParent)
|
||||
{
|
||||
SMD::Bone& parentBone = this->asBones[iParent];
|
||||
SMD::Bone& parentBone = asBones[iParent];
|
||||
|
||||
|
||||
uint32_t iIndex = bone.sAnim.iFirstTimeKey;
|
||||
|
@ -632,9 +610,9 @@ void SMDImporter::ComputeAbsoluteBoneTransformations()
|
|||
|
||||
// store the inverse of the absolute transformation matrix
|
||||
// of the first key as bone offset matrix
|
||||
for (iParent = 0; iParent < this->asBones.size();++iParent)
|
||||
for (iParent = 0; iParent < asBones.size();++iParent)
|
||||
{
|
||||
SMD::Bone& bone = this->asBones[iParent];
|
||||
SMD::Bone& bone = asBones[iParent];
|
||||
aiMatrix4x4& mat = bone.sAnim.asKeys[bone.sAnim.iFirstTimeKey].matrixAbsolute;
|
||||
bone.mOffsetMatrix = mat;
|
||||
bone.mOffsetMatrix.Inverse();
|
||||
|
@ -644,13 +622,13 @@ void SMDImporter::ComputeAbsoluteBoneTransformations()
|
|||
// create output materials
|
||||
void SMDImporter::CreateOutputMaterials()
|
||||
{
|
||||
this->pScene->mNumMaterials = (unsigned int)this->aszTextures.size();
|
||||
this->pScene->mMaterials = new aiMaterial*[std::max(1u, this->pScene->mNumMaterials)];
|
||||
pScene->mNumMaterials = (unsigned int)aszTextures.size();
|
||||
pScene->mMaterials = new aiMaterial*[std::max(1u, pScene->mNumMaterials)];
|
||||
|
||||
for (unsigned int iMat = 0; iMat < this->pScene->mNumMaterials;++iMat)
|
||||
for (unsigned int iMat = 0; iMat < pScene->mNumMaterials;++iMat)
|
||||
{
|
||||
MaterialHelper* pcMat = new MaterialHelper();
|
||||
this->pScene->mMaterials[iMat] = pcMat;
|
||||
pScene->mMaterials[iMat] = pcMat;
|
||||
|
||||
aiString szName;
|
||||
#if _MSC_VER >= 1400
|
||||
|
@ -660,18 +638,18 @@ void SMDImporter::CreateOutputMaterials()
|
|||
#endif
|
||||
pcMat->AddProperty(&szName,AI_MATKEY_NAME);
|
||||
|
||||
::strcpy(szName.data, this->aszTextures[iMat].c_str() );
|
||||
szName.length = this->aszTextures[iMat].length();
|
||||
::strcpy(szName.data, aszTextures[iMat].c_str() );
|
||||
szName.length = aszTextures[iMat].length();
|
||||
pcMat->AddProperty(&szName,AI_MATKEY_TEXTURE_DIFFUSE(0));
|
||||
}
|
||||
|
||||
// create a default material if necessary
|
||||
if (0 == this->pScene->mNumMaterials)
|
||||
if (0 == pScene->mNumMaterials)
|
||||
{
|
||||
this->pScene->mNumMaterials = 1;
|
||||
pScene->mNumMaterials = 1;
|
||||
|
||||
MaterialHelper* pcHelper = new MaterialHelper();
|
||||
this->pScene->mMaterials[0] = pcHelper;
|
||||
pScene->mMaterials[0] = pcHelper;
|
||||
|
||||
int iMode = (int)aiShadingMode_Gouraud;
|
||||
pcHelper->AddProperty<int>(&iMode, 1, AI_MATKEY_SHADING_MODEL);
|
||||
|
@ -693,7 +671,7 @@ void SMDImporter::CreateOutputMaterials()
|
|||
// Parse the file
|
||||
void SMDImporter::ParseFile()
|
||||
{
|
||||
const char* szCurrent = this->mBuffer;
|
||||
const char* szCurrent = mBuffer;
|
||||
|
||||
// read line per line ...
|
||||
while (true)
|
||||
|
@ -718,7 +696,7 @@ void SMDImporter::ParseFile()
|
|||
IsSpaceOrNewLine(*(szCurrent+5)))
|
||||
{
|
||||
szCurrent += 6;
|
||||
this->ParseNodesSection(szCurrent,&szCurrent);
|
||||
ParseNodesSection(szCurrent,&szCurrent);
|
||||
continue;
|
||||
}
|
||||
// "triangles\n" - Starts the triangle section
|
||||
|
@ -726,16 +704,16 @@ void SMDImporter::ParseFile()
|
|||
IsSpaceOrNewLine(*(szCurrent+9)))
|
||||
{
|
||||
szCurrent += 10;
|
||||
this->ParseTrianglesSection(szCurrent,&szCurrent);
|
||||
ParseTrianglesSection(szCurrent,&szCurrent);
|
||||
continue;
|
||||
}
|
||||
// "vertexanimation\n" - Starts the vertex animation section
|
||||
if (0 == ASSIMP_strincmp(szCurrent,"vertexanimation",15) &&
|
||||
IsSpaceOrNewLine(*(szCurrent+15)))
|
||||
{
|
||||
this->bHasUVs = false;
|
||||
bHasUVs = false;
|
||||
szCurrent += 16;
|
||||
this->ParseVASection(szCurrent,&szCurrent);
|
||||
ParseVASection(szCurrent,&szCurrent);
|
||||
continue;
|
||||
}
|
||||
// "skeleton\n" - Starts the skeleton section
|
||||
|
@ -743,7 +721,7 @@ void SMDImporter::ParseFile()
|
|||
IsSpaceOrNewLine(*(szCurrent+8)))
|
||||
{
|
||||
szCurrent += 9;
|
||||
this->ParseSkeletonSection(szCurrent,&szCurrent);
|
||||
ParseSkeletonSection(szCurrent,&szCurrent);
|
||||
continue;
|
||||
}
|
||||
SkipLine(szCurrent,&szCurrent);
|
||||
|
@ -755,14 +733,14 @@ unsigned int SMDImporter::GetTextureIndex(const std::string& filename)
|
|||
{
|
||||
unsigned int iIndex = 0;
|
||||
for (std::vector<std::string>::const_iterator
|
||||
i = this->aszTextures.begin();
|
||||
i != this->aszTextures.end();++i,++iIndex)
|
||||
i = aszTextures.begin();
|
||||
i != aszTextures.end();++i,++iIndex)
|
||||
{
|
||||
// case-insensitive ... just for safety
|
||||
if (0 == ASSIMP_stricmp ( filename.c_str(),(*i).c_str()))return iIndex;
|
||||
}
|
||||
iIndex = (unsigned int)this->aszTextures.size();
|
||||
this->aszTextures.push_back(filename);
|
||||
iIndex = (unsigned int)aszTextures.size();
|
||||
aszTextures.push_back(filename);
|
||||
return iIndex;
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -779,7 +757,7 @@ void SMDImporter::ParseNodesSection(const char* szCurrent,
|
|||
szCurrent += 4;
|
||||
break;
|
||||
}
|
||||
this->ParseNodeInfo(szCurrent,&szCurrent);
|
||||
ParseNodeInfo(szCurrent,&szCurrent);
|
||||
}
|
||||
SkipSpacesAndLineEnd(szCurrent,&szCurrent);
|
||||
*szCurrentOut = szCurrent;
|
||||
|
@ -802,7 +780,7 @@ void SMDImporter::ParseTrianglesSection(const char* szCurrent,
|
|||
szCurrent += 4;
|
||||
break;
|
||||
}
|
||||
this->ParseTriangle(szCurrent,&szCurrent);
|
||||
ParseTriangle(szCurrent,&szCurrent);
|
||||
}
|
||||
SkipSpacesAndLineEnd(szCurrent,&szCurrent);
|
||||
*szCurrentOut = szCurrent;
|
||||
|
@ -833,15 +811,15 @@ void SMDImporter::ParseVASection(const char* szCurrent,
|
|||
// NOTE: The doc says that time values COULD be negative ...
|
||||
// note2: this is the shape key -> valve docs
|
||||
int iTime = 0;
|
||||
if(!this->ParseSignedInt(szCurrent,&szCurrent,iTime) || this->configFrameID != (unsigned int)iTime)break;
|
||||
if(!ParseSignedInt(szCurrent,&szCurrent,iTime) || configFrameID != (unsigned int)iTime)break;
|
||||
SkipLine(szCurrent,&szCurrent);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ParseVertex(szCurrent,&szCurrent,this->asTriangles.back().avVertices[iCurIndex],true);
|
||||
ParseVertex(szCurrent,&szCurrent,asTriangles.back().avVertices[iCurIndex],true);
|
||||
if(3 == ++iCurIndex)
|
||||
{
|
||||
this->asTriangles.push_back(SMD::Face());
|
||||
asTriangles.push_back(SMD::Face());
|
||||
iCurIndex = 0;
|
||||
}
|
||||
}
|
||||
|
@ -850,7 +828,7 @@ void SMDImporter::ParseVASection(const char* szCurrent,
|
|||
if (iCurIndex)
|
||||
{
|
||||
// no degenerates, so let this triangle
|
||||
this->aszTextures.pop_back();
|
||||
aszTextures.pop_back();
|
||||
}
|
||||
|
||||
SkipSpacesAndLineEnd(szCurrent,&szCurrent);
|
||||
|
@ -880,12 +858,12 @@ void SMDImporter::ParseSkeletonSection(const char* szCurrent,
|
|||
{
|
||||
szCurrent += 5;
|
||||
// NOTE: The doc says that time values COULD be negative ...
|
||||
if(!this->ParseSignedInt(szCurrent,&szCurrent,iTime))break;
|
||||
if(!ParseSignedInt(szCurrent,&szCurrent,iTime))break;
|
||||
|
||||
this->iSmallestFrame = std::min(this->iSmallestFrame,iTime);
|
||||
iSmallestFrame = std::min(iSmallestFrame,iTime);
|
||||
SkipLine(szCurrent,&szCurrent);
|
||||
}
|
||||
else this->ParseSkeletonElement(szCurrent,&szCurrent,iTime);
|
||||
else ParseSkeletonElement(szCurrent,&szCurrent,iTime);
|
||||
}
|
||||
*szCurrentOut = szCurrent;
|
||||
}
|
||||
|
@ -903,19 +881,19 @@ void SMDImporter::ParseNodeInfo(const char* szCurrent,
|
|||
{
|
||||
unsigned int iBone = 0;
|
||||
SkipSpacesAndLineEnd(szCurrent,&szCurrent);
|
||||
if(!this->ParseUnsignedInt(szCurrent,&szCurrent,iBone) || !SkipSpaces(szCurrent,&szCurrent))
|
||||
if(!ParseUnsignedInt(szCurrent,&szCurrent,iBone) || !SkipSpaces(szCurrent,&szCurrent))
|
||||
{
|
||||
this->LogErrorNoThrow("Unexpected EOF/EOL while parsing bone index");
|
||||
LogErrorNoThrow("Unexpected EOF/EOL while parsing bone index");
|
||||
SMDI_PARSE_RETURN;
|
||||
}
|
||||
// add our bone to the list
|
||||
if (iBone >= this->asBones.size())this->asBones.resize(iBone+1);
|
||||
SMD::Bone& bone = this->asBones[iBone];
|
||||
if (iBone >= asBones.size())asBones.resize(iBone+1);
|
||||
SMD::Bone& bone = asBones[iBone];
|
||||
|
||||
bool bQuota = true;
|
||||
if ('\"' != *szCurrent)
|
||||
{
|
||||
this->LogWarning("Bone name is expcted to be enclosed in "
|
||||
LogWarning("Bone name is expcted to be enclosed in "
|
||||
"double quotation marks. ");
|
||||
bQuota = false;
|
||||
}
|
||||
|
@ -937,7 +915,7 @@ void SMDImporter::ParseNodeInfo(const char* szCurrent,
|
|||
}
|
||||
else if (!(*szEnd))
|
||||
{
|
||||
this->LogErrorNoThrow("Unexpected EOF/EOL while parsing bone name");
|
||||
LogErrorNoThrow("Unexpected EOF/EOL while parsing bone name");
|
||||
SMDI_PARSE_RETURN;
|
||||
}
|
||||
++szEnd;
|
||||
|
@ -946,9 +924,9 @@ void SMDImporter::ParseNodeInfo(const char* szCurrent,
|
|||
szCurrent = szEnd;
|
||||
|
||||
// the only negative bone parent index that could occur is -1 AFAIK
|
||||
if(!this->ParseSignedInt(szCurrent,&szCurrent,(int&)bone.iParent))
|
||||
if(!ParseSignedInt(szCurrent,&szCurrent,(int&)bone.iParent))
|
||||
{
|
||||
this->LogErrorNoThrow("Unexpected EOF/EOL while parsing bone parent index. Assuming -1");
|
||||
LogErrorNoThrow("Unexpected EOF/EOL while parsing bone parent index. Assuming -1");
|
||||
SMDI_PARSE_RETURN;
|
||||
}
|
||||
|
||||
|
@ -964,50 +942,50 @@ void SMDImporter::ParseSkeletonElement(const char* szCurrent,
|
|||
aiVector3D vRot;
|
||||
|
||||
unsigned int iBone = 0;
|
||||
if(!this->ParseUnsignedInt(szCurrent,&szCurrent,iBone))
|
||||
if(!ParseUnsignedInt(szCurrent,&szCurrent,iBone))
|
||||
{
|
||||
DefaultLogger::get()->error("Unexpected EOF/EOL while parsing bone index");
|
||||
SMDI_PARSE_RETURN;
|
||||
}
|
||||
if (iBone >= this->asBones.size())
|
||||
if (iBone >= asBones.size())
|
||||
{
|
||||
this->LogErrorNoThrow("Bone index in skeleton section is out of range");
|
||||
LogErrorNoThrow("Bone index in skeleton section is out of range");
|
||||
SMDI_PARSE_RETURN;
|
||||
}
|
||||
SMD::Bone& bone = this->asBones[iBone];
|
||||
SMD::Bone& bone = asBones[iBone];
|
||||
|
||||
bone.sAnim.asKeys.push_back(SMD::Bone::Animation::MatrixKey());
|
||||
SMD::Bone::Animation::MatrixKey& key = bone.sAnim.asKeys.back();
|
||||
|
||||
key.dTime = (double)iTime;
|
||||
if(!this->ParseFloat(szCurrent,&szCurrent,(float&)vPos.x))
|
||||
if(!ParseFloat(szCurrent,&szCurrent,(float&)vPos.x))
|
||||
{
|
||||
this->LogErrorNoThrow("Unexpected EOF/EOL while parsing bone.pos.x");
|
||||
LogErrorNoThrow("Unexpected EOF/EOL while parsing bone.pos.x");
|
||||
SMDI_PARSE_RETURN;
|
||||
}
|
||||
if(!this->ParseFloat(szCurrent,&szCurrent,(float&)vPos.y))
|
||||
if(!ParseFloat(szCurrent,&szCurrent,(float&)vPos.y))
|
||||
{
|
||||
this->LogErrorNoThrow("Unexpected EOF/EOL while parsing bone.pos.y");
|
||||
LogErrorNoThrow("Unexpected EOF/EOL while parsing bone.pos.y");
|
||||
SMDI_PARSE_RETURN;
|
||||
}
|
||||
if(!this->ParseFloat(szCurrent,&szCurrent,(float&)vPos.z))
|
||||
if(!ParseFloat(szCurrent,&szCurrent,(float&)vPos.z))
|
||||
{
|
||||
this->LogErrorNoThrow("Unexpected EOF/EOL while parsing bone.pos.z");
|
||||
LogErrorNoThrow("Unexpected EOF/EOL while parsing bone.pos.z");
|
||||
SMDI_PARSE_RETURN;
|
||||
}
|
||||
if(!this->ParseFloat(szCurrent,&szCurrent,(float&)vRot.x))
|
||||
if(!ParseFloat(szCurrent,&szCurrent,(float&)vRot.x))
|
||||
{
|
||||
this->LogErrorNoThrow("Unexpected EOF/EOL while parsing bone.rot.x");
|
||||
LogErrorNoThrow("Unexpected EOF/EOL while parsing bone.rot.x");
|
||||
SMDI_PARSE_RETURN;
|
||||
}
|
||||
if(!this->ParseFloat(szCurrent,&szCurrent,(float&)vRot.y))
|
||||
if(!ParseFloat(szCurrent,&szCurrent,(float&)vRot.y))
|
||||
{
|
||||
this->LogErrorNoThrow("Unexpected EOF/EOL while parsing bone.rot.y");
|
||||
LogErrorNoThrow("Unexpected EOF/EOL while parsing bone.rot.y");
|
||||
SMDI_PARSE_RETURN;
|
||||
}
|
||||
if(!this->ParseFloat(szCurrent,&szCurrent,(float&)vRot.z))
|
||||
if(!ParseFloat(szCurrent,&szCurrent,(float&)vRot.z))
|
||||
{
|
||||
this->LogErrorNoThrow("Unexpected EOF/EOL while parsing bone.rot.z");
|
||||
LogErrorNoThrow("Unexpected EOF/EOL while parsing bone.rot.z");
|
||||
SMDI_PARSE_RETURN;
|
||||
}
|
||||
// build the transformation matrix of the key
|
||||
|
@ -1028,12 +1006,12 @@ void SMDImporter::ParseSkeletonElement(const char* szCurrent,
|
|||
void SMDImporter::ParseTriangle(const char* szCurrent,
|
||||
const char** szCurrentOut)
|
||||
{
|
||||
this->asTriangles.push_back(SMD::Face());
|
||||
SMD::Face& face = this->asTriangles.back();
|
||||
asTriangles.push_back(SMD::Face());
|
||||
SMD::Face& face = asTriangles.back();
|
||||
|
||||
if(!SkipSpaces(szCurrent,&szCurrent))
|
||||
{
|
||||
this->LogErrorNoThrow("Unexpected EOF/EOL while parsing a triangle");
|
||||
LogErrorNoThrow("Unexpected EOF/EOL while parsing a triangle");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1041,15 +1019,15 @@ void SMDImporter::ParseTriangle(const char* szCurrent,
|
|||
const char* szLast = szCurrent;
|
||||
while (!IsSpaceOrNewLine(*szCurrent++));
|
||||
|
||||
face.iTexture = this->GetTextureIndex(std::string(szLast,
|
||||
face.iTexture = GetTextureIndex(std::string(szLast,
|
||||
(uintptr_t)szCurrent-(uintptr_t)szLast));
|
||||
|
||||
this->SkipLine(szCurrent,&szCurrent);
|
||||
SkipLine(szCurrent,&szCurrent);
|
||||
|
||||
// load three vertices
|
||||
for (unsigned int iVert = 0; iVert < 3;++iVert)
|
||||
{
|
||||
this->ParseVertex(szCurrent,&szCurrent,
|
||||
ParseVertex(szCurrent,&szCurrent,
|
||||
face.avVertices[iVert]);
|
||||
}
|
||||
*szCurrentOut = szCurrent;
|
||||
|
@ -1059,7 +1037,7 @@ void SMDImporter::ParseTriangle(const char* szCurrent,
|
|||
bool SMDImporter::ParseFloat(const char* szCurrent,
|
||||
const char** szCurrentOut, float& out)
|
||||
{
|
||||
if(!SkipSpaces(szCurrent,&szCurrent))
|
||||
if(!SkipSpaces(&szCurrent))
|
||||
return false;
|
||||
|
||||
*szCurrentOut = fast_atof_move(szCurrent,out);
|
||||
|
@ -1068,23 +1046,23 @@ bool SMDImporter::ParseFloat(const char* szCurrent,
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
// Parse an unsigned int
|
||||
bool SMDImporter::ParseUnsignedInt(const char* szCurrent,
|
||||
const char** szCurrentOut, uint32_t& out)
|
||||
const char** szCurrentOut, unsigned int& out)
|
||||
{
|
||||
if(!SkipSpaces(szCurrent,&szCurrent))
|
||||
if(!SkipSpaces(&szCurrent))
|
||||
return false;
|
||||
|
||||
out = (uint32_t)strtol10(szCurrent,szCurrentOut);
|
||||
out = strtol10(szCurrent,szCurrentOut);
|
||||
return true;
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Parse a signed int
|
||||
bool SMDImporter::ParseSignedInt(const char* szCurrent,
|
||||
const char** szCurrentOut, int32_t& out)
|
||||
const char** szCurrentOut, int& out)
|
||||
{
|
||||
if(!SkipSpaces(szCurrent,&szCurrent))
|
||||
if(!SkipSpaces(&szCurrent))
|
||||
return false;
|
||||
|
||||
out = (int32_t)strtol10s(szCurrent,szCurrentOut);
|
||||
out = strtol10s(szCurrent,szCurrentOut);
|
||||
return true;
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -1093,67 +1071,67 @@ void SMDImporter::ParseVertex(const char* szCurrent,
|
|||
const char** szCurrentOut, SMD::Vertex& vertex,
|
||||
bool bVASection /*= false*/)
|
||||
{
|
||||
if(!this->ParseSignedInt(szCurrent,&szCurrent,(int32_t&)vertex.iParentNode))
|
||||
if(!ParseSignedInt(szCurrent,&szCurrent,(int&)vertex.iParentNode))
|
||||
{
|
||||
this->LogErrorNoThrow("Unexpected EOF/EOL while parsing vertex.parent");
|
||||
LogErrorNoThrow("Unexpected EOF/EOL while parsing vertex.parent");
|
||||
SMDI_PARSE_RETURN;
|
||||
}
|
||||
if(!this->ParseFloat(szCurrent,&szCurrent,(float&)vertex.pos.x))
|
||||
if(!ParseFloat(szCurrent,&szCurrent,(float&)vertex.pos.x))
|
||||
{
|
||||
this->LogErrorNoThrow("Unexpected EOF/EOL while parsing vertex.pos.x");
|
||||
LogErrorNoThrow("Unexpected EOF/EOL while parsing vertex.pos.x");
|
||||
SMDI_PARSE_RETURN;
|
||||
}
|
||||
if(!this->ParseFloat(szCurrent,&szCurrent,(float&)vertex.pos.y))
|
||||
if(!ParseFloat(szCurrent,&szCurrent,(float&)vertex.pos.y))
|
||||
{
|
||||
this->LogErrorNoThrow("Unexpected EOF/EOL while parsing vertex.pos.y");
|
||||
LogErrorNoThrow("Unexpected EOF/EOL while parsing vertex.pos.y");
|
||||
SMDI_PARSE_RETURN;
|
||||
}
|
||||
if(!this->ParseFloat(szCurrent,&szCurrent,(float&)vertex.pos.z))
|
||||
if(!ParseFloat(szCurrent,&szCurrent,(float&)vertex.pos.z))
|
||||
{
|
||||
this->LogErrorNoThrow("Unexpected EOF/EOL while parsing vertex.pos.z");
|
||||
LogErrorNoThrow("Unexpected EOF/EOL while parsing vertex.pos.z");
|
||||
SMDI_PARSE_RETURN;
|
||||
}
|
||||
if(!this->ParseFloat(szCurrent,&szCurrent,(float&)vertex.nor.x))
|
||||
if(!ParseFloat(szCurrent,&szCurrent,(float&)vertex.nor.x))
|
||||
{
|
||||
this->LogErrorNoThrow("Unexpected EOF/EOL while parsing vertex.nor.x");
|
||||
LogErrorNoThrow("Unexpected EOF/EOL while parsing vertex.nor.x");
|
||||
SMDI_PARSE_RETURN;
|
||||
}
|
||||
if(!this->ParseFloat(szCurrent,&szCurrent,(float&)vertex.nor.y))
|
||||
if(!ParseFloat(szCurrent,&szCurrent,(float&)vertex.nor.y))
|
||||
{
|
||||
this->LogErrorNoThrow("Unexpected EOF/EOL while parsing vertex.nor.y");
|
||||
LogErrorNoThrow("Unexpected EOF/EOL while parsing vertex.nor.y");
|
||||
SMDI_PARSE_RETURN;
|
||||
}
|
||||
if(!this->ParseFloat(szCurrent,&szCurrent,(float&)vertex.nor.z))
|
||||
if(!ParseFloat(szCurrent,&szCurrent,(float&)vertex.nor.z))
|
||||
{
|
||||
this->LogErrorNoThrow("Unexpected EOF/EOL while parsing vertex.nor.z");
|
||||
LogErrorNoThrow("Unexpected EOF/EOL while parsing vertex.nor.z");
|
||||
SMDI_PARSE_RETURN;
|
||||
}
|
||||
|
||||
if (bVASection)SMDI_PARSE_RETURN;
|
||||
|
||||
if(!this->ParseFloat(szCurrent,&szCurrent,(float&)vertex.uv.x))
|
||||
if(!ParseFloat(szCurrent,&szCurrent,(float&)vertex.uv.x))
|
||||
{
|
||||
this->LogErrorNoThrow("Unexpected EOF/EOL while parsing vertex.uv.x");
|
||||
LogErrorNoThrow("Unexpected EOF/EOL while parsing vertex.uv.x");
|
||||
SMDI_PARSE_RETURN;
|
||||
}
|
||||
if(!this->ParseFloat(szCurrent,&szCurrent,(float&)vertex.uv.y))
|
||||
if(!ParseFloat(szCurrent,&szCurrent,(float&)vertex.uv.y))
|
||||
{
|
||||
this->LogErrorNoThrow("Unexpected EOF/EOL while parsing vertex.uv.y");
|
||||
LogErrorNoThrow("Unexpected EOF/EOL while parsing vertex.uv.y");
|
||||
SMDI_PARSE_RETURN;
|
||||
}
|
||||
|
||||
// now read the number of bones affecting this vertex
|
||||
// all elements from now are fully optional, we don't need them
|
||||
unsigned int iSize = 0;
|
||||
if(!this->ParseUnsignedInt(szCurrent,&szCurrent,iSize))SMDI_PARSE_RETURN;
|
||||
if(!ParseUnsignedInt(szCurrent,&szCurrent,iSize))SMDI_PARSE_RETURN;
|
||||
vertex.aiBoneLinks.resize(iSize,std::pair<unsigned int, float>(0,0.0f));
|
||||
|
||||
for (std::vector<std::pair<unsigned int, float> >::iterator
|
||||
i = vertex.aiBoneLinks.begin();
|
||||
i != vertex.aiBoneLinks.end();++i)
|
||||
{
|
||||
if(!this->ParseUnsignedInt(szCurrent,&szCurrent,(*i).first))SMDI_PARSE_RETURN;
|
||||
if(!this->ParseFloat(szCurrent,&szCurrent,(*i).second))SMDI_PARSE_RETURN;
|
||||
if(!ParseUnsignedInt(szCurrent,&szCurrent,(*i).first))SMDI_PARSE_RETURN;
|
||||
if(!ParseFloat(szCurrent,&szCurrent,(*i).second))SMDI_PARSE_RETURN;
|
||||
}
|
||||
|
||||
// go to the beginning of the next line
|
||||
|
|
|
@ -321,13 +321,13 @@ protected:
|
|||
/** Parse an unsigned integer. There may be no sign!
|
||||
*/
|
||||
bool ParseUnsignedInt(const char* szCurrent,
|
||||
const char** szCurrentOut, uint32_t& out);
|
||||
const char** szCurrentOut, unsigned int& out);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Parse a signed integer. Signs (+,-) are handled.
|
||||
*/
|
||||
bool ParseSignedInt(const char* szCurrent,
|
||||
const char** szCurrentOut, int32_t& out);
|
||||
const char** szCurrentOut, int& out);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Fix invalid time values in the file
|
||||
|
@ -377,7 +377,7 @@ private:
|
|||
unsigned int configFrameID;
|
||||
|
||||
/** Buffer to hold the loaded file */
|
||||
char* mBuffer;
|
||||
const char* mBuffer;
|
||||
|
||||
/** Output scene to be filled
|
||||
*/
|
||||
|
|
|
@ -41,22 +41,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/** @file Implementation of the STL importer class */
|
||||
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
// internal headers
|
||||
#include "STLLoader.h"
|
||||
#include "MaterialSystem.h"
|
||||
#include "ParsingUtils.h"
|
||||
#include "fast_atof.h"
|
||||
|
||||
// public assimp headers
|
||||
#include "../include/IOStream.h"
|
||||
#include "../include/IOSystem.h"
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/aiAssert.h"
|
||||
#include "../include/DefaultLogger.h"
|
||||
|
||||
// boost headers
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
||||
|
@ -335,6 +327,8 @@ bool STLImporter::LoadBinaryFile()
|
|||
|
||||
for (unsigned int i = 0; i < pMesh->mNumFaces;++i)
|
||||
{
|
||||
// NOTE: Blender sometimes writes empty normals this is not
|
||||
// our fault ... the RemoveInvalidData helper step should fix that
|
||||
*vn = *((aiVector3D*)sz);
|
||||
sz += sizeof(aiVector3D);
|
||||
*(vn+1) = *vn;
|
||||
|
|
|
@ -61,7 +61,7 @@ struct FaceWithSmoothingGroup
|
|||
|
||||
|
||||
//! Indices. .3ds is using uint16. However, after
|
||||
//! an unique vrtex set has been geneerated it might
|
||||
//! an unique vrtex set has been generated it might
|
||||
//! be an index becomes > 2^16
|
||||
uint32_t mIndices[3];
|
||||
|
||||
|
|
|
@ -43,15 +43,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
* SortByPTypeProcess post-process steps.
|
||||
*/
|
||||
|
||||
// public ASSIMP headers
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/aiPostProcess.h"
|
||||
#include "../include/aiScene.h"
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
// internal headers
|
||||
#include "ProcessHelper.h"
|
||||
#include "SortByPTypeProcess.h"
|
||||
#include "qnan.h"
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
|
|
@ -74,6 +74,7 @@ public:
|
|||
void Execute( aiScene* pScene);
|
||||
};
|
||||
|
||||
#if (!defined AI_BUILD_NO_SORTBYPTYPE_PROCESS)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** SortByPTypeProcess: Sorts meshes by the types of primitives they contain.
|
||||
|
@ -100,6 +101,8 @@ public:
|
|||
void Execute( aiScene* pScene);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
} // end of namespace Assimp
|
||||
|
||||
#endif // !!AI_SORTBYPTYPEPROCESS_H_INC
|
||||
|
|
|
@ -40,7 +40,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
*/
|
||||
|
||||
/** @file Implementation of the helper class to quickly find vertices close to a given position */
|
||||
#include <algorithm>
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
#include "SpatialSort.h"
|
||||
|
||||
using namespace Assimp;
|
||||
|
|
|
@ -42,12 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
/** @file Implementation of the SplitLargeMeshes postprocessing step
|
||||
*/
|
||||
|
||||
|
||||
// public Assimp headers
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/aiPostProcess.h"
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/assimp.hpp"
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
// internal headers of the post-processing framework
|
||||
#include "SplitLargeMeshes.h"
|
||||
|
|
|
@ -40,10 +40,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
/** @file Implementation of the StandardShapes class
|
||||
*/
|
||||
#include "../include/aiTypes.h"
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/aiAssert.h"
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
#include "StandardShapes.h"
|
||||
|
||||
namespace Assimp {
|
||||
|
|
|
@ -64,29 +64,23 @@ inline int ASSIMP_stricmp(const char *s1, const char *s2)
|
|||
return ::_stricmp(s1,s2);
|
||||
|
||||
#else
|
||||
const char *a1, *a2;
|
||||
a1 = s1;
|
||||
a2 = s2;
|
||||
|
||||
while (true)
|
||||
register char c1, c2;
|
||||
do
|
||||
{
|
||||
char c1 = (char)::tolower(*a1);
|
||||
char c2 = (char)::tolower(*a2);
|
||||
if ((0 == c1) && (0 == c2)) return 0;
|
||||
if (c1 < c2) return-1;
|
||||
if (c1 > c2) return 1;
|
||||
++a1;
|
||||
++a2;
|
||||
c1 = tolower(*s1++);
|
||||
c2 = tolower(*s2++);
|
||||
}
|
||||
while ( c1 && (c1 == c2) );
|
||||
|
||||
return c1 - c2;
|
||||
#endif
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
inline int ASSIMP_stricmp(const std::string& a, const std::string& b)
|
||||
{
|
||||
int i = (int)b.length()-(int)a.length();
|
||||
if (i)return i;
|
||||
return ASSIMP_stricmp(a.c_str(),b.c_str());
|
||||
register int i = (int)b.length()-(int)a.length();
|
||||
return (i ? i : ASSIMP_stricmp(a.c_str(),b.c_str()));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
@ -108,25 +102,17 @@ inline int ASSIMP_strincmp(const char *s1, const char *s2, unsigned int n)
|
|||
return ::_strnicmp(s1,s2,n);
|
||||
|
||||
#else
|
||||
const char *a1, *a2;
|
||||
a1 = s1;
|
||||
a2 = s2;
|
||||
|
||||
register char c1, c2;
|
||||
unsigned int p = 0;
|
||||
|
||||
while (true)
|
||||
do
|
||||
{
|
||||
if (p >= n)return 0;
|
||||
|
||||
char c1 = (char)::tolower(*a1);
|
||||
char c2 = (char)::tolower(*a2);
|
||||
if ((0 == c1) && (0 == c2)) return 0;
|
||||
if (c1 < c2) return-1;
|
||||
if (c1 > c2) return 1;
|
||||
++a1;
|
||||
++a2;
|
||||
++p;
|
||||
if (p++ >= n)return 0;
|
||||
c1 = tolower(*s1++);
|
||||
c2 = tolower(*s2++);
|
||||
}
|
||||
while ( c1 && (c1 == c2) );
|
||||
|
||||
return c1 - c2;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,11 +41,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
/** @file A helper class that processes texture transformations */
|
||||
|
||||
|
||||
#include "../include/aiTypes.h"
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/aiAssert.h"
|
||||
|
||||
#include "MaterialSystem.h"
|
||||
#include "AssimpPCH.h"
|
||||
#include "TextureTransform.h"
|
||||
|
||||
namespace Assimp
|
||||
|
|
|
@ -42,13 +42,9 @@ 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.
|
||||
*/
|
||||
#include <vector>
|
||||
#include <assert.h>
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
#include "TriangulateProcess.h"
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/aiPostProcess.h"
|
||||
#include "../include/aiMesh.h"
|
||||
#include "../include/aiScene.h"
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
|
|
@ -43,22 +43,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
* the data structure returned by Assimp
|
||||
*/
|
||||
|
||||
// STL headers
|
||||
#include <vector>
|
||||
#include <assert.h>
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
// internal headers
|
||||
#include "ValidateDataStructure.h"
|
||||
#include "BaseImporter.h"
|
||||
#include "StringComparison.h"
|
||||
#include "fast_atof.h"
|
||||
|
||||
// public ASSIMP headers
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/aiPostProcess.h"
|
||||
#include "../include/aiMesh.h"
|
||||
#include "../include/aiScene.h"
|
||||
#include "../include/aiAssert.h"
|
||||
|
||||
// CRT headers
|
||||
#include <stdarg.h>
|
||||
|
@ -109,7 +100,9 @@ void ValidateDSProcess::ReportError(const char* msg,...)
|
|||
throw new ImportErrorException("Idiot ... learn coding!");
|
||||
}
|
||||
va_end(args);
|
||||
ai_assert(false);
|
||||
#ifdef _DEBUG
|
||||
aiAssert( false,szBuffer,__LINE__,__FILE__ );
|
||||
#endif
|
||||
throw new ImportErrorException("Validation failed: " + std::string(szBuffer,iLen));
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -42,9 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
/** @file Implementation of the VertexTriangleAdjacency helper class
|
||||
*/
|
||||
|
||||
// public ASSIMP headers
|
||||
#include "../include/DefaultLogger.h"
|
||||
#include "../include/aiMesh.h"
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
// internal headers
|
||||
#include "VertexTriangleAdjacency.h"
|
||||
|
|
|
@ -39,19 +39,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
---------------------------------------------------------------------------
|
||||
*/
|
||||
/** @file Implementation of the XFile importer class */
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
#include "XFileImporter.h"
|
||||
#include "XFileParser.h"
|
||||
#include "MaterialSystem.h"
|
||||
#include "ConvertToLHProcess.h"
|
||||
|
||||
#include "../include/IOStream.h"
|
||||
#include "../include/IOSystem.h"
|
||||
#include "../include/aiMesh.h"
|
||||
#include "../include/aiScene.h"
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <boost/format.hpp>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
#if _MSC_VER >= 1400
|
||||
|
|
|
@ -40,13 +40,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
*/
|
||||
|
||||
/** @file Implementation of the XFile parser helper class */
|
||||
|
||||
#include "AssimpPCH.h"
|
||||
|
||||
#include "XFileParser.h"
|
||||
#include "XFileHelper.h"
|
||||
#include "BaseImporter.h"
|
||||
#include "fast_atof.h"
|
||||
#include "../include/DefaultLogger.h"
|
||||
|
||||
#include <boost/format.hpp>
|
||||
|
||||
using namespace Assimp;
|
||||
using namespace Assimp::XFile;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#include <iostream>
|
||||
|
||||
#include "assimpPCH.h"
|
||||
|
||||
#include "../include/aiAssert.h"
|
||||
#ifdef _WIN32
|
||||
#ifndef __GNUC__
|
||||
|
|
|
@ -40,12 +40,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
*/
|
||||
/** @file Implementation of the post processing step "MakeVerboseFormat"
|
||||
*/
|
||||
#include "MakeVerboseFormat.h"
|
||||
#include "../../include/DefaultLogger.h"
|
||||
|
||||
#include "../../include/aiMesh.h"
|
||||
#include "../../include/aiScene.h"
|
||||
#include "../../include/aiAssert.h"
|
||||
#include "../AssimpPCH.h"
|
||||
#include "MakeVerboseFormat.h"
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
|
|
@ -53,11 +53,72 @@ inline unsigned int strtol10( const char* in, const char** out=0)
|
|||
value = ( value * 10 ) + ( *in - '0' );
|
||||
++in;
|
||||
}
|
||||
if (out)
|
||||
*out = in;
|
||||
if (out)*out = in;
|
||||
return value;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
inline unsigned int strtol8( const char* in, const char** out=0)
|
||||
{
|
||||
unsigned int value = 0;
|
||||
|
||||
while ( 1 )
|
||||
{
|
||||
if ( *in < '0' || *in > '7' )
|
||||
break;
|
||||
|
||||
value = ( value << 3 ) + ( *in - '0' );
|
||||
++in;
|
||||
}
|
||||
if (out)*out = in;
|
||||
return value;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
// convert a string in hex format to a number
|
||||
inline unsigned int strtol16( const char* in, const char** out=0)
|
||||
{
|
||||
unsigned int value = 0;
|
||||
|
||||
while ( 1 )
|
||||
{
|
||||
if ( *in >= '0' && *in <= '9' )
|
||||
{
|
||||
value = ( value << 4u ) + ( *in - '0' );
|
||||
}
|
||||
else if (*in >= 'A' && *in <= 'F')
|
||||
{
|
||||
value = ( value << 4u ) + ( *in - 'A' ) + 10;
|
||||
}
|
||||
else if (*in >= 'a' && *in <= 'f')
|
||||
{
|
||||
value = ( value << 4u ) + ( *in - 'a' ) + 10;
|
||||
}
|
||||
else break;
|
||||
++in;
|
||||
}
|
||||
if (out)*out = in;
|
||||
return value;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
// convert just one hex digit
|
||||
inline unsigned int HexDigitToDecimal(char in)
|
||||
{
|
||||
unsigned int out = 0xffffffff;
|
||||
if (in >= '0' && in <= '9')
|
||||
out = in - '0';
|
||||
|
||||
else if (in >= 'a' && in <= 'f')
|
||||
out = 10u + in - 'a';
|
||||
|
||||
else if (in >= 'A' && in <= 'F')
|
||||
out = 10u + in - 'A';
|
||||
|
||||
// return value is 0xffffffff if the input is not a hex digit
|
||||
return out;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
// signed variant of strtol10
|
||||
inline int strtol10s( const char* in, const char** out=0)
|
||||
|
@ -70,6 +131,18 @@ inline int strtol10s( const char* in, const char** out=0)
|
|||
return value;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
// 0xNNNN - hex
|
||||
// 0NNN - oct
|
||||
// NNN - dec
|
||||
inline unsigned int strtol_cppstyle( const char* in, const char** out=0)
|
||||
{
|
||||
if ('0' == in[0])
|
||||
{
|
||||
return 'x' == in[1] ? strtol10(in+2,out) : strtol8(in+1,out);
|
||||
}
|
||||
return strtol10(in, out);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
// specal version of the function, providing higher accuracy
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
#produces shared library output in bin/libassimp.so
|
||||
|
||||
|
||||
SOURCES = 3DSConverter.cpp \
|
||||
SOURCES = AssimpPCH.cpp \
|
||||
3DSConverter.cpp \
|
||||
3DSLoader.cpp \
|
||||
aiAssert.cpp \
|
||||
ASELoader.cpp \
|
||||
|
@ -59,6 +60,9 @@ SOURCES = 3DSConverter.cpp \
|
|||
RawLoader.cpp \
|
||||
OFFLoader.cpp \
|
||||
SortByPTypeProcess.cpp \
|
||||
FindInvalidDataProcess.cpp \
|
||||
ACLoader.cpp \
|
||||
LWSLoader.cpp \
|
||||
XFileParser.cpp
|
||||
|
||||
OBJECTS = $(SOURCES:.cpp=.o)
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
#rough makefile for build with mingw
|
||||
#produces shared library output in bin/libassimp.so
|
||||
|
||||
|
||||
SOURCES = AssimpPCH.cpp \
|
||||
3DSConverter.cpp \
|
||||
3DSLoader.cpp \
|
||||
aiAssert.cpp \
|
||||
ASELoader.cpp \
|
||||
ASEParser.cpp \
|
||||
Assimp.cpp BaseImporter.cpp BaseProcess.cpp \
|
||||
CalcTangentsProcess.cpp \
|
||||
ConvertToLHProcess.cpp \
|
||||
DefaultIOStream.cpp \
|
||||
DefaultIOSystem.cpp \
|
||||
DefaultLogger.cpp \
|
||||
DXFLoader.cpp \
|
||||
FixNormalsStep.cpp \
|
||||
GenFaceNormalsProcess.cpp \
|
||||
GenVertexNormalsProcess.cpp \
|
||||
HMPLoader.cpp \
|
||||
Importer.cpp \
|
||||
ImproveCacheLocality.cpp \
|
||||
JoinVerticesProcess.cpp \
|
||||
RemoveVCProcess.cpp \
|
||||
LimitBoneWeightsProcess.cpp \
|
||||
LWOBLoader.cpp \
|
||||
LWOLoader.cpp \
|
||||
LWOMaterial.cpp \
|
||||
MaterialSystem.cpp \
|
||||
MD2Loader.cpp \
|
||||
MD3Loader.cpp \
|
||||
MD5Loader.cpp \
|
||||
MD5Parser.cpp \
|
||||
MDCLoader.cpp \
|
||||
MDLLoader.cpp \
|
||||
MDLMaterialLoader.cpp \
|
||||
NFFLoader.cpp \
|
||||
ObjFileImporter.cpp \
|
||||
ObjFileMtlImporter.cpp \
|
||||
ObjFileParser.cpp \
|
||||
OptimizeGraphProcess.cpp \
|
||||
PlyLoader.cpp \
|
||||
PlyParser.cpp \
|
||||
PretransformVertices.cpp \
|
||||
RemoveComments.cpp \
|
||||
RemoveRedundantMaterials.cpp \
|
||||
SGSpatialSort.cpp \
|
||||
SMDLoader.cpp \
|
||||
SpatialSort.cpp \
|
||||
SplitLargeMeshes.cpp \
|
||||
StandardShapes.cpp \
|
||||
STLLoader.cpp \
|
||||
TextureTransform.cpp \
|
||||
TriangulateProcess.cpp \
|
||||
ValidateDataStructure.cpp \
|
||||
VertexTriangleAdjacency.cpp \
|
||||
XFileImporter.cpp \
|
||||
MDRLoader.cpp \
|
||||
RawLoader.cpp \
|
||||
OFFLoader.cpp \
|
||||
SortByPTypeProcess.cpp \
|
||||
FindInvalidDataProcess.cpp \
|
||||
ACLoader.cpp \
|
||||
LWSLoader.cpp \
|
||||
XFileParser.cpp
|
||||
|
||||
OBJECTS = $(SOURCES:.cpp=.o)
|
||||
|
||||
TARGET = ./../bin/libassimp.so
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): $(OBJECTS)
|
||||
gcc -o $@ $(OBJECTS) -shared -lstdc++
|
||||
%.o:%.cpp
|
||||
$(CXX) -g -Wall -c $? -o $@ -I../include -I"C:\Program Files\boost\boost_1_35_0" -I"%BOOST_DIR%"
|
||||
clean:
|
||||
del *.o
|
||||
|
||||
|
||||
STATIC = ./../bin/libassimp.a
|
||||
static: $(STATIC)
|
||||
$(STATIC): $(OBJECTS)
|
||||
ar rcs $@ $(OBJECTS)
|
||||
|
47
code/qnan.h
47
code/qnan.h
|
@ -4,29 +4,38 @@
|
|||
#define AI_QNAN_H_INCLUDED
|
||||
|
||||
|
||||
|
||||
inline bool is_qnan(const float in)
|
||||
// ---------------------------------------------------------------------------
|
||||
// check whether a float is NaN
|
||||
AI_FORCE_INLINE bool is_qnan(float in)
|
||||
{
|
||||
// _isnan() takes a double as argument and would
|
||||
// require a cast. Therefore we must do it on our own ...
|
||||
// Another method would be to check whether in != in.
|
||||
// This should also wor since nan compares to inequal,
|
||||
// even when compared with itself. However, this could
|
||||
// cause problems with other special floats like snan
|
||||
union _tagFPUNION
|
||||
{
|
||||
float f;
|
||||
int32_t i;
|
||||
} FPUNION1,FPUNION2;
|
||||
|
||||
FPUNION1.f = in;
|
||||
FPUNION2.f = std::numeric_limits<float>::quiet_NaN();
|
||||
return FPUNION1.i == FPUNION2.i;
|
||||
return (in != in);
|
||||
}
|
||||
|
||||
inline bool is_not_qnan(const float in)
|
||||
// ---------------------------------------------------------------------------
|
||||
// check whether a float is NOT NaN.
|
||||
AI_FORCE_INLINE bool is_not_qnan(float in)
|
||||
{
|
||||
return !is_qnan(in);
|
||||
return (in == in);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// check whether a float is either NaN or (+/-) INF. Denorms return false,
|
||||
// they're treated like normal values.
|
||||
AI_FORCE_INLINE bool is_special_float(float in)
|
||||
{
|
||||
union IEEESingle
|
||||
{
|
||||
float Float;
|
||||
struct
|
||||
{
|
||||
uint32_t Frac : 23;
|
||||
uint32_t Exp : 8;
|
||||
uint32_t Sign : 1;
|
||||
} IEEE;
|
||||
} f;
|
||||
|
||||
f.Float = in;
|
||||
return (f.IEEE.Exp == (1u << 8)-1);
|
||||
}
|
||||
|
||||
#endif // !! AI_QNAN_H_INCLUDED
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
|
||||
|
||||
#ifndef AI_BOOST_FORMAT_DUMMY_INCLUDED
|
||||
#define AI_BOOST_FORMAT_DUMMY_INCLUDED
|
||||
|
||||
#ifndef BOOST_FORMAT_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
class str;
|
||||
|
||||
class format
|
||||
{
|
||||
friend class str;
|
||||
public:
|
||||
format (const std::string& _d)
|
||||
: d(_d)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
const format& operator % (T in) const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string d;
|
||||
};
|
||||
|
||||
class str : public std::string
|
||||
{
|
||||
public:
|
||||
|
||||
str(const format& f)
|
||||
{
|
||||
*((std::string* const)this) = std::string( f.d );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#else
|
||||
# error "format.h was already included"
|
||||
#endif //
|
||||
#endif // !! AI_BOOST_FORMAT_DUMMY_INCLUDED
|
|
@ -0,0 +1,63 @@
|
|||
|
||||
#ifndef __AI_BOOST_SCOPED_PTR_INCLUDED
|
||||
#define __AI_BOOST_SCOPED_PTR_INCLUDED
|
||||
|
||||
#ifndef BOOST_SCOPED_PTR_HPP_INCLUDED
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
namespace boost {
|
||||
|
||||
// small replacement for boost::scoped_ptr
|
||||
template <class T>
|
||||
class scoped_ptr
|
||||
{
|
||||
public:
|
||||
|
||||
// provide a default construtctor
|
||||
scoped_ptr()
|
||||
: ptr(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
// construction from an existing heap object of type T
|
||||
scoped_ptr(T* _ptr)
|
||||
: ptr(_ptr)
|
||||
{
|
||||
}
|
||||
|
||||
// automatic destruction of the wrapped object at the
|
||||
// end of our lifetime
|
||||
~scoped_ptr()
|
||||
{
|
||||
delete ptr;
|
||||
}
|
||||
|
||||
inline T* get()
|
||||
{
|
||||
return ptr;
|
||||
}
|
||||
|
||||
inline operator T*()
|
||||
{
|
||||
return ptr;
|
||||
}
|
||||
|
||||
inline T* operator-> ()
|
||||
{
|
||||
return ptr;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
// encapsulated object pointer
|
||||
T* ptr;
|
||||
|
||||
};
|
||||
|
||||
} // end of namespace boost
|
||||
|
||||
#else
|
||||
# error "scoped_ptr.h was already included"
|
||||
#endif
|
||||
#endif // __AI_BOOST_SCOPED_PTR_INCLUDED
|
|
@ -1,222 +0,0 @@
|
|||
// ISO C9x compliant stdint.h for Microsoft Visual Studio
|
||||
// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
|
||||
//
|
||||
// Copyright (c) 2006 Alexander Chemeris
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. The name of the author may be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _MSC_VER // [
|
||||
#error "Use this header only with Microsoft Visual C++ compilers!"
|
||||
#endif // _MSC_VER ]
|
||||
|
||||
#ifndef _MSC_STDINT_H_ // [
|
||||
#define _MSC_STDINT_H_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
// For Visual Studio 6 in C++ mode wrap <wchar.h> include with 'extern "C++" {}'
|
||||
// or compiler give many errors like this:
|
||||
// error C2733: second C linkage of overloaded function 'wmemchr' not allowed
|
||||
#if (_MSC_VER < 1300) && defined(__cplusplus)
|
||||
extern "C++" {
|
||||
#endif
|
||||
# include <wchar.h>
|
||||
#if (_MSC_VER < 1300) && defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// 7.18.1 Integer types
|
||||
|
||||
// 7.18.1.1 Exact-width integer types
|
||||
typedef __int8 int8_t;
|
||||
typedef __int16 int16_t;
|
||||
typedef __int32 int32_t;
|
||||
typedef __int64 int64_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
|
||||
// 7.18.1.2 Minimum-width integer types
|
||||
typedef int8_t int_least8_t;
|
||||
typedef int16_t int_least16_t;
|
||||
typedef int32_t int_least32_t;
|
||||
typedef int64_t int_least64_t;
|
||||
typedef uint8_t uint_least8_t;
|
||||
typedef uint16_t uint_least16_t;
|
||||
typedef uint32_t uint_least32_t;
|
||||
typedef uint64_t uint_least64_t;
|
||||
|
||||
// 7.18.1.3 Fastest minimum-width integer types
|
||||
typedef int8_t int_fast8_t;
|
||||
typedef int16_t int_fast16_t;
|
||||
typedef int32_t int_fast32_t;
|
||||
typedef int64_t int_fast64_t;
|
||||
typedef uint8_t uint_fast8_t;
|
||||
typedef uint16_t uint_fast16_t;
|
||||
typedef uint32_t uint_fast32_t;
|
||||
typedef uint64_t uint_fast64_t;
|
||||
|
||||
// 7.18.1.4 Integer types capable of holding object pointers
|
||||
#ifdef _WIN64 // [
|
||||
typedef __int64 intptr_t;
|
||||
typedef unsigned __int64 uintptr_t;
|
||||
#else // _WIN64 ][
|
||||
typedef int intptr_t;
|
||||
typedef unsigned int uintptr_t;
|
||||
#endif // _WIN64 ]
|
||||
|
||||
// 7.18.1.5 Greatest-width integer types
|
||||
typedef int64_t intmax_t;
|
||||
typedef uint64_t uintmax_t;
|
||||
|
||||
|
||||
// 7.18.2 Limits of specified-width integer types
|
||||
|
||||
#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259
|
||||
|
||||
// 7.18.2.1 Limits of exact-width integer types
|
||||
#define INT8_MIN ((int8_t)_I8_MIN)
|
||||
#define INT8_MAX _I8_MAX
|
||||
#define INT16_MIN ((int16_t)_I16_MIN)
|
||||
#define INT16_MAX _I16_MAX
|
||||
#define INT32_MIN ((int32_t)_I32_MIN)
|
||||
#define INT32_MAX _I32_MAX
|
||||
#define INT64_MIN ((int64_t)_I64_MIN)
|
||||
#define INT64_MAX _I64_MAX
|
||||
#define UINT8_MAX _UI8_MAX
|
||||
#define UINT16_MAX _UI16_MAX
|
||||
#define UINT32_MAX _UI32_MAX
|
||||
#define UINT64_MAX _UI64_MAX
|
||||
|
||||
// 7.18.2.2 Limits of minimum-width integer types
|
||||
#define INT_LEAST8_MIN INT8_MIN
|
||||
#define INT_LEAST8_MAX INT8_MAX
|
||||
#define INT_LEAST16_MIN INT16_MIN
|
||||
#define INT_LEAST16_MAX INT16_MAX
|
||||
#define INT_LEAST32_MIN INT32_MIN
|
||||
#define INT_LEAST32_MAX INT32_MAX
|
||||
#define INT_LEAST64_MIN INT64_MIN
|
||||
#define INT_LEAST64_MAX INT64_MAX
|
||||
#define UINT_LEAST8_MAX UINT8_MAX
|
||||
#define UINT_LEAST16_MAX UINT16_MAX
|
||||
#define UINT_LEAST32_MAX UINT32_MAX
|
||||
#define UINT_LEAST64_MAX UINT64_MAX
|
||||
|
||||
// 7.18.2.3 Limits of fastest minimum-width integer types
|
||||
#define INT_FAST8_MIN INT8_MIN
|
||||
#define INT_FAST8_MAX INT8_MAX
|
||||
#define INT_FAST16_MIN INT16_MIN
|
||||
#define INT_FAST16_MAX INT16_MAX
|
||||
#define INT_FAST32_MIN INT32_MIN
|
||||
#define INT_FAST32_MAX INT32_MAX
|
||||
#define INT_FAST64_MIN INT64_MIN
|
||||
#define INT_FAST64_MAX INT64_MAX
|
||||
#define UINT_FAST8_MAX UINT8_MAX
|
||||
#define UINT_FAST16_MAX UINT16_MAX
|
||||
#define UINT_FAST32_MAX UINT32_MAX
|
||||
#define UINT_FAST64_MAX UINT64_MAX
|
||||
|
||||
// 7.18.2.4 Limits of integer types capable of holding object pointers
|
||||
#ifdef _WIN64 // [
|
||||
# define INTPTR_MIN INT64_MIN
|
||||
# define INTPTR_MAX INT64_MAX
|
||||
# define UINTPTR_MAX UINT64_MAX
|
||||
#else // _WIN64 ][
|
||||
# define INTPTR_MIN INT32_MIN
|
||||
# define INTPTR_MAX INT32_MAX
|
||||
# define UINTPTR_MAX UINT32_MAX
|
||||
#endif // _WIN64 ]
|
||||
|
||||
// 7.18.2.5 Limits of greatest-width integer types
|
||||
#define INTMAX_MIN INT64_MIN
|
||||
#define INTMAX_MAX INT64_MAX
|
||||
#define UINTMAX_MAX UINT64_MAX
|
||||
|
||||
// 7.18.3 Limits of other integer types
|
||||
|
||||
#ifdef _WIN64 // [
|
||||
# define PTRDIFF_MIN _I64_MIN
|
||||
# define PTRDIFF_MAX _I64_MAX
|
||||
#else // _WIN64 ][
|
||||
# define PTRDIFF_MIN _I32_MIN
|
||||
# define PTRDIFF_MAX _I32_MAX
|
||||
#endif // _WIN64 ]
|
||||
|
||||
#define SIG_ATOMIC_MIN INT_MIN
|
||||
#define SIG_ATOMIC_MAX INT_MAX
|
||||
|
||||
#ifndef SIZE_MAX // [
|
||||
# ifdef _WIN64 // [
|
||||
# define SIZE_MAX _UI64_MAX
|
||||
# else // _WIN64 ][
|
||||
# define SIZE_MAX _UI32_MAX
|
||||
# endif // _WIN64 ]
|
||||
#endif // SIZE_MAX ]
|
||||
|
||||
// WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>
|
||||
#ifndef WCHAR_MIN // [
|
||||
# define WCHAR_MIN 0
|
||||
#endif // WCHAR_MIN ]
|
||||
#ifndef WCHAR_MAX // [
|
||||
# define WCHAR_MAX _UI16_MAX
|
||||
#endif // WCHAR_MAX ]
|
||||
|
||||
#define WINT_MIN 0
|
||||
#define WINT_MAX _UI16_MAX
|
||||
|
||||
#endif // __STDC_LIMIT_MACROS ]
|
||||
|
||||
|
||||
// 7.18.4 Limits of other integer types
|
||||
|
||||
#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260
|
||||
|
||||
// 7.18.4.1 Macros for minimum-width integer constants
|
||||
|
||||
#define INT8_C(val) val##i8
|
||||
#define INT16_C(val) val##i16
|
||||
#define INT32_C(val) val##i32
|
||||
#define INT64_C(val) val##i64
|
||||
|
||||
#define UINT8_C(val) val##ui8
|
||||
#define UINT16_C(val) val##ui16
|
||||
#define UINT32_C(val) val##ui32
|
||||
#define UINT64_C(val) val##ui64
|
||||
|
||||
// 7.18.4.2 Macros for greatest-width integer constants
|
||||
#define INTMAX_C INT64_C
|
||||
#define UINTMAX_C UINT64_C
|
||||
|
||||
#endif // __STDC_CONSTANT_MACROS ]
|
||||
|
||||
|
||||
#endif // _MSC_STDINT_H_ ]
|
|
@ -0,0 +1,729 @@
|
|||
/* A portable stdint.h
|
||||
****************************************************************************
|
||||
* BSD License:
|
||||
****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2005-2007 Paul Hsieh
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************
|
||||
*
|
||||
* Version 0.1.10
|
||||
*
|
||||
* The ANSI C standard committee, for the C99 standard, specified the
|
||||
* inclusion of a new standard include file called stdint.h. This is
|
||||
* a very useful and long desired include file which contains several
|
||||
* very precise definitions for integer scalar types that is
|
||||
* critically important for making portable several classes of
|
||||
* applications including cryptography, hashing, variable length
|
||||
* integer libraries and so on. But for most developers its likely
|
||||
* useful just for programming sanity.
|
||||
*
|
||||
* The problem is that most compiler vendors have decided not to
|
||||
* implement the C99 standard, and the next C++ language standard
|
||||
* (which has a lot more mindshare these days) will be a long time in
|
||||
* coming and its unknown whether or not it will include stdint.h or
|
||||
* how much adoption it will have. Either way, it will be a long time
|
||||
* before all compilers come with a stdint.h and it also does nothing
|
||||
* for the extremely large number of compilers available today which
|
||||
* do not include this file, or anything comparable to it.
|
||||
*
|
||||
* So that's what this file is all about. Its an attempt to build a
|
||||
* single universal include file that works on as many platforms as
|
||||
* possible to deliver what stdint.h is supposed to. A few things
|
||||
* that should be noted about this file:
|
||||
*
|
||||
* 1) It is not guaranteed to be portable and/or present an identical
|
||||
* interface on all platforms. The extreme variability of the
|
||||
* ANSI C standard makes this an impossibility right from the
|
||||
* very get go. Its really only meant to be useful for the vast
|
||||
* majority of platforms that possess the capability of
|
||||
* implementing usefully and precisely defined, standard sized
|
||||
* integer scalars. Systems which are not intrinsically 2s
|
||||
* complement may produce invalid constants.
|
||||
*
|
||||
* 2) There is an unavoidable use of non-reserved symbols.
|
||||
*
|
||||
* 3) Other standard include files are invoked.
|
||||
*
|
||||
* 4) This file may come in conflict with future platforms that do
|
||||
* include stdint.h. The hope is that one or the other can be
|
||||
* used with no real difference.
|
||||
*
|
||||
* 5) In the current verison, if your platform can't represent
|
||||
* int32_t, int16_t and int8_t, it just dumps out with a compiler
|
||||
* error.
|
||||
*
|
||||
* 6) 64 bit integers may or may not be defined. Test for their
|
||||
* presence with the test: #ifdef INT64_MAX or #ifdef UINT64_MAX.
|
||||
* Note that this is different from the C99 specification which
|
||||
* requires the existence of 64 bit support in the compiler. If
|
||||
* this is not defined for your platform, yet it is capable of
|
||||
* dealing with 64 bits then it is because this file has not yet
|
||||
* been extended to cover all of your system's capabilities.
|
||||
*
|
||||
* 7) (u)intptr_t may or may not be defined. Test for its presence
|
||||
* with the test: #ifdef PTRDIFF_MAX. If this is not defined
|
||||
* for your platform, then it is because this file has not yet
|
||||
* been extended to cover all of your system's capabilities, not
|
||||
* because its optional.
|
||||
*
|
||||
* 8) The following might not been defined even if your platform is
|
||||
* capable of defining it:
|
||||
*
|
||||
* WCHAR_MIN
|
||||
* WCHAR_MAX
|
||||
* (u)int64_t
|
||||
* PTRDIFF_MIN
|
||||
* PTRDIFF_MAX
|
||||
* (u)intptr_t
|
||||
*
|
||||
* 9) The following have not been defined:
|
||||
*
|
||||
* WINT_MIN
|
||||
* WINT_MAX
|
||||
*
|
||||
* 10) The criteria for defining (u)int_least(*)_t isn't clear,
|
||||
* except for systems which don't have a type that precisely
|
||||
* defined 8, 16, or 32 bit types (which this include file does
|
||||
* not support anyways). Default definitions have been given.
|
||||
*
|
||||
* 11) The criteria for defining (u)int_fast(*)_t isn't something I
|
||||
* would trust to any particular compiler vendor or the ANSI C
|
||||
* committee. It is well known that "compatible systems" are
|
||||
* commonly created that have very different performance
|
||||
* characteristics from the systems they are compatible with,
|
||||
* especially those whose vendors make both the compiler and the
|
||||
* system. Default definitions have been given, but its strongly
|
||||
* recommended that users never use these definitions for any
|
||||
* reason (they do *NOT* deliver any serious guarantee of
|
||||
* improved performance -- not in this file, nor any vendor's
|
||||
* stdint.h).
|
||||
*
|
||||
* 12) The following macros:
|
||||
*
|
||||
* PRINTF_INTMAX_MODIFIER
|
||||
* PRINTF_INT64_MODIFIER
|
||||
* PRINTF_INT32_MODIFIER
|
||||
* PRINTF_INT16_MODIFIER
|
||||
* PRINTF_LEAST64_MODIFIER
|
||||
* PRINTF_LEAST32_MODIFIER
|
||||
* PRINTF_LEAST16_MODIFIER
|
||||
* PRINTF_INTPTR_MODIFIER
|
||||
*
|
||||
* are strings which have been defined as the modifiers required
|
||||
* for the "d", "u" and "x" printf formats to correctly output
|
||||
* (u)intmax_t, (u)int64_t, (u)int32_t, (u)int16_t, (u)least64_t,
|
||||
* (u)least32_t, (u)least16_t and (u)intptr_t types respectively.
|
||||
* PRINTF_INTPTR_MODIFIER is not defined for some systems which
|
||||
* provide their own stdint.h. PRINTF_INT64_MODIFIER is not
|
||||
* defined if INT64_MAX is not defined. These are an extension
|
||||
* beyond what C99 specifies must be in stdint.h.
|
||||
*
|
||||
* In addition, the following macros are defined:
|
||||
*
|
||||
* PRINTF_INTMAX_HEX_WIDTH
|
||||
* PRINTF_INT64_HEX_WIDTH
|
||||
* PRINTF_INT32_HEX_WIDTH
|
||||
* PRINTF_INT16_HEX_WIDTH
|
||||
* PRINTF_INT8_HEX_WIDTH
|
||||
* PRINTF_INTMAX_DEC_WIDTH
|
||||
* PRINTF_INT64_DEC_WIDTH
|
||||
* PRINTF_INT32_DEC_WIDTH
|
||||
* PRINTF_INT16_DEC_WIDTH
|
||||
* PRINTF_INT8_DEC_WIDTH
|
||||
*
|
||||
* Which specifies the maximum number of characters required to
|
||||
* print the number of that type in either hexadecimal or decimal.
|
||||
* These are an extension beyond what C99 specifies must be in
|
||||
* stdint.h.
|
||||
*
|
||||
* Compilers tested (all with 0 warnings at their highest respective
|
||||
* settings): Borland Turbo C 2.0, WATCOM C/C++ 11.0 (16 bits and 32
|
||||
* bits), Microsoft Visual C++ 6.0 (32 bit), Microsoft Visual Studio
|
||||
* .net (VC7), Intel C++ 4.0, GNU gcc v3.3.3
|
||||
*
|
||||
* This file should be considered a work in progress. Suggestions for
|
||||
* improvements, especially those which increase coverage are strongly
|
||||
* encouraged.
|
||||
*
|
||||
* Acknowledgements
|
||||
*
|
||||
* The following people have made significant contributions to the
|
||||
* development and testing of this file:
|
||||
*
|
||||
* Chris Howie
|
||||
* John Steele Scott
|
||||
* Dave Thorup
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <limits.h>
|
||||
#include <signal.h>
|
||||
|
||||
/*
|
||||
* For gcc with _STDINT_H, fill in the PRINTF_INT*_MODIFIER macros, and
|
||||
* do nothing else. On the Mac OS X version of gcc this is _STDINT_H_.
|
||||
*/
|
||||
|
||||
#if ((defined(__STDC__) && __STDC__ && __STDC_VERSION__ >= 199901L) || (defined (__WATCOMC__) && (defined (_STDINT_H_INCLUDED) || __WATCOMC__ >= 1250)) || (defined(__GNUC__) && (defined(_STDINT_H) || defined(_STDINT_H_)) )) && !defined (_PSTDINT_H_INCLUDED)
|
||||
#include <stdint.h>
|
||||
#define _PSTDINT_H_INCLUDED
|
||||
# ifndef PRINTF_INT64_MODIFIER
|
||||
# define PRINTF_INT64_MODIFIER "ll"
|
||||
# endif
|
||||
# ifndef PRINTF_INT32_MODIFIER
|
||||
# define PRINTF_INT32_MODIFIER "l"
|
||||
# endif
|
||||
# ifndef PRINTF_INT16_MODIFIER
|
||||
# define PRINTF_INT16_MODIFIER "h"
|
||||
# endif
|
||||
# ifndef PRINTF_INTMAX_MODIFIER
|
||||
# define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
|
||||
# endif
|
||||
# ifndef PRINTF_INT64_HEX_WIDTH
|
||||
# define PRINTF_INT64_HEX_WIDTH "16"
|
||||
# endif
|
||||
# ifndef PRINTF_INT32_HEX_WIDTH
|
||||
# define PRINTF_INT32_HEX_WIDTH "8"
|
||||
# endif
|
||||
# ifndef PRINTF_INT16_HEX_WIDTH
|
||||
# define PRINTF_INT16_HEX_WIDTH "4"
|
||||
# endif
|
||||
# ifndef PRINTF_INT8_HEX_WIDTH
|
||||
# define PRINTF_INT8_HEX_WIDTH "2"
|
||||
# endif
|
||||
# ifndef PRINTF_INT64_DEC_WIDTH
|
||||
# define PRINTF_INT64_DEC_WIDTH "20"
|
||||
# endif
|
||||
# ifndef PRINTF_INT32_DEC_WIDTH
|
||||
# define PRINTF_INT32_DEC_WIDTH "10"
|
||||
# endif
|
||||
# ifndef PRINTF_INT16_DEC_WIDTH
|
||||
# define PRINTF_INT16_DEC_WIDTH "5"
|
||||
# endif
|
||||
# ifndef PRINTF_INT8_DEC_WIDTH
|
||||
# define PRINTF_INT8_DEC_WIDTH "3"
|
||||
# endif
|
||||
# ifndef PRINTF_INTMAX_HEX_WIDTH
|
||||
# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH
|
||||
# endif
|
||||
# ifndef PRINTF_INTMAX_DEC_WIDTH
|
||||
# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH
|
||||
# endif
|
||||
|
||||
/*
|
||||
* Something really weird is going on with Open Watcom. Just pull some of
|
||||
* these duplicated definitions from Open Watcom's stdint.h file for now.
|
||||
*/
|
||||
|
||||
# if defined (__WATCOMC__) && __WATCOMC__ >= 1250
|
||||
# if !defined (INT64_C)
|
||||
# define INT64_C(x) (x + (INT64_MAX - INT64_MAX))
|
||||
# endif
|
||||
# if !defined (UINT64_C)
|
||||
# define UINT64_C(x) (x + (UINT64_MAX - UINT64_MAX))
|
||||
# endif
|
||||
# if !defined (INT32_C)
|
||||
# define INT32_C(x) (x + (INT32_MAX - INT32_MAX))
|
||||
# endif
|
||||
# if !defined (UINT32_C)
|
||||
# define UINT32_C(x) (x + (UINT32_MAX - UINT32_MAX))
|
||||
# endif
|
||||
# if !defined (INT16_C)
|
||||
# define INT16_C(x) (x)
|
||||
# endif
|
||||
# if !defined (UINT16_C)
|
||||
# define UINT16_C(x) (x)
|
||||
# endif
|
||||
# if !defined (INT8_C)
|
||||
# define INT8_C(x) (x)
|
||||
# endif
|
||||
# if !defined (UINT8_C)
|
||||
# define UINT8_C(x) (x)
|
||||
# endif
|
||||
# if !defined (UINT64_MAX)
|
||||
# define UINT64_MAX 18446744073709551615ULL
|
||||
# endif
|
||||
# if !defined (INT64_MAX)
|
||||
# define INT64_MAX 9223372036854775807LL
|
||||
# endif
|
||||
# if !defined (UINT32_MAX)
|
||||
# define UINT32_MAX 4294967295UL
|
||||
# endif
|
||||
# if !defined (INT32_MAX)
|
||||
# define INT32_MAX 2147483647L
|
||||
# endif
|
||||
# if !defined (INTMAX_MAX)
|
||||
# define INTMAX_MAX INT64_MAX
|
||||
# endif
|
||||
# if !defined (INTMAX_MIN)
|
||||
# define INTMAX_MIN INT64_MIN
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef _PSTDINT_H_INCLUDED
|
||||
#define _PSTDINT_H_INCLUDED
|
||||
|
||||
#ifndef SIZE_MAX
|
||||
# define SIZE_MAX (~(size_t)0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Deduce the type assignments from limits.h under the assumption that
|
||||
* integer sizes in bits are powers of 2, and follow the ANSI
|
||||
* definitions.
|
||||
*/
|
||||
|
||||
#ifndef UINT8_MAX
|
||||
# define UINT8_MAX 0xff
|
||||
#endif
|
||||
#ifndef uint8_t
|
||||
# if (UCHAR_MAX == UINT8_MAX) || defined (S_SPLINT_S)
|
||||
typedef unsigned char uint8_t;
|
||||
# define UINT8_C(v) ((uint8_t) v)
|
||||
# else
|
||||
# error "Platform not supported"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef INT8_MAX
|
||||
# define INT8_MAX 0x7f
|
||||
#endif
|
||||
#ifndef INT8_MIN
|
||||
# define INT8_MIN INT8_C(0x80)
|
||||
#endif
|
||||
#ifndef int8_t
|
||||
# if (SCHAR_MAX == INT8_MAX) || defined (S_SPLINT_S)
|
||||
typedef signed char int8_t;
|
||||
# define INT8_C(v) ((int8_t) v)
|
||||
# else
|
||||
# error "Platform not supported"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef UINT16_MAX
|
||||
# define UINT16_MAX 0xffff
|
||||
#endif
|
||||
#ifndef uint16_t
|
||||
#if (UINT_MAX == UINT16_MAX) || defined (S_SPLINT_S)
|
||||
typedef unsigned int uint16_t;
|
||||
# ifndef PRINTF_INT16_MODIFIER
|
||||
# define PRINTF_INT16_MODIFIER ""
|
||||
# endif
|
||||
# define UINT16_C(v) ((uint16_t) (v))
|
||||
#elif (USHRT_MAX == UINT16_MAX)
|
||||
typedef unsigned short uint16_t;
|
||||
# define UINT16_C(v) ((uint16_t) (v))
|
||||
# ifndef PRINTF_INT16_MODIFIER
|
||||
# define PRINTF_INT16_MODIFIER "h"
|
||||
# endif
|
||||
#else
|
||||
#error "Platform not supported"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef INT16_MAX
|
||||
# define INT16_MAX 0x7fff
|
||||
#endif
|
||||
#ifndef INT16_MIN
|
||||
# define INT16_MIN INT16_C(0x8000)
|
||||
#endif
|
||||
#ifndef int16_t
|
||||
#if (INT_MAX == INT16_MAX) || defined (S_SPLINT_S)
|
||||
typedef signed int int16_t;
|
||||
# define INT16_C(v) ((int16_t) (v))
|
||||
# ifndef PRINTF_INT16_MODIFIER
|
||||
# define PRINTF_INT16_MODIFIER ""
|
||||
# endif
|
||||
#elif (SHRT_MAX == INT16_MAX)
|
||||
typedef signed short int16_t;
|
||||
# define INT16_C(v) ((int16_t) (v))
|
||||
# ifndef PRINTF_INT16_MODIFIER
|
||||
# define PRINTF_INT16_MODIFIER "h"
|
||||
# endif
|
||||
#else
|
||||
#error "Platform not supported"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef UINT32_MAX
|
||||
# define UINT32_MAX (0xffffffffUL)
|
||||
#endif
|
||||
#ifndef uint32_t
|
||||
#if (ULONG_MAX == UINT32_MAX) || defined (S_SPLINT_S)
|
||||
typedef unsigned long uint32_t;
|
||||
# define UINT32_C(v) v ## UL
|
||||
# ifndef PRINTF_INT32_MODIFIER
|
||||
# define PRINTF_INT32_MODIFIER "l"
|
||||
# endif
|
||||
#elif (UINT_MAX == UINT32_MAX)
|
||||
typedef unsigned int uint32_t;
|
||||
# ifndef PRINTF_INT32_MODIFIER
|
||||
# define PRINTF_INT32_MODIFIER ""
|
||||
# endif
|
||||
# define UINT32_C(v) v ## U
|
||||
#elif (USHRT_MAX == UINT32_MAX)
|
||||
typedef unsigned short uint32_t;
|
||||
# define UINT32_C(v) ((unsigned short) (v))
|
||||
# ifndef PRINTF_INT32_MODIFIER
|
||||
# define PRINTF_INT32_MODIFIER ""
|
||||
# endif
|
||||
#else
|
||||
#error "Platform not supported"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef INT32_MAX
|
||||
# define INT32_MAX (0x7fffffffL)
|
||||
#endif
|
||||
#ifndef INT32_MIN
|
||||
# define INT32_MIN INT32_C(0x80000000)
|
||||
#endif
|
||||
#ifndef int32_t
|
||||
#if (LONG_MAX == INT32_MAX) || defined (S_SPLINT_S)
|
||||
typedef signed long int32_t;
|
||||
# define INT32_C(v) v ## L
|
||||
# ifndef PRINTF_INT32_MODIFIER
|
||||
# define PRINTF_INT32_MODIFIER "l"
|
||||
# endif
|
||||
#elif (INT_MAX == INT32_MAX)
|
||||
typedef signed int int32_t;
|
||||
# define INT32_C(v) v
|
||||
# ifndef PRINTF_INT32_MODIFIER
|
||||
# define PRINTF_INT32_MODIFIER ""
|
||||
# endif
|
||||
#elif (SHRT_MAX == INT32_MAX)
|
||||
typedef signed short int32_t;
|
||||
# define INT32_C(v) ((short) (v))
|
||||
# ifndef PRINTF_INT32_MODIFIER
|
||||
# define PRINTF_INT32_MODIFIER ""
|
||||
# endif
|
||||
#else
|
||||
#error "Platform not supported"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The macro stdint_int64_defined is temporarily used to record
|
||||
* whether or not 64 integer support is available. It must be
|
||||
* defined for any 64 integer extensions for new platforms that are
|
||||
* added.
|
||||
*/
|
||||
|
||||
#undef stdint_int64_defined
|
||||
#if (defined(__STDC__) && defined(__STDC_VERSION__)) || defined (S_SPLINT_S)
|
||||
# if (__STDC__ && __STDC_VERSION >= 199901L) || defined (S_SPLINT_S)
|
||||
# define stdint_int64_defined
|
||||
typedef long long int64_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
# define UINT64_C(v) v ## ULL
|
||||
# define INT64_C(v) v ## LL
|
||||
# ifndef PRINTF_INT64_MODIFIER
|
||||
# define PRINTF_INT64_MODIFIER "ll"
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined (stdint_int64_defined)
|
||||
# if defined(__GNUC__)
|
||||
# define stdint_int64_defined
|
||||
__extension__ typedef long long int64_t;
|
||||
__extension__ typedef unsigned long long uint64_t;
|
||||
# define UINT64_C(v) v ## ULL
|
||||
# define INT64_C(v) v ## LL
|
||||
# ifndef PRINTF_INT64_MODIFIER
|
||||
# define PRINTF_INT64_MODIFIER "ll"
|
||||
# endif
|
||||
# elif defined(__MWERKS__) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || defined (__APPLE_CC__) || defined (_LONG_LONG) || defined (_CRAYC) || defined (S_SPLINT_S)
|
||||
# define stdint_int64_defined
|
||||
typedef long long int64_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
# define UINT64_C(v) v ## ULL
|
||||
# define INT64_C(v) v ## LL
|
||||
# ifndef PRINTF_INT64_MODIFIER
|
||||
# define PRINTF_INT64_MODIFIER "ll"
|
||||
# endif
|
||||
# elif (defined(__WATCOMC__) && defined(__WATCOM_INT64__)) || (defined(_MSC_VER) && _INTEGRAL_MAX_BITS >= 64) || (defined (__BORLANDC__) && __BORLANDC__ > 0x460) || defined (__alpha) || defined (__DECC)
|
||||
# define stdint_int64_defined
|
||||
typedef __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
# define UINT64_C(v) v ## UI64
|
||||
# define INT64_C(v) v ## I64
|
||||
# ifndef PRINTF_INT64_MODIFIER
|
||||
# define PRINTF_INT64_MODIFIER "I64"
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined (LONG_LONG_MAX) && defined (INT64_C)
|
||||
# define LONG_LONG_MAX INT64_C (9223372036854775807)
|
||||
#endif
|
||||
#ifndef ULONG_LONG_MAX
|
||||
# define ULONG_LONG_MAX UINT64_C (18446744073709551615)
|
||||
#endif
|
||||
|
||||
#if !defined (INT64_MAX) && defined (INT64_C)
|
||||
# define INT64_MAX INT64_C (9223372036854775807)
|
||||
#endif
|
||||
#if !defined (INT64_MIN) && defined (INT64_C)
|
||||
# define INT64_MIN INT64_C (-9223372036854775808)
|
||||
#endif
|
||||
#if !defined (UINT64_MAX) && defined (INT64_C)
|
||||
# define UINT64_MAX UINT64_C (18446744073709551615)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Width of hexadecimal for number field.
|
||||
*/
|
||||
|
||||
#ifndef PRINTF_INT64_HEX_WIDTH
|
||||
# define PRINTF_INT64_HEX_WIDTH "16"
|
||||
#endif
|
||||
#ifndef PRINTF_INT32_HEX_WIDTH
|
||||
# define PRINTF_INT32_HEX_WIDTH "8"
|
||||
#endif
|
||||
#ifndef PRINTF_INT16_HEX_WIDTH
|
||||
# define PRINTF_INT16_HEX_WIDTH "4"
|
||||
#endif
|
||||
#ifndef PRINTF_INT8_HEX_WIDTH
|
||||
# define PRINTF_INT8_HEX_WIDTH "2"
|
||||
#endif
|
||||
|
||||
#ifndef PRINTF_INT64_DEC_WIDTH
|
||||
# define PRINTF_INT64_DEC_WIDTH "20"
|
||||
#endif
|
||||
#ifndef PRINTF_INT32_DEC_WIDTH
|
||||
# define PRINTF_INT32_DEC_WIDTH "10"
|
||||
#endif
|
||||
#ifndef PRINTF_INT16_DEC_WIDTH
|
||||
# define PRINTF_INT16_DEC_WIDTH "5"
|
||||
#endif
|
||||
#ifndef PRINTF_INT8_DEC_WIDTH
|
||||
# define PRINTF_INT8_DEC_WIDTH "3"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Ok, lets not worry about 128 bit integers for now. Moore's law says
|
||||
* we don't need to worry about that until about 2040 at which point
|
||||
* we'll have bigger things to worry about.
|
||||
*/
|
||||
|
||||
#ifdef stdint_int64_defined
|
||||
typedef int64_t intmax_t;
|
||||
typedef uint64_t uintmax_t;
|
||||
# define INTMAX_MAX INT64_MAX
|
||||
# define INTMAX_MIN INT64_MIN
|
||||
# define UINTMAX_MAX UINT64_MAX
|
||||
# define UINTMAX_C(v) UINT64_C(v)
|
||||
# define INTMAX_C(v) INT64_C(v)
|
||||
# ifndef PRINTF_INTMAX_MODIFIER
|
||||
# define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
|
||||
# endif
|
||||
# ifndef PRINTF_INTMAX_HEX_WIDTH
|
||||
# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH
|
||||
# endif
|
||||
# ifndef PRINTF_INTMAX_DEC_WIDTH
|
||||
# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH
|
||||
# endif
|
||||
#else
|
||||
typedef int32_t intmax_t;
|
||||
typedef uint32_t uintmax_t;
|
||||
# define INTMAX_MAX INT32_MAX
|
||||
# define UINTMAX_MAX UINT32_MAX
|
||||
# define UINTMAX_C(v) UINT32_C(v)
|
||||
# define INTMAX_C(v) INT32_C(v)
|
||||
# ifndef PRINTF_INTMAX_MODIFIER
|
||||
# define PRINTF_INTMAX_MODIFIER PRINTF_INT32_MODIFIER
|
||||
# endif
|
||||
# ifndef PRINTF_INTMAX_HEX_WIDTH
|
||||
# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT32_HEX_WIDTH
|
||||
# endif
|
||||
# ifndef PRINTF_INTMAX_DEC_WIDTH
|
||||
# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT32_DEC_WIDTH
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Because this file currently only supports platforms which have
|
||||
* precise powers of 2 as bit sizes for the default integers, the
|
||||
* least definitions are all trivial. Its possible that a future
|
||||
* version of this file could have different definitions.
|
||||
*/
|
||||
|
||||
#ifndef stdint_least_defined
|
||||
typedef int8_t int_least8_t;
|
||||
typedef uint8_t uint_least8_t;
|
||||
typedef int16_t int_least16_t;
|
||||
typedef uint16_t uint_least16_t;
|
||||
typedef int32_t int_least32_t;
|
||||
typedef uint32_t uint_least32_t;
|
||||
# define PRINTF_LEAST32_MODIFIER PRINTF_INT32_MODIFIER
|
||||
# define PRINTF_LEAST16_MODIFIER PRINTF_INT16_MODIFIER
|
||||
# define UINT_LEAST8_MAX UINT8_MAX
|
||||
# define INT_LEAST8_MAX INT8_MAX
|
||||
# define UINT_LEAST16_MAX UINT16_MAX
|
||||
# define INT_LEAST16_MAX INT16_MAX
|
||||
# define UINT_LEAST32_MAX UINT32_MAX
|
||||
# define INT_LEAST32_MAX INT32_MAX
|
||||
# define INT_LEAST8_MIN INT8_MIN
|
||||
# define INT_LEAST16_MIN INT16_MIN
|
||||
# define INT_LEAST32_MIN INT32_MIN
|
||||
# ifdef stdint_int64_defined
|
||||
typedef int64_t int_least64_t;
|
||||
typedef uint64_t uint_least64_t;
|
||||
# define PRINTF_LEAST64_MODIFIER PRINTF_INT64_MODIFIER
|
||||
# define UINT_LEAST64_MAX UINT64_MAX
|
||||
# define INT_LEAST64_MAX INT64_MAX
|
||||
# define INT_LEAST64_MIN INT64_MIN
|
||||
# endif
|
||||
#endif
|
||||
#undef stdint_least_defined
|
||||
|
||||
/*
|
||||
* The ANSI C committee pretending to know or specify anything about
|
||||
* performance is the epitome of misguided arrogance. The mandate of
|
||||
* this file is to *ONLY* ever support that absolute minimum
|
||||
* definition of the fast integer types, for compatibility purposes.
|
||||
* No extensions, and no attempt to suggest what may or may not be a
|
||||
* faster integer type will ever be made in this file. Developers are
|
||||
* warned to stay away from these types when using this or any other
|
||||
* stdint.h.
|
||||
*/
|
||||
|
||||
typedef int_least8_t int_fast8_t;
|
||||
typedef uint_least8_t uint_fast8_t;
|
||||
typedef int_least16_t int_fast16_t;
|
||||
typedef uint_least16_t uint_fast16_t;
|
||||
typedef int_least32_t int_fast32_t;
|
||||
typedef uint_least32_t uint_fast32_t;
|
||||
#define UINT_FAST8_MAX UINT_LEAST8_MAX
|
||||
#define INT_FAST8_MAX INT_LEAST8_MAX
|
||||
#define UINT_FAST16_MAX UINT_LEAST16_MAX
|
||||
#define INT_FAST16_MAX INT_LEAST16_MAX
|
||||
#define UINT_FAST32_MAX UINT_LEAST32_MAX
|
||||
#define INT_FAST32_MAX INT_LEAST32_MAX
|
||||
#define INT_FAST8_MIN INT_LEAST8_MIN
|
||||
#define INT_FAST16_MIN INT_LEAST16_MIN
|
||||
#define INT_FAST32_MIN INT_LEAST32_MIN
|
||||
#ifdef stdint_int64_defined
|
||||
typedef int_least64_t int_fast64_t;
|
||||
typedef uint_least64_t uint_fast64_t;
|
||||
# define UINT_FAST64_MAX UINT_LEAST64_MAX
|
||||
# define INT_FAST64_MAX INT_LEAST64_MAX
|
||||
# define INT_FAST64_MIN INT_LEAST64_MIN
|
||||
#endif
|
||||
|
||||
#undef stdint_int64_defined
|
||||
|
||||
/*
|
||||
* Whatever piecemeal, per compiler thing we can do about the wchar_t
|
||||
* type limits.
|
||||
*/
|
||||
|
||||
#if defined(__WATCOMC__) || defined(_MSC_VER) || defined (__GNUC__)
|
||||
# include <wchar.h>
|
||||
# ifndef WCHAR_MIN
|
||||
# define WCHAR_MIN 0
|
||||
# endif
|
||||
# ifndef WCHAR_MAX
|
||||
# define WCHAR_MAX ((wchar_t)-1)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Whatever piecemeal, per compiler/platform thing we can do about the
|
||||
* (u)intptr_t types and limits.
|
||||
*/
|
||||
|
||||
#if defined (_MSC_VER) && defined (_UINTPTR_T_DEFINED)
|
||||
# define STDINT_H_UINTPTR_T_DEFINED
|
||||
#endif
|
||||
|
||||
#ifndef STDINT_H_UINTPTR_T_DEFINED
|
||||
# if defined (__alpha__) || defined (__ia64__) || defined (__x86_64__) || defined (_WIN64)
|
||||
# define stdint_intptr_bits 64
|
||||
# elif defined (__WATCOMC__) || defined (__TURBOC__)
|
||||
# if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
|
||||
# define stdint_intptr_bits 16
|
||||
# else
|
||||
# define stdint_intptr_bits 32
|
||||
# endif
|
||||
# elif defined (__i386__) || defined (_WIN32) || defined (WIN32)
|
||||
# define stdint_intptr_bits 32
|
||||
# elif defined (__INTEL_COMPILER)
|
||||
/* TODO -- what will Intel do about x86-64? */
|
||||
# endif
|
||||
|
||||
# ifdef stdint_intptr_bits
|
||||
# define stdint_intptr_glue3_i(a,b,c) a##b##c
|
||||
# define stdint_intptr_glue3(a,b,c) stdint_intptr_glue3_i(a,b,c)
|
||||
# ifndef PRINTF_INTPTR_MODIFIER
|
||||
# define PRINTF_INTPTR_MODIFIER stdint_intptr_glue3(PRINTF_INT,stdint_intptr_bits,_MODIFIER)
|
||||
# endif
|
||||
# ifndef PTRDIFF_MAX
|
||||
# define PTRDIFF_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
|
||||
# endif
|
||||
# ifndef PTRDIFF_MIN
|
||||
# define PTRDIFF_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
|
||||
# endif
|
||||
# ifndef UINTPTR_MAX
|
||||
# define UINTPTR_MAX stdint_intptr_glue3(UINT,stdint_intptr_bits,_MAX)
|
||||
# endif
|
||||
# ifndef INTPTR_MAX
|
||||
# define INTPTR_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
|
||||
# endif
|
||||
# ifndef INTPTR_MIN
|
||||
# define INTPTR_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
|
||||
# endif
|
||||
# ifndef INTPTR_C
|
||||
# define INTPTR_C(x) stdint_intptr_glue3(INT,stdint_intptr_bits,_C)(x)
|
||||
# endif
|
||||
# ifndef UINTPTR_C
|
||||
# define UINTPTR_C(x) stdint_intptr_glue3(UINT,stdint_intptr_bits,_C)(x)
|
||||
# endif
|
||||
typedef stdint_intptr_glue3(uint,stdint_intptr_bits,_t) uintptr_t;
|
||||
typedef stdint_intptr_glue3( int,stdint_intptr_bits,_t) intptr_t;
|
||||
# else
|
||||
/* TODO -- This following is likely wrong for some platforms, and does
|
||||
nothing for the definition of uintptr_t. */
|
||||
typedef ptrdiff_t intptr_t;
|
||||
# endif
|
||||
# define STDINT_H_UINTPTR_T_DEFINED
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Assumes sig_atomic_t is signed and we have a 2s complement machine.
|
||||
*/
|
||||
|
||||
#ifndef SIG_ATOMIC_MAX
|
||||
# define SIG_ATOMIC_MAX ((((sig_atomic_t) 1) << (sizeof (sig_atomic_t)*CHAR_BIT-1)) - 1)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -34,4 +34,7 @@ struct X
|
|||
# pragma warning (disable : 4103)
|
||||
#endif
|
||||
|
||||
|
||||
#define AI_PUSHPACK_IS_DEFINED
|
||||
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ void aiAssert (bool expression, const std::string &message, unsigned int uiLine,
|
|||
//! \def ai_assert
|
||||
//! \brief ASSIM specific assertion test
|
||||
#ifdef DEBUG
|
||||
# define ai_assert(expression) aiAssert (expression, #expression, __LINE__, __FILE__);
|
||||
# define ai_assert(expression) Assimp::aiAssert (expression, #expression, __LINE__, __FILE__);
|
||||
#else
|
||||
# define ai_assert(expression)
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (ASSIMP)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the following
|
||||
conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the ASSIMP team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the ASSIMP Development Team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file Defines the aiCamera data structure
|
||||
*/
|
||||
|
||||
#ifndef AI_CAMERA_H_INC
|
||||
#define AI_CAMERA_H_INC
|
||||
|
||||
#include "aiTypes.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Helper structure to describe a camera.
|
||||
*
|
||||
*
|
||||
*/
|
||||
struct aiCamera
|
||||
{
|
||||
/** The name of the camera.
|
||||
*
|
||||
* By this name it is referenced by a node in the scene graph.
|
||||
*/
|
||||
aiString mName;
|
||||
|
||||
|
||||
float fHorizontalFOV;
|
||||
|
||||
float fCLipPlaneNear;
|
||||
float fCLipPlaneFar;
|
||||
};
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AI_CAMERA_H_INC
|
|
@ -102,15 +102,24 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** \brief Causes the 3DS loader to ignore pivot points in the file
|
||||
/** \brief Configures the 3DS loader to ignore pivot points in the file
|
||||
*
|
||||
* There are some faulty 3DS files which look only correctly with
|
||||
* pivot points disabled.
|
||||
* Property type: integer (1: true; !1: false).
|
||||
* Property type: integer (0: false; !0: true). Default value: false.
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_3DS_IGNORE_PIVOT "imp.3ds.nopivot"
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** \brief Configures the AC loader to collect all surfaces which have the
|
||||
* "Backface cull" flag set in separate meshes.
|
||||
*
|
||||
* Property type: integer (0: false; !0: true). Default value: true.
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_AC_SEPARATE_BFCULL "imp.ac.sepbfcull"
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** \brief Specifies the maximum angle that may be between two vertex tangents
|
||||
* that their tangents and bitangents are smoothed.
|
||||
|
@ -139,25 +148,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
* This is an input parameter to the OptimizeGraph-Step.
|
||||
*
|
||||
* Nodes whose referenced meshes have less faces than this value
|
||||
* are propably joined with neighbors with identical world matrices.
|
||||
* are propably joined with neighbors with identical local matrices.
|
||||
* However, it is just a hint to the step.
|
||||
* Property type: integer
|
||||
*/
|
||||
#define AI_CONFIG_PP_OG_MIN_NUM_FACES "pp.og.min_faces"
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** \brief Specifies whether animations are removed from the asset.
|
||||
* This is an input parameter to the OptimizeGraph-Step.
|
||||
*
|
||||
* If an application does not need the animation data, erasing it at the
|
||||
* beginning of the post-process pipeline allows some steps - including
|
||||
* OptimizeGraph itself - to apply further optimizations.
|
||||
* Property type: integer (1: true; !1: false).
|
||||
*/
|
||||
#define AI_CONFIG_PP_OG_REMOVE_ANIMATIONS "pp.og.remove_anims"
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** \brief Specifies whether the OptimizeGraphProcess joins nodes even if
|
||||
* their local transformations are inequal.
|
||||
|
@ -186,36 +183,77 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
enum aiVertexComponent
|
||||
enum aiComponent
|
||||
{
|
||||
//! Normal vectors
|
||||
aiVertexComponent_NORMALS = 0x2u,
|
||||
aiComponent_NORMALS = 0x2u,
|
||||
|
||||
//! Tangents and bitangents go always together ...
|
||||
aiVertexComponent_TANGENTS_AND_BITANGENTS = 0x4u,
|
||||
aiComponent_TANGENTS_AND_BITANGENTS = 0x4u,
|
||||
|
||||
//! ALL color sets
|
||||
//! Use aiVertexComponent_COLORn(N) to specifiy the N'th set
|
||||
aiVertexComponent_COLORS = 0x8,
|
||||
//! Use aiComponent_COLORn(N) to specifiy the N'th set
|
||||
aiComponent_COLORS = 0x8,
|
||||
|
||||
//! ALL texture UV sets
|
||||
//! aiVertexComponent_TEXCOORDn(N) to specifiy the N'th set
|
||||
aiVertexComponent_TEXCOORDS = 0x10,
|
||||
//! aiComponent_TEXCOORDn(N) to specifiy the N'th set
|
||||
aiComponent_TEXCOORDS = 0x10,
|
||||
|
||||
//! Removes all bone weights from all meshes.
|
||||
//! The scenegraph nodes corresponding to the
|
||||
//! bones are removed
|
||||
aiComponent_BONEWEIGHTS = 0x20,
|
||||
|
||||
//! Removes all bone animations (aiScene::mAnimations)
|
||||
aiComponent_ANIMATIONS = 0x40,
|
||||
|
||||
//! Removes all embedded textures (aiScene::mTextures)
|
||||
aiComponent_TEXTURES = 0x80,
|
||||
|
||||
//! Removes all light sources (aiScene::mLights)
|
||||
//! The scenegraph nodes corresponding to the
|
||||
//! light sources are removed.
|
||||
aiComponent_LIGHTS = 0x100,
|
||||
|
||||
//! Removes all light sources (aiScene::mCameras)
|
||||
//! The scenegraph nodes corresponding to the
|
||||
//! cameras are removed.
|
||||
aiComponent_CAMERAS = 0x200,
|
||||
|
||||
//! Removes all meshes (aiScene::mMeshes). The
|
||||
//! #AI_SCENE_FLAGS_ANIM_SKELETON_ONLY flag is set in aiScene::mFlags.
|
||||
aiComponent_MESHES = 0x400,
|
||||
};
|
||||
|
||||
#define aiVertexComponent_COLORSn(n) (1u << (n+10u))
|
||||
#define aiVertexComponent_TEXCOORDSn(n) (1u << (n+20u))
|
||||
#define aiComponent_COLORSn(n) (1u << (n+20u))
|
||||
#define aiComponent_TEXCOORDSn(n) (1u << (n+25u))
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** \brief Input parameter to the #aiProcess_RemVertexComponentXYZ step:
|
||||
* Specifies the vertex components to be removed.
|
||||
/** \brief Input parameter to the #aiProcess_RemoveComponent step:
|
||||
* Specifies the parts of the data structure to be removed.
|
||||
*
|
||||
* See the documentation to this step for further details. The property
|
||||
* is expected to be an integer, a bitwise combination of the
|
||||
* #aiVertexComponent flags defined above in this header. The default
|
||||
* value is 0.
|
||||
* #aiComponent flags defined above in this header. The default
|
||||
* value is 0. Important: if no valid mesh is remaining after the
|
||||
* step has been executed (e.g you thought it was funny to specify ALL
|
||||
* of the flags defined above) the import FAILS. Mainly because there is
|
||||
* no data to work on anymore ...
|
||||
*/
|
||||
#define AI_CONFIG_PP_RVC_FLAGS "pp.rvc.flags"
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** \brief Causes assimp to favour speed against import quality.
|
||||
*
|
||||
* Enabling this option may result in faster loading, but it needn't.
|
||||
* It represents just a hint to loaders and post-processing steps to use
|
||||
* faster code paths, if possible.
|
||||
* This property is expected to be an integer, != 0 stands for true.
|
||||
* The default value is 0.
|
||||
*/
|
||||
#define AI_CONFIG_FAVOUR_SPEED "imp.speed_flag"
|
||||
|
||||
#endif // !! AI_CONFIG_H_INC
|
||||
|
|
|
@ -39,21 +39,72 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** Assimo build configuration setup. See the notes in the comment
|
||||
* blocks to find out how you can customize the Assimp build
|
||||
*/
|
||||
|
||||
#ifndef AI_DEFINES_H_INC
|
||||
#define AI_DEFINES_H_INC
|
||||
|
||||
|
||||
// ************************************************************
|
||||
// Define ASSIMP_BUILD_NO_XX_LOADER to disable a specific
|
||||
// file format loader. The loader will be excluded from the
|
||||
// build in this case. 'XX' stands for the file extension
|
||||
// of the loader, e.g. ASSIMP_BUILD_NO_X_LOADER will disable
|
||||
// the X loader.
|
||||
// ************************************************************
|
||||
|
||||
// ************************************************************
|
||||
// Define ASSIMP_BUILD_NO_XX_PROCESS to disable a specific
|
||||
// post-processing step. The spe will be excluded from the
|
||||
// build in this case. 'XX' stands for the name of the loader.
|
||||
// Name list:
|
||||
//
|
||||
// CALCTANGENTS
|
||||
// JOINVERTICES
|
||||
// CONVERTTOLH
|
||||
// TRIANGULATE
|
||||
// GENFACENORMALS
|
||||
// GENVERTEXNORMALS
|
||||
// REMOVEVC
|
||||
// SPLITLARGEMESHES
|
||||
// PRETRANSFORMVERTICES
|
||||
// LIMITBONEWEIGHTS
|
||||
// VALIDATEDS
|
||||
// IMPROVECACHELOCALITY
|
||||
// FIXINFACINGNORMALS
|
||||
// REMOVE_REDUNDANTMATERIALS
|
||||
// OPTIMIZEGRAPH
|
||||
// SORTBYPTYPE
|
||||
// FINDINVALIDDATA
|
||||
// ************************************************************
|
||||
|
||||
|
||||
// ************************************************************
|
||||
// Define AI_C_THREADSAFE if you want a thread-safe C-API
|
||||
// This feature requires boost.
|
||||
// ************************************************************
|
||||
|
||||
|
||||
// compiler specific includes and definitions
|
||||
#if (defined _MSC_VER)
|
||||
|
||||
// include stdint.h from the C98 standard
|
||||
# include "Compiler/MSVC/stdint.h"
|
||||
# include "Compiler/pstdint.h"
|
||||
|
||||
# undef ASSIMP_API
|
||||
|
||||
|
||||
// ************************************************************
|
||||
// Define ASSIMP_BUILD_DLL_EXPORT to build a DLL of the library
|
||||
// ************************************************************
|
||||
# if (defined ASSIMP_BUILD_DLL_EXPORT)
|
||||
|
||||
# if (defined ASSIMP_API)
|
||||
# error ASSIMP_API is defined, although it shouldn't
|
||||
# endif
|
||||
|
||||
# define ASSIMP_API __declspec(dllexport)
|
||||
# pragma warning (disable : 4251)
|
||||
|
||||
|
@ -67,8 +118,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
# define ASSIMP_API
|
||||
# endif
|
||||
|
||||
# define AI_FORCE_INLINE __forceinline
|
||||
|
||||
#else
|
||||
# define ASSIMP_API
|
||||
# define AI_FORCE_INLINE inline
|
||||
#endif // (defined _MSC_VER)
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -78,6 +132,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
// To build the documentation, make sure ASSIMP_DOXYGEN_BUILD
|
||||
// is defined by Doxygen's preprocessor. The corresponding
|
||||
// entries in the DoxyFile look like this:
|
||||
// ************************************************************
|
||||
#if 0
|
||||
ENABLE_PREPROCESSING = YES
|
||||
MACRO_EXPANSION = YES
|
||||
|
@ -97,6 +152,33 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#if (defined(__BORLANDC__) || defined (__BCPLUSPLUS__))
|
||||
|
||||
// for borland add the replacement pstdint.h, too
|
||||
# include "Compiler/pstdint.h"
|
||||
|
||||
// "W8059 Packgröße der Struktur geändert"
|
||||
// TODO: find a way to deactivate this warning automatically
|
||||
// maybe there is a pragma to do exactly this?
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// ************************************************************
|
||||
// Define ASSIMP_BUILD_BOOST_WORKAROUND to compile assimp
|
||||
// without boost. This is done by using a few workaround
|
||||
// classes. However, some assimp features are not available
|
||||
// in this case.
|
||||
// ************************************************************
|
||||
#ifdef ASSIMP_BUILD_BOOST_WORKAROUND
|
||||
|
||||
// threading support in the C-API requires boost
|
||||
# ifdef AI_C_THREADSAFE
|
||||
# error Unable to activate C-API threading support. Boost is required for this.
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
// helper macro that sets a pointer to NULL in debug builds
|
||||
#if (!defined AI_DEBUG_INVALIDATE_PTR)
|
||||
# if (defined _DEBUG)
|
||||
|
@ -106,9 +188,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
# endif
|
||||
#endif
|
||||
|
||||
// Use our own definition of PI here
|
||||
#define AI_MATH_PI (3.1415926538)
|
||||
#define AI_MATH_TWO_PI (AI_MATH_PI * 2.0)
|
||||
|
||||
// macrod to convert from radians to degrees and the reverse
|
||||
#define AI_DEG_TO_RAD(x) (x*0.0174532925f)
|
||||
#define AI_RAD_TO_DEG(x) (x*57.2957795f)
|
||||
|
||||
|
|
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (ASSIMP)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2008, ASSIMP Development Team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the following
|
||||
conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the ASSIMP team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the ASSIMP Development Team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file Defines the aiLight data structure
|
||||
*/
|
||||
|
||||
#ifndef AI_TEXTURE_H_INC
|
||||
#define AI_TEXTURE_H_INC
|
||||
|
||||
#include "aiTypes.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Enumerates all supported types of light sources.
|
||||
*/
|
||||
enum aiLightSourceType
|
||||
{
|
||||
aiLightSource_UNDEFINED = 0x0,
|
||||
aiLightSource_DIRECTIONAL = 0x1,
|
||||
aiLightSource_POINT = 0x2,
|
||||
aiLightSource_SPOT = 0x3
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Helper structure to describe a light source.
|
||||
*
|
||||
* Assimp supports multiple sorts of light sources, including
|
||||
* directional, point and spot lights. All of them are defined with just
|
||||
* a single structure.
|
||||
*/
|
||||
struct aiLight
|
||||
{
|
||||
/** The name of the light sources.
|
||||
*
|
||||
* By this name it is referenced by a node in the scene graph.
|
||||
*/
|
||||
aiString mName;
|
||||
|
||||
/** The type of the light source.
|
||||
*/
|
||||
aiLightSourceType mType;
|
||||
|
||||
aiMatrix4x4 mLocalTransform;
|
||||
|
||||
float mAttenuationConstant;
|
||||
float mAttenuationLinear;
|
||||
float mAttenuationQuadratic;
|
||||
|
||||
aiColor3D mColorDiffuse;
|
||||
aiColor3D mColorSpecular;
|
||||
aiColor3D mColorAmbient;
|
||||
|
||||
float mAngleOuterCone;
|
||||
float mAngleInnerCone;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
aiLight()
|
||||
: mType (aiLightSource_UNDEFINED)
|
||||
, mAttenuationConstant (0.f)
|
||||
, mAttenuationLinear (1.f)
|
||||
, mAttenuationQuadratic (0.f)
|
||||
, mAngleOuterCone (AI_MATH_TWO_PI)
|
||||
, mAngleInnerCone (AI_MATH_TWO_PI)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
|
@ -49,15 +49,7 @@ extern "C" {
|
|||
struct aiMatrix3x3;
|
||||
struct aiQuaternion;
|
||||
|
||||
// Set packing to 4
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
|
||||
#pragma pack(push,4)
|
||||
#define PACK_STRUCT
|
||||
#elif defined( __GNUC__ )
|
||||
#define PACK_STRUCT __attribute__((packed))
|
||||
#else
|
||||
#error Compiler not supported
|
||||
#endif
|
||||
#include "./Compiler/pushpack1.h"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a row-major 4x4 matrix,
|
||||
|
@ -170,11 +162,7 @@ struct aiMatrix4x4
|
|||
} PACK_STRUCT;
|
||||
|
||||
|
||||
// Reset packing
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
|
||||
#pragma pack( pop )
|
||||
#endif
|
||||
#undef PACK_STRUCT
|
||||
#include "./Compiler/poppack1.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // end extern "C"
|
||||
|
|
|
@ -217,12 +217,12 @@ inline void aiMatrix4x4::FromEulerAngles(float x, float y, float z)
|
|||
{
|
||||
aiMatrix4x4& _this = *this;
|
||||
|
||||
const float A = ::cosf(x);
|
||||
const float B = ::sinf(x);
|
||||
const float C = ::cosf(y);
|
||||
const float D = ::sinf(y);
|
||||
const float E = ::cosf(z);
|
||||
const float F = ::sinf(z);
|
||||
const float A = ::cos(x);
|
||||
const float B = ::sin(x);
|
||||
const float C = ::cos(y);
|
||||
const float D = ::sin(y);
|
||||
const float E = ::cos(z);
|
||||
const float F = ::sin(z);
|
||||
const float AD = A * D;
|
||||
const float BD = B * D;
|
||||
_this.a1 = C * E;
|
||||
|
|
|
@ -259,13 +259,13 @@ enum aiPrimitiveType
|
|||
{
|
||||
/** A point primitive.
|
||||
* This is just a single vertex in the virtual world,
|
||||
* #aiFace contains just one index for such a primitive,
|
||||
* #aiFace contains just one index for such a primitive.
|
||||
*/
|
||||
aiPrimitiveType_POINT = 0x1,
|
||||
|
||||
/** A line primitive.
|
||||
* This is a line defined through a start and an end position.
|
||||
* #aiFace contains exactly two indices for such a primitive,
|
||||
* #aiFace contains exactly two indices for such a primitive.
|
||||
*/
|
||||
aiPrimitiveType_LINE = 0x2,
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue