GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Finished loading of MD2, MD3, MDL2, MDL3, MDL4, MDL5, MDL7, MDL. Firs… · wise86-android/assimp@b422d4e

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • code
    • 3DSConverter.cpp
    • 3DSHelper.h
    • 3DSLoader.cpp
    • ASELoader.cpp
    • BaseImporter.h
    • DefaultIOStream.cpp
    • DefaultIOSystem.cpp
    • HMPLoader.cpp
    • HMPLoader.h
    • Importer.cpp
    • LimitBoneWeightsProcess.cpp
    • LimitBoneWeightsProcess.h
    • MD2FileData.h
    • MD2Loader.cpp
    • MD2Loader.h
    • MD3FileData.h
    • MD3Loader.cpp
    • MD3Loader.h
    • MD4Loader.cpp
    • MDLFileData.h
    • MDLLoader.cpp
    • MDLLoader.h
    • MDLMaterialLoader.cpp
    • MaterialSystem.cpp
    • MaterialSystem.h
    • ParsingUtils.h
    • PlyLoader.cpp
    • PlyParser.h
    • SMDLoader.cpp
    • SMDLoader.h
    • SplitLargeMeshes.h
    • TextureTransform.cpp
    • ValidateDataStructure.cpp
    • ValidateDataStructure.h
    • XFileImporter.cpp
    • XFileParser.cpp
    • extra
      • MakeVerboseFormat.cpp
    • qnan.h
  • doc
    • dox.h
  • include
    • IOStream.h
    • IOSystem.h
    • LogStream.h
    • Logger.h
    • aiDefines.h
    • aiMaterial.h
    • aiMaterial.inl
    • aiMatrix3x3.h
    • aiMatrix3x3.inl
    • aiMatrix4x4.h
    • aiMatrix4x4.inl
    • aiPostProcess.h
    • aiQuaternion.h
    • aiScene.h
    • aiTexture.h
    • aiTypes.h
    • assimp.hpp
    • assimp.h
  • port/jAssimp
    • assimp.iml
    • jni_bridge
      • BuildHeader.bat
      • JNICalls.cpp
      • JNIEnvironment.cpp
      • JNIEnvironment.h
      • JNILogger.cpp
      • JNILogger.h
      • assimp_Animation.h
      • assimp_Importer.h
      • assimp_Material.h
      • assimp_Mesh.h
      • assimp_Node.h
      • assimp_PostProcessStep.h
      • assimp_Scene.h
      • assimp_Texture.h
    • src/assimp
      • Bone.java
      • IOStream.java
      • IOSystem.java
      • Importer.java
      • Material.java
      • Mesh.java
      • Node.java
      • PostProcessStep.java
      • ShadingMode.java
      • TextureMapMode.java
      • TextureOp.java
  • test
    • HMP
      • planar.hmp
      • terrain.hmp
      • terrain_withtexture.hmp
    • SMD
      • triangle.smd
  • tools/assimp_view
    • Material.cpp
  • workspaces
    • jidea5.1
      • jAssimp.ipr
    • vc8
      • assimp.vcproj

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎code/3DSConverter.cpp‎

Copy file name to clipboardExpand all lines: code/3DSConverter.cpp
+26-23Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,22 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4040
*/
4141

4242
/** @file Implementation of the 3ds importer class */
43+
44+
// internal headers
4345
#include "3DSLoader.h"
4446
#include "MaterialSystem.h"
4547
#include "TextureTransform.h"
4648
#include "StringComparison.h"
49+
#include "qnan.h"
4750

51+
// public ASSIMP headers
4852
#include "../include/DefaultLogger.h"
4953
#include "../include/IOStream.h"
5054
#include "../include/IOSystem.h"
5155
#include "../include/aiMesh.h"
5256
#include "../include/aiScene.h"
5357
#include "../include/aiAssert.h"
5458

55-
#include <boost/scoped_ptr.hpp>
5659

5760
using namespace Assimp;
5861

@@ -427,10 +430,12 @@ void Dot3DSImporter::ConvertMeshes(aiScene* pcOut)
427430
a != (*i).mFaceMaterials.end();++a,++iNum)
428431
{
429432
// check range
430-
if ((*a) >= this->mScene->mMaterials.size())
433+
if ((*a) >= this->mScene->mMaterials.size())
431434
{
432-
// use the last material instead
433-
aiSplit[this->mScene->mMaterials.size()-1].push_back(iNum);
435+
DefaultLogger::get()->error("Face material index is out of range");
436+
437+
// use the last material instead
438+
aiSplit[this->mScene->mMaterials.size()-1].push_back(iNum);
434439
}
435440
else aiSplit[*a].push_back(iNum);
436441
}
@@ -450,15 +455,15 @@ void Dot3DSImporter::ConvertMeshes(aiScene* pcOut)
450455
p_pcOut->mColors[0] = (aiColor4D*)new std::string((*i).mName);
451456
avOutMeshes.push_back(p_pcOut);
452457

453-
458+
// (code for keyframe animation. however, this is currently not supported by Assimp)
459+
#if 0
454460
if (bFirst)
455461
{
456462
p_pcOut->mColors[1] = (aiColor4D*)new aiMatrix4x4();
457-
458463
*((aiMatrix4x4*)p_pcOut->mColors[1]) = (*i).mMat;
459464
bFirst = false;
460465
}
461-
466+
#endif
462467

463468
// convert vertices
464469
p_pcOut->mNumVertices = (unsigned int)aiSplit[p].size()*3;
@@ -519,16 +524,6 @@ void Dot3DSImporter::ConvertMeshes(aiScene* pcOut)
519524
// apply texture coordinate scalings
520525
TextureTransform::BakeScaleNOffset ( p_pcOut, &this->mScene->mMaterials[
521526
p_pcOut->mMaterialIndex] );
522-
523-
// setup bitflags to indicate which texture coordinate
524-
// channels are used
525-
p_pcOut->mNumUVComponents[0] = 2;
526-
if (p_pcOut->HasTextureCoords(1))
527-
p_pcOut->mNumUVComponents[1] = 2;
528-
if (p_pcOut->HasTextureCoords(2))
529-
p_pcOut->mNumUVComponents[2] = 2;
530-
if (p_pcOut->HasTextureCoords(3))
531-
p_pcOut->mNumUVComponents[3] = 2;
532527
}
533528
}
534529
}
@@ -579,6 +574,8 @@ void Dot3DSImporter::AddNodeToGraph(aiScene* pcSOut,aiNode* pcOut,Dot3DS::Node*
579574
{
580575
const unsigned int iIndex = iArray[i];
581576

577+
// (code for keyframe animation. however, this is currently not supported by Assimp)
578+
#if 0
582579
if (NULL != pcSOut->mMeshes[iIndex]->mColors[1])
583580
{
584581
pcOut->mTransformation = *((aiMatrix4x4*)
@@ -587,7 +584,7 @@ void Dot3DSImporter::AddNodeToGraph(aiScene* pcSOut,aiNode* pcOut,Dot3DS::Node*
587584
delete (aiMatrix4x4*)pcSOut->mMeshes[iIndex]->mColors[1];
588585
pcSOut->mMeshes[iIndex]->mColors[1] = NULL;
589586
}
590-
587+
#endif
591588
pcOut->mMeshes[i] = iIndex;
592589
}
593590

@@ -681,11 +678,17 @@ void Dot3DSImporter::GenerateNodeGraph(aiScene* pcOut)
681678
pcNode->mMeshes[0] = i;
682679
pcNode->mNumMeshes = 1;
683680

684-
std::string s;
685-
std::stringstream ss(s);
686-
ss << "UNNAMED[" << i << + "]";
687-
688-
pcNode->mName.Set(s);
681+
char szBuffer[128];
682+
int iLen;
683+
#if _MSC_VER >= 1400
684+
iLen = sprintf_s(szBuffer,"UNNAMED_%i",i);
685+
#else
686+
iLen = sprintf(szBuffer,"UNNAMED_%i",i);
687+
#endif
688+
ai_assert(0 < iLen);
689+
::memcpy(pcNode->mName.data,szBuffer,iLen);
690+
pcNode->mName.data[iLen] = '\0';
691+
pcNode->mName.length = iLen;
689692

690693
// add the new child to the parent node
691694
pcOut->mRootNode->mChildren[i] = pcNode;
Collapse file

‎code/3DSHelper.h‎

Copy file name to clipboardExpand all lines: code/3DSHelper.h
+26-30Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,22 @@ class Dot3DSFile
9393
//! From AutoDesk 3ds SDK
9494
typedef enum
9595
{
96+
// translated to gouraud shading with wireframe active
9697
Wire = 0,
98+
99+
// if this material is set, no vertex normals will
100+
// be calculated for the model. Face normals + gouraud
97101
Flat = 1,
102+
103+
// standard gouraud shading
98104
Gouraud = 2,
105+
106+
// phong shading
99107
Phong = 3,
108+
109+
// cooktorrance or anistropic phong shading ...
110+
// the exact meaning is unknown, if you know it
111+
// feel free to tell me ;-)
100112
Metal = 4,
101113

102114
// required by the ASE loader
@@ -127,7 +139,8 @@ class Dot3DSFile
127139
CHUNK_PERCENTF = 0x0031, // float4 percentage
128140
// **************************************************************
129141

130-
// Unknown and ignored
142+
// Unknown and ignored. Possibly a chunk used by PROJ (
143+
// Discreet 3DS max Project File)?
131144
CHUNK_PRJ = 0xC23D,
132145

133146
// Unknown. Possibly a reference to an external .mli file?
@@ -387,9 +400,10 @@ struct Material
387400
mTwoSided (false)
388401
{
389402
static int iCnt = 0;
390-
std::stringstream ss;
391-
ss << "$$_UNNAMED_" << iCnt++ << "_$$";
392-
ss >> mName;
403+
404+
char szTemp[128];
405+
sprintf(szTemp,"$$_UNNAMED_%i_$$",iCnt++);
406+
mName = szTemp;
393407
}
394408

395409
//! Name of the material
@@ -442,9 +456,10 @@ struct Mesh
442456
Mesh()
443457
{
444458
static int iCnt = 0;
445-
std::stringstream ss;
446-
ss << "$$_UNNAMED_" << iCnt++ << "_$$";
447-
ss >> mName;
459+
460+
char szTemp[128];
461+
sprintf(szTemp,"$$_UNNAMED_%i_$$",iCnt++);
462+
mName = szTemp;
448463
}
449464

450465
//! Name of the mesh
@@ -481,9 +496,10 @@ struct Node
481496

482497
{
483498
static int iCnt = 0;
484-
std::stringstream ss;
485-
ss << "$$_UNNAMED_" << iCnt++ << "_$$";
486-
ss >> mName;
499+
500+
char szTemp[128];
501+
sprintf(szTemp,"$$_UNNAMED_%i_$$",iCnt++);
502+
mName = szTemp;
487503

488504
mHierarchyPos = 0;
489505
mHierarchyIndex = 0;
@@ -538,26 +554,6 @@ struct Scene
538554
Node* pcRootNode;
539555
};
540556

541-
// ---------------------------------------------------------------------------
542-
inline bool is_qnan(float p_fIn)
543-
{
544-
// NOTE: Comparison against qnan is generally problematic
545-
// because qnan == qnan is false AFAIK
546-
union FTOINT
547-
{
548-
float fFloat;
549-
int32_t iInt;
550-
} one, two;
551-
one.fFloat = std::numeric_limits<float>::quiet_NaN();
552-
two.fFloat = p_fIn;
553-
554-
return (one.iInt == two.iInt);
555-
}
556-
// ---------------------------------------------------------------------------
557-
inline bool is_not_qnan(float p_fIn)
558-
{
559-
return !is_qnan(p_fIn);
560-
}
561557

562558
} // end of namespace Dot3DS
563559
} // end of namespace Assimp
Collapse file

‎code/3DSLoader.cpp‎

Copy file name to clipboardExpand all lines: code/3DSLoader.cpp
+21-29Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,33 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4040
*/
4141

4242
/** @file Implementation of the 3ds importer class */
43+
44+
// internal headers
4345
#include "3DSLoader.h"
4446
#include "MaterialSystem.h"
4547
#include "TextureTransform.h"
4648
#include "StringComparison.h"
49+
#include "qnan.h"
4750

51+
// public ASSIMP headers
4852
#include "../include/DefaultLogger.h"
4953
#include "../include/IOStream.h"
5054
#include "../include/IOSystem.h"
5155
#include "../include/aiMesh.h"
5256
#include "../include/aiScene.h"
5357
#include "../include/aiAssert.h"
5458

59+
// boost headers
5560
#include <boost/scoped_ptr.hpp>
5661

5762
using namespace Assimp;
5863

59-
#define ASSIMP_3DS_WARN_CHUNK_OVERFLOW_MSG \
60-
"WARNING: Size of chunk data plus size of " \
61-
"subordinate chunks is larger than the size " \
62-
"specified in the higher-level chunk header." \
64+
#if (!defined ASSIMP_3DS_WARN_CHUNK_OVERFLOW_MSG)
65+
# define ASSIMP_3DS_WARN_CHUNK_OVERFLOW_MSG \
66+
"WARNING: Size of chunk data plus size of " \
67+
"subordinate chunks is larger than the size " \
68+
"specified in the top-level chunk header."
69+
#endif
6370

6471
// ------------------------------------------------------------------------------------------------
6572
// Constructor to be privately used by Importer
@@ -92,22 +99,6 @@ bool Dot3DSImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler) co
9299
return false;
93100
}
94101
// ------------------------------------------------------------------------------------------------
95-
// recursively delete a given node
96-
void DeleteNodeRecursively (aiNode* p_piNode)
97-
{
98-
if (!p_piNode)return;
99-
100-
if (p_piNode->mChildren)
101-
{
102-
for (unsigned int i = 0 ; i < p_piNode->mNumChildren;++i)
103-
{
104-
DeleteNodeRecursively(p_piNode->mChildren[i]);
105-
}
106-
}
107-
delete p_piNode;
108-
return;
109-
}
110-
// ------------------------------------------------------------------------------------------------
111102
// Imports the given file into the given scene structure.
112103
void Dot3DSImporter::InternReadFile(
113104
const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler)
@@ -125,7 +116,7 @@ void Dot3DSImporter::InternReadFile(
125116
size_t fileSize = file->FileSize();
126117
if( fileSize < 16)
127118
{
128-
throw new ImportErrorException( ".3ds File is too small.");
119+
throw new ImportErrorException( "3DS File is too small.");
129120
}
130121

131122
this->mScene = new Dot3DS::Scene();
@@ -780,8 +771,9 @@ void Dot3DSImporter::ParseFaceChunk(int* piRemaining)
780771
case Dot3DSFile::CHUNK_FACEMAT:
781772

782773
// at fist an asciiz with the material name
783-
while (*sz++ != '\0')
774+
while (*sz++)
784775
{
776+
// make sure we don't run over the end of the chunk
785777
if (sz > pcCurNext-1)break;
786778
}
787779

@@ -800,7 +792,7 @@ void Dot3DSImporter::ParseFaceChunk(int* piRemaining)
800792
break;
801793
}
802794
}
803-
if (iIndex == 0xFFFFFFFF)
795+
if (0xFFFFFFFF == iIndex)
804796
{
805797
// this material is not known. Ignore this. We will later
806798
// assign the default material to all faces using *this*
@@ -818,13 +810,14 @@ void Dot3DSImporter::ParseFaceChunk(int* piRemaining)
818810

819811
// check range
820812
if (iTemp >= mMesh.mFaceMaterials.size())
821-
{
813+
{
814+
DefaultLogger::get()->error("Invalid face index in face material list");
822815
mMesh.mFaceMaterials[mMesh.mFaceMaterials.size()-1] = iIndex;
823-
}
816+
}
824817
else
825-
{
818+
{
826819
mMesh.mFaceMaterials[iTemp] = iIndex;
827-
}
820+
}
828821
this->mCurrent += sizeof(uint16_t);
829822
}
830823

@@ -959,8 +952,7 @@ void Dot3DSImporter::ParseMeshChunk(int* piRemaining)
959952
}
960953
break;
961954

962-
#if (defined _DEBUG)
963-
955+
#if 0
964956
case Dot3DSFile::CHUNK_TXTINFO:
965957

966958
// for debugging purposes. Read two bytes to determine the mapping type
Collapse file

‎code/ASELoader.cpp‎

Copy file name to clipboardExpand all lines: code/ASELoader.cpp
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4040
*/
4141

4242
/** @file Implementation of the ASE importer class */
43+
44+
// internal headers
4345
#include "ASELoader.h"
4446
#include "3DSSpatialSort.h"
4547
#include "MaterialSystem.h"
4648
#include "StringComparison.h"
4749
#include "TextureTransform.h"
50+
51+
// utilities
4852
#include "fast_atof.h"
53+
#include "qnan.h"
4954

55+
// ASSIMP public headers
5056
#include "../include/IOStream.h"
5157
#include "../include/IOSystem.h"
5258
#include "../include/aiMesh.h"
Collapse file

‎code/BaseImporter.h‎

Copy file name to clipboardExpand all lines: code/BaseImporter.h
+10-2Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class BaseImporter
111111
// -------------------------------------------------------------------
112112
/** Imports the given file and returns the imported data.
113113
* If the import succeeds, ownership of the data is transferred to
114-
* the caller. If the import failes, NULL is returned. The function
114+
* the caller. If the import fails, NULL is returned. The function
115115
* takes care that any partially constructed data is destroyed
116116
* beforehand.
117117
*
@@ -154,7 +154,15 @@ class BaseImporter
154154
* an error. If it terminates normally, the data in aiScene is
155155
* expected to be correct. Override this function to implement the
156156
* actual importing.
157-
*
157+
* <br>
158+
* The output scene must meet the following conditions:<br>
159+
* - at least one mesh must be there<br>
160+
* - at least a root node must be there<br>
161+
* - at least one material must be there<br>
162+
* - there may be no meshes with 0 vertices or faces<br>
163+
* This won't be checked (except by the validation step), Assimp will
164+
* crash if one of the conditions is not met!
165+
*
158166
* @param pFile Path of the file to be imported.
159167
* @param pScene The scene object to hold the imported data.
160168
* NULL is not a valid parameter.

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.