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-9d2fd5bffc1fpull/1/head
parent
c9eee99303
commit
559daf900d
|
@ -265,6 +265,12 @@ void Dot3DSImporter::ConvertMaterial(Dot3DS::Material& oldMat,
|
||||||
|
|
||||||
case Dot3DS::Dot3DSFile::Metal :
|
case Dot3DS::Dot3DSFile::Metal :
|
||||||
eShading = aiShadingMode_CookTorrance; break;
|
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);
|
mat.AddProperty<int>( (int*)&eShading,1,AI_MATKEY_SHADING_MODEL);
|
||||||
|
|
||||||
|
@ -402,7 +408,6 @@ void Dot3DSImporter::ConvertMeshes(aiScene* pcOut)
|
||||||
aiSplit[*a].push_back(iNum);
|
aiSplit[*a].push_back(iNum);
|
||||||
}
|
}
|
||||||
// now generate submeshes
|
// now generate submeshes
|
||||||
bool bFirst = true;
|
|
||||||
for (unsigned int p = 0; p < this->mScene->mMaterials.size();++p)
|
for (unsigned int p = 0; p < this->mScene->mMaterials.size();++p)
|
||||||
{
|
{
|
||||||
if (aiSplit[p].size() != 0)
|
if (aiSplit[p].size() != 0)
|
||||||
|
@ -586,8 +591,6 @@ void Dot3DSImporter::GenerateNodeGraph(aiScene* pcOut)
|
||||||
// | | | |
|
// | | | |
|
||||||
// MESH_0 MESH_1 MESH_2 ... MESH_N
|
// MESH_0 MESH_1 MESH_2 ... MESH_N
|
||||||
//
|
//
|
||||||
unsigned int iCnt = 0;
|
|
||||||
|
|
||||||
DefaultLogger::get()->warn("No hierarchy information has been found in the file. ");
|
DefaultLogger::get()->warn("No hierarchy information has been found in the file. ");
|
||||||
|
|
||||||
pcOut->mRootNode->mNumChildren = pcOut->mNumMeshes;
|
pcOut->mRootNode->mNumChildren = pcOut->mNumMeshes;
|
||||||
|
|
|
@ -326,8 +326,8 @@ struct Texture
|
||||||
, mOffsetU (0.0f)
|
, mOffsetU (0.0f)
|
||||||
, mOffsetV (0.0f)
|
, mOffsetV (0.0f)
|
||||||
, mRotation (0.0f)
|
, mRotation (0.0f)
|
||||||
, iUVSrc (0)
|
|
||||||
, mMapMode (aiTextureMapMode_Wrap)
|
, mMapMode (aiTextureMapMode_Wrap)
|
||||||
|
, iUVSrc (0)
|
||||||
{
|
{
|
||||||
mTextureBlend = std::numeric_limits<float>::quiet_NaN();
|
mTextureBlend = std::numeric_limits<float>::quiet_NaN();
|
||||||
}
|
}
|
||||||
|
@ -364,9 +364,9 @@ struct Material
|
||||||
mTransparency (1.0f),
|
mTransparency (1.0f),
|
||||||
mBumpHeight (1.0f),
|
mBumpHeight (1.0f),
|
||||||
iBakeUVTransform (0),
|
iBakeUVTransform (0),
|
||||||
pcSingleTexture (NULL),
|
|
||||||
mShininessStrength (1.0f),
|
mShininessStrength (1.0f),
|
||||||
mTwoSided (false)
|
mTwoSided (false),
|
||||||
|
pcSingleTexture (NULL)
|
||||||
{
|
{
|
||||||
static int iCnt = 0;
|
static int iCnt = 0;
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "ParsingUtils.h"
|
#include "ParsingUtils.h"
|
||||||
#include "StandardShapes.h"
|
#include "StandardShapes.h"
|
||||||
#include "fast_atof.h"
|
#include "fast_atof.h"
|
||||||
|
#include "qnan.h"
|
||||||
|
|
||||||
// public assimp headers
|
// public assimp headers
|
||||||
#include "../include/IOStream.h"
|
#include "../include/IOStream.h"
|
||||||
|
@ -105,7 +106,7 @@ bool GetNextLine(const char*& buffer, char out[4096])
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#define AI_NFF_PARSE_FLOAT(f) \
|
#define AI_NFF_PARSE_FLOAT(f) \
|
||||||
SkipSpaces(&sz); \
|
SkipSpaces(&sz); \
|
||||||
sz = fast_atof_move(sz, f);
|
if (!::IsLineEnd(*sz))sz = fast_atof_move(sz, f);
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#define AI_NFF_PARSE_TRIPLE(v) \
|
#define AI_NFF_PARSE_TRIPLE(v) \
|
||||||
|
@ -115,10 +116,12 @@ bool GetNextLine(const char*& buffer, char out[4096])
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#define AI_NFF_PARSE_SHAPE_INFORMATION() \
|
#define AI_NFF_PARSE_SHAPE_INFORMATION() \
|
||||||
sz = &line[1]; \
|
aiVector3D center, radius(1.0f,std::numeric_limits<float>::quiet_NaN(),std::numeric_limits<float>::quiet_NaN()); \
|
||||||
aiVector3D center; float radius; \
|
|
||||||
AI_NFF_PARSE_TRIPLE(center); \
|
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;
|
currentMesh.center = center;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -156,7 +159,9 @@ void NFFImporter::InternReadFile( const std::string& pFile,
|
||||||
|
|
||||||
char line[4096];
|
char line[4096];
|
||||||
const char* sz;
|
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))
|
while (GetNextLine(buffer,line))
|
||||||
{
|
{
|
||||||
if ('p' == line[0])
|
if ('p' == line[0])
|
||||||
|
@ -186,7 +191,12 @@ void NFFImporter::InternReadFile( const std::string& pFile,
|
||||||
SkipSpaces(sz,&sz);
|
SkipSpaces(sz,&sz);
|
||||||
m = strtol10(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)
|
for (unsigned int n = 0; n < m;++n)
|
||||||
{
|
{
|
||||||
if(!GetNextLine(buffer,line))
|
if(!GetNextLine(buffer,line))
|
||||||
|
@ -197,12 +207,12 @@ void NFFImporter::InternReadFile( const std::string& pFile,
|
||||||
|
|
||||||
aiVector3D v; sz = &line[0];
|
aiVector3D v; sz = &line[0];
|
||||||
AI_NFF_PARSE_TRIPLE(v);
|
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);
|
AI_NFF_PARSE_TRIPLE(v);
|
||||||
out->normals.push_back(v);
|
out->normals[out->vertices.size()-n-1] = v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out->faces.push_back(m);
|
out->faces.push_back(m);
|
||||||
|
@ -256,15 +266,88 @@ void NFFImporter::InternReadFile( const std::string& pFile,
|
||||||
MeshInfo& currentMesh = meshesLocked.back();
|
MeshInfo& currentMesh = meshesLocked.back();
|
||||||
currentMesh.shader = s;
|
currentMesh.shader = s;
|
||||||
|
|
||||||
|
sz = &line[1];
|
||||||
AI_NFF_PARSE_SHAPE_INFORMATION();
|
AI_NFF_PARSE_SHAPE_INFORMATION();
|
||||||
|
|
||||||
// generate the sphere - it consists of simple triangles
|
// we don't need scaling or translation here - we do it in the node's transform
|
||||||
StandardShapes::MakeSphere(aiVector3D(), radius, iTesselation, currentMesh.vertices);
|
StandardShapes::MakeSphere(aiVector3D(), 1.0f, iTesselation, currentMesh.vertices);
|
||||||
currentMesh.faces.resize(currentMesh.vertices.size()/3,3);
|
currentMesh.faces.resize(currentMesh.vertices.size()/3,3);
|
||||||
|
|
||||||
// generate a name for the mesh
|
// generate a name for the mesh
|
||||||
::sprintf(currentMesh.name,"sphere_%i",sphere++);
|
::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
|
// 'tess' - tesselation
|
||||||
else if (!strncmp(line,"tess",4) && IsSpace(line[4]))
|
else if (!strncmp(line,"tess",4) && IsSpace(line[4]))
|
||||||
{
|
{
|
||||||
|
@ -359,12 +442,17 @@ void NFFImporter::InternReadFile( const std::string& pFile,
|
||||||
node->mNumMeshes = 1;
|
node->mNumMeshes = 1;
|
||||||
node->mMeshes = new unsigned int[1];
|
node->mMeshes = new unsigned int[1];
|
||||||
node->mMeshes[0] = m;
|
node->mMeshes[0] = m;
|
||||||
|
node->mName.Set(src.name);
|
||||||
|
|
||||||
// setup the transformation matrix of the node
|
// setup the transformation matrix of the node
|
||||||
node->mTransformation.a4 = src.center.x;
|
node->mTransformation.a4 = src.center.x;
|
||||||
node->mTransformation.b4 = src.center.y;
|
node->mTransformation.b4 = src.center.y;
|
||||||
node->mTransformation.c4 = src.center.z;
|
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;
|
++ppcChildren;
|
||||||
}
|
}
|
||||||
else *pMeshes++ = m;
|
else *pMeshes++ = m;
|
||||||
|
|
|
@ -119,7 +119,7 @@ private:
|
||||||
bool bHasNormals, bLocked;
|
bool bHasNormals, bLocked;
|
||||||
|
|
||||||
// for spheres, cones and cylinders: center point of the object
|
// for spheres, cones and cylinders: center point of the object
|
||||||
aiVector3D center;
|
aiVector3D center, radius;
|
||||||
|
|
||||||
char name[128];
|
char name[128];
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,10 @@ protected:
|
||||||
Entry() { /** intentionally not initialized.*/ }
|
Entry() { /** intentionally not initialized.*/ }
|
||||||
Entry( unsigned int pIndex, const aiVector3D& pPosition, float pDistance,uint32_t pSG)
|
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; }
|
bool operator < (const Entry& e) const { return mDistance < e.mDistance; }
|
||||||
|
|
|
@ -95,8 +95,7 @@ void ComputeNormalsWithSmoothingsGroups(MeshWithSmoothingGroups<T>& sMesh)
|
||||||
|
|
||||||
// now generate the spatial sort tree
|
// now generate the spatial sort tree
|
||||||
SGSpatialSort sSort;
|
SGSpatialSort sSort;
|
||||||
for( std::vector<T>::iterator
|
for( std::vector<T>::iterator i = sMesh.mFaces.begin();
|
||||||
i = sMesh.mFaces.begin();
|
|
||||||
i != sMesh.mFaces.end();++i)
|
i != sMesh.mFaces.end();++i)
|
||||||
{
|
{
|
||||||
sSort.Add(sMesh.mPositions[(*i).mIndices[0]],(*i).mIndices[0],(*i).iSmoothGroup);
|
sSort.Add(sMesh.mPositions[(*i).mIndices[0]],(*i).mIndices[0],(*i).iSmoothGroup);
|
||||||
|
@ -105,8 +104,7 @@ void ComputeNormalsWithSmoothingsGroups(MeshWithSmoothingGroups<T>& sMesh)
|
||||||
}
|
}
|
||||||
sSort.Prepare();
|
sSort.Prepare();
|
||||||
|
|
||||||
for( std::vector<T>::iterator
|
for( std::vector<T>::iterator i = sMesh.mFaces.begin();
|
||||||
i = sMesh.mFaces.begin();
|
|
||||||
i != sMesh.mFaces.end();++i)
|
i != sMesh.mFaces.end();++i)
|
||||||
{
|
{
|
||||||
std::vector<unsigned int> poResult;
|
std::vector<unsigned int> poResult;
|
||||||
|
|
Binary file not shown.
|
@ -59,32 +59,52 @@ class ASSIMP_API StandardShapes
|
||||||
|
|
||||||
public:
|
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
|
/** @brief Generates an icosahedron
|
||||||
*
|
*
|
||||||
* @param center Center point of the 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.
|
* @param positions Receives output triangles.
|
||||||
*/
|
*/
|
||||||
static void MakeIcosahedron(aiVector3D& center,float length,
|
static void MakeIcosahedron(aiVector3D& center,const aiVector3D& length,
|
||||||
std::vector<aiVector3D>& positions);
|
std::vector<aiVector3D>& positions);
|
||||||
|
|
||||||
|
|
||||||
/** @brief Generates a dodecahedron
|
/** @brief Generates a dodecahedron
|
||||||
*
|
*
|
||||||
* @param center Center point of the dodecahedron
|
* @param center Center point of the dodecahedron
|
||||||
* @param length Face length of the dodecahedron
|
* @param length Radius of the dodecahedron
|
||||||
* @param positions Receives output triangles.
|
* @param positions Receives output triangles
|
||||||
*/
|
*/
|
||||||
static void MakeDodecahedron(aiVector3D& center,float length,
|
static void MakeDodecahedron(aiVector3D& center,const aiVector3D& length,
|
||||||
std::vector<aiVector3D>& positions);
|
std::vector<aiVector3D>& positions);
|
||||||
|
|
||||||
/** @brief Generates an octahedron
|
/** @brief Generates an octahedron
|
||||||
*
|
*
|
||||||
* @param center Center point of the 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.
|
* @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);
|
std::vector<aiVector3D>& positions);
|
||||||
|
|
||||||
|
|
||||||
|
@ -95,7 +115,7 @@ public:
|
||||||
* @param tess Number of subdivions - 0 generates a octahedron
|
* @param tess Number of subdivions - 0 generates a octahedron
|
||||||
* @param positions Receives output triangles.
|
* @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);
|
std::vector<aiVector3D>& positions);
|
||||||
|
|
||||||
/** @brief Generates a cone or a cylinder, either opened or closed.
|
/** @brief Generates a cone or a cylinder, either opened or closed.
|
||||||
|
@ -141,6 +161,40 @@ public:
|
||||||
float radius, unsigned int tess,
|
float radius, unsigned int tess,
|
||||||
std::vector<aiVector3D>& positions);
|
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
|
} // ! Assimp
|
||||||
|
|
||||||
|
|
12
code/qnan.h
12
code/qnan.h
|
@ -3,9 +3,7 @@
|
||||||
#if (!defined AI_QNAN_H_INCLUDED)
|
#if (!defined AI_QNAN_H_INCLUDED)
|
||||||
#define 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)
|
inline bool is_qnan(const float in)
|
||||||
{
|
{
|
||||||
|
@ -21,14 +19,6 @@ inline bool is_qnan(const float in)
|
||||||
int32_t i;
|
int32_t i;
|
||||||
} FPUNION1,FPUNION2;
|
} 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;
|
FPUNION1.f = in;
|
||||||
FPUNION2.f = std::numeric_limits<float>::quiet_NaN();
|
FPUNION2.f = std::numeric_limits<float>::quiet_NaN();
|
||||||
return FPUNION1.i == FPUNION2.i;
|
return FPUNION1.i == FPUNION2.i;
|
||||||
|
|
|
@ -452,3 +452,4 @@ struct aiMesh
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // AI_MESH_H_INC
|
#endif // AI_MESH_H_INC
|
||||||
|
|
||||||
|
|
|
@ -164,7 +164,7 @@ struct aiTexture
|
||||||
|
|
||||||
// Construction
|
// Construction
|
||||||
aiTexture ()
|
aiTexture ()
|
||||||
: mHeight(0), mWidth(0), pcData(NULL)
|
: mWidth(0), mHeight(0), pcData(NULL)
|
||||||
{
|
{
|
||||||
achFormatHint[0] = '\0';
|
achFormatHint[0] = '\0';
|
||||||
achFormatHint[1] = '\0';
|
achFormatHint[1] = '\0';
|
||||||
|
|
|
@ -55,6 +55,7 @@ struct aiVector3D
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
aiVector3D () : x(0.0f), y(0.0f), z(0.0f) {}
|
aiVector3D () : x(0.0f), y(0.0f), z(0.0f) {}
|
||||||
aiVector3D (float _x, float _y, float _z) : x(_x), y(_y), z(_z) {}
|
aiVector3D (float _x, float _y, float _z) : x(_x), y(_y), z(_z) {}
|
||||||
|
aiVector3D (float _xyz) : x(_xyz), y(_xyz), z(_xyz) {}
|
||||||
aiVector3D (const aiVector3D& o) : x(o.x), y(o.y), z(o.z) {}
|
aiVector3D (const aiVector3D& o) : x(o.x), y(o.y), z(o.z) {}
|
||||||
|
|
||||||
void Set( float pX, float pY, float pZ) { x = pX; y = pY; z = pZ; }
|
void Set( float pX, float pY, float pZ) { x = pX; y = pY; z = pZ; }
|
||||||
|
@ -78,6 +79,9 @@ struct aiVector3D
|
||||||
inline aiVector3D& operator= (float f)
|
inline aiVector3D& operator= (float f)
|
||||||
{x = y = z = f;return *this;}
|
{x = y = z = f;return *this;}
|
||||||
|
|
||||||
|
const aiVector3D SymMul(const aiVector3D& o)
|
||||||
|
{return aiVector3D(x*o.x,y*o.y,z*o.z);}
|
||||||
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
|
||||||
float x, y, z;
|
float x, y, z;
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
dod 0 0 0 5
|
|
@ -0,0 +1,2 @@
|
||||||
|
f 1 0 0
|
||||||
|
hex 0 0 0 5 10 20
|
|
@ -0,0 +1 @@
|
||||||
|
oct 0 0 0 5 5 5
|
|
@ -1,10 +1,27 @@
|
||||||
|
|
||||||
|
tess 4
|
||||||
|
|
||||||
|
f 0.3 0.3 0.3 1 1
|
||||||
|
|
||||||
# a centered sphere
|
# a centered sphere
|
||||||
|
|
||||||
|
|
||||||
s 0 0 0 5
|
s 0 0 0 5
|
||||||
|
|
||||||
# a polgyon that should not be visible
|
s 20 0 0 5
|
||||||
p 4
|
|
||||||
5 0 0
|
s 40 0 0 5
|
||||||
0 -5 0
|
|
||||||
-5 0 0
|
s 60 0 0 5
|
||||||
0 5 0
|
|
||||||
|
|
||||||
|
|
||||||
|
f 1 1 1 1 1
|
||||||
|
|
||||||
|
s -5 0 0 3
|
||||||
|
|
||||||
|
s 0 5 0 3
|
||||||
|
s 0 -5 0 3
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ s 5.0 4.0 8.0 3.0
|
||||||
f 0.0 1.0 0.0 0 1 1
|
f 0.0 1.0 0.0 0 1 1
|
||||||
|
|
||||||
# And another one
|
# And another one
|
||||||
s 1.0 -4.0 2.0 4.0
|
s 1.0 -4.0 2.0 4.0 2 2
|
||||||
|
|
||||||
#red
|
#red
|
||||||
f 1.0 0.0 0.0 0 1 1
|
f 1.0 0.0 0.0 0 1 1
|
||||||
|
@ -22,3 +22,8 @@ f 1.0 0.0 0.0 0 1 1
|
||||||
# a simple cone
|
# a simple cone
|
||||||
c 10 10 5 3
|
c 10 10 5 3
|
||||||
c 14 14 3 6
|
c 14 14 3 6
|
||||||
|
|
||||||
|
|
||||||
|
# An icosahedron
|
||||||
|
tess 0
|
||||||
|
s 1 -15 2 4 8 8
|
|
@ -0,0 +1 @@
|
||||||
|
tet 0 0 0 5
|
|
@ -201,6 +201,7 @@ class AssetHelper
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
// flip all normal vectors
|
// flip all normal vectors
|
||||||
void FlipNormals();
|
void FlipNormals();
|
||||||
|
void FlipNormalsInt();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // !! IG
|
#endif // !! IG
|
|
@ -93,10 +93,11 @@ public:
|
||||||
|
|
||||||
bool g_bWasFlipped = false;
|
bool g_bWasFlipped = false;
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
// Flip all normal vectors
|
// Flip all normal vectors
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void AssetHelper::FlipNormals()
|
void AssetHelper::FlipNormalsInt()
|
||||||
{
|
{
|
||||||
// invert all normal vectors
|
// invert all normal vectors
|
||||||
for (unsigned int i = 0; i < this->pcScene->mNumMeshes;++i)
|
for (unsigned int i = 0; i < this->pcScene->mNumMeshes;++i)
|
||||||
|
@ -107,6 +108,13 @@ void AssetHelper::FlipNormals()
|
||||||
pcMesh->mNormals[a] *= -1.0f;
|
pcMesh->mNormals[a] *= -1.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
void AssetHelper::FlipNormals()
|
||||||
|
{
|
||||||
|
FlipNormalsInt();
|
||||||
|
|
||||||
// recreate native data
|
// recreate native data
|
||||||
DeleteAssetData(true);
|
DeleteAssetData(true);
|
||||||
CreateAssetData();
|
CreateAssetData();
|
||||||
|
@ -145,12 +153,14 @@ void AssetHelper::SetNormalSet(unsigned int iSet)
|
||||||
{
|
{
|
||||||
MyGenFaceNormalsProcess* pcProcess = new MyGenFaceNormalsProcess();
|
MyGenFaceNormalsProcess* pcProcess = new MyGenFaceNormalsProcess();
|
||||||
pcProcess->Execute(this->pcScene);
|
pcProcess->Execute(this->pcScene);
|
||||||
|
//FlipNormalsInt();
|
||||||
delete pcProcess;
|
delete pcProcess;
|
||||||
}
|
}
|
||||||
else if (SMOOTH == iSet)
|
else if (SMOOTH == iSet)
|
||||||
{
|
{
|
||||||
MyGenVertexNormalsProcess* pcProcess = new MyGenVertexNormalsProcess();
|
MyGenVertexNormalsProcess* pcProcess = new MyGenVertexNormalsProcess();
|
||||||
pcProcess->Execute(this->pcScene);
|
pcProcess->Execute(this->pcScene);
|
||||||
|
//FlipNormalsInt();
|
||||||
delete pcProcess;
|
delete pcProcess;
|
||||||
}
|
}
|
||||||
else if (ORIGINAL == iSet)
|
else if (ORIGINAL == iSet)
|
||||||
|
|
Loading…
Reference in New Issue