Added NFF loader. No standard shapes yet (sphere, cone), but a class for them (StandardShapes) has been declared.

Fixed a small bug in the DXF loader, a few test models, however, are still corrupted.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@121 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/1/head
aramis_acg 2008-09-07 16:51:05 +00:00
parent 56563016b0
commit f69446937b
13 changed files with 784 additions and 44 deletions

View File

@ -92,21 +92,21 @@ bool DXFImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler) const
// ------------------------------------------------------------------------------------------------
bool DXFImporter::GetNextLine()
{
if(!SkipLine(buffer,&buffer))return false;
if(!SkipSpaces(buffer,&buffer))return GetNextLine();
if(!SkipLine(&buffer))return false;
if(!SkipSpaces(&buffer))return GetNextLine();
return true;
}
// ------------------------------------------------------------------------------------------------
bool DXFImporter::GetNextToken()
{
SkipSpaces(buffer,&buffer);
SkipSpaces(&buffer);
groupCode = strtol10s(buffer,&buffer);
if(!GetNextLine())return false;
// copy the data line to a separate buffer
char* m = cursor;
while (!IsLineEnd ( *buffer ) && m < (cursor+sizeof(cursor)/sizeof(char)))
char* m = cursor, *end = &cursor[4096];
while (!IsLineEnd ( *buffer ) && m < end)
*m++ = *buffer++;
*m = '\0';
@ -143,10 +143,6 @@ void DXFImporter::InternReadFile( const std::string& pFile,
if (!::strcmp(cursor,"ENTITIES"))
if (!ParseEntities())break;
// HEADER section - just to print the file format version
else if (!::strcmp(cursor,"HEADER"))
if (!ParseHeader())break;
// other sections such as BLOCK - skip them to make
// sure there will be no name conflicts
else
@ -273,27 +269,6 @@ bool DXFImporter::ParseEntities()
return false;
}
// ------------------------------------------------------------------------------------------------
bool DXFImporter::ParseHeader()
{
// --- at the moment we don't need any information from the header
while (GetNextToken())
{
if (!groupCode)
{
if (!::strcmp(cursor,"ENDSEC"))
return true;
}
// print comment strings
else if (999 == groupCode)
{
DefaultLogger::get()->info(std::string( cursor ));
}
}
return false;
}
// ------------------------------------------------------------------------------------------------
bool DXFImporter::Parse3DFace()
{

View File

@ -106,12 +106,6 @@ protected:
*/
bool ParseEntities();
// -------------------------------------------------------------------
/** Parses the HEADER section in the file
* @return false if the end of the file was reached
*/
bool ParseHeader();
// -------------------------------------------------------------------
/** Parses a 3DFACE section in the file
* @return false if the end of the file was reached

View File

@ -157,7 +157,7 @@ bool GenVertexNormalsProcess::GenMeshVertexNormals (aiMesh* pMesh)
vertexFinder.FindPositions( posThis, posEpsilon, verticesFound);
aiVector3D pcNor;
unsigned int div = 0;
//unsigned int div = 0;
for (unsigned int a = 0; a < verticesFound.size(); ++a)
{
unsigned int vidx = verticesFound[a];
@ -167,7 +167,7 @@ bool GenVertexNormalsProcess::GenMeshVertexNormals (aiMesh* pMesh)
continue;
pcNor += pMesh->mNormals[vidx];
++div;
//++div;
}
pcNor.Normalize();
pcNew[i] = pcNor;

View File

@ -110,6 +110,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#if (!defined AI_BUILD_NO_DXF_IMPORTER)
# include "DXFLoader.h"
#endif
#if (!defined AI_BUILD_NO_NFF_IMPORTER)
# include "NFFLoader.h"
#endif
// PostProcess-Steps
@ -228,6 +231,9 @@ Importer::Importer() :
#if (!defined AI_BUILD_NO_DXF_IMPORTER)
mImporter.push_back( new DXFImporter());
#endif
#if (!defined AI_BUILD_NO_NFF_IMPORTER)
mImporter.push_back( new NFFImporter());
#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 -

391
code/NFFLoader.cpp 100644
View File

@ -0,0 +1,391 @@
/*
---------------------------------------------------------------------------
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 STL importer class */
// internal headers
#include "NFFLoader.h"
#include "MaterialSystem.h"
#include "ParsingUtils.h"
#include "StandardShapes.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;
// ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer
NFFImporter::NFFImporter()
{
}
// ------------------------------------------------------------------------------------------------
// Destructor, private as well
NFFImporter::~NFFImporter()
{
}
// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
bool NFFImporter::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() != 4 || extension[0] != '.' ||
extension[1] != 'n' && extension[1] != 'N' ||
extension[2] != 'f' && extension[2] != 'F' ||
extension[3] != 'f' && extension[3] != 'F');
}
// ------------------------------------------------------------------------------------------------
bool GetNextLine(const char*& buffer, char out[4096])
{
char* _out = out;
char* const end = _out+4096;
while (!IsLineEnd( *buffer ) && _out < end)
*_out++ = *buffer++;
*_out = '\0';
if ('\0' == *buffer)return false;
while (IsLineEnd( *buffer ))++buffer;
return true;
}
// ------------------------------------------------------------------------------------------------
#define AI_NFF_PARSE_FLOAT(f) \
SkipSpaces(&sz); \
sz = fast_atof_move(sz, f);
// ------------------------------------------------------------------------------------------------
#define AI_NFF_PARSE_TRIPLE(v) \
AI_NFF_PARSE_FLOAT(v.x) \
AI_NFF_PARSE_FLOAT(v.y) \
AI_NFF_PARSE_FLOAT(v.z)
// ------------------------------------------------------------------------------------------------
// Imports the given file into the given scene structure.
void NFFImporter::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 NFF file " + pFile + ".");
unsigned int m = (unsigned int)file->FileSize();
// allocate storage and copy the contents of the file to a memory buffer
// (terminate it with zero)
std::vector<char> mBuffer2(m+1);
file->Read(&mBuffer2[0],m,1);
const char* buffer = &mBuffer2[0];
mBuffer2[m] = '\0';
// mesh arrays - separate here to make the handling of
// the pointers below easier.
std::vector<MeshInfo> meshes;
std::vector<MeshInfo> meshesWithNormals;
std::vector<MeshInfo> meshesLocked;
MeshInfo* currentMeshWithNormals = NULL;
MeshInfo* currentMesh = NULL;
char line[4096];
const char* sz;
unsigned int sphere = 0,cylinder = 0,cone = 0,numNamed = 0;
while (GetNextLine(buffer,line))
{
if ('p' == line[0])
{
MeshInfo* out = NULL;
// 'pp' - polygon patch primitive
if ('p' == line[1])
{
if (meshesWithNormals.empty())
{
meshesWithNormals.push_back(MeshInfo(true));
currentMeshWithNormals = &meshesWithNormals.back();
}
sz = &line[2];out = currentMeshWithNormals;
}
// 'p' - polygon primitive
else
{
if (meshes.empty())
{
meshes.push_back(MeshInfo(false));
currentMesh = &meshes.back();
}
sz = &line[1];out = currentMesh;
}
SkipSpaces(sz,&sz);
m = strtol10(sz);
out->faces.push_back(m);
for (unsigned int n = 0; n < m;++n)
{
if(!GetNextLine(buffer,line))
{
DefaultLogger::get()->error("NFF: Unexpected EOF was encountered");
break;
}
aiVector3D v; sz = &line[0];
AI_NFF_PARSE_TRIPLE(v);
out->vertices.push_back(v);
if (&meshesWithNormals.back() == out)
{
AI_NFF_PARSE_TRIPLE(v);
out->normals.push_back(v);
}
}
}
// 'f' - shading information block
else if ('f' == line[0] && IsSpace(line[1]))
{
SkipSpaces(&line[1],&sz);
ShadingInfo s; // color;
// read just the RGB colors, the rest is ignored for the moment
sz = fast_atof_move(sz, s.color.r);
SkipSpaces(&sz);
sz = fast_atof_move(sz, s.color.g);
SkipSpaces(&sz);
sz = fast_atof_move(sz, s.color.b);
// check whether we have this material already -
// although we have the RRM-Step, this is necessary here.
// otherwise we would generate hundreds of small meshes
// with just a few faces - this is surely never wanted.
currentMesh = currentMeshWithNormals = NULL;
for (std::vector<MeshInfo>::iterator it = meshes.begin(), end = meshes.end();
it != end;++it)
{
if ((*it).bLocked)continue;
if ((*it).shader == s)
{
if ((*it).bHasNormals)currentMeshWithNormals = &(*it);
else currentMesh = &(*it);
}
}
if (!currentMesh)
{
meshes.push_back(MeshInfo(false));
currentMesh = &meshes.back();
currentMesh->shader = s;
}
if (!currentMeshWithNormals)
{
meshesWithNormals.push_back(MeshInfo(true));
currentMeshWithNormals = &meshesWithNormals.back();
currentMeshWithNormals->shader = s;
}
}
// 's' - sphere
else if ('s' == line[0] && IsSpace(line[1]))
{
meshesLocked.push_back(MeshInfo(false,true));
MeshInfo& currentMesh = meshesLocked.back();
sz = &line[1];
aiVector3D center; float radius;
AI_NFF_PARSE_TRIPLE(center);
AI_NFF_PARSE_FLOAT(radius);
currentMesh.center = center;
// generate the sphere - it consists of simple triangles
StandardShapes::MakeSphere(aiVector3D(), radius, 500.0f, currentMesh.vertices);
currentMesh.faces.resize(currentMesh.vertices.size(),3);
// generate a name for the mesh
::sprintf(currentMesh.name,"sphere_%i",sphere++);
}
// 'c' - cone
else if ('c' == line[0] && IsSpace(line[1]))
{
meshesLocked.push_back(MeshInfo(false,true));
MeshInfo& currentMesh = meshes.back();
sz = &line[1];
aiVector3D center1, center2; float radius1, radius2;
AI_NFF_PARSE_TRIPLE(center1);
AI_NFF_PARSE_FLOAT(radius1);
AI_NFF_PARSE_TRIPLE(center2);
AI_NFF_PARSE_FLOAT(radius2);
// compute the center point of the cone/cylinder
center2 = (center2-center1)/2.f;
currentMesh.center = center1+center2;
center1 = -center2;
// generate the cone - it consists of simple triangles
StandardShapes::MakeCone(center1, radius1, center2, radius2, 500.0f, currentMesh.vertices);
currentMesh.faces.resize(currentMesh.vertices.size(),3);
// generate a name for the mesh
if (radius1 != radius2)
::sprintf(currentMesh.name,"cone_%i",cone++);
else ::sprintf(currentMesh.name,"cylinder_%i",cylinder++);
}
// '#' - comment
else if ('#' == line[0])
{
DefaultLogger::get()->info(line);
}
}
// copy all arrays into one large
meshes.reserve(meshes.size()+meshesLocked.size()+meshesWithNormals.size());
meshes.insert(meshes.end(),meshesLocked.begin(),meshesLocked.end());
meshes.insert(meshes.end(),meshesWithNormals.begin(),meshesWithNormals.end());
// now generate output meshes. first find out how many meshes we'll need
std::vector<MeshInfo>::const_iterator it = meshes.begin(), end = meshes.end();
for (;it != end;++it)
{
if (!(*it).faces.empty())
{
++pScene->mNumMeshes;
if ((*it).name[0])++numNamed;
}
}
// generate a dummy root node - assign all unnamed elements such
// as polygons and polygon patches to the root node and generate
// sub nodes for named objects such as spheres and cones.
aiNode* const root = new aiNode();
root->mName.Set("<NFF_Root>");
root->mNumChildren = numNamed;
root->mNumMeshes = pScene->mNumMeshes-numNamed;
aiNode** ppcChildren;
unsigned int* pMeshes;
if (root->mNumMeshes)
pMeshes = root->mMeshes = new unsigned int[root->mNumMeshes];
if (root->mNumChildren)
ppcChildren = root->mChildren = new aiNode*[root->mNumChildren];
if (!pScene->mNumMeshes)throw new ImportErrorException("NFF: No meshes loaded");
pScene->mMeshes = new aiMesh*[pScene->mNumMeshes];
pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials = pScene->mNumMeshes];
for (it = meshes.begin(), m = 0; it != end;++it)
{
if ((*it).faces.empty())continue;
const MeshInfo& src = *it;
aiMesh* const mesh = pScene->mMeshes[m] = new aiMesh();
mesh->mNumVertices = (unsigned int)src.vertices.size();
mesh->mNumFaces = (unsigned int)src.faces.size();
// generate sub nodes for named meshes
if (src.name[0])
{
aiNode* const node = *ppcChildren = new aiNode();
node->mParent = root;
node->mNumMeshes = 1;
node->mMeshes = new unsigned int[1];
node->mMeshes[0] = m;
// 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;
++ppcChildren;
}
else *pMeshes++ = m;
// copy vertex positions
mesh->mVertices = new aiVector3D[mesh->mNumVertices];
::memcpy(mesh->mVertices,&src.vertices[0],sizeof(aiVector3D)*mesh->mNumVertices);
if (src.bHasNormals)
{
ai_assert(src.normals.size() == src.vertices.size());
// copy normal vectors
mesh->mNormals = new aiVector3D[mesh->mNumVertices];
::memcpy(mesh->mNormals,&src.normals[0],sizeof(aiVector3D)*mesh->mNumVertices);
}
// generate faces
unsigned int p = 0;
aiFace* pFace = mesh->mFaces = new aiFace[mesh->mNumFaces];
for (std::vector<unsigned int>::const_iterator it2 = src.faces.begin(),
end2 = src.faces.end();
it2 != end2;++it2,++pFace)
{
pFace->mIndices = new unsigned int [ pFace->mNumIndices = *it2 ];
for (unsigned int o = 0; o < pFace->mNumIndices;++o)
pFace->mIndices[o] = p++;
}
// generate a material for the mesh
MaterialHelper* pcMat = (MaterialHelper*)(pScene->
mMaterials[m++] = new MaterialHelper());
aiString s;
s.Set(AI_DEFAULT_MATERIAL_NAME);
pcMat->AddProperty(&s, AI_MATKEY_NAME);
pcMat->AddProperty(&src.shader.color,1,AI_MATKEY_COLOR_DIFFUSE);
pcMat->AddProperty(&src.shader.color,1,AI_MATKEY_COLOR_SPECULAR);
}
pScene->mRootNode = root;
}

133
code/NFFLoader.h 100644
View File

@ -0,0 +1,133 @@
/*
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 NFF importer class. */
#ifndef AI_NFFLOADER_H_INCLUDED
#define AI_NFFLOADER_H_INCLUDED
#include "BaseImporter.h"
#include <vector>
#include "../include/aiTypes.h"
namespace Assimp {
// ---------------------------------------------------------------------------
/** NFF (Neutral File Format) Importer class
*/
class NFFImporter : public BaseImporter
{
friend class Importer;
protected:
/** Constructor to be privately used by Importer */
NFFImporter();
/** Destructor, private as well */
~NFFImporter();
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("*.nff");
}
// -------------------------------------------------------------------
/** Imports the given file into the given scene structure.
* See BaseImporter::InternReadFile() for details
*/
void InternReadFile( const std::string& pFile, aiScene* pScene,
IOSystem* pIOHandler);
private:
// describes face material properties
struct ShadingInfo
{
ShadingInfo()
: color(0.6f,0.6f,0.6f,1.0f)
{}
aiColor4D color;
//float diffuse, specular; --- not implemented yet
bool operator == (const ShadingInfo& other) const
{return color == other.color;}
};
// describes a NFF mesh
struct MeshInfo
{
MeshInfo(bool bHN, bool bL = false)
: bHasNormals(bHN)
, bLocked(bL)
{
name[0] = '\0'; // by default meshes are unnamed
}
ShadingInfo shader;
bool bHasNormals, bLocked;
// for spheres, cones and cylinders: center point of the object
aiVector3D center;
char name[128];
std::vector<aiVector3D> vertices, normals;
std::vector<unsigned int> faces;
};
};
} // end of namespace Assimp
#endif // AI_NFFIMPORTER_H_IN

View File

@ -46,8 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../include/aiAssert.h"
namespace Assimp
{
namespace Assimp {
// ---------------------------------------------------------------------------
/** \brief Helper class to remove single and multi line comments from a file

View File

@ -50,7 +50,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// 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"

View File

@ -45,8 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "BaseImporter.h"
#include "../include/aiTypes.h"
namespace Assimp
{
namespace Assimp {
// ---------------------------------------------------------------------------
/** Clas to load STL files
@ -90,7 +89,7 @@ protected:
// -------------------------------------------------------------------
/** Loads a binary .stl file
* @return true if the default vertex color should be used as material color
* @return true if the default vertex color must be used as material color
*/
bool LoadBinaryFile();

View File

@ -0,0 +1,82 @@
/*
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 StandardShapes class
*/
#include "../include/aiTypes.h"
#include "../include/DefaultLogger.h"
#include "../include/aiAssert.h"
#include "StandardShapes.h"
namespace Assimp {
// ------------------------------------------------------------------------------------------------
void StandardShapes::MakeSphere(
aiVector3D& center,
float radius,
float tess,
std::vector<aiVector3D>& positions)
{
}
// ------------------------------------------------------------------------------------------------
void StandardShapes::MakeCone(
aiVector3D& center1,
float radius1,
aiVector3D& center2,
float radius2,
float tess,
std::vector<aiVector3D>& positions,
bool bOpened /*= false*/)
{
}
// ------------------------------------------------------------------------------------------------
void StandardShapes::MakeCircle(
aiVector3D& center,
aiVector3D& normal,
float radius,
float tess,
std::vector<aiVector3D>& positions)
{
}
} // ! Assimp

View File

@ -0,0 +1,118 @@
/*
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 Declares a helper class, "StandardShapes" which generates
* vertices for standard shapes, such as cylnders, cones, spheres ..
*/
#ifndef AI_STANDARD_SHAPES_H_INC
#define AI_STANDARD_SHAPES_H_INC
#include <vector>
namespace Assimp {
// ---------------------------------------------------------------------------
/** \brief Helper class to generate vertex buffers for standard geometric
* shapes, such as cylinders, cones, boxes, spheres, elipsoids ... .
*/
class ASSIMP_API StandardShapes
{
// class cannot be instanced
StandardShapes() {}
public:
/** @brief Generates a sphere
*
* @param center Center point of the sphere
* @param radius Radius of the sphere
* @param tess Number of triangles in the equator line of the sphere
* @param positions Receives output triangles.
*/
static void MakeSphere(aiVector3D& center,float radius,float tess,
std::vector<aiVector3D>& positions);
/** @brief Generates a cone or a cylinder, either opened or closed.
*
* @code
*
* |-----| <- radius 1
*
* __x__ <- center 1
* / \
* / \
* / \
* / \
* /______x______\ <- center 2
*
* |-------------| <- radius 2
*
* @endcode
*
* @param center1 First center point
* @param radius1 First radius
* @param center2 Second center point
* @param radius2 Second radius
* @param tess Number of triangles per circle
* @param bOpened true for an open cone/cylinder.
* @param positions Receives output triangles.
*/
static void MakeCone(aiVector3D& center1,float radius1,
aiVector3D& center2,float radius2,float tess,
std::vector<aiVector3D>& positions,bool bOpened = false);
/** @brief Generates a flat circle
*
* @param center Center point of the circle
* @param radius Radius of the circle
* @param normal Normal vector of the circle.
* This is also the normal vector of all triangles generated by
* this function.
* @param tess Number of triangles
* @param positions Receives output triangles.
*/
static void MakeCircle(aiVector3D& center, aiVector3D& normal,
float radius, float tess,
std::vector<aiVector3D>& positions);
};
} // ! Assimp
#endif // !! AI_STANDARD_SHAPES_H_INC

View File

@ -99,6 +99,12 @@ struct aiColor3D
aiColor3D (float _r, float _g, float _b) : r(_r), g(_g), b(_b) {}
aiColor3D (const aiColor3D& o) : r(o.r), g(o.g), b(o.b) {}
bool operator == (const aiColor3D& other) const
{return r == other.r && g == other.g && b == other.b;}
bool operator != (const aiColor3D& other) const
{return r != other.r || g != other.g || b != other.b;}
#endif // !__cplusplus
//! Red, green and blue color values
@ -120,6 +126,12 @@ struct aiColor4D
aiColor4D (const aiColor4D& o)
: r(o.r), g(o.g), b(o.b), a(o.a) {}
bool operator == (const aiColor4D& other) const
{return r == other.r && g == other.g && b == other.b && a == other.a;}
bool operator != (const aiColor4D& other) const
{return r != other.r || g != other.g || b != other.b || a != other.a;}
#endif // !__cplusplus
//! Red, green, blue and alpha color values

View File

@ -818,6 +818,10 @@
RelativePath="..\..\code\SplitLargeMeshes.h"
>
</File>
<File
RelativePath="..\..\code\StandardShapes.h"
>
</File>
<File
RelativePath="..\..\code\StringComparison.h"
>
@ -1085,6 +1089,18 @@
>
</File>
</Filter>
<Filter
Name="RAW"
>
</Filter>
<Filter
Name="NFF"
>
<File
RelativePath="..\..\code\NFFLoader.h"
>
</File>
</Filter>
</Filter>
</Filter>
<Filter
@ -1190,6 +1206,10 @@
RelativePath="..\..\code\SplitLargeMeshes.cpp"
>
</File>
<File
RelativePath="..\..\code\StandardShapes.cpp"
>
</File>
<File
RelativePath="..\..\code\TextureTransform.cpp"
>
@ -1377,6 +1397,18 @@
>
</File>
</Filter>
<Filter
Name="RAW"
>
</Filter>
<Filter
Name="NFF"
>
<File
RelativePath="..\..\code\NFFLoader.cpp"
>
</File>
</Filter>
</Filter>
</Filter>
<Filter