mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-15 20:53:50 +00:00
Just the functional assimp lib rather than the entire assimp repository unnecessarily.
This commit is contained in:
parent
0f7641a282
commit
e9ea38eda3
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.
|
||||
|
|
@ -50,9 +49,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
// internal headers
|
||||
#include "LWOLoader.h"
|
||||
#include <assimp/StringComparison.h>
|
||||
#include <assimp/SGSpatialSort.h>
|
||||
#include <assimp/ByteSwapper.h>
|
||||
#include "StringComparison.h"
|
||||
#include "SGSpatialSort.h"
|
||||
#include "ByteSwapper.h"
|
||||
#include "ProcessHelper.h"
|
||||
#include "ConvertToLHProcess.h"
|
||||
#include <assimp/IOSystem.hpp>
|
||||
|
|
@ -188,7 +187,7 @@ void LWOImporter::InternReadFile( const std::string& pFile,
|
|||
|
||||
// old lightwave file format (prior to v6)
|
||||
if (AI_LWO_FOURCC_LWOB == fileType) {
|
||||
ASSIMP_LOG_INFO("LWO file format: LWOB (<= LightWave 5.5)");
|
||||
DefaultLogger::get()->info("LWO file format: LWOB (<= LightWave 5.5)");
|
||||
|
||||
mIsLWO2 = false;
|
||||
mIsLXOB = false;
|
||||
|
|
@ -197,12 +196,12 @@ void LWOImporter::InternReadFile( const std::string& pFile,
|
|||
// New lightwave format
|
||||
else if (AI_LWO_FOURCC_LWO2 == fileType) {
|
||||
mIsLXOB = false;
|
||||
ASSIMP_LOG_INFO("LWO file format: LWO2 (>= LightWave 6)");
|
||||
DefaultLogger::get()->info("LWO file format: LWO2 (>= LightWave 6)");
|
||||
}
|
||||
// MODO file format
|
||||
else if (AI_LWO_FOURCC_LXOB == fileType) {
|
||||
mIsLXOB = true;
|
||||
ASSIMP_LOG_INFO("LWO file format: LXOB (Modo)");
|
||||
DefaultLogger::get()->info("LWO file format: LXOB (Modo)");
|
||||
}
|
||||
// we don't know this format
|
||||
else
|
||||
|
|
@ -271,7 +270,7 @@ void LWOImporter::InternReadFile( const std::string& pFile,
|
|||
unsigned int idx = (*it).surfaceIndex;
|
||||
if (idx >= mTags->size())
|
||||
{
|
||||
ASSIMP_LOG_WARN("LWO: Invalid face surface index");
|
||||
DefaultLogger::get()->warn("LWO: Invalid face surface index");
|
||||
idx = UINT_MAX;
|
||||
}
|
||||
if(UINT_MAX == idx || UINT_MAX == (idx = _mMapping[idx])) {
|
||||
|
|
@ -423,9 +422,7 @@ void LWOImporter::InternReadFile( const std::string& pFile,
|
|||
// So we use a separate implementation.
|
||||
ComputeNormals(mesh,smoothingGroups,_mSurfaces[i]);
|
||||
}
|
||||
else {
|
||||
ASSIMP_LOG_DEBUG("LWO2: No need to compute normals, they're already there");
|
||||
}
|
||||
else DefaultLogger::get()->debug("LWO2: No need to compute normals, they're already there");
|
||||
++p;
|
||||
}
|
||||
}
|
||||
|
|
@ -434,6 +431,7 @@ void LWOImporter::InternReadFile( const std::string& pFile,
|
|||
unsigned int num = static_cast<unsigned int>(apcMeshes.size() - meshStart);
|
||||
if (layer.mName != "<LWODefault>" || num > 0) {
|
||||
aiNode* pcNode = new aiNode();
|
||||
apcNodes[layer.mIndex] = pcNode;
|
||||
pcNode->mName.Set(layer.mName);
|
||||
pcNode->mParent = (aiNode*)&layer;
|
||||
pcNode->mNumMeshes = num;
|
||||
|
|
@ -443,7 +441,6 @@ void LWOImporter::InternReadFile( const std::string& pFile,
|
|||
for (unsigned int p = 0; p < pcNode->mNumMeshes;++p)
|
||||
pcNode->mMeshes[p] = p + meshStart;
|
||||
}
|
||||
apcNodes[layer.mIndex] = pcNode;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -586,7 +583,7 @@ void LWOImporter::GenerateNodeGraph(std::map<uint16_t,aiNode*>& apcNodes)
|
|||
//Set parent of all children, inserting pivots
|
||||
//std::cout << "Set parent of all children" << std::endl;
|
||||
std::map<uint16_t, aiNode*> mapPivot;
|
||||
for (auto itapcNodes = apcNodes.begin(); itapcNodes != apcNodes.end(); ++itapcNodes) {
|
||||
for (std::map<uint16_t,aiNode*>::iterator itapcNodes = apcNodes.begin(); itapcNodes != apcNodes.end(); ++itapcNodes) {
|
||||
|
||||
//Get the parent index
|
||||
LWO::Layer* nodeLayer = (LWO::Layer*)(itapcNodes->second->mParent);
|
||||
|
|
@ -595,6 +592,7 @@ void LWOImporter::GenerateNodeGraph(std::map<uint16_t,aiNode*>& apcNodes)
|
|||
//Create pivot node, store it into the pivot map, and set the parent as the pivot
|
||||
aiNode* pivotNode = new aiNode();
|
||||
pivotNode->mName.Set("Pivot-"+std::string(itapcNodes->second->mName.data));
|
||||
mapPivot[-(itapcNodes->first+2)] = pivotNode;
|
||||
itapcNodes->second->mParent = pivotNode;
|
||||
|
||||
//Look for the parent node to attach the pivot to
|
||||
|
|
@ -612,19 +610,18 @@ void LWOImporter::GenerateNodeGraph(std::map<uint16_t,aiNode*>& apcNodes)
|
|||
pivotNode->mTransformation.a4 = nodeLayer->mPivot.x;
|
||||
pivotNode->mTransformation.b4 = nodeLayer->mPivot.y;
|
||||
pivotNode->mTransformation.c4 = nodeLayer->mPivot.z;
|
||||
mapPivot[-(itapcNodes->first+2)] = pivotNode;
|
||||
}
|
||||
|
||||
//Merge pivot map into node map
|
||||
//std::cout << "Merge pivot map into node map" << std::endl;
|
||||
for (auto itMapPivot = mapPivot.begin(); itMapPivot != mapPivot.end(); ++itMapPivot) {
|
||||
for (std::map<uint16_t, aiNode*>::iterator itMapPivot = mapPivot.begin(); itMapPivot != mapPivot.end(); ++itMapPivot) {
|
||||
apcNodes[itMapPivot->first] = itMapPivot->second;
|
||||
}
|
||||
|
||||
//Set children of all parents
|
||||
apcNodes[-1] = root;
|
||||
for (auto itMapParentNodes = apcNodes.begin(); itMapParentNodes != apcNodes.end(); ++itMapParentNodes) {
|
||||
for (auto itMapChildNodes = apcNodes.begin(); itMapChildNodes != apcNodes.end(); ++itMapChildNodes) {
|
||||
for (std::map<uint16_t,aiNode*>::iterator itMapParentNodes = apcNodes.begin(); itMapParentNodes != apcNodes.end(); ++itMapParentNodes) {
|
||||
for (std::map<uint16_t,aiNode*>::iterator itMapChildNodes = apcNodes.begin(); itMapChildNodes != apcNodes.end(); ++itMapChildNodes) {
|
||||
if ((itMapParentNodes->first != itMapChildNodes->first) && (itMapParentNodes->second == itMapChildNodes->second->mParent)) {
|
||||
++(itMapParentNodes->second->mNumChildren);
|
||||
}
|
||||
|
|
@ -632,7 +629,7 @@ void LWOImporter::GenerateNodeGraph(std::map<uint16_t,aiNode*>& apcNodes)
|
|||
if (itMapParentNodes->second->mNumChildren) {
|
||||
itMapParentNodes->second->mChildren = new aiNode* [ itMapParentNodes->second->mNumChildren ];
|
||||
uint16_t p = 0;
|
||||
for (auto itMapChildNodes = apcNodes.begin(); itMapChildNodes != apcNodes.end(); ++itMapChildNodes) {
|
||||
for (std::map<uint16_t,aiNode*>::iterator itMapChildNodes = apcNodes.begin(); itMapChildNodes != apcNodes.end(); ++itMapChildNodes) {
|
||||
if ((itMapParentNodes->first != itMapChildNodes->first) && (itMapParentNodes->second == itMapChildNodes->second->mParent)) {
|
||||
itMapParentNodes->second->mChildren[p++] = itMapChildNodes->second;
|
||||
}
|
||||
|
|
@ -688,13 +685,13 @@ void LWOImporter::ResolveClips()
|
|||
if (Clip::REF == clip.type) {
|
||||
|
||||
if (clip.clipRef >= mClips.size()) {
|
||||
ASSIMP_LOG_ERROR("LWO2: Clip referrer index is out of range");
|
||||
DefaultLogger::get()->error("LWO2: Clip referrer index is out of range");
|
||||
clip.clipRef = 0;
|
||||
}
|
||||
|
||||
Clip& dest = mClips[clip.clipRef];
|
||||
if (Clip::REF == dest.type) {
|
||||
ASSIMP_LOG_ERROR("LWO2: Clip references another clip reference");
|
||||
DefaultLogger::get()->error("LWO2: Clip references another clip reference");
|
||||
clip.type = Clip::UNSUPPORTED;
|
||||
}
|
||||
|
||||
|
|
@ -713,7 +710,7 @@ void LWOImporter::AdjustTexturePath(std::string& out)
|
|||
if (!mIsLWO2 && ::strstr(out.c_str(), "(sequence)")) {
|
||||
|
||||
// remove the (sequence) and append 000
|
||||
ASSIMP_LOG_INFO("LWOB: Sequence of animated texture found. It will be ignored");
|
||||
DefaultLogger::get()->info("LWOB: Sequence of animated texture found. It will be ignored");
|
||||
out = out.substr(0,out.length()-10) + "000";
|
||||
}
|
||||
|
||||
|
|
@ -788,10 +785,10 @@ void LWOImporter::LoadLWO2Polygons(unsigned int length)
|
|||
{
|
||||
// read unsupported stuff too (although we won't process it)
|
||||
case AI_LWO_MBAL:
|
||||
ASSIMP_LOG_WARN("LWO2: Encountered unsupported primitive chunk (METABALL)");
|
||||
DefaultLogger::get()->warn("LWO2: Encountered unsupported primitive chunk (METABALL)");
|
||||
break;
|
||||
case AI_LWO_CURV:
|
||||
ASSIMP_LOG_WARN("LWO2: Encountered unsupported primitive chunk (SPLINE)");;
|
||||
DefaultLogger::get()->warn("LWO2: Encountered unsupported primitive chunk (SPLINE)");;
|
||||
break;
|
||||
|
||||
// These are ok with no restrictions
|
||||
|
|
@ -803,7 +800,7 @@ void LWOImporter::LoadLWO2Polygons(unsigned int length)
|
|||
default:
|
||||
|
||||
// hm!? wtf is this? ok ...
|
||||
ASSIMP_LOG_ERROR("LWO2: Ignoring unknown polygon type.");
|
||||
DefaultLogger::get()->error("LWO2: Ignoring unknown polygon type.");
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -866,7 +863,7 @@ void LWOImporter::CopyFaceIndicesLWO2(FaceList::iterator& it,
|
|||
face.mIndices[i] = ReadVSizedIntLWO2((uint8_t*&)cursor) + mCurLayer->mPointIDXOfs;
|
||||
if(face.mIndices[i] > mCurLayer->mTempPoints.size())
|
||||
{
|
||||
ASSIMP_LOG_WARN("LWO2: Failure evaluating face record, index is out of range");
|
||||
DefaultLogger::get()->warn("LWO2: Failure evaluating face record, index is out of range");
|
||||
face.mIndices[i] = (unsigned int)mCurLayer->mTempPoints.size()-1;
|
||||
}
|
||||
}
|
||||
|
|
@ -893,7 +890,7 @@ void LWOImporter::LoadLWO2PolygonTags(unsigned int length)
|
|||
unsigned int j = GetU2();
|
||||
|
||||
if (i >= mCurLayer->mFaces.size()) {
|
||||
ASSIMP_LOG_WARN("LWO2: face index in PTAG is out of range");
|
||||
DefaultLogger::get()->warn("LWO2: face index in PTAG is out of range");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -916,7 +913,7 @@ VMapEntry* FindEntry(std::vector< T >& list,const std::string& name, bool perPol
|
|||
for (auto & elem : list) {
|
||||
if (elem.name == name) {
|
||||
if (!perPoly) {
|
||||
ASSIMP_LOG_WARN("LWO2: Found two VMAP sections with equal names");
|
||||
DefaultLogger::get()->warn("LWO2: Found two VMAP sections with equal names");
|
||||
}
|
||||
return &elem;
|
||||
}
|
||||
|
|
@ -1001,7 +998,7 @@ void LWOImporter::LoadLWO2VertexMap(unsigned int length, bool perPoly)
|
|||
{
|
||||
case AI_LWO_TXUV:
|
||||
if (dims != 2) {
|
||||
ASSIMP_LOG_WARN("LWO2: Skipping UV channel \'"
|
||||
DefaultLogger::get()->warn("LWO2: Skipping UV channel \'"
|
||||
+ name + "\' with !2 components");
|
||||
return;
|
||||
}
|
||||
|
|
@ -1010,7 +1007,7 @@ void LWOImporter::LoadLWO2VertexMap(unsigned int length, bool perPoly)
|
|||
case AI_LWO_WGHT:
|
||||
case AI_LWO_MNVW:
|
||||
if (dims != 1) {
|
||||
ASSIMP_LOG_WARN("LWO2: Skipping Weight Channel \'"
|
||||
DefaultLogger::get()->warn("LWO2: Skipping Weight Channel \'"
|
||||
+ name + "\' with !1 components");
|
||||
return;
|
||||
}
|
||||
|
|
@ -1020,7 +1017,7 @@ void LWOImporter::LoadLWO2VertexMap(unsigned int length, bool perPoly)
|
|||
case AI_LWO_RGB:
|
||||
case AI_LWO_RGBA:
|
||||
if (dims != 3 && dims != 4) {
|
||||
ASSIMP_LOG_WARN("LWO2: Skipping Color Map \'"
|
||||
DefaultLogger::get()->warn("LWO2: Skipping Color Map \'"
|
||||
+ name + "\' with a dimension > 4 or < 3");
|
||||
return;
|
||||
}
|
||||
|
|
@ -1035,7 +1032,7 @@ void LWOImporter::LoadLWO2VertexMap(unsigned int length, bool perPoly)
|
|||
if (name != "vert_normals" || dims != 3 || mCurLayer->mNormals.name.length())
|
||||
return;
|
||||
|
||||
ASSIMP_LOG_INFO("Processing non-standard extension: MODO VMAP.NORM.vert_normals");
|
||||
DefaultLogger::get()->info("Processing non-standard extension: MODO VMAP.NORM.vert_normals");
|
||||
|
||||
mCurLayer->mNormals.name = name;
|
||||
base = & mCurLayer->mNormals;
|
||||
|
|
@ -1050,7 +1047,7 @@ void LWOImporter::LoadLWO2VertexMap(unsigned int length, bool perPoly)
|
|||
if (name == "APS.Level") {
|
||||
// XXX handle this (seems to be subdivision-related).
|
||||
}
|
||||
ASSIMP_LOG_WARN_F("LWO2: Skipping unknown VMAP/VMAD channel \'", name, "\'");
|
||||
DefaultLogger::get()->warn("LWO2: Skipping unknown VMAP/VMAD channel \'" + name + "\'");
|
||||
return;
|
||||
};
|
||||
base->Allocate((unsigned int)mCurLayer->mTempPoints.size());
|
||||
|
|
@ -1070,7 +1067,7 @@ void LWOImporter::LoadLWO2VertexMap(unsigned int length, bool perPoly)
|
|||
|
||||
unsigned int idx = ReadVSizedIntLWO2(mFileBuffer) + mCurLayer->mPointIDXOfs;
|
||||
if (idx >= numPoints) {
|
||||
ASSIMP_LOG_WARN_F("LWO2: Failure evaluating VMAP/VMAD entry \'", name, "\', vertex index is out of range");
|
||||
DefaultLogger::get()->warn("LWO2: Failure evaluating VMAP/VMAD entry \'" + name + "\', vertex index is out of range");
|
||||
mFileBuffer += base->dims<<2u;
|
||||
continue;
|
||||
}
|
||||
|
|
@ -1080,7 +1077,7 @@ void LWOImporter::LoadLWO2VertexMap(unsigned int length, bool perPoly)
|
|||
// we have already a VMAP entry for this vertex - thus
|
||||
// we need to duplicate the corresponding polygon.
|
||||
if (polyIdx >= numFaces) {
|
||||
ASSIMP_LOG_WARN_F("LWO2: Failure evaluating VMAD entry \'", name, "\', polygon index is out of range");
|
||||
DefaultLogger::get()->warn("LWO2: Failure evaluating VMAD entry \'" + name + "\', polygon index is out of range");
|
||||
mFileBuffer += base->dims<<2u;
|
||||
continue;
|
||||
}
|
||||
|
|
@ -1121,7 +1118,7 @@ void LWOImporter::LoadLWO2VertexMap(unsigned int length, bool perPoly)
|
|||
CreateNewEntry(mCurLayer->mNormals, srcIdx );
|
||||
}
|
||||
if (!had) {
|
||||
ASSIMP_LOG_WARN_F("LWO2: Failure evaluating VMAD entry \'", name, "\', vertex index wasn't found in that polygon");
|
||||
DefaultLogger::get()->warn("LWO2: Failure evaluating VMAD entry \'" + name + "\', vertex index wasn't found in that polygon");
|
||||
ai_assert(had);
|
||||
}
|
||||
}
|
||||
|
|
@ -1182,11 +1179,11 @@ void LWOImporter::LoadLWO2Clip(unsigned int length)
|
|||
break;
|
||||
|
||||
case AI_LWO_STCC:
|
||||
ASSIMP_LOG_WARN("LWO2: Color shifted images are not supported");
|
||||
DefaultLogger::get()->warn("LWO2: Color shifted images are not supported");
|
||||
break;
|
||||
|
||||
case AI_LWO_ANIM:
|
||||
ASSIMP_LOG_WARN("LWO2: Animated textures are not supported");
|
||||
DefaultLogger::get()->warn("LWO2: Animated textures are not supported");
|
||||
break;
|
||||
|
||||
case AI_LWO_XREF:
|
||||
|
|
@ -1203,7 +1200,7 @@ void LWOImporter::LoadLWO2Clip(unsigned int length)
|
|||
break;
|
||||
|
||||
default:
|
||||
ASSIMP_LOG_WARN("LWO2: Encountered unknown CLIP sub-chunk");
|
||||
DefaultLogger::get()->warn("LWO2: Encountered unknown CLIP subchunk");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1284,7 +1281,7 @@ void LWOImporter::LoadLWO2Envelope(unsigned int length)
|
|||
{
|
||||
AI_LWO_VALIDATE_CHUNK_LENGTH(head.length,SPAN,4);
|
||||
if (envelope.keys.size()<2)
|
||||
ASSIMP_LOG_WARN("LWO2: Unexpected SPAN chunk");
|
||||
DefaultLogger::get()->warn("LWO2: Unexpected SPAN chunk");
|
||||
else {
|
||||
LWO::Key& key = envelope.keys.back();
|
||||
switch (GetU4())
|
||||
|
|
@ -1302,7 +1299,7 @@ void LWOImporter::LoadLWO2Envelope(unsigned int length)
|
|||
case AI_LWO_BEZ2:
|
||||
key.inter = LWO::IT_BEZ2;break;
|
||||
default:
|
||||
ASSIMP_LOG_WARN("LWO2: Unknown interval interpolation mode");
|
||||
DefaultLogger::get()->warn("LWO2: Unknown interval interpolation mode");
|
||||
};
|
||||
|
||||
// todo ... read params
|
||||
|
|
@ -1311,8 +1308,7 @@ void LWOImporter::LoadLWO2Envelope(unsigned int length)
|
|||
}
|
||||
|
||||
default:
|
||||
ASSIMP_LOG_WARN("LWO2: Encountered unknown ENVL subchunk");
|
||||
break;
|
||||
DefaultLogger::get()->warn("LWO2: Encountered unknown ENVL subchunk");
|
||||
}
|
||||
// regardless how much we did actually read, go to the next chunk
|
||||
mFileBuffer = next;
|
||||
|
|
@ -1411,7 +1407,7 @@ void LWOImporter::LoadLWO2File()
|
|||
case AI_LWO_VMAD:
|
||||
if (mCurLayer->mFaces.empty())
|
||||
{
|
||||
ASSIMP_LOG_WARN("LWO2: Unexpected VMAD chunk");
|
||||
DefaultLogger::get()->warn("LWO2: Unexpected VMAD chunk");
|
||||
break;
|
||||
}
|
||||
// --- intentionally no break here
|
||||
|
|
@ -1421,7 +1417,7 @@ void LWOImporter::LoadLWO2File()
|
|||
break;
|
||||
|
||||
if (mCurLayer->mTempPoints.empty())
|
||||
ASSIMP_LOG_WARN("LWO2: Unexpected VMAP chunk");
|
||||
DefaultLogger::get()->warn("LWO2: Unexpected VMAP chunk");
|
||||
else LoadLWO2VertexMap(head.length,head.type == AI_LWO_VMAD);
|
||||
break;
|
||||
}
|
||||
|
|
@ -1442,21 +1438,17 @@ void LWOImporter::LoadLWO2File()
|
|||
if (skip)
|
||||
break;
|
||||
|
||||
if (mCurLayer->mFaces.empty()) {
|
||||
ASSIMP_LOG_WARN("LWO2: Unexpected PTAG");
|
||||
} else {
|
||||
LoadLWO2PolygonTags(head.length);
|
||||
}
|
||||
if (mCurLayer->mFaces.empty())
|
||||
DefaultLogger::get()->warn("LWO2: Unexpected PTAG");
|
||||
else LoadLWO2PolygonTags(head.length);
|
||||
break;
|
||||
}
|
||||
// list of tags
|
||||
case AI_LWO_TAGS:
|
||||
{
|
||||
if (!mTags->empty()) {
|
||||
ASSIMP_LOG_WARN("LWO2: SRFS chunk encountered twice");
|
||||
} else {
|
||||
LoadLWOTags(head.length);
|
||||
}
|
||||
if (!mTags->empty())
|
||||
DefaultLogger::get()->warn("LWO2: SRFS chunk encountered twice");
|
||||
else LoadLWOTags(head.length);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue