assimp/code/3DS/3DSHelper.h

683 lines
22 KiB
C
Raw Normal View History

/*
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2020, assimp team
2018-01-28 18:42:05 +00:00
2017-05-09 17:57:36 +00:00
All rights reserved.
2015-05-19 03:52:10 +00:00
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.
2015-05-19 03:52:10 +00:00
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
2015-05-19 03:52:10 +00:00
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2015-05-19 03:52:10 +00:00
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2015-05-19 03:52:10 +00:00
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>
2020-02-18 13:41:19 +00:00
#include <assimp/SpatialSort.h>
#include <assimp/StringUtils.h>
2020-02-18 13:41:19 +00:00
#include <assimp/anim.h>
2017-02-22 16:20:26 +00:00
#include <assimp/camera.h>
#include <assimp/light.h>
2020-02-18 13:41:19 +00:00
#include <assimp/material.h>
#include <assimp/qnan.h>
#include <stdio.h> //sprintf
2020-02-18 13:41:19 +00:00
namespace Assimp {
namespace D3DS {
#include <assimp/Compiler/pushpack1.h>
// ---------------------------------------------------------------------------
/** Discreet3DS class: Helper class for loading 3ds files. Defines chunks
* and data structures.
*/
class Discreet3DS {
private:
2018-09-21 14:25:27 +00:00
Discreet3DS() AI_NO_EXCEPT {
// empty
}
~Discreet3DS() {
// empty
}
public:
2015-05-19 03:57:13 +00:00
//! data structure for a single chunk in a .3ds file
struct Chunk {
2020-02-18 13:41:19 +00:00
uint16_t Flag;
uint32_t Size;
2015-05-19 03:57:13 +00:00
} PACK_STRUCT;
//! Used for shading field in material3ds structure
//! From AutoDesk 3ds SDK
2020-02-18 13:41:19 +00:00
typedef enum {
2015-05-19 03:57:13 +00:00
// 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
2020-02-18 13:41:19 +00:00
enum {
KEY_USE_TENS = 0x1,
KEY_USE_CONT = 0x2,
KEY_USE_BIAS = 0x4,
KEY_USE_EASE_TO = 0x8,
KEY_USE_EASE_FROM = 0x10
};
enum {
2015-05-19 03:57:13 +00:00
// ********************************************************************
// Basic chunks which can be found everywhere in the file
2020-02-18 13:41:19 +00:00
CHUNK_VERSION = 0x0002,
CHUNK_RGBF = 0x0010, // float4 R; float4 G; float4 B
CHUNK_RGBB = 0x0011, // int1 R; int1 G; int B
2015-05-19 03:57:13 +00:00
// Linear color values (gamma = 2.2?)
2020-02-18 13:41:19 +00:00
CHUNK_LINRGBF = 0x0013, // float4 R; float4 G; float4 B
CHUNK_LINRGBB = 0x0012, // int1 R; int1 G; int B
2015-05-19 03:57:13 +00:00
2020-02-18 13:41:19 +00:00
CHUNK_PERCENTW = 0x0030, // int2 percentage
CHUNK_PERCENTF = 0x0031, // float4 percentage
CHUNK_PERCENTD = 0x0032, // float8 percentage
2015-05-19 03:57:13 +00:00
// ********************************************************************
// Prj master chunk
2020-02-18 13:41:19 +00:00
CHUNK_PRJ = 0xC23D,
2015-05-19 03:57:13 +00:00
// MDLI master chunk
2020-02-18 13:41:19 +00:00
CHUNK_MLI = 0x3DAA,
2015-05-19 03:57:13 +00:00
// Primary main chunk of the .3ds file
2020-02-18 13:41:19 +00:00
CHUNK_MAIN = 0x4D4D,
2015-05-19 03:57:13 +00:00
// Mesh main chunk
2020-02-18 13:41:19 +00:00
CHUNK_OBJMESH = 0x3D3D,
2015-05-19 03:57:13 +00:00
// Specifies the background color of the .3ds file
// This is passed through the material system for
// viewing purposes.
2020-02-18 13:41:19 +00:00
CHUNK_BKGCOLOR = 0x1200,
2015-05-19 03:57:13 +00:00
// Specifies the ambient base color of the scene.
// This is added to all materials in the file
2020-02-18 13:41:19 +00:00
CHUNK_AMBCOLOR = 0x2100,
2015-05-19 03:57:13 +00:00
// Specifies the background image for the whole scene
// This value is passed through the material system
// to the viewer
2020-02-18 13:41:19 +00:00
CHUNK_BIT_MAP = 0x1100,
CHUNK_BIT_MAP_EXISTS = 0x1101,
2015-05-19 03:57:13 +00:00
// ********************************************************************
// 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
2020-02-18 13:41:19 +00:00
CHUNK_OBJBLOCK = 0x4000,
CHUNK_TRIMESH = 0x4100,
CHUNK_VERTLIST = 0x4110,
2015-05-19 03:57:13 +00:00
CHUNK_VERTFLAGS = 0x4111,
2020-02-18 13:41:19 +00:00
CHUNK_FACELIST = 0x4120,
CHUNK_FACEMAT = 0x4130,
CHUNK_MAPLIST = 0x4140,
CHUNK_SMOOLIST = 0x4150,
CHUNK_TRMATRIX = 0x4160,
2015-05-19 03:57:13 +00:00
CHUNK_MESHCOLOR = 0x4165,
2020-02-18 13:41:19 +00:00
CHUNK_TXTINFO = 0x4170,
CHUNK_LIGHT = 0x4600,
CHUNK_CAMERA = 0x4700,
2015-05-19 03:57:13 +00:00
CHUNK_HIERARCHY = 0x4F00,
// Specifies the global scaling factor. This is applied
// to the root node's transformation matrix
2020-02-18 13:41:19 +00:00
CHUNK_MASTER_SCALE = 0x0100,
2015-05-19 03:57:13 +00:00
// ********************************************************************
// Material chunks
2020-02-18 13:41:19 +00:00
CHUNK_MAT_MATERIAL = 0xAFFF,
2015-05-19 03:57:13 +00:00
2020-02-18 13:41:19 +00:00
// 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
2015-05-19 03:57:13 +00:00
2020-02-18 13:41:19 +00:00
// Specifies the shininess of the material
// followed by percentage chunk
CHUNK_MAT_SHININESS = 0xA040,
CHUNK_MAT_SHININESS_PERCENT = 0xA041,
2015-05-19 03:57:13 +00:00
2020-02-18 13:41:19 +00:00
// Specifies the shading mode to be used
// followed by a short
CHUNK_MAT_SHADING = 0xA100,
2015-05-19 03:57:13 +00:00
2020-02-18 13:41:19 +00:00
// 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,
2015-05-19 03:57:13 +00:00
2020-02-18 13:41:19 +00:00
// Always followed by percentage chunk (?)
CHUNK_MAT_SELF_ILPCT = 0xA084,
2015-05-19 03:57:13 +00:00
2020-02-18 13:41:19 +00:00
// Always followed by percentage chunk
CHUNK_MAT_TRANSPARENCY = 0xA050,
2015-05-19 03:57:13 +00:00
2020-02-18 13:41:19 +00:00
// Diffuse texture channel 0
CHUNK_MAT_TEXTURE = 0xA200,
2015-05-19 03:57:13 +00:00
2020-02-18 13:41:19 +00:00
// Contains opacity information for each texel
CHUNK_MAT_OPACMAP = 0xA210,
2015-05-19 03:57:13 +00:00
2020-02-18 13:41:19 +00:00
// Contains a reflection map to be used to reflect
// the environment. This is partially supported.
CHUNK_MAT_REFLMAP = 0xA220,
2015-05-19 03:57:13 +00:00
2020-02-18 13:41:19 +00:00
// Self Illumination map (emissive colors)
CHUNK_MAT_SELFIMAP = 0xA33d,
2015-05-19 03:57:13 +00:00
2020-02-18 13:41:19 +00:00
// 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,
2015-05-19 03:57:13 +00:00
2020-02-18 13:41:19 +00:00
// Specular map. Seems to influence the specular color
CHUNK_MAT_SPECMAP = 0xA204,
2015-05-19 03:57:13 +00:00
2020-02-18 13:41:19 +00:00
// Holds shininess data.
CHUNK_MAT_MAT_SHINMAP = 0xA33C,
2015-05-19 03:57:13 +00:00
2020-02-18 13:41:19 +00:00
// 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,
2015-05-19 03:57:13 +00:00
2020-02-18 13:41:19 +00:00
// 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,
2015-05-19 03:57:13 +00:00
2020-02-18 13:41:19 +00:00
// UV-coordinates rotation around the z-axis
// Assumed to be in radians.
CHUNK_MAT_MAP_ANG = 0xA35C,
2015-05-19 03:57:13 +00:00
2020-02-18 13:41:19 +00:00
// Tiling flags for 3DS files
CHUNK_MAT_MAP_TILING = 0xa351,
2015-05-19 03:57:13 +00:00
2020-02-18 13:41:19 +00:00
// Specifies the file name of a texture
CHUNK_MAPFILE = 0xA300,
2015-05-19 03:57:13 +00:00
2020-02-18 13:41:19 +00:00
// Specifies whether a materail requires two-sided rendering
CHUNK_MAT_TWO_SIDE = 0xA081,
2015-05-19 03:57:13 +00:00
// ********************************************************************
// Main keyframer chunk. Contains translation/rotation/scaling data
2020-02-18 13:41:19 +00:00
CHUNK_KEYFRAMER = 0xB000,
2015-05-19 03:57:13 +00:00
// Supported sub chunks
2020-02-18 13:41:19 +00:00
CHUNK_TRACKINFO = 0xB002,
CHUNK_TRACKOBJNAME = 0xB010,
CHUNK_TRACKDUMMYOBJNAME = 0xB011,
CHUNK_TRACKPIVOT = 0xB013,
CHUNK_TRACKPOS = 0xB020,
CHUNK_TRACKROTATE = 0xB021,
CHUNK_TRACKSCALE = 0xB022,
2015-05-19 03:57:13 +00:00
// ********************************************************************
// Keyframes for various other stuff in the file
// Partially ignored
2020-02-18 13:41:19 +00:00
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,
2015-05-19 03:57:13 +00:00
// ********************************************************************
// light sub-chunks
2020-02-18 13:41:19 +00:00
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,
2015-05-19 03:57:13 +00:00
// camera sub-chunks
2020-02-18 13:41:19 +00:00
CHUNK_CAM_RANGES = 0x4720
2015-05-19 03:57:13 +00:00
};
};
// ---------------------------------------------------------------------------
/** Helper structure representing a 3ds mesh face */
2020-02-18 13:41:19 +00:00
struct Face : public FaceWithSmoothingGroup {
};
#ifdef _WIN32
# pragma warning(disable : 4315)
#endif
2020-02-18 13:41:19 +00:00
// ---------------------------------------------------------------------------
/** Helper structure representing a texture */
2018-09-21 14:07:09 +00:00
struct Texture {
2015-05-19 03:57:13 +00:00
//! Default constructor
2018-09-21 14:25:27 +00:00
Texture() AI_NO_EXCEPT
2020-02-18 13:41:19 +00:00
: 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) {
2015-05-19 03:57:13 +00:00
mTextureBlend = get_qnan();
}
2020-03-01 12:15:45 +00:00
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
}
2020-02-18 13:41:19 +00:00
Texture(Texture &&other) AI_NO_EXCEPT : mTextureBlend(std::move(other.mTextureBlend)),
mMapName(std::move(other.mMapName)),
mOffsetU(std::move(other.mOffsetU)),
mOffsetV(std::move(other.mOffsetV)),
mScaleU(std::move(other.mScaleU)),
mScaleV(std::move(other.mScaleV)),
mRotation(std::move(other.mRotation)),
mMapMode(std::move(other.mMapMode)),
bPrivate(std::move(other.bPrivate)),
iUVSrc(std::move(other.iUVSrc)) {
2020-02-18 13:41:19 +00:00
// empty
}
Texture &operator=(Texture &&other) AI_NO_EXCEPT {
if (this == &other) {
return *this;
}
mTextureBlend = std::move(other.mTextureBlend);
mMapName = std::move(other.mMapName);
mOffsetU = std::move(other.mOffsetU);
mOffsetV = std::move(other.mOffsetV);
mScaleU = std::move(other.mScaleU);
mScaleV = std::move(other.mScaleV);
mRotation = std::move(other.mRotation);
mMapMode = std::move(other.mMapMode);
bPrivate = std::move(other.bPrivate);
iUVSrc = std::move(other.iUVSrc);
2020-02-16 14:37:20 +00:00
2020-02-18 13:41:19 +00:00
return *this;
2020-02-16 14:37:20 +00:00
}
2015-05-19 03:57:13 +00:00
//! Specifies the blend factor for the texture
ai_real mTextureBlend;
2015-05-19 03:57:13 +00:00
//! 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;
2015-05-19 03:57:13 +00:00
//! Specifies the mapping mode to be used for the texture
aiTextureMapMode mMapMode;
//! Used internally
bool bPrivate;
int iUVSrc;
};
#include <assimp/Compiler/poppack1.h>
// ---------------------------------------------------------------------------
/** Helper structure representing a 3ds material */
2020-02-18 13:41:19 +00:00
struct Material {
//! Default constructor has been deleted
2020-03-01 12:15:45 +00:00
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
}
2015-05-19 03:57:13 +00:00
//! Constructor with explicit name
2020-02-18 13:41:19 +00:00
explicit Material(const std::string &name) :
2020-03-01 12:15:45 +00:00
mName(name),
mDiffuse(ai_real(0.6), ai_real(0.6), ai_real(0.6)),
2020-02-18 13:41:19 +00:00
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) {
2020-03-01 12:15:45 +00:00
// empty
}
2020-02-18 13:41:19 +00:00
Material(const Material &other) = default;
Material &operator=(const Material &other) = default;
//! Move constructor. This is explicitly written because MSVC doesn't support defaulting it
2018-09-21 14:25:27 +00:00
Material(Material &&other) AI_NO_EXCEPT
2020-02-18 13:41:19 +00:00
: mName(std::move(other.mName)),
mDiffuse(std::move(other.mDiffuse)),
mSpecularExponent(std::move(other.mSpecularExponent)),
mShininessStrength(std::move(other.mShininessStrength)),
mSpecular(std::move(other.mSpecular)),
mAmbient(std::move(other.mAmbient)),
mShading(std::move(other.mShading)),
mTransparency(std::move(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(std::move(other.mBumpHeight)),
mEmissive(std::move(other.mEmissive)),
sTexAmbient(std::move(other.sTexAmbient)),
mTwoSided(std::move(other.mTwoSided)) {
}
2018-09-21 14:25:27 +00:00
Material &operator=(Material &&other) AI_NO_EXCEPT {
if (this == &other) {
return *this;
}
mName = std::move(other.mName);
mDiffuse = std::move(other.mDiffuse);
mSpecularExponent = std::move(other.mSpecularExponent);
mShininessStrength = std::move(other.mShininessStrength),
mSpecular = std::move(other.mSpecular);
mAmbient = std::move(other.mAmbient);
mShading = std::move(other.mShading);
mTransparency = std::move(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 = std::move(other.mBumpHeight);
mEmissive = std::move(other.mEmissive);
sTexAmbient = std::move(other.sTexAmbient);
mTwoSided = std::move(other.mTwoSided);
return *this;
}
2020-03-01 12:15:45 +00:00
virtual ~Material() {
// empty
}
2015-05-19 03:57:13 +00:00
//! Name of the material
std::string mName;
//! Diffuse color of the material
aiColor3D mDiffuse;
//! Specular exponent
ai_real mSpecularExponent;
2015-05-19 03:57:13 +00:00
//! Shininess strength, in percent
ai_real mShininessStrength;
2015-05-19 03:57:13 +00:00
//! 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;
2015-05-19 03:57:13 +00:00
//! 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;
2015-05-19 03:57:13 +00:00
//! 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 */
2020-02-18 13:41:19 +00:00
struct Mesh : public MeshWithSmoothingGroups<D3DS::Face> {
2018-01-27 15:17:31 +00:00
//! Default constructor has been deleted
Mesh() = delete;
2015-05-19 03:52:10 +00:00
//! Constructor with explicit name
2020-02-18 13:41:19 +00:00
explicit Mesh(const std::string &name) :
mName(name) {
2015-05-19 03:57:13 +00:00
}
2015-05-19 03:57:13 +00:00
//! Name of the mesh
std::string mName;
2015-05-19 03:57:13 +00:00
//! Texture coordinates
std::vector<aiVector3D> mTexCoords;
2015-05-19 03:57:13 +00:00
//! Face materials
std::vector<unsigned int> mFaceMaterials;
2015-05-19 03:57:13 +00:00
//! 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. */
2020-02-18 13:41:19 +00:00
struct aiFloatKey {
double mTime; ///< The time of this key
ai_real mValue; ///< The value of this key
#ifdef __cplusplus
2015-05-19 03:57:13 +00:00
// time is not compared
2020-02-18 13:41:19 +00:00
bool operator==(const aiFloatKey &o) const { return o.mValue == this->mValue; }
2020-02-18 13:41:19 +00:00
bool operator!=(const aiFloatKey &o) const { return o.mValue != this->mValue; }
2015-05-19 03:57:13 +00:00
// Only time is compared. This operator is defined
// for use with std::sort
2020-02-18 13:41:19 +00:00
bool operator<(const aiFloatKey &o) const { return mTime < o.mTime; }
2020-02-18 13:41:19 +00:00
bool operator>(const aiFloatKey &o) const { return mTime > o.mTime; }
#endif
};
// ---------------------------------------------------------------------------
/** Helper structure to represent a 3ds file node */
2020-02-18 13:41:19 +00:00
struct Node {
2018-01-27 15:35:44 +00:00
Node() = delete;
2020-02-18 13:41:19 +00:00
explicit Node(const std::string &name) :
mParent(NULL), mName(name), mInstanceNumber(0), mHierarchyPos(0), mHierarchyIndex(0), mInstanceCount(1) {
aRotationKeys.reserve(20);
aPositionKeys.reserve(20);
aScalingKeys.reserve(20);
2015-05-19 03:57:13 +00:00
}
2020-02-18 13:41:19 +00:00
~Node() {
for (unsigned int i = 0; i < mChildren.size(); ++i)
2015-05-19 03:57:13 +00:00
delete mChildren[i];
}
2015-05-19 03:57:13 +00:00
//! Pointer to the parent node
2020-02-18 13:41:19 +00:00
Node *mParent;
2015-05-19 03:57:13 +00:00
//! Holds all child nodes
2020-02-18 13:41:19 +00:00
std::vector<Node *> mChildren;
2015-05-19 03:57:13 +00:00
//! Name of the node
std::string mName;
2015-05-19 03:57:13 +00:00
//! InstanceNumber of the node
int32_t mInstanceNumber;
2015-05-19 03:57:13 +00:00
//! Dummy nodes: real name to be combined with the $$$DUMMY
std::string mDummyName;
2015-05-19 03:57:13 +00:00
//! Position of the node in the hierarchy (tree depth)
int16_t mHierarchyPos;
2015-05-19 03:57:13 +00:00
//! Index of the node
int16_t mHierarchyIndex;
2015-05-19 03:57:13 +00:00
//! Rotation keys loaded from the file
std::vector<aiQuatKey> aRotationKeys;
2015-05-19 03:57:13 +00:00
//! Position keys loaded from the file
std::vector<aiVectorKey> aPositionKeys;
2015-05-19 03:57:13 +00:00
//! Scaling keys loaded from the file
std::vector<aiVectorKey> aScalingKeys;
2015-05-19 03:57:13 +00:00
// For target lights (spot lights and directional lights):
// The position of the target
2020-02-18 13:41:19 +00:00
std::vector<aiVectorKey> aTargetPositionKeys;
2015-05-19 03:57:13 +00:00
// For cameras: the camera roll angle
2020-02-18 13:41:19 +00:00
std::vector<aiFloatKey> aCameraRollKeys;
2015-05-19 03:57:13 +00:00
//! Pivot position loaded from the file
aiVector3D vPivot;
2015-05-19 03:57:13 +00:00
//instance count, will be kept only for the first node
int32_t mInstanceCount;
2015-05-19 03:57:13 +00:00
//! Add a child node, setup the right parent node for it
//! \param pc Node to be 'adopted'
2020-02-18 13:41:19 +00:00
inline Node &push_back(Node *pc) {
2015-05-19 03:57:13 +00:00
mChildren.push_back(pc);
pc->mParent = this;
return *this;
}
};
// ---------------------------------------------------------------------------
/** Helper structure analogue to aiScene */
2020-02-18 13:41:19 +00:00
struct Scene {
2015-05-19 03:57:13 +00:00
//! List of all materials loaded
//! NOTE: 3ds references materials globally
std::vector<Material> mMaterials;
2015-05-19 03:57:13 +00:00
//! List of all meshes loaded
std::vector<Mesh> mMeshes;
2015-05-19 03:57:13 +00:00
//! List of all cameras loaded
2020-02-18 13:41:19 +00:00
std::vector<aiCamera *> mCameras;
2015-05-19 03:57:13 +00:00
//! List of all lights loaded
2020-02-18 13:41:19 +00:00
std::vector<aiLight *> mLights;
2015-05-19 03:57:13 +00:00
//! 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