Merge branch 'master' of https://github.com/assimp/assimp
This commit is contained in:
@@ -47,9 +47,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "SceneCombiner.h"
|
||||
#include "SplitLargeMeshes.h"
|
||||
#include "StringComparison.h"
|
||||
#include "../include/assimp/IOSystem.hpp"
|
||||
#include "../include/assimp/DefaultLogger.hpp"
|
||||
#include "../include/assimp/Exporter.hpp"
|
||||
#include "../include/assimp/IOSystem.hpp"
|
||||
#include "../include/assimp/DefaultLogger.hpp"
|
||||
#include "../include/assimp/Exporter.hpp"
|
||||
#include <memory>
|
||||
|
||||
using namespace Assimp;
|
||||
@@ -324,6 +324,7 @@ void Discreet3DSExporter::WriteMaterials()
|
||||
break;
|
||||
|
||||
default:
|
||||
shading_mode_out = Discreet3DS::Flat;
|
||||
ai_assert(false);
|
||||
};
|
||||
writer.PutU2(static_cast<uint16_t>(shading_mode_out));
|
||||
|
||||
@@ -51,8 +51,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "AssbinLoader.h"
|
||||
#include "assbin_chunks.h"
|
||||
#include "MemoryIOWrapper.h"
|
||||
#include "../include/assimp/mesh.h"
|
||||
#include "../include/assimp/anim.h"
|
||||
#include "../include/assimp/mesh.h"
|
||||
#include "../include/assimp/anim.h"
|
||||
#include "../include/assimp/scene.h"
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
@@ -199,7 +199,8 @@ template <typename T> void ReadBounds( IOStream * stream, T* /*p*/, unsigned int
|
||||
|
||||
void AssbinImporter::ReadBinaryNode( IOStream * stream, aiNode** node )
|
||||
{
|
||||
ai_assert( Read<uint32_t>(stream) == ASSBIN_CHUNK_AINODE);
|
||||
uint32_t chunkID = Read<uint32_t>(stream);
|
||||
ai_assert(chunkID == ASSBIN_CHUNK_AINODE);
|
||||
/*uint32_t size =*/ Read<uint32_t>(stream);
|
||||
|
||||
*node = new aiNode();
|
||||
@@ -230,7 +231,8 @@ void AssbinImporter::ReadBinaryNode( IOStream * stream, aiNode** node )
|
||||
// -----------------------------------------------------------------------------------
|
||||
void AssbinImporter::ReadBinaryBone( IOStream * stream, aiBone* b )
|
||||
{
|
||||
ai_assert( Read<uint32_t>(stream) == ASSBIN_CHUNK_AIBONE );
|
||||
uint32_t chunkID = Read<uint32_t>(stream);
|
||||
ai_assert(chunkID == ASSBIN_CHUNK_AIBONE);
|
||||
/*uint32_t size =*/ Read<uint32_t>(stream);
|
||||
|
||||
b->mName = Read<aiString>(stream);
|
||||
@@ -253,7 +255,8 @@ void AssbinImporter::ReadBinaryBone( IOStream * stream, aiBone* b )
|
||||
|
||||
void AssbinImporter::ReadBinaryMesh( IOStream * stream, aiMesh* mesh )
|
||||
{
|
||||
ai_assert( Read<uint32_t>(stream) == ASSBIN_CHUNK_AIMESH);
|
||||
uint32_t chunkID = Read<uint32_t>(stream);
|
||||
ai_assert(chunkID == ASSBIN_CHUNK_AIMESH);
|
||||
/*uint32_t size =*/ Read<uint32_t>(stream);
|
||||
|
||||
mesh->mPrimitiveTypes = Read<unsigned int>(stream);
|
||||
@@ -377,7 +380,8 @@ void AssbinImporter::ReadBinaryMesh( IOStream * stream, aiMesh* mesh )
|
||||
|
||||
void AssbinImporter::ReadBinaryMaterialProperty(IOStream * stream, aiMaterialProperty* prop)
|
||||
{
|
||||
ai_assert( Read<uint32_t>(stream) == ASSBIN_CHUNK_AIMATERIALPROPERTY);
|
||||
uint32_t chunkID = Read<uint32_t>(stream);
|
||||
ai_assert(chunkID == ASSBIN_CHUNK_AIMATERIALPROPERTY);
|
||||
/*uint32_t size =*/ Read<uint32_t>(stream);
|
||||
|
||||
prop->mKey = Read<aiString>(stream);
|
||||
@@ -393,7 +397,8 @@ void AssbinImporter::ReadBinaryMaterialProperty(IOStream * stream, aiMaterialPro
|
||||
// -----------------------------------------------------------------------------------
|
||||
void AssbinImporter::ReadBinaryMaterial(IOStream * stream, aiMaterial* mat)
|
||||
{
|
||||
ai_assert( Read<uint32_t>(stream) == ASSBIN_CHUNK_AIMATERIAL);
|
||||
uint32_t chunkID = Read<uint32_t>(stream);
|
||||
ai_assert(chunkID == ASSBIN_CHUNK_AIMATERIAL);
|
||||
/*uint32_t size =*/ Read<uint32_t>(stream);
|
||||
|
||||
mat->mNumAllocated = mat->mNumProperties = Read<unsigned int>(stream);
|
||||
@@ -414,7 +419,8 @@ void AssbinImporter::ReadBinaryMaterial(IOStream * stream, aiMaterial* mat)
|
||||
// -----------------------------------------------------------------------------------
|
||||
void AssbinImporter::ReadBinaryNodeAnim(IOStream * stream, aiNodeAnim* nd)
|
||||
{
|
||||
ai_assert( Read<uint32_t>(stream) == ASSBIN_CHUNK_AINODEANIM);
|
||||
uint32_t chunkID = Read<uint32_t>(stream);
|
||||
ai_assert(chunkID == ASSBIN_CHUNK_AINODEANIM);
|
||||
/*uint32_t size =*/ Read<uint32_t>(stream);
|
||||
|
||||
nd->mNodeName = Read<aiString>(stream);
|
||||
@@ -462,7 +468,8 @@ void AssbinImporter::ReadBinaryNodeAnim(IOStream * stream, aiNodeAnim* nd)
|
||||
// -----------------------------------------------------------------------------------
|
||||
void AssbinImporter::ReadBinaryAnim( IOStream * stream, aiAnimation* anim )
|
||||
{
|
||||
ai_assert( Read<uint32_t>(stream) == ASSBIN_CHUNK_AIANIMATION);
|
||||
uint32_t chunkID = Read<uint32_t>(stream);
|
||||
ai_assert(chunkID == ASSBIN_CHUNK_AIANIMATION);
|
||||
/*uint32_t size =*/ Read<uint32_t>(stream);
|
||||
|
||||
anim->mName = Read<aiString> (stream);
|
||||
@@ -482,7 +489,8 @@ void AssbinImporter::ReadBinaryAnim( IOStream * stream, aiAnimation* anim )
|
||||
|
||||
void AssbinImporter::ReadBinaryTexture(IOStream * stream, aiTexture* tex)
|
||||
{
|
||||
ai_assert( Read<uint32_t>(stream) == ASSBIN_CHUNK_AITEXTURE);
|
||||
uint32_t chunkID = Read<uint32_t>(stream);
|
||||
ai_assert(chunkID == ASSBIN_CHUNK_AITEXTURE);
|
||||
/*uint32_t size =*/ Read<uint32_t>(stream);
|
||||
|
||||
tex->mWidth = Read<unsigned int>(stream);
|
||||
@@ -505,7 +513,8 @@ void AssbinImporter::ReadBinaryTexture(IOStream * stream, aiTexture* tex)
|
||||
// -----------------------------------------------------------------------------------
|
||||
void AssbinImporter::ReadBinaryLight( IOStream * stream, aiLight* l )
|
||||
{
|
||||
ai_assert( Read<uint32_t>(stream) == ASSBIN_CHUNK_AILIGHT);
|
||||
uint32_t chunkID = Read<uint32_t>(stream);
|
||||
ai_assert(chunkID == ASSBIN_CHUNK_AILIGHT);
|
||||
/*uint32_t size =*/ Read<uint32_t>(stream);
|
||||
|
||||
l->mName = Read<aiString>(stream);
|
||||
@@ -531,7 +540,8 @@ void AssbinImporter::ReadBinaryLight( IOStream * stream, aiLight* l )
|
||||
// -----------------------------------------------------------------------------------
|
||||
void AssbinImporter::ReadBinaryCamera( IOStream * stream, aiCamera* cam )
|
||||
{
|
||||
ai_assert( Read<uint32_t>(stream) == ASSBIN_CHUNK_AICAMERA);
|
||||
uint32_t chunkID = Read<uint32_t>(stream);
|
||||
ai_assert(chunkID == ASSBIN_CHUNK_AICAMERA);
|
||||
/*uint32_t size =*/ Read<uint32_t>(stream);
|
||||
|
||||
cam->mName = Read<aiString>(stream);
|
||||
@@ -546,7 +556,8 @@ void AssbinImporter::ReadBinaryCamera( IOStream * stream, aiCamera* cam )
|
||||
|
||||
void AssbinImporter::ReadBinaryScene( IOStream * stream, aiScene* scene )
|
||||
{
|
||||
ai_assert( Read<uint32_t>(stream) == ASSBIN_CHUNK_AISCENE);
|
||||
uint32_t chunkID = Read<uint32_t>(stream);
|
||||
ai_assert(chunkID == ASSBIN_CHUNK_AISCENE);
|
||||
/*uint32_t size =*/ Read<uint32_t>(stream);
|
||||
|
||||
scene->mFlags = Read<unsigned int>(stream);
|
||||
|
||||
@@ -423,6 +423,21 @@ const char* aiGetErrorString()
|
||||
return gLastErrorString.c_str();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------
|
||||
// Return the description of a importer given its index
|
||||
const aiImporterDesc* aiGetImportFormatDescription( size_t pIndex)
|
||||
{
|
||||
return Importer().GetImporterInfo(pIndex);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------
|
||||
// Return the number of importers
|
||||
size_t aiGetImportFormatCount(void)
|
||||
{
|
||||
return Importer().GetImporterCount();
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Returns the error text of the last failed import process.
|
||||
aiBool aiIsExtensionSupported(const char* szExtension)
|
||||
|
||||
@@ -480,7 +480,9 @@ namespace Assimp
|
||||
struct Assimp::BatchData
|
||||
{
|
||||
BatchData()
|
||||
: next_id(0xffff)
|
||||
: pIOSystem()
|
||||
, pImporter()
|
||||
, next_id(0xffff)
|
||||
{}
|
||||
|
||||
// IO system to be used for all imports
|
||||
|
||||
@@ -51,7 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "XMLTools.h"
|
||||
#include "../include/assimp/IOSystem.hpp"
|
||||
#include "../include/assimp/Exporter.hpp"
|
||||
#include "../include/assimp/scene.h"
|
||||
#include "../include/assimp/scene.h"
|
||||
|
||||
#include "Exceptional.h"
|
||||
|
||||
@@ -127,6 +127,8 @@ void ColladaExporter::WriteFile()
|
||||
WriteTextures();
|
||||
WriteHeader();
|
||||
|
||||
WriteCamerasLibrary();
|
||||
WriteLightsLibrary();
|
||||
WriteMaterials();
|
||||
WriteGeometryLibrary();
|
||||
|
||||
@@ -165,8 +167,6 @@ void ColladaExporter::WriteHeader()
|
||||
std::time_t date = std::time(NULL);
|
||||
std::strftime(date_str, date_nb_chars, "%Y-%m-%dT%H:%M:%S", std::localtime(&date));
|
||||
|
||||
std::string scene_name = mScene->mRootNode->mName.C_Str();
|
||||
|
||||
aiVector3D scaling;
|
||||
aiQuaternion rotation;
|
||||
aiVector3D position;
|
||||
@@ -286,6 +286,201 @@ void ColladaExporter::WriteTextures() {
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Write the embedded textures
|
||||
void ColladaExporter::WriteCamerasLibrary() {
|
||||
if(mScene->HasCameras()) {
|
||||
|
||||
mOutput << startstr << "<library_cameras>" << endstr;
|
||||
PushTag();
|
||||
|
||||
for( size_t a = 0; a < mScene->mNumCameras; ++a)
|
||||
WriteCamera( a);
|
||||
|
||||
PopTag();
|
||||
mOutput << startstr << "</library_cameras>" << endstr;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void ColladaExporter::WriteCamera(size_t pIndex){
|
||||
|
||||
const aiCamera *cam = mScene->mCameras[pIndex];
|
||||
const std::string idstrEscaped = XMLEscape(cam->mName.C_Str());
|
||||
|
||||
mOutput << startstr << "<camera id=\"" << idstrEscaped << "-camera\" name=\"" << idstrEscaped << "_name\" >" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<optics>" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<technique_common>" << endstr;
|
||||
PushTag();
|
||||
//assimp doesn't support the import of orthographic cameras! se we write
|
||||
//always perspective
|
||||
mOutput << startstr << "<perspective>" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<xfov sid=\"xfov\">"<<
|
||||
AI_RAD_TO_DEG(cam->mHorizontalFOV)
|
||||
<<"</xfov>" << endstr;
|
||||
mOutput << startstr << "<aspect_ratio>"
|
||||
<< cam->mAspect
|
||||
<< "</aspect_ratio>" << endstr;
|
||||
mOutput << startstr << "<znear sid=\"znear\">"
|
||||
<< cam->mClipPlaneNear
|
||||
<< "</znear>" << endstr;
|
||||
mOutput << startstr << "<zfar sid=\"zfar\">"
|
||||
<< cam->mClipPlaneFar
|
||||
<< "</zfar>" << endstr;
|
||||
PopTag();
|
||||
mOutput << startstr << "</perspective>" << endstr;
|
||||
PopTag();
|
||||
mOutput << startstr << "</technique_common>" << endstr;
|
||||
PopTag();
|
||||
mOutput << startstr << "</optics>" << endstr;
|
||||
PopTag();
|
||||
mOutput << startstr << "</camera>" << endstr;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Write the embedded textures
|
||||
void ColladaExporter::WriteLightsLibrary() {
|
||||
if(mScene->HasLights()) {
|
||||
|
||||
mOutput << startstr << "<library_lights>" << endstr;
|
||||
PushTag();
|
||||
|
||||
for( size_t a = 0; a < mScene->mNumLights; ++a)
|
||||
WriteLight( a);
|
||||
|
||||
PopTag();
|
||||
mOutput << startstr << "</library_lights>" << endstr;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void ColladaExporter::WriteLight(size_t pIndex){
|
||||
|
||||
const aiLight *light = mScene->mLights[pIndex];
|
||||
const std::string idstrEscaped = XMLEscape(light->mName.C_Str());
|
||||
|
||||
mOutput << startstr << "<light id=\"" << idstrEscaped << "-light\" name=\""
|
||||
<< idstrEscaped << "_name\" >" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<technique_common>" << endstr;
|
||||
PushTag();
|
||||
switch(light->mType){
|
||||
case aiLightSource_AMBIENT:
|
||||
WriteAmbienttLight(light);
|
||||
break;
|
||||
case aiLightSource_DIRECTIONAL:
|
||||
WriteDirectionalLight(light);
|
||||
break;
|
||||
case aiLightSource_POINT:
|
||||
WritePointLight(light);
|
||||
break;
|
||||
case aiLightSource_SPOT:
|
||||
WriteSpotLight(light);
|
||||
break;
|
||||
case aiLightSource_UNDEFINED:
|
||||
case _aiLightSource_Force32Bit:
|
||||
break;
|
||||
}
|
||||
PopTag();
|
||||
mOutput << startstr << "</technique_common>" << endstr;
|
||||
|
||||
PopTag();
|
||||
mOutput << startstr << "</light>" << endstr;
|
||||
|
||||
}
|
||||
|
||||
void ColladaExporter::WritePointLight(const aiLight *const light){
|
||||
const aiColor3D &color= light->mColorDiffuse;
|
||||
mOutput << startstr << "<point>" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<color sid=\"color\">"
|
||||
<< color.r<<" "<<color.g<<" "<<color.b
|
||||
<<"</color>" << endstr;
|
||||
mOutput << startstr << "<constant_attenuation>"
|
||||
<< light->mAttenuationConstant
|
||||
<<"</constant_attenuation>" << endstr;
|
||||
mOutput << startstr << "<linear_attenuation>"
|
||||
<< light->mAttenuationLinear
|
||||
<<"</linear_attenuation>" << endstr;
|
||||
mOutput << startstr << "<quadratic_attenuation>"
|
||||
<< light->mAttenuationQuadratic
|
||||
<<"</quadratic_attenuation>" << endstr;
|
||||
|
||||
PopTag();
|
||||
mOutput << startstr << "</point>" << endstr;
|
||||
|
||||
}
|
||||
void ColladaExporter::WriteDirectionalLight(const aiLight *const light){
|
||||
const aiColor3D &color= light->mColorDiffuse;
|
||||
mOutput << startstr << "<directional>" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<color sid=\"color\">"
|
||||
<< color.r<<" "<<color.g<<" "<<color.b
|
||||
<<"</color>" << endstr;
|
||||
|
||||
PopTag();
|
||||
mOutput << startstr << "</directional>" << endstr;
|
||||
|
||||
}
|
||||
void ColladaExporter::WriteSpotLight(const aiLight *const light){
|
||||
|
||||
const aiColor3D &color= light->mColorDiffuse;
|
||||
mOutput << startstr << "<spot>" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<color sid=\"color\">"
|
||||
<< color.r<<" "<<color.g<<" "<<color.b
|
||||
<<"</color>" << endstr;
|
||||
mOutput << startstr << "<constant_attenuation>"
|
||||
<< light->mAttenuationConstant
|
||||
<<"</constant_attenuation>" << endstr;
|
||||
mOutput << startstr << "<linear_attenuation>"
|
||||
<< light->mAttenuationLinear
|
||||
<<"</linear_attenuation>" << endstr;
|
||||
mOutput << startstr << "<quadratic_attenuation>"
|
||||
<< light->mAttenuationQuadratic
|
||||
<<"</quadratic_attenuation>" << endstr;
|
||||
/*
|
||||
out->mAngleOuterCone = AI_DEG_TO_RAD (std::acos(std::pow(0.1f,1.f/srcLight->mFalloffExponent))+
|
||||
srcLight->mFalloffAngle);
|
||||
*/
|
||||
|
||||
const float fallOffAngle = AI_RAD_TO_DEG(light->mAngleInnerCone);
|
||||
mOutput << startstr <<"<falloff_angle sid=\"fall_off_angle\">"
|
||||
<< fallOffAngle
|
||||
<<"</falloff_angle>" << endstr;
|
||||
double temp = light->mAngleOuterCone-light->mAngleInnerCone;
|
||||
|
||||
temp = std::cos(temp);
|
||||
temp = std::log(temp)/std::log(0.1);
|
||||
temp = 1/temp;
|
||||
mOutput << startstr << "<falloff_exponent sid=\"fall_off_exponent\">"
|
||||
<< temp
|
||||
<<"</falloff_exponent>" << endstr;
|
||||
|
||||
|
||||
PopTag();
|
||||
mOutput << startstr << "</spot>" << endstr;
|
||||
|
||||
}
|
||||
|
||||
void ColladaExporter::WriteAmbienttLight(const aiLight *const light){
|
||||
|
||||
const aiColor3D &color= light->mColorAmbient;
|
||||
mOutput << startstr << "<ambient>" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<color sid=\"color\">"
|
||||
<< color.r<<" "<<color.g<<" "<<color.b
|
||||
<<"</color>" << endstr;
|
||||
|
||||
PopTag();
|
||||
mOutput << startstr << "</ambient>" << endstr;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Reads a single surface entry from the given material keys
|
||||
void ColladaExporter::ReadMaterialSurface( Surface& poSurface, const aiMaterial* pSrcMat, aiTextureType pTexture, const char* pKey, size_t pType, size_t pIndex)
|
||||
@@ -425,8 +620,6 @@ void ColladaExporter::WriteMaterials()
|
||||
{
|
||||
materials.resize( mScene->mNumMaterials);
|
||||
|
||||
std::set<std::string> material_names;
|
||||
|
||||
/// collect all materials from the scene
|
||||
size_t numTextures = 0;
|
||||
for( size_t a = 0; a < mScene->mNumMaterials; ++a )
|
||||
@@ -847,6 +1040,23 @@ void ColladaExporter::WriteNode(aiNode* pNode)
|
||||
mOutput << mat.d1 << " " << mat.d2 << " " << mat.d3 << " " << mat.d4;
|
||||
mOutput << "</matrix>" << endstr;
|
||||
|
||||
if(pNode->mNumMeshes==0){
|
||||
//check if it is a camera node
|
||||
for(size_t i=0; i<mScene->mNumCameras; i++){
|
||||
if(mScene->mCameras[i]->mName == pNode->mName){
|
||||
mOutput << startstr <<"<instance_camera url=\"#" << node_name_escaped << "-camera\"/>" << endstr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//check if it is a light node
|
||||
for(size_t i=0; i<mScene->mNumLights; i++){
|
||||
if(mScene->mLights[i]->mName == pNode->mName){
|
||||
mOutput << startstr <<"<instance_light url=\"#" << node_name_escaped << "-light\"/>" << endstr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}else
|
||||
// instance every geometry
|
||||
for( size_t a = 0; a < pNode->mNumMeshes; ++a )
|
||||
{
|
||||
@@ -854,9 +1064,8 @@ void ColladaExporter::WriteNode(aiNode* pNode)
|
||||
// do not instanciate mesh if empty. I wonder how this could happen
|
||||
if( mesh->mNumFaces == 0 || mesh->mNumVertices == 0 )
|
||||
continue;
|
||||
|
||||
mOutput << startstr << "<instance_geometry url=\"#" << XMLEscape(GetMeshId( pNode->mMeshes[a])) << "\">" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<instance_geometry url=\"#" << XMLEscape(GetMeshId( pNode->mMeshes[a])) << "\">" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<bind_material>" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<technique_common>" << endstr;
|
||||
|
||||
@@ -47,6 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "../include/assimp/ai_assert.h"
|
||||
#include "../include/assimp/material.h"
|
||||
#include "../include/assimp/mesh.h"
|
||||
#include "../include/assimp/light.h"
|
||||
#include "../include/assimp/Exporter.hpp"
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
@@ -83,6 +84,22 @@ protected:
|
||||
/// Writes the material setup
|
||||
void WriteMaterials();
|
||||
|
||||
/// Writes the cameras library
|
||||
void WriteCamerasLibrary();
|
||||
|
||||
// Write a camera entry
|
||||
void WriteCamera(size_t pIndex);
|
||||
|
||||
/// Writes the cameras library
|
||||
void WriteLightsLibrary();
|
||||
|
||||
// Write a camera entry
|
||||
void WriteLight(size_t pIndex);
|
||||
void WritePointLight(const aiLight *const light);
|
||||
void WriteDirectionalLight(const aiLight *const light);
|
||||
void WriteSpotLight(const aiLight *const light);
|
||||
void WriteAmbienttLight(const aiLight *const light);
|
||||
|
||||
/// Writes the geometry library
|
||||
void WriteGeometryLibrary();
|
||||
|
||||
@@ -144,8 +161,11 @@ protected:
|
||||
struct Property
|
||||
{
|
||||
bool exist;
|
||||
float value;
|
||||
Property() { exist = false; }
|
||||
float value;
|
||||
Property()
|
||||
: exist(false)
|
||||
, value(0.0f)
|
||||
{}
|
||||
};
|
||||
|
||||
// summarize a material in an convinient way.
|
||||
|
||||
@@ -47,7 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
#include "../include/assimp/types.h"
|
||||
#include "../include/assimp/light.h"
|
||||
#include "../include/assimp/mesh.h"
|
||||
#include "../include/assimp/material.h"
|
||||
|
||||
@@ -134,7 +134,8 @@ struct Camera
|
||||
struct Light
|
||||
{
|
||||
Light()
|
||||
: mAttConstant (1.f)
|
||||
: mType (aiLightSource_UNDEFINED)
|
||||
, mAttConstant (1.f)
|
||||
, mAttLinear (0.f)
|
||||
, mAttQuadratic (0.f)
|
||||
, mFalloffAngle (180.f)
|
||||
@@ -172,13 +173,14 @@ struct Light
|
||||
struct InputSemanticMapEntry
|
||||
{
|
||||
InputSemanticMapEntry()
|
||||
: mSet (0)
|
||||
: mSet(0)
|
||||
, mType(IT_Invalid)
|
||||
{}
|
||||
|
||||
//! Index of set, optional
|
||||
unsigned int mSet;
|
||||
|
||||
//! Name of referenced vertex input
|
||||
//! Type of referenced vertex input
|
||||
InputType mType;
|
||||
};
|
||||
|
||||
@@ -235,7 +237,7 @@ struct Node
|
||||
{
|
||||
std::string mName;
|
||||
std::string mID;
|
||||
std::string mSID;
|
||||
std::string mSID;
|
||||
Node* mParent;
|
||||
std::vector<Node*> mChildren;
|
||||
|
||||
@@ -384,8 +386,8 @@ struct Controller
|
||||
// accessor URL of the joint names
|
||||
std::string mJointNameSource;
|
||||
|
||||
///< The bind shape matrix, as array of floats. I'm not sure what this matrix actually describes, but it can't be ignored in all cases
|
||||
float mBindShapeMatrix[16];
|
||||
///< The bind shape matrix, as array of floats. I'm not sure what this matrix actually describes, but it can't be ignored in all cases
|
||||
float mBindShapeMatrix[16];
|
||||
|
||||
// accessor URL of the joint inverse bind matrices
|
||||
std::string mJointOffsetMatrixSource;
|
||||
@@ -609,7 +611,15 @@ struct ChannelEntry
|
||||
const Collada::Accessor* mValueAccessor; ///> Collada accessor to the key value values
|
||||
const Collada::Data* mValueData; ///> Source datat array for the key value values
|
||||
|
||||
ChannelEntry() { mChannel = NULL; mSubElement = 0; }
|
||||
ChannelEntry()
|
||||
: mChannel()
|
||||
, mTransformIndex()
|
||||
, mSubElement()
|
||||
, mTimeAccessor()
|
||||
, mTimeData()
|
||||
, mValueAccessor()
|
||||
, mValueData()
|
||||
{}
|
||||
};
|
||||
|
||||
} // end of namespace Collada
|
||||
|
||||
@@ -81,7 +81,10 @@ static const aiImporterDesc desc = {
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor to be privately used by Importer
|
||||
ColladaLoader::ColladaLoader()
|
||||
: noSkeletonMesh(), ignoreUpDirection(false), mNodeNameCounter()
|
||||
: noSkeletonMesh()
|
||||
, ignoreUpDirection(false)
|
||||
, invertTransparency(false)
|
||||
, mNodeNameCounter()
|
||||
{}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
@@ -346,8 +349,8 @@ void ColladaLoader::BuildLightsForNode( const ColladaParser& pParser, const Coll
|
||||
{
|
||||
// Need to rely on falloff_exponent. I don't know how to interpret it, so I need to guess ....
|
||||
// epsilon chosen to be 0.1
|
||||
out->mAngleOuterCone = AI_DEG_TO_RAD (std::acos(std::pow(0.1f,1.f/srcLight->mFalloffExponent))+
|
||||
srcLight->mFalloffAngle);
|
||||
out->mAngleOuterCone = std::acos(std::pow(0.1f,1.f/srcLight->mFalloffExponent))+
|
||||
out->mAngleInnerCone;
|
||||
}
|
||||
else {
|
||||
out->mAngleOuterCone = out->mAngleInnerCone + AI_DEG_TO_RAD( srcLight->mPenumbraAngle );
|
||||
@@ -916,7 +919,7 @@ void ColladaLoader::StoreAnimations( aiScene* pScene, const ColladaParser& pPars
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructs the animations for the given source anim
|
||||
void ColladaLoader::StoreAnimations( aiScene* pScene, const ColladaParser& pParser, const Collada::Animation* pSrcAnim, const std::string pPrefix)
|
||||
void ColladaLoader::StoreAnimations( aiScene* pScene, const ColladaParser& pParser, const Collada::Animation* pSrcAnim, const std::string &pPrefix)
|
||||
{
|
||||
std::string animName = pPrefix.empty() ? pSrcAnim->mName : pPrefix + "_" + pSrcAnim->mName;
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ protected:
|
||||
* @param pSrcAnim the source animation to process
|
||||
* @param pPrefix Prefix to the name in case of nested animations
|
||||
*/
|
||||
void StoreAnimations( aiScene* pScene, const ColladaParser& pParser, const Collada::Animation* pSrcAnim, const std::string pPrefix);
|
||||
void StoreAnimations( aiScene* pScene, const ColladaParser& pParser, const Collada::Animation* pSrcAnim, const std::string& pPrefix);
|
||||
|
||||
/** Constructs the animation for the given source anim */
|
||||
void CreateAnimation( aiScene* pScene, const ColladaParser& pParser, const Collada::Animation* pSrcAnim, const std::string& pName);
|
||||
|
||||
@@ -412,7 +412,7 @@ void ComputeUVMappingProcess::Execute( aiScene* pScene)
|
||||
{
|
||||
if (!DefaultLogger::isNullLogger())
|
||||
{
|
||||
sprintf(buffer, "Found non-UV mapped texture (%s,%i). Mapping type: %s",
|
||||
sprintf(buffer, "Found non-UV mapped texture (%s,%u). Mapping type: %s",
|
||||
TextureTypeToString((aiTextureType)prop->mSemantic),prop->mIndex,
|
||||
MappingTypeToString(mapping));
|
||||
|
||||
|
||||
@@ -86,27 +86,6 @@ namespace {
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// print warning, do return
|
||||
void ParseWarning(const std::string& message, const Token& token)
|
||||
{
|
||||
if(DefaultLogger::get()) {
|
||||
DefaultLogger::get()->warn(Util::AddTokenText("FBX-Parser",message,&token));
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
/* void ParseWarning(const std::string& message, const Element* element = NULL)
|
||||
{
|
||||
if(element) {
|
||||
ParseWarning(message,element->KeyToken());
|
||||
return;
|
||||
}
|
||||
if(DefaultLogger::get()) {
|
||||
DefaultLogger::get()->warn("FBX-Parser: " + message);
|
||||
}
|
||||
}
|
||||
*/
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void ParseError(const std::string& message, TokenPtr token)
|
||||
{
|
||||
|
||||
@@ -58,6 +58,7 @@ using namespace Assimp;
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor to be privately used by Importer
|
||||
FindInvalidDataProcess::FindInvalidDataProcess()
|
||||
: configEpsilon(0.0f)
|
||||
{
|
||||
// nothing to do here
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ bool FixInfacingNormalsProcess::ProcessMesh( aiMesh* pcMesh, unsigned int index)
|
||||
if (!DefaultLogger::isNullLogger())
|
||||
{
|
||||
char buffer[128]; // should be sufficiently large
|
||||
::sprintf(buffer,"Mesh %i: Normals are facing inwards (or the mesh is planar)",index);
|
||||
::sprintf(buffer,"Mesh %u: Normals are facing inwards (or the mesh is planar)",index);
|
||||
DefaultLogger::get()->info(buffer);
|
||||
}
|
||||
|
||||
|
||||
@@ -173,7 +173,6 @@ public:
|
||||
// --------------------------------------------------
|
||||
Line(const IfcLine& entity, ConversionData& conv)
|
||||
: Curve(entity,conv)
|
||||
, entity(entity)
|
||||
{
|
||||
ConvertCartesianPoint(p,entity.Pnt);
|
||||
ConvertVector(v,entity.Dir);
|
||||
@@ -221,7 +220,6 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
const IfcLine& entity;
|
||||
IfcVector3 p,v;
|
||||
};
|
||||
|
||||
@@ -238,7 +236,6 @@ public:
|
||||
// --------------------------------------------------
|
||||
CompositeCurve(const IfcCompositeCurve& entity, ConversionData& conv)
|
||||
: BoundedCurve(entity,conv)
|
||||
, entity(entity)
|
||||
, total()
|
||||
{
|
||||
curves.reserve(entity.Segments.size());
|
||||
@@ -331,7 +328,6 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
const IfcCompositeCurve& entity;
|
||||
std::vector< CurveEntry > curves;
|
||||
|
||||
IfcFloat total;
|
||||
@@ -349,8 +345,6 @@ public:
|
||||
// --------------------------------------------------
|
||||
TrimmedCurve(const IfcTrimmedCurve& entity, ConversionData& conv)
|
||||
: BoundedCurve(entity,conv)
|
||||
, entity(entity)
|
||||
, ok()
|
||||
{
|
||||
base = boost::shared_ptr<const Curve>(Curve::Convert(entity.BasisCurve,conv));
|
||||
|
||||
@@ -448,11 +442,9 @@ private:
|
||||
|
||||
|
||||
private:
|
||||
const IfcTrimmedCurve& entity;
|
||||
ParamRange range;
|
||||
IfcFloat maxval;
|
||||
bool agree_sense;
|
||||
bool ok;
|
||||
|
||||
boost::shared_ptr<const Curve> base;
|
||||
};
|
||||
@@ -469,7 +461,6 @@ public:
|
||||
// --------------------------------------------------
|
||||
PolyLine(const IfcPolyline& entity, ConversionData& conv)
|
||||
: BoundedCurve(entity,conv)
|
||||
, entity(entity)
|
||||
{
|
||||
points.reserve(entity.Points.size());
|
||||
|
||||
@@ -507,7 +498,6 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
const IfcPolyline& entity;
|
||||
std::vector<IfcVector3> points;
|
||||
};
|
||||
|
||||
|
||||
@@ -60,9 +60,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include "StreamReader.h"
|
||||
#include "MemoryIOWrapper.h"
|
||||
#include "../include/assimp/scene.h"
|
||||
#include "../include/assimp/Importer.hpp"
|
||||
|
||||
#include "../include/assimp/scene.h"
|
||||
#include "../include/assimp/Importer.hpp"
|
||||
|
||||
|
||||
namespace Assimp {
|
||||
template<> const std::string LogFunctions<IFCImporter>::log_prefix = "IFC: ";
|
||||
@@ -93,8 +93,6 @@ namespace {
|
||||
void SetUnits(ConversionData& conv);
|
||||
void SetCoordinateSpace(ConversionData& conv);
|
||||
void ProcessSpatialStructures(ConversionData& conv);
|
||||
aiNode* ProcessSpatialStructure(aiNode* parent, const IfcProduct& el ,ConversionData& conv);
|
||||
void ProcessProductRepresentation(const IfcProduct& el, aiNode* nd, ConversionData& conv);
|
||||
void MakeTreeRelative(ConversionData& conv);
|
||||
void ConvertUnit(const EXPRESS::DataType& dt,ConversionData& conv);
|
||||
|
||||
@@ -421,16 +419,6 @@ void ResolveObjectPlacement(aiMatrix4x4& m, const IfcObjectPlacement& place, Con
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void GetAbsTransform(aiMatrix4x4& out, const aiNode* nd, ConversionData& conv)
|
||||
{
|
||||
aiMatrix4x4 t;
|
||||
if (nd->mParent) {
|
||||
GetAbsTransform(t,nd->mParent,conv);
|
||||
}
|
||||
out = t*nd->mTransformation;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool ProcessMappedItem(const IfcMappedItem& mapped, aiNode* nd_src, std::vector< aiNode* >& subnodes_src, unsigned int matid, ConversionData& conv)
|
||||
{
|
||||
@@ -682,14 +670,14 @@ aiNode* ProcessSpatialStructure(aiNode* parent, const IfcProduct& el, Conversion
|
||||
// skip over space and annotation nodes - usually, these have no meaning in Assimp's context
|
||||
bool skipGeometry = false;
|
||||
if(conv.settings.skipSpaceRepresentations) {
|
||||
if(const IfcSpace* const space = el.ToPtr<IfcSpace>()) {
|
||||
if(el.ToPtr<IfcSpace>()) {
|
||||
IFCImporter::LogDebug("skipping IfcSpace entity due to importer settings");
|
||||
skipGeometry = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(conv.settings.skipAnnotations) {
|
||||
if(const IfcAnnotation* const ann = el.ToPtr<IfcAnnotation>()) {
|
||||
if(el.ToPtr<IfcAnnotation>()) {
|
||||
IFCImporter::LogDebug("skipping IfcAnnotation entity due to importer settings");
|
||||
return NULL;
|
||||
}
|
||||
@@ -764,7 +752,7 @@ aiNode* ProcessSpatialStructure(aiNode* parent, const IfcProduct& el, Conversion
|
||||
continue;
|
||||
}
|
||||
BOOST_FOREACH(const IfcProduct& pro, cont->RelatedElements) {
|
||||
if(const IfcOpeningElement* const open = pro.ToPtr<IfcOpeningElement>()) {
|
||||
if(pro.ToPtr<IfcOpeningElement>()) {
|
||||
// IfcOpeningElement is handled below. Sadly we can't use it here as is:
|
||||
// The docs say that opening elements are USUALLY attached to building storey,
|
||||
// but we want them for the building elements to which they belong.
|
||||
|
||||
@@ -114,7 +114,7 @@ void ProcessParametrizedProfile(const IfcParameterizedProfileDef& def, TempMesh&
|
||||
meshout.vertcnt.push_back(4);
|
||||
}
|
||||
else if( const IfcCircleProfileDef* const circle = def.ToPtr<IfcCircleProfileDef>()) {
|
||||
if( const IfcCircleHollowProfileDef* const hollow = def.ToPtr<IfcCircleHollowProfileDef>()) {
|
||||
if(def.ToPtr<IfcCircleHollowProfileDef>()) {
|
||||
// TODO
|
||||
}
|
||||
const size_t segments = 32;
|
||||
|
||||
@@ -110,7 +110,7 @@ void ImproveCacheLocalityProcess::Execute( aiScene* pScene)
|
||||
}
|
||||
if (!DefaultLogger::isNullLogger()) {
|
||||
char szBuff[128]; // should be sufficiently large in every case
|
||||
::sprintf(szBuff,"Cache relevant are %i meshes (%i faces). Average output ACMR is %f",
|
||||
::sprintf(szBuff,"Cache relevant are %u meshes (%u faces). Average output ACMR is %f",
|
||||
numm,numf,out/numf);
|
||||
|
||||
DefaultLogger::get()->info(szBuff);
|
||||
@@ -182,7 +182,7 @@ float ImproveCacheLocalityProcess::ProcessMesh( aiMesh* pMesh, unsigned int mesh
|
||||
// the JoinIdenticalVertices process has not been executed on this
|
||||
// mesh, otherwise this value would normally be at least minimally
|
||||
// smaller than 3.0 ...
|
||||
sprintf(szBuff,"Mesh %i: Not suitable for vcache optimization",meshNum);
|
||||
sprintf(szBuff,"Mesh %u: Not suitable for vcache optimization",meshNum);
|
||||
DefaultLogger::get()->warn(szBuff);
|
||||
return 0.f;
|
||||
}
|
||||
@@ -361,7 +361,7 @@ float ImproveCacheLocalityProcess::ProcessMesh( aiMesh* pMesh, unsigned int mesh
|
||||
if ( DefaultLogger::get()->getLogSeverity() == Logger::VERBOSE) {
|
||||
char szBuff[128]; // should be sufficiently large in every case
|
||||
|
||||
::sprintf(szBuff,"Mesh %i | ACMR in: %f out: %f | ~%.1f%%",meshNum,fACMR,fACMR2,
|
||||
::sprintf(szBuff,"Mesh %u | ACMR in: %f out: %f | ~%.1f%%",meshNum,fACMR,fACMR2,
|
||||
((fACMR - fACMR2) / fACMR) * 100.f);
|
||||
DefaultLogger::get()->debug(szBuff);
|
||||
}
|
||||
|
||||
@@ -263,16 +263,21 @@ void ObjFileMtlImporter::createMaterial()
|
||||
}
|
||||
|
||||
std::vector<std::string> token;
|
||||
const unsigned int numToken = tokenize<std::string>( line, token, " " );
|
||||
std::string name( "" );
|
||||
if ( numToken == 1 ) {
|
||||
name = AI_DEFAULT_MATERIAL_NAME;
|
||||
} else {
|
||||
name = token[ 1 ];
|
||||
}
|
||||
const unsigned int numToken = tokenize<std::string>( line, token, " \t" );
|
||||
std::string name( "" );
|
||||
if ( numToken == 1 ) {
|
||||
name = AI_DEFAULT_MATERIAL_NAME;
|
||||
} else {
|
||||
// skip newmtl and all following white spaces
|
||||
std::size_t first_ws_pos = line.find_first_of(" \t");
|
||||
std::size_t first_non_ws_pos = line.find_first_not_of(" \t", first_ws_pos);
|
||||
if (first_non_ws_pos != std::string::npos) {
|
||||
name = line.substr(first_non_ws_pos);
|
||||
}
|
||||
}
|
||||
|
||||
std::map<std::string, ObjFile::Material*>::iterator it = m_pModel->m_MaterialMap.find( name );
|
||||
if ( m_pModel->m_MaterialMap.end() == it) {
|
||||
std::map<std::string, ObjFile::Material*>::iterator it = m_pModel->m_MaterialMap.find( name );
|
||||
if ( m_pModel->m_MaterialMap.end() == it) {
|
||||
// New Material created
|
||||
m_pModel->m_pCurrentMaterial = new ObjFile::Material();
|
||||
m_pModel->m_pCurrentMaterial->MaterialName.Set( name );
|
||||
|
||||
@@ -469,7 +469,7 @@ void ObjFileParser::getMaterialDesc()
|
||||
return;
|
||||
|
||||
char *pStart = &(*m_DataIt);
|
||||
while( m_DataIt != m_DataItEnd && !IsSpaceOrNewLine( *m_DataIt ) ) {
|
||||
while( m_DataIt != m_DataItEnd && !IsLineEnd( *m_DataIt ) ) {
|
||||
++m_DataIt;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/ai_assert.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
static const aiImporterDesc desc = {
|
||||
@@ -184,12 +185,11 @@ USE_ODDLPARSER_NS
|
||||
//------------------------------------------------------------------------------------------------
|
||||
OpenGEXImporter::VertexContainer::VertexContainer()
|
||||
: m_numVerts( 0 )
|
||||
, m_vertices()
|
||||
, m_vertices(NULL)
|
||||
, m_numNormals( 0 )
|
||||
, m_normals()
|
||||
, m_textureCoords()
|
||||
, m_numUVComps() {
|
||||
// empty
|
||||
, m_normals(NULL) {
|
||||
std::fill(&m_numUVComps[0], &m_numUVComps[AI_MAX_NUMBER_OF_TEXTURECOORDS], 0U);
|
||||
std::fill(&m_textureCoords[0], &m_textureCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS], static_cast<aiVector3D *>(NULL));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
@@ -216,9 +216,9 @@ OpenGEXImporter::RefInfo::~RefInfo() {
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
OpenGEXImporter::OpenGEXImporter()
|
||||
: m_meshCache()
|
||||
, m_root( NULL )
|
||||
: m_root( NULL )
|
||||
, m_nodeChildMap()
|
||||
, m_meshCache()
|
||||
, m_mesh2refMap()
|
||||
, m_ctx( NULL )
|
||||
, m_currentNode( NULL )
|
||||
@@ -227,7 +227,7 @@ OpenGEXImporter::OpenGEXImporter()
|
||||
, m_tokenType( Grammar::NoneType )
|
||||
, m_nodeStack()
|
||||
, m_unresolvedRefStack() {
|
||||
// empty
|
||||
std::fill(&m_metrics[0], &m_metrics[MetricInfo::Max], MetricInfo());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
@@ -666,7 +666,6 @@ void OpenGEXImporter::handleVertexArrayNode( ODDLParser::DDLNode *node, aiScene
|
||||
}
|
||||
|
||||
const size_t numItems( countDataArrayListItems( vaList ) );
|
||||
Value *next( vaList->m_dataList );
|
||||
if( Position == attribType ) {
|
||||
m_currentVertices.m_numVerts = numItems;
|
||||
m_currentVertices.m_vertices = new aiVector3D[ numItems ];
|
||||
|
||||
@@ -71,6 +71,10 @@ using namespace Assimp;
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor to be privately used by Importer
|
||||
OptimizeGraphProcess::OptimizeGraphProcess()
|
||||
: mScene()
|
||||
, nodes_in()
|
||||
, nodes_out()
|
||||
, count_merged()
|
||||
{}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
@@ -122,7 +126,7 @@ void OptimizeGraphProcess::CollectNewChildren(aiNode* nd, std::list<aiNode*>& no
|
||||
++it;
|
||||
}
|
||||
|
||||
if (nd->mNumMeshes || child_nodes.size()) {
|
||||
if (nd->mNumMeshes || !child_nodes.empty()) {
|
||||
nodes.push_back(nd);
|
||||
}
|
||||
else {
|
||||
@@ -172,7 +176,7 @@ void OptimizeGraphProcess::CollectNewChildren(aiNode* nd, std::list<aiNode*>& no
|
||||
}
|
||||
++it;
|
||||
}
|
||||
if (join_master && join.size()) {
|
||||
if (join_master && !join.empty()) {
|
||||
join_master->mName.length = sprintf(join_master->mName.data,"$MergedNode_%i",count_merged++);
|
||||
|
||||
unsigned int out_meshes = 0;
|
||||
|
||||
@@ -60,9 +60,10 @@ static const unsigned int DeadBeef = 0xdeadbeef;
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor to be privately used by Importer
|
||||
OptimizeMeshesProcess::OptimizeMeshesProcess()
|
||||
: pts (false)
|
||||
, max_verts( NotSet )
|
||||
, max_faces( NotSet ) {
|
||||
: mScene()
|
||||
, pts(false)
|
||||
, max_verts( NotSet )
|
||||
, max_faces( NotSet ) {
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
@@ -164,9 +164,6 @@ private:
|
||||
//! Per mesh info
|
||||
std::vector<MeshInfo> meshes;
|
||||
|
||||
//! Next output mesh
|
||||
aiMesh* mesh;
|
||||
|
||||
//! Output meshes
|
||||
std::vector<aiMesh*> output;
|
||||
|
||||
|
||||
@@ -43,14 +43,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#if !defined(ASSIMP_BUILD_NO_EXPORT) && !defined(ASSIMP_BUILD_NO_PLY_EXPORTER)
|
||||
|
||||
#include "PlyExporter.h"
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <cmath>
|
||||
#include "Exceptional.h"
|
||||
#include "../include/assimp/scene.h"
|
||||
#include "../include/assimp/version.h"
|
||||
#include "../include/assimp/IOSystem.hpp"
|
||||
#include "Exceptional.h"
|
||||
#include "../include/assimp/scene.h"
|
||||
#include "../include/assimp/version.h"
|
||||
#include "../include/assimp/IOSystem.hpp"
|
||||
#include "../include/assimp/Exporter.hpp"
|
||||
#include "qnan.h"
|
||||
#include "qnan.h"
|
||||
|
||||
|
||||
using namespace Assimp;
|
||||
@@ -96,8 +96,7 @@ void ExportScenePlyBinary(const char* pFile, IOSystem* pIOSystem, const aiScene*
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
PlyExporter::PlyExporter(const char* _filename, const aiScene* pScene, bool binary)
|
||||
: filename(_filename)
|
||||
, pScene(pScene)
|
||||
, endl("\n")
|
||||
, endl("\n")
|
||||
{
|
||||
// make sure that all formatting happens using the standard, C locale and not the user's current locale
|
||||
const std::locale& l = std::locale("C");
|
||||
|
||||
@@ -78,7 +78,6 @@ private:
|
||||
private:
|
||||
|
||||
const std::string filename;
|
||||
const aiScene* const pScene;
|
||||
|
||||
// obviously, this endl() doesn't flush() the stream
|
||||
const std::string endl;
|
||||
|
||||
@@ -54,7 +54,9 @@ using namespace Assimp;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor to be privately used by Importer
|
||||
RemoveVCProcess::RemoveVCProcess()
|
||||
RemoveVCProcess::RemoveVCProcess() :
|
||||
configDeleteFlags()
|
||||
, mScene()
|
||||
{}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -46,7 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "STEPFileReader.h"
|
||||
#include "STEPFileEncoding.h"
|
||||
#include "TinyFormatter.h"
|
||||
#include "fast_atof.h"
|
||||
#include "fast_atof.h"
|
||||
#include <boost/make_shared.hpp>
|
||||
|
||||
|
||||
@@ -55,28 +55,6 @@ namespace EXPRESS = STEP::EXPRESS;
|
||||
|
||||
#include <functional>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// From http://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-stdstring
|
||||
|
||||
// trim from start
|
||||
static inline std::string <rim(std::string &s) {
|
||||
s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1( std::ptr_fun(Assimp::IsSpace<char>))));
|
||||
return s;
|
||||
}
|
||||
|
||||
// trim from end
|
||||
static inline std::string &rtrim(std::string &s) {
|
||||
s.erase(std::find_if(s.rbegin(), s.rend(), std::not1( std::ptr_fun(Assimp::IsSpace<char>))).base(),s.end());
|
||||
return s;
|
||||
}
|
||||
// trim from both ends
|
||||
static inline std::string &trim(std::string &s) {
|
||||
return ltrim(rtrim(s));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
std::string AddLineNumber(const std::string& s,uint64_t line /*= LINE_NOT_SPECIFIED*/, const std::string& prefix = "")
|
||||
{
|
||||
|
||||
@@ -43,13 +43,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#if !defined(ASSIMP_BUILD_NO_EXPORT) && !defined(ASSIMP_BUILD_NO_STL_EXPORTER)
|
||||
|
||||
#include "STLExporter.h"
|
||||
#include "../include/assimp/version.h"
|
||||
#include "../include/assimp/IOSystem.hpp"
|
||||
#include "../include/assimp/scene.h"
|
||||
#include "../include/assimp/Exporter.hpp"
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include "Exceptional.h"
|
||||
#include "ByteSwapper.h"
|
||||
#include "../include/assimp/version.h"
|
||||
#include "../include/assimp/IOSystem.hpp"
|
||||
#include "../include/assimp/scene.h"
|
||||
#include "../include/assimp/Exporter.hpp"
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include "Exceptional.h"
|
||||
#include "ByteSwapper.h"
|
||||
|
||||
using namespace Assimp;
|
||||
namespace Assimp {
|
||||
@@ -75,7 +75,7 @@ void ExportSceneSTLBinary(const char* pFile,IOSystem* pIOSystem, const aiScene*
|
||||
STLExporter exporter(pFile, pScene, true);
|
||||
|
||||
// we're still here - export successfully completed. Write the file.
|
||||
boost::scoped_ptr<IOStream> outfile (pIOSystem->Open(pFile,"wt"));
|
||||
boost::scoped_ptr<IOStream> outfile (pIOSystem->Open(pFile,"wb"));
|
||||
if(outfile == NULL) {
|
||||
throw DeadlyExportError("could not open output .stl file: " + std::string(pFile));
|
||||
}
|
||||
@@ -89,8 +89,7 @@ void ExportSceneSTLBinary(const char* pFile,IOSystem* pIOSystem, const aiScene*
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
STLExporter :: STLExporter(const char* _filename, const aiScene* pScene, bool binary)
|
||||
: filename(_filename)
|
||||
, pScene(pScene)
|
||||
, endl("\n")
|
||||
, endl("\n")
|
||||
{
|
||||
// make sure that all formatting happens using the standard, C locale and not the user's current locale
|
||||
const std::locale& l = std::locale("C");
|
||||
|
||||
@@ -75,7 +75,6 @@ private:
|
||||
private:
|
||||
|
||||
const std::string filename;
|
||||
const aiScene* const pScene;
|
||||
|
||||
// this endl() doesn't flush() the stream
|
||||
const std::string endl;
|
||||
|
||||
@@ -397,11 +397,11 @@ void SortByPTypeProcess::Execute( aiScene* pScene)
|
||||
if (!DefaultLogger::isNullLogger())
|
||||
{
|
||||
char buffer[1024];
|
||||
::sprintf(buffer,"Points: %i%s, Lines: %i%s, Triangles: %i%s, Polygons: %i%s (Meshes, X = removed)",
|
||||
aiNumMeshesPerPType[0], (configRemoveMeshes & aiPrimitiveType_POINT ? "X" : ""),
|
||||
aiNumMeshesPerPType[1], (configRemoveMeshes & aiPrimitiveType_LINE ? "X" : ""),
|
||||
aiNumMeshesPerPType[2], (configRemoveMeshes & aiPrimitiveType_TRIANGLE ? "X" : ""),
|
||||
aiNumMeshesPerPType[3], (configRemoveMeshes & aiPrimitiveType_POLYGON ? "X" : ""));
|
||||
::sprintf(buffer,"Points: %u%s, Lines: %u%s, Triangles: %u%s, Polygons: %u%s (Meshes, X = removed)",
|
||||
aiNumMeshesPerPType[0], ((configRemoveMeshes & aiPrimitiveType_POINT) ? "X" : ""),
|
||||
aiNumMeshesPerPType[1], ((configRemoveMeshes & aiPrimitiveType_LINE) ? "X" : ""),
|
||||
aiNumMeshesPerPType[2], ((configRemoveMeshes & aiPrimitiveType_TRIANGLE) ? "X" : ""),
|
||||
aiNumMeshesPerPType[3], ((configRemoveMeshes & aiPrimitiveType_POLYGON) ? "X" : ""));
|
||||
DefaultLogger::get()->info(buffer);
|
||||
DefaultLogger::get()->debug("SortByPTypeProcess finished");
|
||||
}
|
||||
|
||||
@@ -115,21 +115,6 @@ void ExportSceneStep(const char* pFile,IOSystem* pIOSystem, const aiScene* pScen
|
||||
|
||||
|
||||
namespace {
|
||||
inline uint64_t toIndexHash(int32_t id1, int32_t id2)
|
||||
{
|
||||
// dont wonder that -1/-1 -> hash=-1
|
||||
uint64_t hash = (uint32_t) id1;
|
||||
hash = (hash << 32);
|
||||
hash += (uint32_t) id2;
|
||||
return hash;
|
||||
}
|
||||
|
||||
inline void fromIndexHash(uint64_t hash, int32_t &id1, int32_t &id2)
|
||||
{
|
||||
id1 = (hash & 0xFFFFFFFF00000000) >> 32;
|
||||
id2 = (hash & 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
// Collect world transformations for each node
|
||||
void CollectTrafos(const aiNode* node, std::map<const aiNode*, aiMatrix4x4>& trafos) {
|
||||
const aiMatrix4x4& parent = node->mParent ? trafos[node->mParent] : aiMatrix4x4();
|
||||
@@ -152,7 +137,7 @@ namespace {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor for a specific scene to export
|
||||
StepExporter::StepExporter(const aiScene* pScene, IOSystem* pIOSystem, const std::string& path, const std::string& file, const ExportProperties* pProperties) : mIOSystem(pIOSystem), mPath(path), mFile(file), mProperties(pProperties)
|
||||
StepExporter::StepExporter(const aiScene* pScene, IOSystem* pIOSystem, const std::string& path, const std::string& file, const ExportProperties* pProperties) : mProperties(pProperties), mIOSystem(pIOSystem), mFile(file), mPath(path), mScene(pScene), endstr(";\n")
|
||||
{
|
||||
CollectTrafos(pScene->mRootNode, trafos);
|
||||
CollectMeshes(pScene->mRootNode, meshes);
|
||||
@@ -160,11 +145,6 @@ StepExporter::StepExporter(const aiScene* pScene, IOSystem* pIOSystem, const std
|
||||
// make sure that all formatting happens using the standard, C locale and not the user's current locale
|
||||
mOutput.imbue( std::locale("C") );
|
||||
|
||||
mScene = pScene;
|
||||
|
||||
// set up strings
|
||||
endstr = ";\n";
|
||||
|
||||
// start writing
|
||||
WriteFile();
|
||||
}
|
||||
|
||||
@@ -54,7 +54,8 @@ using namespace Assimp;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor to be privately used by Importer
|
||||
TextureTransformStep::TextureTransformStep()
|
||||
TextureTransformStep::TextureTransformStep() :
|
||||
configFlags()
|
||||
{
|
||||
// nothing to do here
|
||||
}
|
||||
|
||||
@@ -60,7 +60,8 @@ using namespace Assimp;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor to be privately used by Importer
|
||||
ValidateDSProcess::ValidateDSProcess()
|
||||
ValidateDSProcess::ValidateDSProcess() :
|
||||
mScene()
|
||||
{}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
@@ -690,8 +691,7 @@ void ValidateDSProcess::Validate( const aiMaterial* pMaterial)
|
||||
if (aiPTI_String == prop->mType) {
|
||||
// FIX: strings are now stored in a less expensive way, but we can't use the
|
||||
// validation routine for 'normal' aiStrings
|
||||
uint32_t len;
|
||||
if (prop->mDataLength < 5 || prop->mDataLength < 4 + (len=*reinterpret_cast<uint32_t*>(prop->mData)) + 1) {
|
||||
if (prop->mDataLength < 5 || prop->mDataLength < 4 + (*reinterpret_cast<uint32_t*>(prop->mData)) + 1) {
|
||||
ReportError("aiMaterial::mProperties[%i].mDataLength is "
|
||||
"too small to contain a string (%i, needed: %i)",
|
||||
i,prop->mDataLength,sizeof(aiString));
|
||||
|
||||
@@ -95,17 +95,18 @@ void ExportSceneXFile(const char* pFile,IOSystem* pIOSystem, const aiScene* pSce
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor for a specific scene to export
|
||||
XFileExporter::XFileExporter(const aiScene* pScene, IOSystem* pIOSystem, const std::string& path, const std::string& file, const ExportProperties* pProperties) : mIOSystem(pIOSystem), mPath(path), mFile(file), mProperties(pProperties)
|
||||
XFileExporter::XFileExporter(const aiScene* pScene, IOSystem* pIOSystem, const std::string& path, const std::string& file, const ExportProperties* pProperties)
|
||||
: mProperties(pProperties),
|
||||
mIOSystem(pIOSystem),
|
||||
mPath(path),
|
||||
mFile(file),
|
||||
mScene(pScene),
|
||||
mSceneOwned(false),
|
||||
endstr("\n")
|
||||
{
|
||||
// make sure that all formatting happens using the standard, C locale and not the user's current locale
|
||||
mOutput.imbue( std::locale("C") );
|
||||
|
||||
mScene = pScene;
|
||||
mSceneOwned = false;
|
||||
|
||||
// set up strings
|
||||
endstr = "\n";
|
||||
|
||||
// start writing
|
||||
WriteFile();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user