NFF finished except cone implementation.
Added fixes by lynxeye to make assimp work with GCC 4. Website - again a backup of the current version. git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@130 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
This commit is contained in:
@@ -265,6 +265,12 @@ void Dot3DSImporter::ConvertMaterial(Dot3DS::Material& oldMat,
|
||||
|
||||
case Dot3DS::Dot3DSFile::Metal :
|
||||
eShading = aiShadingMode_CookTorrance; break;
|
||||
|
||||
// FIX to workaround a warning with GCC 4 who complained
|
||||
// about a missing case Blinn: here - Blinn isn't a valid
|
||||
// value in the 3DS Loader, it is just needed for ASE
|
||||
case Dot3DS::Dot3DSFile::Blinn :
|
||||
eShading = aiShadingMode_Blinn; break;
|
||||
}
|
||||
mat.AddProperty<int>( (int*)&eShading,1,AI_MATKEY_SHADING_MODEL);
|
||||
|
||||
@@ -402,7 +408,6 @@ void Dot3DSImporter::ConvertMeshes(aiScene* pcOut)
|
||||
aiSplit[*a].push_back(iNum);
|
||||
}
|
||||
// now generate submeshes
|
||||
bool bFirst = true;
|
||||
for (unsigned int p = 0; p < this->mScene->mMaterials.size();++p)
|
||||
{
|
||||
if (aiSplit[p].size() != 0)
|
||||
@@ -586,8 +591,6 @@ void Dot3DSImporter::GenerateNodeGraph(aiScene* pcOut)
|
||||
// | | | |
|
||||
// MESH_0 MESH_1 MESH_2 ... MESH_N
|
||||
//
|
||||
unsigned int iCnt = 0;
|
||||
|
||||
DefaultLogger::get()->warn("No hierarchy information has been found in the file. ");
|
||||
|
||||
pcOut->mRootNode->mNumChildren = pcOut->mNumMeshes;
|
||||
|
||||
+3
-3
@@ -326,8 +326,8 @@ struct Texture
|
||||
, mOffsetU (0.0f)
|
||||
, mOffsetV (0.0f)
|
||||
, mRotation (0.0f)
|
||||
, iUVSrc (0)
|
||||
, mMapMode (aiTextureMapMode_Wrap)
|
||||
, iUVSrc (0)
|
||||
{
|
||||
mTextureBlend = std::numeric_limits<float>::quiet_NaN();
|
||||
}
|
||||
@@ -364,9 +364,9 @@ struct Material
|
||||
mTransparency (1.0f),
|
||||
mBumpHeight (1.0f),
|
||||
iBakeUVTransform (0),
|
||||
pcSingleTexture (NULL),
|
||||
mShininessStrength (1.0f),
|
||||
mTwoSided (false)
|
||||
mTwoSided (false),
|
||||
pcSingleTexture (NULL)
|
||||
{
|
||||
static int iCnt = 0;
|
||||
|
||||
|
||||
+1
-1
@@ -269,4 +269,4 @@ protected:
|
||||
|
||||
} // end of namespace Assimp
|
||||
|
||||
#endif // AI_3DSIMPORTER_H_INC
|
||||
#endif // AI_3DSIMPORTER_H_INC
|
||||
|
||||
+1
-1
@@ -189,4 +189,4 @@ protected:
|
||||
|
||||
} // end of namespace Assimp
|
||||
|
||||
#endif // AI_BASEIMPORTER_H_INC
|
||||
#endif // AI_BASEIMPORTER_H_INC
|
||||
|
||||
+99
-11
@@ -47,6 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "ParsingUtils.h"
|
||||
#include "StandardShapes.h"
|
||||
#include "fast_atof.h"
|
||||
#include "qnan.h"
|
||||
|
||||
// public assimp headers
|
||||
#include "../include/IOStream.h"
|
||||
@@ -105,7 +106,7 @@ bool GetNextLine(const char*& buffer, char out[4096])
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#define AI_NFF_PARSE_FLOAT(f) \
|
||||
SkipSpaces(&sz); \
|
||||
sz = fast_atof_move(sz, f);
|
||||
if (!::IsLineEnd(*sz))sz = fast_atof_move(sz, f);
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#define AI_NFF_PARSE_TRIPLE(v) \
|
||||
@@ -115,10 +116,12 @@ bool GetNextLine(const char*& buffer, char out[4096])
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#define AI_NFF_PARSE_SHAPE_INFORMATION() \
|
||||
sz = &line[1]; \
|
||||
aiVector3D center; float radius; \
|
||||
aiVector3D center, radius(1.0f,std::numeric_limits<float>::quiet_NaN(),std::numeric_limits<float>::quiet_NaN()); \
|
||||
AI_NFF_PARSE_TRIPLE(center); \
|
||||
AI_NFF_PARSE_FLOAT(radius); \
|
||||
AI_NFF_PARSE_TRIPLE(radius); \
|
||||
if (is_qnan(radius.z))radius.z = radius.x; \
|
||||
if (is_qnan(radius.y))radius.y = radius.x; \
|
||||
currentMesh.radius = radius; \
|
||||
currentMesh.center = center;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
@@ -156,7 +159,9 @@ void NFFImporter::InternReadFile( const std::string& pFile,
|
||||
|
||||
char line[4096];
|
||||
const char* sz;
|
||||
unsigned int sphere = 0,cylinder = 0,cone = 0,numNamed = 0;
|
||||
unsigned int sphere = 0,cylinder = 0,cone = 0,numNamed = 0,
|
||||
dodecahedron = 0,octecahedron = 0,octahedron = 0,tetrahedron = 0, hexahedron = 0;
|
||||
|
||||
while (GetNextLine(buffer,line))
|
||||
{
|
||||
if ('p' == line[0])
|
||||
@@ -186,7 +191,12 @@ void NFFImporter::InternReadFile( const std::string& pFile,
|
||||
SkipSpaces(sz,&sz);
|
||||
m = strtol10(sz);
|
||||
|
||||
out->vertices.reserve(out->vertices.size()+m);
|
||||
// ---- flip the face order
|
||||
out->vertices.resize(out->vertices.size()+m);
|
||||
if (out == currentMeshWithNormals)
|
||||
{
|
||||
out->normals.resize(out->vertices.size());
|
||||
}
|
||||
for (unsigned int n = 0; n < m;++n)
|
||||
{
|
||||
if(!GetNextLine(buffer,line))
|
||||
@@ -197,12 +207,12 @@ void NFFImporter::InternReadFile( const std::string& pFile,
|
||||
|
||||
aiVector3D v; sz = &line[0];
|
||||
AI_NFF_PARSE_TRIPLE(v);
|
||||
out->vertices.push_back(v);
|
||||
out->vertices[out->vertices.size()-n-1] = v;
|
||||
|
||||
if ('p' == line[1])
|
||||
if (out == currentMeshWithNormals)
|
||||
{
|
||||
AI_NFF_PARSE_TRIPLE(v);
|
||||
out->normals.push_back(v);
|
||||
out->normals[out->vertices.size()-n-1] = v;
|
||||
}
|
||||
}
|
||||
out->faces.push_back(m);
|
||||
@@ -256,15 +266,88 @@ void NFFImporter::InternReadFile( const std::string& pFile,
|
||||
MeshInfo& currentMesh = meshesLocked.back();
|
||||
currentMesh.shader = s;
|
||||
|
||||
sz = &line[1];
|
||||
AI_NFF_PARSE_SHAPE_INFORMATION();
|
||||
|
||||
// generate the sphere - it consists of simple triangles
|
||||
StandardShapes::MakeSphere(aiVector3D(), radius, iTesselation, currentMesh.vertices);
|
||||
// we don't need scaling or translation here - we do it in the node's transform
|
||||
StandardShapes::MakeSphere(aiVector3D(), 1.0f, iTesselation, currentMesh.vertices);
|
||||
currentMesh.faces.resize(currentMesh.vertices.size()/3,3);
|
||||
|
||||
// generate a name for the mesh
|
||||
::sprintf(currentMesh.name,"sphere_%i",sphere++);
|
||||
}
|
||||
// 'dod' - dodecahedron
|
||||
else if (!strncmp(line,"dod",3) && IsSpace(line[3]))
|
||||
{
|
||||
meshesLocked.push_back(MeshInfo(false,true));
|
||||
MeshInfo& currentMesh = meshesLocked.back();
|
||||
currentMesh.shader = s;
|
||||
|
||||
sz = &line[4];
|
||||
AI_NFF_PARSE_SHAPE_INFORMATION();
|
||||
|
||||
// we don't need scaling or translation here - we do it in the node's transform
|
||||
StandardShapes::MakeDodecahedron(aiVector3D(), 1.0f, currentMesh.vertices);
|
||||
currentMesh.faces.resize(currentMesh.vertices.size()/3,3);
|
||||
|
||||
// generate a name for the mesh
|
||||
::sprintf(currentMesh.name,"dodecahedron_%i",dodecahedron++);
|
||||
}
|
||||
|
||||
// 'oct' - octahedron
|
||||
else if (!strncmp(line,"oct",3) && IsSpace(line[3]))
|
||||
{
|
||||
meshesLocked.push_back(MeshInfo(false,true));
|
||||
MeshInfo& currentMesh = meshesLocked.back();
|
||||
currentMesh.shader = s;
|
||||
|
||||
sz = &line[4];
|
||||
AI_NFF_PARSE_SHAPE_INFORMATION();
|
||||
|
||||
// we don't need scaling or translation here - we do it in the node's transform
|
||||
StandardShapes::MakeOctahedron(aiVector3D(), 1.0f, currentMesh.vertices);
|
||||
currentMesh.faces.resize(currentMesh.vertices.size()/3,3);
|
||||
|
||||
// generate a name for the mesh
|
||||
::sprintf(currentMesh.name,"octecahedron_%i",octecahedron++);
|
||||
}
|
||||
|
||||
// 'tet' - tetrahedron
|
||||
else if (!strncmp(line,"tet",3) && IsSpace(line[3]))
|
||||
{
|
||||
meshesLocked.push_back(MeshInfo(false,true));
|
||||
MeshInfo& currentMesh = meshesLocked.back();
|
||||
currentMesh.shader = s;
|
||||
|
||||
sz = &line[4];
|
||||
AI_NFF_PARSE_SHAPE_INFORMATION();
|
||||
|
||||
// we don't need scaling or translation here - we do it in the node's transform
|
||||
StandardShapes::MakeTetrahedron(aiVector3D(), 1.0f, currentMesh.vertices);
|
||||
currentMesh.faces.resize(currentMesh.vertices.size()/3,3);
|
||||
|
||||
// generate a name for the mesh
|
||||
::sprintf(currentMesh.name,"tetrahedron_%i",tetrahedron++);
|
||||
}
|
||||
|
||||
// 'hex' - hexahedron
|
||||
else if (!strncmp(line,"hex",3) && IsSpace(line[3]))
|
||||
{
|
||||
meshesLocked.push_back(MeshInfo(false,true));
|
||||
MeshInfo& currentMesh = meshesLocked.back();
|
||||
currentMesh.shader = s;
|
||||
|
||||
sz = &line[4];
|
||||
AI_NFF_PARSE_SHAPE_INFORMATION();
|
||||
|
||||
// we don't need scaling or translation here - we do it in the node's transform
|
||||
StandardShapes::MakeHexahedron(aiVector3D(),1.0f, currentMesh.vertices);
|
||||
currentMesh.faces.resize(currentMesh.vertices.size()/3,3);
|
||||
|
||||
// generate a name for the mesh
|
||||
::sprintf(currentMesh.name,"hexahedron_%i",hexahedron++);
|
||||
}
|
||||
|
||||
// 'tess' - tesselation
|
||||
else if (!strncmp(line,"tess",4) && IsSpace(line[4]))
|
||||
{
|
||||
@@ -359,12 +442,17 @@ void NFFImporter::InternReadFile( const std::string& pFile,
|
||||
node->mNumMeshes = 1;
|
||||
node->mMeshes = new unsigned int[1];
|
||||
node->mMeshes[0] = m;
|
||||
node->mName.Set(src.name);
|
||||
|
||||
// setup the transformation matrix of the node
|
||||
node->mTransformation.a4 = src.center.x;
|
||||
node->mTransformation.b4 = src.center.y;
|
||||
node->mTransformation.c4 = src.center.z;
|
||||
|
||||
node->mTransformation.a1 = src.radius.x;
|
||||
node->mTransformation.b2 = src.radius.y;
|
||||
node->mTransformation.c3 = src.radius.z;
|
||||
|
||||
++ppcChildren;
|
||||
}
|
||||
else *pMeshes++ = m;
|
||||
|
||||
+1
-1
@@ -119,7 +119,7 @@ private:
|
||||
bool bHasNormals, bLocked;
|
||||
|
||||
// for spheres, cones and cylinders: center point of the object
|
||||
aiVector3D center;
|
||||
aiVector3D center, radius;
|
||||
|
||||
char name[128];
|
||||
|
||||
|
||||
@@ -110,7 +110,10 @@ protected:
|
||||
Entry() { /** intentionally not initialized.*/ }
|
||||
Entry( unsigned int pIndex, const aiVector3D& pPosition, float pDistance,uint32_t pSG)
|
||||
:
|
||||
mPosition( pPosition), mIndex( pIndex), mDistance( pDistance),mSmoothGroups (pSG)
|
||||
mIndex( pIndex),
|
||||
mPosition( pPosition),
|
||||
mSmoothGroups (pSG),
|
||||
mDistance( pDistance)
|
||||
{ }
|
||||
|
||||
bool operator < (const Entry& e) const { return mDistance < e.mDistance; }
|
||||
@@ -122,4 +125,4 @@ protected:
|
||||
|
||||
} // end of namespace Assimp
|
||||
|
||||
#endif // AI_SPATIALSORT_H_INC
|
||||
#endif // AI_SPATIALSORT_H_INC
|
||||
|
||||
@@ -100,4 +100,4 @@ void ComputeNormalsWithSmoothingsGroups(MeshWithSmoothingGroups<T>& sMesh);
|
||||
// include implementations
|
||||
#include "SmoothingGroups.inl"
|
||||
|
||||
#endif // !! AI_SMOOTHINGGROUPS_H_INC
|
||||
#endif // !! AI_SMOOTHINGGROUPS_H_INC
|
||||
|
||||
@@ -95,8 +95,7 @@ void ComputeNormalsWithSmoothingsGroups(MeshWithSmoothingGroups<T>& sMesh)
|
||||
|
||||
// now generate the spatial sort tree
|
||||
SGSpatialSort sSort;
|
||||
for( std::vector<T>::iterator
|
||||
i = sMesh.mFaces.begin();
|
||||
for( std::vector<T>::iterator i = sMesh.mFaces.begin();
|
||||
i != sMesh.mFaces.end();++i)
|
||||
{
|
||||
sSort.Add(sMesh.mPositions[(*i).mIndices[0]],(*i).mIndices[0],(*i).iSmoothGroup);
|
||||
@@ -105,8 +104,7 @@ void ComputeNormalsWithSmoothingsGroups(MeshWithSmoothingGroups<T>& sMesh)
|
||||
}
|
||||
sSort.Prepare();
|
||||
|
||||
for( std::vector<T>::iterator
|
||||
i = sMesh.mFaces.begin();
|
||||
for( std::vector<T>::iterator i = sMesh.mFaces.begin();
|
||||
i != sMesh.mFaces.end();++i)
|
||||
{
|
||||
std::vector<unsigned int> poResult;
|
||||
|
||||
Binary file not shown.
+62
-8
@@ -59,32 +59,52 @@ class ASSIMP_API StandardShapes
|
||||
|
||||
public:
|
||||
|
||||
/** @brief Generates a hexahedron (cube)
|
||||
*
|
||||
* Hexahedrons can be scaled on all axes.
|
||||
* @param center Center point of the hexahedron
|
||||
* @param length Radius of the hexahedron
|
||||
* @param positions Receives output triangles.
|
||||
*/
|
||||
static void MakeHexahedron(aiVector3D& center,const aiVector3D& length,
|
||||
std::vector<aiVector3D>& positions);
|
||||
|
||||
|
||||
/** @brief Generates an icosahedron
|
||||
*
|
||||
* @param center Center point of the icosahedron
|
||||
* @param length Face length of the icosahedron
|
||||
* @param length Radius of the icosahedron
|
||||
* @param positions Receives output triangles.
|
||||
*/
|
||||
static void MakeIcosahedron(aiVector3D& center,float length,
|
||||
static void MakeIcosahedron(aiVector3D& center,const aiVector3D& length,
|
||||
std::vector<aiVector3D>& positions);
|
||||
|
||||
|
||||
/** @brief Generates a dodecahedron
|
||||
*
|
||||
* @param center Center point of the dodecahedron
|
||||
* @param length Face length of the dodecahedron
|
||||
* @param positions Receives output triangles.
|
||||
* @param length Radius of the dodecahedron
|
||||
* @param positions Receives output triangles
|
||||
*/
|
||||
static void MakeDodecahedron(aiVector3D& center,float length,
|
||||
static void MakeDodecahedron(aiVector3D& center,const aiVector3D& length,
|
||||
std::vector<aiVector3D>& positions);
|
||||
|
||||
/** @brief Generates an octahedron
|
||||
*
|
||||
* @param center Center point of the octahedron
|
||||
* @param length Face length of the octahedron
|
||||
* @param length Radius of the octahedron
|
||||
* @param positions Receives output triangles.
|
||||
*/
|
||||
static void MakeOctahedron(aiVector3D& center,float length,
|
||||
static void MakeOctahedron(aiVector3D& center,const aiVector3D& length,
|
||||
std::vector<aiVector3D>& positions);
|
||||
|
||||
/** @brief Generates a tetrahedron
|
||||
*
|
||||
* @param center Center point of the tetrahedron
|
||||
* @param length Radius of the octahedron
|
||||
* @param positions Receives output triangles.
|
||||
*/
|
||||
static void MakeTetrahedron(aiVector3D& center,const aiVector3D& length,
|
||||
std::vector<aiVector3D>& positions);
|
||||
|
||||
|
||||
@@ -95,7 +115,7 @@ public:
|
||||
* @param tess Number of subdivions - 0 generates a octahedron
|
||||
* @param positions Receives output triangles.
|
||||
*/
|
||||
static void MakeSphere(aiVector3D& center,float radius,unsigned int tess,
|
||||
static void MakeSphere(aiVector3D& center,float length,unsigned int tess,
|
||||
std::vector<aiVector3D>& positions);
|
||||
|
||||
/** @brief Generates a cone or a cylinder, either opened or closed.
|
||||
@@ -140,6 +160,40 @@ public:
|
||||
static void MakeCircle(aiVector3D& center, aiVector3D& normal,
|
||||
float radius, unsigned int tess,
|
||||
std::vector<aiVector3D>& positions);
|
||||
|
||||
|
||||
// simplified versions - the radius is a single float and applies
|
||||
// to all axes. These version of the functions must be used if ou
|
||||
// REALLY want a platonic primitive :-)
|
||||
static void MakeHexahedron(aiVector3D& center,float length,
|
||||
std::vector<aiVector3D>& positions)
|
||||
{
|
||||
MakeHexahedron(center,aiVector3D(length),positions);
|
||||
}
|
||||
|
||||
static void MakeDodecahedron(aiVector3D& center,float length,
|
||||
std::vector<aiVector3D>& positions)
|
||||
{
|
||||
MakeDodecahedron(center,aiVector3D(length),positions);
|
||||
}
|
||||
|
||||
static void MakeOcathedron(aiVector3D& center,float length,
|
||||
std::vector<aiVector3D>& positions)
|
||||
{
|
||||
MakeOctahedron(center,aiVector3D(length),positions);
|
||||
}
|
||||
|
||||
static void MakeTetrahedron(aiVector3D& center,float length,
|
||||
std::vector<aiVector3D>& positions)
|
||||
{
|
||||
MakeTetrahedron(center,aiVector3D(length),positions);
|
||||
}
|
||||
|
||||
static void MakeIcosahedron(aiVector3D& center,float length,
|
||||
std::vector<aiVector3D>& positions)
|
||||
{
|
||||
MakeIcosahedron(center,aiVector3D(length),positions);
|
||||
}
|
||||
|
||||
};
|
||||
} // ! Assimp
|
||||
|
||||
+2
-12
@@ -3,9 +3,7 @@
|
||||
#if (!defined AI_QNAN_H_INCLUDED)
|
||||
#define AI_QNAN_H_INCLUDED
|
||||
|
||||
#if (!defined ASSIMP_BUILD_CPP_09)
|
||||
# include <boost/static_assert.hpp>
|
||||
#endif
|
||||
|
||||
|
||||
inline bool is_qnan(const float in)
|
||||
{
|
||||
@@ -21,14 +19,6 @@ inline bool is_qnan(const float in)
|
||||
int32_t i;
|
||||
} FPUNION1,FPUNION2;
|
||||
|
||||
// use a compile-time asertion if possible
|
||||
#if (defined ASSIMP_BUILD_CPP_09)
|
||||
static_assert(sizeof(float)==sizeof(int32_t),
|
||||
"A float seems not to be 4 bytes on this platform");
|
||||
#else
|
||||
BOOST_STATIC_ASSERT(sizeof(float)==sizeof(int32_t));
|
||||
#endif
|
||||
|
||||
FPUNION1.f = in;
|
||||
FPUNION2.f = std::numeric_limits<float>::quiet_NaN();
|
||||
return FPUNION1.i == FPUNION2.i;
|
||||
@@ -39,4 +29,4 @@ inline bool is_not_qnan(const float in)
|
||||
return !is_qnan(in);
|
||||
}
|
||||
|
||||
#endif // !! AI_QNAN_H_INCLUDED
|
||||
#endif // !! AI_QNAN_H_INCLUDED
|
||||
|
||||
Reference in New Issue
Block a user