summaryrefslogtreecommitdiff
path: root/src/mesh/assimp-master/code/AssetLib/3DS/3DSHelper.h
blob: dc109803586565640af8bc53f28fbbbf89ee5d85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
/*
Open Asset Import Library (assimp)
----------------------------------------------------------------------

Copyright (c) 2006-2022, assimp team


All rights reserved.

Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:

* Redistributions of source code must retain the above
  copyright notice, this list of conditions and the
  following disclaimer.

* Redistributions in binary form must reproduce the above
  copyright notice, this list of conditions and the
  following disclaimer in the documentation and/or other
  materials provided with the distribution.

* Neither the name of the assimp team, nor the names of its
  contributors may be used to endorse or promote products
  derived from this software without specific prior
  written permission of the assimp team.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

----------------------------------------------------------------------
*/

/** @file Defines helper data structures for the import of 3DS files */

#ifndef AI_3DSFILEHELPER_H_INC
#define AI_3DSFILEHELPER_H_INC

#include <assimp/SmoothingGroups.h>
#include <assimp/SpatialSort.h>
#include <assimp/StringUtils.h>
#include <assimp/anim.h>
#include <assimp/camera.h>
#include <assimp/light.h>
#include <assimp/material.h>
#include <assimp/qnan.h>
#include <cstdio> //sprintf

namespace Assimp {
namespace D3DS {

#include <assimp/Compiler/pushpack1.h>

// ---------------------------------------------------------------------------
/** Defines chunks and data structures.
*/
namespace Discreet3DS {

    //! data structure for a single chunk in a .3ds file
    struct Chunk {
        uint16_t Flag;
        uint32_t Size;
    } PACK_STRUCT;

    //! Used for shading field in material3ds structure
    //! From AutoDesk 3ds SDK
    typedef enum {
        // translated to gouraud shading with wireframe active
        Wire = 0x0,

        // if this material is set, no vertex normals will
        // be calculated for the model. Face normals + gouraud
        Flat = 0x1,

        // standard gouraud shading
        Gouraud = 0x2,

        // phong shading
        Phong = 0x3,

        // cooktorrance or anistropic phong shading ...
        // the exact meaning is unknown, if you know it
        // feel free to tell me ;-)
        Metal = 0x4,

        // required by the ASE loader
        Blinn = 0x5
    } shadetype3ds;

    // Flags for animated keys
    enum {
        KEY_USE_TENS = 0x1,
        KEY_USE_CONT = 0x2,
        KEY_USE_BIAS = 0x4,
        KEY_USE_EASE_TO = 0x8,
        KEY_USE_EASE_FROM = 0x10
    };

    enum {

        // ********************************************************************
        // Basic chunks which can be found everywhere in the file
        CHUNK_VERSION = 0x0002,
        CHUNK_RGBF = 0x0010, // float4 R; float4 G; float4 B
        CHUNK_RGBB = 0x0011, // int1 R; int1 G; int B

        // Linear color values (gamma = 2.2?)
        CHUNK_LINRGBF = 0x0013, // float4 R; float4 G; float4 B
        CHUNK_LINRGBB = 0x0012, // int1 R; int1 G; int B

        CHUNK_PERCENTW = 0x0030, // int2   percentage
        CHUNK_PERCENTF = 0x0031, // float4  percentage
        CHUNK_PERCENTD = 0x0032, // float8  percentage
        // ********************************************************************

        // Prj master chunk
        CHUNK_PRJ = 0xC23D,

        // MDLI master chunk
        CHUNK_MLI = 0x3DAA,

        // Primary main chunk of the .3ds file
        CHUNK_MAIN = 0x4D4D,

        // Mesh main chunk
        CHUNK_OBJMESH = 0x3D3D,

        // Specifies the background color of the .3ds file
        // This is passed through the material system for
        // viewing purposes.
        CHUNK_BKGCOLOR = 0x1200,

        // Specifies the ambient base color of the scene.
        // This is added to all materials in the file
        CHUNK_AMBCOLOR = 0x2100,

        // Specifies the background image for the whole scene
        // This value is passed through the material system
        // to the viewer
        CHUNK_BIT_MAP = 0x1100,
        CHUNK_BIT_MAP_EXISTS = 0x1101,

        // ********************************************************************
        // Viewport related stuff. Ignored
        CHUNK_DEFAULT_VIEW = 0x3000,
        CHUNK_VIEW_TOP = 0x3010,
        CHUNK_VIEW_BOTTOM = 0x3020,
        CHUNK_VIEW_LEFT = 0x3030,
        CHUNK_VIEW_RIGHT = 0x3040,
        CHUNK_VIEW_FRONT = 0x3050,
        CHUNK_VIEW_BACK = 0x3060,
        CHUNK_VIEW_USER = 0x3070,
        CHUNK_VIEW_CAMERA = 0x3080,
        // ********************************************************************

        // Mesh chunks
        CHUNK_OBJBLOCK = 0x4000,
        CHUNK_TRIMESH = 0x4100,
        CHUNK_VERTLIST = 0x4110,
        CHUNK_VERTFLAGS = 0x4111,
        CHUNK_FACELIST = 0x4120,
        CHUNK_FACEMAT = 0x4130,
        CHUNK_MAPLIST = 0x4140,
        CHUNK_SMOOLIST = 0x4150,
        CHUNK_TRMATRIX = 0x4160,
        CHUNK_MESHCOLOR = 0x4165,
        CHUNK_TXTINFO = 0x4170,
        CHUNK_LIGHT = 0x4600,
        CHUNK_CAMERA = 0x4700,
        CHUNK_HIERARCHY = 0x4F00,

        // Specifies the global scaling factor. This is applied
        // to the root node's transformation matrix
        CHUNK_MASTER_SCALE = 0x0100,

        // ********************************************************************
        // Material chunks
        CHUNK_MAT_MATERIAL = 0xAFFF,

        // asciiz containing the name of the material
        CHUNK_MAT_MATNAME = 0xA000,
        CHUNK_MAT_AMBIENT = 0xA010, // followed by color chunk
        CHUNK_MAT_DIFFUSE = 0xA020, // followed by color chunk
        CHUNK_MAT_SPECULAR = 0xA030, // followed by color chunk

        // Specifies the shininess of the material
        // followed by percentage chunk
        CHUNK_MAT_SHININESS = 0xA040,
        CHUNK_MAT_SHININESS_PERCENT = 0xA041,

        // Specifies the shading mode to be used
        // followed by a short
        CHUNK_MAT_SHADING = 0xA100,

        // NOTE: Emissive color (self illumination) seems not
        // to be a color but a single value, type is unknown.
        // Make the parser accept both of them.
        // followed by percentage chunk (?)
        CHUNK_MAT_SELF_ILLUM = 0xA080,

        // Always followed by percentage chunk  (?)
        CHUNK_MAT_SELF_ILPCT = 0xA084,

        // Always followed by percentage chunk
        CHUNK_MAT_TRANSPARENCY = 0xA050,

        // Diffuse texture channel 0
        CHUNK_MAT_TEXTURE = 0xA200,

        // Contains opacity information for each texel
        CHUNK_MAT_OPACMAP = 0xA210,

        // Contains a reflection map to be used to reflect
        // the environment. This is partially supported.
        CHUNK_MAT_REFLMAP = 0xA220,

        // Self Illumination map (emissive colors)
        CHUNK_MAT_SELFIMAP = 0xA33d,

        // Bumpmap. Not specified whether it is a heightmap
        // or a normal map. Assme it is a heightmap since
        // artist normally prefer this format.
        CHUNK_MAT_BUMPMAP = 0xA230,

        // Specular map. Seems to influence the specular color
        CHUNK_MAT_SPECMAP = 0xA204,

        // Holds shininess data.
        CHUNK_MAT_MAT_SHINMAP = 0xA33C,

        // Scaling in U/V direction.
        // (need to gen separate UV coordinate set
        // and do this by hand)
        CHUNK_MAT_MAP_USCALE = 0xA354,
        CHUNK_MAT_MAP_VSCALE = 0xA356,

        // Translation in U/V direction.
        // (need to gen separate UV coordinate set
        // and do this by hand)
        CHUNK_MAT_MAP_UOFFSET = 0xA358,
        CHUNK_MAT_MAP_VOFFSET = 0xA35a,

        // UV-coordinates rotation around the z-axis
        // Assumed to be in radians.
        CHUNK_MAT_MAP_ANG = 0xA35C,

        // Tiling flags for 3DS files
        CHUNK_MAT_MAP_TILING = 0xa351,

        // Specifies the file name of a texture
        CHUNK_MAPFILE = 0xA300,

        // Specifies whether a material requires two-sided rendering
        CHUNK_MAT_TWO_SIDE = 0xA081,
        // ********************************************************************

        // Main keyframer chunk. Contains translation/rotation/scaling data
        CHUNK_KEYFRAMER = 0xB000,

        // Supported sub chunks
        CHUNK_TRACKINFO = 0xB002,
        CHUNK_TRACKOBJNAME = 0xB010,
        CHUNK_TRACKDUMMYOBJNAME = 0xB011,
        CHUNK_TRACKPIVOT = 0xB013,
        CHUNK_TRACKPOS = 0xB020,
        CHUNK_TRACKROTATE = 0xB021,
        CHUNK_TRACKSCALE = 0xB022,

        // ********************************************************************
        // Keyframes for various other stuff in the file
        // Partially ignored
        CHUNK_AMBIENTKEY = 0xB001,
        CHUNK_TRACKMORPH = 0xB026,
        CHUNK_TRACKHIDE = 0xB029,
        CHUNK_OBJNUMBER = 0xB030,
        CHUNK_TRACKCAMERA = 0xB003,
        CHUNK_TRACKFOV = 0xB023,
        CHUNK_TRACKROLL = 0xB024,
        CHUNK_TRACKCAMTGT = 0xB004,
        CHUNK_TRACKLIGHT = 0xB005,
        CHUNK_TRACKLIGTGT = 0xB006,
        CHUNK_TRACKSPOTL = 0xB007,
        CHUNK_FRAMES = 0xB008,
        // ********************************************************************

        // light sub-chunks
        CHUNK_DL_OFF = 0x4620,
        CHUNK_DL_OUTER_RANGE = 0x465A,
        CHUNK_DL_INNER_RANGE = 0x4659,
        CHUNK_DL_MULTIPLIER = 0x465B,
        CHUNK_DL_EXCLUDE = 0x4654,
        CHUNK_DL_ATTENUATE = 0x4625,
        CHUNK_DL_SPOTLIGHT = 0x4610,

        // camera sub-chunks
        CHUNK_CAM_RANGES = 0x4720
    };
}

// ---------------------------------------------------------------------------
/** Helper structure representing a 3ds mesh face */
struct Face : public FaceWithSmoothingGroup {
};

#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4315)
#endif // _MSC_VER

// ---------------------------------------------------------------------------
/** Helper structure representing a texture */
struct Texture {
    //! Default constructor
    Texture() AI_NO_EXCEPT
            : mTextureBlend(0.0f),
              mMapName(),
              mOffsetU(0.0),
              mOffsetV(0.0),
              mScaleU(1.0),
              mScaleV(1.0),
              mRotation(0.0),
              mMapMode(aiTextureMapMode_Wrap),
              bPrivate(),
              iUVSrc(0) {
        mTextureBlend = get_qnan();
    }

    Texture(const Texture &other) :
            mTextureBlend(other.mTextureBlend),
            mMapName(other.mMapName),
            mOffsetU(other.mOffsetU),
            mOffsetV(other.mOffsetV),
            mScaleU(other.mScaleU),
            mScaleV(other.mScaleV),
            mRotation(other.mRotation),
            mMapMode(other.mMapMode),
            bPrivate(other.bPrivate),
            iUVSrc(other.iUVSrc) {
        // empty
    }

    Texture(Texture &&other) AI_NO_EXCEPT : mTextureBlend(other.mTextureBlend),
                                            mMapName(std::move(other.mMapName)),
                                            mOffsetU(other.mOffsetU),
                                            mOffsetV(other.mOffsetV),
                                            mScaleU(other.mScaleU),
                                            mScaleV(other.mScaleV),
                                            mRotation(other.mRotation),
                                            mMapMode(other.mMapMode),
                                            bPrivate(other.bPrivate),
                                            iUVSrc(other.iUVSrc) {
        // empty
    }

    Texture &operator=(Texture &&other) AI_NO_EXCEPT {
        if (this == &other) {
            return *this;
        }

        mTextureBlend = other.mTextureBlend;
        mMapName = std::move(other.mMapName);
        mOffsetU = other.mOffsetU;
        mOffsetV = other.mOffsetV;
        mScaleU = other.mScaleU;
        mScaleV = other.mScaleV;
        mRotation = other.mRotation;
        mMapMode = other.mMapMode;
        bPrivate = other.bPrivate;
        iUVSrc = other.iUVSrc;

        return *this;
    }

    //! Specifies the blend factor for the texture
    ai_real mTextureBlend;

    //! Specifies the filename of the texture
    std::string mMapName;

    //! Specifies texture coordinate offsets/scaling/rotations
    ai_real mOffsetU;
    ai_real mOffsetV;
    ai_real mScaleU;
    ai_real mScaleV;
    ai_real mRotation;

    //! Specifies the mapping mode to be used for the texture
    aiTextureMapMode mMapMode;

    //! Used internally
    bool bPrivate;
    int iUVSrc;
};

#include <assimp/Compiler/poppack1.h>

#ifdef _MSC_VER
#pragma warning(pop)
#endif // _MSC_VER

// ---------------------------------------------------------------------------
/** Helper structure representing a 3ds material */
struct Material {
    //! Default constructor has been deleted
    Material() :
            mName(),
            mDiffuse(ai_real(0.6), ai_real(0.6), ai_real(0.6)),
            mSpecularExponent(ai_real(0.0)),
            mShininessStrength(ai_real(1.0)),
            mShading(Discreet3DS::Gouraud),
            mTransparency(ai_real(1.0)),
            mBumpHeight(ai_real(1.0)),
            mTwoSided(false) {
        // empty
    }

    //! Constructor with explicit name
    explicit Material(const std::string &name) :
            mName(name),
            mDiffuse(ai_real(0.6), ai_real(0.6), ai_real(0.6)),
            mSpecularExponent(ai_real(0.0)),
            mShininessStrength(ai_real(1.0)),
            mShading(Discreet3DS::Gouraud),
            mTransparency(ai_real(1.0)),
            mBumpHeight(ai_real(1.0)),
            mTwoSided(false) {
        // empty
    }

    Material(const Material &other) :
            mName(other.mName),
            mDiffuse(other.mDiffuse),
            mSpecularExponent(other.mSpecularExponent),
            mShininessStrength(other.mShininessStrength),
            mSpecular(other.mSpecular),
            mAmbient(other.mAmbient),
            mShading(other.mShading),
            mTransparency(other.mTransparency),
            sTexDiffuse(other.sTexDiffuse),
            sTexOpacity(other.sTexOpacity),
            sTexSpecular(other.sTexSpecular),
            sTexReflective(other.sTexReflective),
            sTexBump(other.sTexBump),
            sTexEmissive(other.sTexEmissive),
            sTexShininess(other.sTexShininess),
            mBumpHeight(other.mBumpHeight),
            mEmissive(other.mEmissive),
            sTexAmbient(other.sTexAmbient),
            mTwoSided(other.mTwoSided) {
        // empty
    }

    //! Move constructor. This is explicitly written because MSVC doesn't support defaulting it
    Material(Material &&other) AI_NO_EXCEPT : mName(std::move(other.mName)),
                                              mDiffuse(other.mDiffuse),
                                              mSpecularExponent(other.mSpecularExponent),
                                              mShininessStrength(other.mShininessStrength),
                                              mSpecular(other.mSpecular),
                                              mAmbient(other.mAmbient),
                                              mShading(other.mShading),
                                              mTransparency(other.mTransparency),
                                              sTexDiffuse(std::move(other.sTexDiffuse)),
                                              sTexOpacity(std::move(other.sTexOpacity)),
                                              sTexSpecular(std::move(other.sTexSpecular)),
                                              sTexReflective(std::move(other.sTexReflective)),
                                              sTexBump(std::move(other.sTexBump)),
                                              sTexEmissive(std::move(other.sTexEmissive)),
                                              sTexShininess(std::move(other.sTexShininess)),
                                              mBumpHeight(other.mBumpHeight),
                                              mEmissive(other.mEmissive),
                                              sTexAmbient(std::move(other.sTexAmbient)),
                                              mTwoSided(other.mTwoSided) {
        // empty
    }

    Material &operator=(Material &&other) AI_NO_EXCEPT {
        if (this == &other) {
            return *this;
        }

        mName = std::move(other.mName);
        mDiffuse = other.mDiffuse;
        mSpecularExponent = other.mSpecularExponent;
        mShininessStrength = other.mShininessStrength,
        mSpecular = other.mSpecular;
        mAmbient = other.mAmbient;
        mShading = other.mShading;
        mTransparency = other.mTransparency;
        sTexDiffuse = std::move(other.sTexDiffuse);
        sTexOpacity = std::move(other.sTexOpacity);
        sTexSpecular = std::move(other.sTexSpecular);
        sTexReflective = std::move(other.sTexReflective);
        sTexBump = std::move(other.sTexBump);
        sTexEmissive = std::move(other.sTexEmissive);
        sTexShininess = std::move(other.sTexShininess);
        mBumpHeight = other.mBumpHeight;
        mEmissive = other.mEmissive;
        sTexAmbient = std::move(other.sTexAmbient);
        mTwoSided = other.mTwoSided;

        return *this;
    }

    virtual ~Material() {
        // empty
    }

    //! Name of the material
    std::string mName;
    //! Diffuse color of the material
    aiColor3D mDiffuse;
    //! Specular exponent
    ai_real mSpecularExponent;
    //! Shininess strength, in percent
    ai_real mShininessStrength;
    //! Specular color of the material
    aiColor3D mSpecular;
    //! Ambient color of the material
    aiColor3D mAmbient;
    //! Shading type to be used
    Discreet3DS::shadetype3ds mShading;
    //! Opacity of the material
    ai_real mTransparency;
    //! Diffuse texture channel
    Texture sTexDiffuse;
    //! Opacity texture channel
    Texture sTexOpacity;
    //! Specular texture channel
    Texture sTexSpecular;
    //! Reflective texture channel
    Texture sTexReflective;
    //! Bump texture channel
    Texture sTexBump;
    //! Emissive texture channel
    Texture sTexEmissive;
    //! Shininess texture channel
    Texture sTexShininess;
    //! Scaling factor for the bump values
    ai_real mBumpHeight;
    //! Emissive color
    aiColor3D mEmissive;
    //! Ambient texture channel
    //! (used by the ASE format)
    Texture sTexAmbient;
    //! True if the material must be rendered from two sides
    bool mTwoSided;
};

// ---------------------------------------------------------------------------
/** Helper structure to represent a 3ds file mesh */
struct Mesh : public MeshWithSmoothingGroups<D3DS::Face> {
    //! Default constructor has been deleted
    Mesh() = delete;

    //! Constructor with explicit name
    explicit Mesh(const std::string &name) :
            mName(name) {
    }

    //! Name of the mesh
    std::string mName;

    //! Texture coordinates
    std::vector<aiVector3D> mTexCoords;

    //! Face materials
    std::vector<unsigned int> mFaceMaterials;

    //! Local transformation matrix
    aiMatrix4x4 mMat;
};

// ---------------------------------------------------------------------------
/** Float key - quite similar to aiVectorKey and aiQuatKey. Both are in the
    C-API, so it would be difficult to make them a template. */
struct aiFloatKey {
    double mTime; ///< The time of this key
    ai_real mValue; ///< The value of this key

#ifdef __cplusplus

    // time is not compared
    bool operator==(const aiFloatKey &o) const { return o.mValue == this->mValue; }

    bool operator!=(const aiFloatKey &o) const { return o.mValue != this->mValue; }

    // Only time is compared. This operator is defined
    // for use with std::sort
    bool operator<(const aiFloatKey &o) const { return mTime < o.mTime; }

    bool operator>(const aiFloatKey &o) const { return mTime > o.mTime; }

#endif
};

// ---------------------------------------------------------------------------
/** Helper structure to represent a 3ds file node */
struct Node {
    Node() = delete;

    explicit Node(const std::string &name) :
            mParent(nullptr),
            mName(name),
            mInstanceNumber(0),
            mHierarchyPos(0),
            mHierarchyIndex(0),
            mInstanceCount(1) {
        aRotationKeys.reserve(20);
        aPositionKeys.reserve(20);
        aScalingKeys.reserve(20);
    }

    ~Node() {
        for (unsigned int i = 0; i < mChildren.size(); ++i)
            delete mChildren[i];
    }

    //! Pointer to the parent node
    Node *mParent;

    //! Holds all child nodes
    std::vector<Node *> mChildren;

    //! Name of the node
    std::string mName;

    //! InstanceNumber of the node
    int32_t mInstanceNumber;

    //! Dummy nodes: real name to be combined with the $$$DUMMY
    std::string mDummyName;

    //! Position of the node in the hierarchy (tree depth)
    int16_t mHierarchyPos;

    //! Index of the node
    int16_t mHierarchyIndex;

    //! Rotation keys loaded from the file
    std::vector<aiQuatKey> aRotationKeys;

    //! Position keys loaded from the file
    std::vector<aiVectorKey> aPositionKeys;

    //! Scaling keys loaded from the file
    std::vector<aiVectorKey> aScalingKeys;

    // For target lights (spot lights and directional lights):
    // The position of the target
    std::vector<aiVectorKey> aTargetPositionKeys;

    // For cameras: the camera roll angle
    std::vector<aiFloatKey> aCameraRollKeys;

    //! Pivot position loaded from the file
    aiVector3D vPivot;

    //instance count, will be kept only for the first node
    int32_t mInstanceCount;

    //! Add a child node, setup the right parent node for it
    //! \param pc Node to be 'adopted'
    inline Node &push_back(Node *pc) {
        mChildren.push_back(pc);
        pc->mParent = this;
        return *this;
    }
};
// ---------------------------------------------------------------------------
/** Helper structure analogue to aiScene */
struct Scene {
    //! List of all materials loaded
    //! NOTE: 3ds references materials globally
    std::vector<Material> mMaterials;

    //! List of all meshes loaded
    std::vector<Mesh> mMeshes;

    //! List of all cameras loaded
    std::vector<aiCamera *> mCameras;

    //! List of all lights loaded
    std::vector<aiLight *> mLights;

    //! Pointer to the root node of the scene
    // --- moved to main class
    // Node* pcRootNode;
};

} // end of namespace D3DS
} // end of namespace Assimp

#endif // AI_XFILEHELPER_H_INC