mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-17 13:43:48 +00:00
Just the functional assimp lib rather than the entire assimp repository unnecessarily.
This commit is contained in:
parent
bf170ffbca
commit
25ce4477ce
1747 changed files with 9012 additions and 925008 deletions
|
|
@ -3,8 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -52,12 +51,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
// internal headers
|
||||
#include "3DSLoader.h"
|
||||
#include <assimp/Macros.h>
|
||||
#include "Macros.h"
|
||||
#include <assimp/IOSystem.hpp>
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
#include <assimp/importerdesc.h>
|
||||
#include <assimp/StringComparison.h>
|
||||
#include "StringComparison.h"
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
|
@ -71,7 +70,7 @@ static const aiImporterDesc desc = {
|
|||
0,
|
||||
0,
|
||||
0,
|
||||
"3ds prj"
|
||||
"3ds prj"
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -106,31 +105,29 @@ static const aiImporterDesc desc = {
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor to be privately used by Importer
|
||||
Discreet3DSImporter::Discreet3DSImporter()
|
||||
: stream()
|
||||
, mLastNodeIndex()
|
||||
, mCurrentNode()
|
||||
, mRootNode()
|
||||
, mScene()
|
||||
, mMasterScale()
|
||||
, bHasBG()
|
||||
, bIsPrj() {
|
||||
// empty
|
||||
}
|
||||
: stream(),
|
||||
mLastNodeIndex(),
|
||||
mCurrentNode(),
|
||||
mRootNode(),
|
||||
mScene(),
|
||||
mMasterScale(),
|
||||
bHasBG(),
|
||||
bIsPrj()
|
||||
{}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Destructor, private as well
|
||||
Discreet3DSImporter::~Discreet3DSImporter() {
|
||||
// empty
|
||||
}
|
||||
Discreet3DSImporter::~Discreet3DSImporter()
|
||||
{}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Returns whether the class can handle the format of the given file.
|
||||
bool Discreet3DSImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const {
|
||||
bool Discreet3DSImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const
|
||||
{
|
||||
std::string extension = GetExtension(pFile);
|
||||
if(extension == "3ds" || extension == "prj") {
|
||||
if(extension == "3ds" || extension == "prj" ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!extension.length() || checkSig) {
|
||||
uint16_t token[3];
|
||||
token[0] = 0x4d4d;
|
||||
|
|
@ -173,7 +170,7 @@ void Discreet3DSImporter::InternReadFile( const std::string& pFile,
|
|||
|
||||
// Initialize members
|
||||
mLastNodeIndex = -1;
|
||||
mCurrentNode = new D3DS::Node("UNNAMED");
|
||||
mCurrentNode = new D3DS::Node();
|
||||
mRootNode = mCurrentNode;
|
||||
mRootNode->mHierarchyPos = -1;
|
||||
mRootNode->mHierarchyIndex = -1;
|
||||
|
|
@ -212,7 +209,7 @@ void Discreet3DSImporter::InternReadFile( const std::string& pFile,
|
|||
ConvertScene(pScene);
|
||||
|
||||
// Generate the node graph for the scene. This is a little bit
|
||||
// tricky since we'll need to split some meshes into sub-meshes
|
||||
// tricky since we'll need to split some meshes into submeshes
|
||||
GenerateNodeGraph(pScene);
|
||||
|
||||
// Now apply the master scaling factor to the scene
|
||||
|
|
@ -258,9 +255,8 @@ void Discreet3DSImporter::ReadChunk(Discreet3DS::Chunk* pcOut)
|
|||
if (pcOut->Size - sizeof(Discreet3DS::Chunk) > stream->GetRemainingSize())
|
||||
throw DeadlyImportError("Chunk is too large");
|
||||
|
||||
if (pcOut->Size - sizeof(Discreet3DS::Chunk) > stream->GetRemainingSizeToLimit()) {
|
||||
ASSIMP_LOG_ERROR("3DS: Chunk overflow");
|
||||
}
|
||||
if (pcOut->Size - sizeof(Discreet3DS::Chunk) > stream->GetRemainingSizeToLimit())
|
||||
DefaultLogger::get()->error("3DS: Chunk overflow");
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
@ -321,7 +317,7 @@ void Discreet3DSImporter::ParseEditorChunk()
|
|||
// print the version number
|
||||
char buff[10];
|
||||
ASSIMP_itoa10(buff,stream->GetI2());
|
||||
ASSIMP_LOG_INFO_F(std::string("3DS file format version: "), buff);
|
||||
DefaultLogger::get()->info(std::string("3DS file format version: ") + buff);
|
||||
}
|
||||
break;
|
||||
};
|
||||
|
|
@ -350,7 +346,7 @@ void Discreet3DSImporter::ParseObjectChunk()
|
|||
case Discreet3DS::CHUNK_MAT_MATERIAL:
|
||||
|
||||
// Add a new material to the list
|
||||
mScene->mMaterials.push_back(D3DS::Material(std::string("UNNAMED_" + to_string(mScene->mMaterials.size()))));
|
||||
mScene->mMaterials.push_back(D3DS::Material());
|
||||
ParseMaterialChunk();
|
||||
break;
|
||||
|
||||
|
|
@ -362,7 +358,7 @@ void Discreet3DSImporter::ParseObjectChunk()
|
|||
if (is_qnan(mClrAmbient.r))
|
||||
{
|
||||
// We failed to read the ambient base color.
|
||||
ASSIMP_LOG_ERROR("3DS: Failed to read ambient base color");
|
||||
DefaultLogger::get()->error("3DS: Failed to read ambient base color");
|
||||
mClrAmbient.r = mClrAmbient.g = mClrAmbient.b = 0.0f;
|
||||
}
|
||||
break;
|
||||
|
|
@ -406,7 +402,11 @@ void Discreet3DSImporter::ParseChunk(const char* name, unsigned int num)
|
|||
case Discreet3DS::CHUNK_TRIMESH:
|
||||
{
|
||||
// this starts a new triangle mesh
|
||||
mScene->mMeshes.push_back(D3DS::Mesh(std::string(name, num)));
|
||||
mScene->mMeshes.push_back(D3DS::Mesh());
|
||||
D3DS::Mesh& m = mScene->mMeshes.back();
|
||||
|
||||
// Setup the name of the mesh
|
||||
m.mName = std::string(name, num);
|
||||
|
||||
// Read mesh chunks
|
||||
ParseMeshChunk();
|
||||
|
|
@ -464,7 +464,7 @@ void Discreet3DSImporter::ParseChunk(const char* name, unsigned int num)
|
|||
if (len < 1e-5) {
|
||||
|
||||
// There are some files with lookat == position. Don't know why or whether it's ok or not.
|
||||
ASSIMP_LOG_ERROR("3DS: Unable to read proper camera look-at vector");
|
||||
DefaultLogger::get()->error("3DS: Unable to read proper camera look-at vector");
|
||||
camera->mLookAt = aiVector3D(0.0,1.0,0.0);
|
||||
|
||||
}
|
||||
|
|
@ -630,9 +630,9 @@ void Discreet3DSImporter::SkipTCBInfo()
|
|||
if (!flags) {
|
||||
// Currently we can't do anything with these values. They occur
|
||||
// quite rare, so it wouldn't be worth the effort implementing
|
||||
// them. 3DS is not really suitable for complex animations,
|
||||
// them. 3DS ist not really suitable for complex animations,
|
||||
// so full support is not required.
|
||||
ASSIMP_LOG_WARN("3DS: Skipping TCB animation info");
|
||||
DefaultLogger::get()->warn("3DS: Skipping TCB animation info");
|
||||
}
|
||||
|
||||
if (flags & Discreet3DS::KEY_USE_TENS) {
|
||||
|
|
@ -690,7 +690,8 @@ void Discreet3DSImporter::ParseHierarchyChunk(uint16_t parent)
|
|||
pcNode->mInstanceCount++;
|
||||
instanceNumber = pcNode->mInstanceCount;
|
||||
}
|
||||
pcNode = new D3DS::Node(name);
|
||||
pcNode = new D3DS::Node();
|
||||
pcNode->mName = name;
|
||||
pcNode->mInstanceNumber = instanceNumber;
|
||||
|
||||
// There are two unknown values which we can safely ignore
|
||||
|
|
@ -733,6 +734,7 @@ void Discreet3DSImporter::ParseHierarchyChunk(uint16_t parent)
|
|||
|
||||
// If object name is DUMMY, take this one instead
|
||||
if (mCurrentNode->mName == "$$$DUMMY") {
|
||||
//DefaultLogger::get()->warn("3DS: Skipping dummy object name for non-dummy object");
|
||||
mCurrentNode->mName = std::string(sz);
|
||||
break;
|
||||
}
|
||||
|
|
@ -743,7 +745,7 @@ void Discreet3DSImporter::ParseHierarchyChunk(uint16_t parent)
|
|||
|
||||
if ( Discreet3DS::CHUNK_TRACKINFO != parent)
|
||||
{
|
||||
ASSIMP_LOG_WARN("3DS: Skipping pivot subchunk for non usual object");
|
||||
DefaultLogger::get()->warn("3DS: Skipping pivot subchunk for non usual object");
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -805,7 +807,7 @@ void Discreet3DSImporter::ParseHierarchyChunk(uint16_t parent)
|
|||
{
|
||||
// roll keys are accepted for cameras only
|
||||
if (parent != Discreet3DS::CHUNK_TRACKCAMERA) {
|
||||
ASSIMP_LOG_WARN("3DS: Ignoring roll track for non-camera object");
|
||||
DefaultLogger::get()->warn("3DS: Ignoring roll track for non-camera object");
|
||||
break;
|
||||
}
|
||||
bool sortKeys = false;
|
||||
|
|
@ -845,7 +847,7 @@ void Discreet3DSImporter::ParseHierarchyChunk(uint16_t parent)
|
|||
// CAMERA FOV KEYFRAME
|
||||
case Discreet3DS::CHUNK_TRACKFOV:
|
||||
{
|
||||
ASSIMP_LOG_ERROR("3DS: Skipping FOV animation track. "
|
||||
DefaultLogger::get()->error("3DS: Skipping FOV animation track. "
|
||||
"This is not supported");
|
||||
}
|
||||
break;
|
||||
|
|
@ -985,7 +987,7 @@ void Discreet3DSImporter::ParseFaceChunk()
|
|||
}
|
||||
}
|
||||
if (0xcdcdcdcd == idx) {
|
||||
ASSIMP_LOG_ERROR_F( "3DS: Unknown material: ", sz);
|
||||
DefaultLogger::get()->error(std::string("3DS: Unknown material: ") + sz);
|
||||
}
|
||||
|
||||
// Now continue and read all material indices
|
||||
|
|
@ -995,7 +997,7 @@ void Discreet3DSImporter::ParseFaceChunk()
|
|||
|
||||
// check range
|
||||
if (fidx >= mMesh.mFaceMaterials.size()) {
|
||||
ASSIMP_LOG_ERROR("3DS: Invalid face index in face material list");
|
||||
DefaultLogger::get()->error("3DS: Invalid face index in face material list");
|
||||
}
|
||||
else mMesh.mFaceMaterials[fidx] = idx;
|
||||
}}
|
||||
|
|
@ -1110,7 +1112,7 @@ void Discreet3DSImporter::ParseMaterialChunk()
|
|||
|
||||
if (!cnt) {
|
||||
// This may not be, we use the default name instead
|
||||
ASSIMP_LOG_ERROR("3DS: Empty material name");
|
||||
DefaultLogger::get()->error("3DS: Empty material name");
|
||||
}
|
||||
else mScene->mMaterials.back().mName = std::string(sz,cnt);
|
||||
}
|
||||
|
|
@ -1123,7 +1125,7 @@ void Discreet3DSImporter::ParseMaterialChunk()
|
|||
ParseColorChunk(pc);
|
||||
if (is_qnan(pc->r)) {
|
||||
// color chunk is invalid. Simply ignore it
|
||||
ASSIMP_LOG_ERROR("3DS: Unable to read DIFFUSE chunk");
|
||||
DefaultLogger::get()->error("3DS: Unable to read DIFFUSE chunk");
|
||||
pc->r = pc->g = pc->b = 1.0f;
|
||||
}}
|
||||
break;
|
||||
|
|
@ -1135,7 +1137,7 @@ void Discreet3DSImporter::ParseMaterialChunk()
|
|||
ParseColorChunk(pc);
|
||||
if (is_qnan(pc->r)) {
|
||||
// color chunk is invalid. Simply ignore it
|
||||
ASSIMP_LOG_ERROR("3DS: Unable to read SPECULAR chunk");
|
||||
DefaultLogger::get()->error("3DS: Unable to read SPECULAR chunk");
|
||||
pc->r = pc->g = pc->b = 1.0f;
|
||||
}}
|
||||
break;
|
||||
|
|
@ -1147,7 +1149,7 @@ void Discreet3DSImporter::ParseMaterialChunk()
|
|||
ParseColorChunk(pc);
|
||||
if (is_qnan(pc->r)) {
|
||||
// color chunk is invalid. Simply ignore it
|
||||
ASSIMP_LOG_ERROR("3DS: Unable to read AMBIENT chunk");
|
||||
DefaultLogger::get()->error("3DS: Unable to read AMBIENT chunk");
|
||||
pc->r = pc->g = pc->b = 0.0f;
|
||||
}}
|
||||
break;
|
||||
|
|
@ -1159,7 +1161,7 @@ void Discreet3DSImporter::ParseMaterialChunk()
|
|||
ParseColorChunk(pc);
|
||||
if (is_qnan(pc->r)) {
|
||||
// color chunk is invalid. Simply ignore it
|
||||
ASSIMP_LOG_ERROR("3DS: Unable to read EMISSIVE chunk");
|
||||
DefaultLogger::get()->error("3DS: Unable to read EMISSIVE chunk");
|
||||
pc->r = pc->g = pc->b = 0.0f;
|
||||
}}
|
||||
break;
|
||||
|
|
@ -1293,7 +1295,7 @@ void Discreet3DSImporter::ParseTextureChunk(D3DS::Texture* pcOut)
|
|||
pcOut->mScaleU = stream->GetF4();
|
||||
if (0.0f == pcOut->mScaleU)
|
||||
{
|
||||
ASSIMP_LOG_WARN("Texture coordinate scaling in the x direction is zero. Assuming 1.");
|
||||
DefaultLogger::get()->warn("Texture coordinate scaling in the x direction is zero. Assuming 1.");
|
||||
pcOut->mScaleU = 1.0f;
|
||||
}
|
||||
break;
|
||||
|
|
@ -1302,7 +1304,7 @@ void Discreet3DSImporter::ParseTextureChunk(D3DS::Texture* pcOut)
|
|||
pcOut->mScaleV = stream->GetF4();
|
||||
if (0.0f == pcOut->mScaleV)
|
||||
{
|
||||
ASSIMP_LOG_WARN("Texture coordinate scaling in the y direction is zero. Assuming 1.");
|
||||
DefaultLogger::get()->warn("Texture coordinate scaling in the y direction is zero. Assuming 1.");
|
||||
pcOut->mScaleV = 1.0f;
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue