Skip to content

Commit

Permalink
Added support for compressed x files (all files from dx sdk, except c…
Browse files Browse the repository at this point in the history
…ar2.x, work, no further tests yet).

Added a working makefile for mingw, provides more configs now. Not perfect yet.
Added decompression part of zlib (inflate).
Moved IrrXML to ./contrib dir.
Moved some IRR/IRRmesh shared code.
FIXME: makefile for gnu/linux is untested yet.
Code cleanup.
Unified #ifndef ASSIMP_BUILD_nnn_IMPORTER directives.
OBJ loader supports map_bump, map_ka, map_ks, map_ns now.
Endianess conversion in the ply loader is correct now.
Changed IRR/IRRMESH coordinate system conversion. Not absolutely right now, but better than before.


git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@305 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
  • Loading branch information
aramis_acg committed Jan 18, 2009
1 parent 9b83f3b commit d41f570
Show file tree
Hide file tree
Showing 84 changed files with 7,547 additions and 1,293 deletions.
22 changes: 10 additions & 12 deletions code/3DSConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

/** @file Implementation of the 3ds importer class */


#include "AssimpPCH.h"
#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER

// internal headers
#include "3DSLoader.h"
Expand Down Expand Up @@ -125,16 +125,13 @@ void Discreet3DSImporter::ReplaceDefaultMaterial()

DefaultLogger::get()->info("3DS: Generating default material");
}
return;
}

// ------------------------------------------------------------------------------------------------
// Check whether all indices are valid. Otherwise we'd crash before the validation step was reached
// Check whether all indices are valid. Otherwise we'd crash before the validation step is reached
void Discreet3DSImporter::CheckIndices(D3DS::Mesh& sMesh)
{
for (std::vector< D3DS::Face >::iterator
i = sMesh.mFaces.begin();
i != sMesh.mFaces.end();++i)
for (std::vector< D3DS::Face >::iterator i = sMesh.mFaces.begin(); i != sMesh.mFaces.end();++i)
{
// check whether all indices are in range
for (unsigned int a = 0; a < 3;++a)
Expand All @@ -151,13 +148,15 @@ void Discreet3DSImporter::CheckIndices(D3DS::Mesh& sMesh)
}
}
}
return;
}

// ------------------------------------------------------------------------------------------------
// Generate out unique verbose format representation
void Discreet3DSImporter::MakeUnique(D3DS::Mesh& sMesh)
{
// TODO: really necessary? I don't think. Just a waste of memory and time
// to do it now in a separate buffer.

// Allocate output storage
std::vector<aiVector3D> vNew (sMesh.mFaces.size() * 3);
std::vector<aiVector3D> vNew2;
Expand All @@ -180,10 +179,10 @@ void Discreet3DSImporter::MakeUnique(D3DS::Mesh& sMesh)
}
sMesh.mPositions = vNew;
sMesh.mTexCoords = vNew2;
return;
}

// ------------------------------------------------------------------------------------------------
// Convert a 3DS texture to texture keys in an aiMaterial
void CopyTexture(MaterialHelper& mat, D3DS::Texture& texture, aiTextureType type)
{
// Setup the texture name
Expand All @@ -200,6 +199,7 @@ void CopyTexture(MaterialHelper& mat, D3DS::Texture& texture, aiTextureType type
mat.AddProperty<int>((int*)&texture.mMapMode,1,AI_MATKEY_MAPPINGMODE_V(type,0));

// Mirroring - double the scaling values
// FIXME: this is not really correct ...
if (texture.mMapMode == aiTextureMapMode_Mirror)
{
texture.mScaleU *= 2.f;
Expand Down Expand Up @@ -337,7 +337,6 @@ void Discreet3DSImporter::ConvertMaterial(D3DS::Material& oldMat,
tex.Set( oldMat.mName);
mat.AddProperty( &tex, AI_MATKEY_NAME);
}
return;
}

// ------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -642,7 +641,6 @@ void Discreet3DSImporter::AddNodeToGraph(aiScene* pcSOut,aiNode* pcOut,
pcOut->mChildren[i]->mParent = pcOut;
AddNodeToGraph(pcSOut,pcOut->mChildren[i],pcIn->mChildren[i],abs);
}
return;
}

// ------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -809,6 +807,6 @@ void Discreet3DSImporter::ConvertScene(aiScene* pcOut)
pcOut->mCameras = new aiCamera*[pcOut->mNumCameras];
::memcpy(pcOut->mCameras,&mScene->mCameras[0],sizeof(void*)*pcOut->mNumCameras);
}

return;
}

#endif // !! ASSIMP_BUILD_NO_3DS_IMPORTER
42 changes: 24 additions & 18 deletions code/3DSLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,47 +42,43 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/** @file Implementation of the 3ds importer class */

#include "AssimpPCH.h"
#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER

// internal headers
#include "3DSLoader.h"
#include "TextureTransform.h"

using namespace Assimp;

// ------------------------------------------------------------------------------------------------
// Begins a new parsing block
// - Reads the current chunk and validates it
// - computes its length

#define ASSIMP_3DS_BEGIN_CHUNK() \
Discreet3DS::Chunk chunk; \
ReadChunk(&chunk); \
int chunkSize = chunk.Size-sizeof(Discreet3DS::Chunk); \
int oldReadLimit = stream->GetReadLimit(); \
#define ASSIMP_3DS_BEGIN_CHUNK() \
Discreet3DS::Chunk chunk; \
ReadChunk(&chunk); \
int chunkSize = chunk.Size-sizeof(Discreet3DS::Chunk); \
const int oldReadLimit = stream->GetReadLimit(); \
stream->SetReadLimit(stream->GetCurrentPos() + chunkSize);


// ------------------------------------------------------------------------------------------------
// End a parsing block
// Must follow at the end of each parsing block

#define ASSIMP_3DS_END_CHUNK() \
stream->SkipToReadLimit(); \
stream->SetReadLimit(oldReadLimit); \
if (stream->GetRemainingSizeToLimit() == 0)return;

// Must follow at the end of each parsing block, reset chunk end marker to previous value
#define ASSIMP_3DS_END_CHUNK() \
stream->SkipToReadLimit(); \
stream->SetReadLimit(oldReadLimit); \
if (stream->GetRemainingSizeToLimit() == 0) \
return;

// ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer
Discreet3DSImporter::Discreet3DSImporter()
{
}
{}

// ------------------------------------------------------------------------------------------------
// Destructor, private as well
Discreet3DSImporter::~Discreet3DSImporter()
{
}
{}

// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
Expand Down Expand Up @@ -551,6 +547,7 @@ void Discreet3DSImporter::InverseNodeSearch(D3DS::Node* pcNode,D3DS::Node* pcCur
}

// ------------------------------------------------------------------------------------------------
// Find a node with a specific name in the import hierarchy
D3DS::Node* FindNode(D3DS::Node* root, const std::string& name)
{
if (root->mName == name)return root;
Expand All @@ -572,6 +569,7 @@ bool KeyUniqueCompare(const T& first, const T& second)
}

// ------------------------------------------------------------------------------------------------
// Skip some additional import data.
void Discreet3DSImporter::SkipTCBInfo()
{
unsigned int flags = stream->GetI2();
Expand Down Expand Up @@ -600,6 +598,7 @@ void Discreet3DSImporter::SkipTCBInfo()
}

// ------------------------------------------------------------------------------------------------
// Read hierarchy and keyframe info
void Discreet3DSImporter::ParseHierarchyChunk(uint16_t parent)
{
ASSIMP_3DS_BEGIN_CHUNK();
Expand Down Expand Up @@ -897,7 +896,9 @@ void Discreet3DSImporter::ParseHierarchyChunk(uint16_t parent)
// recursively continue processing this hierarchy level
return ParseHierarchyChunk(parent);
}

// ------------------------------------------------------------------------------------------------
// Read a face chunk - it contains smoothing groups and material assignments
void Discreet3DSImporter::ParseFaceChunk()
{
ASSIMP_3DS_BEGIN_CHUNK();
Expand Down Expand Up @@ -972,7 +973,9 @@ void Discreet3DSImporter::ParseFaceChunk()
// recursively continue processing this hierarchy level
return ParseFaceChunk();
}

// ------------------------------------------------------------------------------------------------
// Read a mesh chunk. Here's the actual mesh data
void Discreet3DSImporter::ParseMeshChunk()
{
ASSIMP_3DS_BEGIN_CHUNK();
Expand Down Expand Up @@ -1095,6 +1098,7 @@ void Discreet3DSImporter::ParseMeshChunk()
}

// ------------------------------------------------------------------------------------------------
// Read a 3DS material chunk
void Discreet3DSImporter::ParseMaterialChunk()
{
ASSIMP_3DS_BEGIN_CHUNK();
Expand Down Expand Up @@ -1432,3 +1436,5 @@ void Discreet3DSImporter::ParseColorChunk(aiColor3D* out,
return ParseColorChunk(out,acceptPercent);
};
}

#endif // !! ASSIMP_BUILD_NO_3DS_IMPORTER
14 changes: 8 additions & 6 deletions code/ASELoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

/** @file Implementation of the ASE importer class */


#include "AssimpPCH.h"
#ifndef ASSIMP_BUILD_NO_ASE_IMPORTER

// internal headers
#include "ASELoader.h"
Expand All @@ -60,13 +60,13 @@ using namespace Assimp::ASE;
// ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer
ASEImporter::ASEImporter()
{
}
{}

// ------------------------------------------------------------------------------------------------
// Destructor, private as well
ASEImporter::~ASEImporter()
{
}
{}

// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
bool ASEImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler) const
Expand All @@ -93,7 +93,7 @@ bool ASEImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler) const
void ASEImporter::SetupProperties(const Importer* pImp)
{
configRecomputeNormals = (pImp->GetPropertyInteger(
AI_CONFIG_IMPORT_ASE_RECONSTRUCT_NORMALS,0) ? true : false);
AI_CONFIG_IMPORT_ASE_RECONSTRUCT_NORMALS,1) ? true : false);
}

// ------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -1423,3 +1423,5 @@ bool ASEImporter::GenerateNormals(ASE::Mesh& mesh)
ComputeNormalsWithSmoothingsGroups<ASE::Face>(mesh);
return false;
}

#endif // !! ASSIMP_BUILD_NO_BASE_IMPORTER
Loading

0 comments on commit d41f570

Please sign in to comment.