2008-05-09 17:24:28 +00:00
|
|
|
/*
|
2008-05-22 10:20:31 +00:00
|
|
|
Open Asset Import Library (ASSIMP)
|
2008-05-09 17:24:28 +00:00
|
|
|
----------------------------------------------------------------------
|
|
|
|
|
|
|
|
Copyright (c) 2006-2008, ASSIMP Development 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 Development 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.
|
|
|
|
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2008-11-16 21:56:45 +00:00
|
|
|
/** @file Defines helper data structures for the import of 3DS files */
|
2008-08-08 15:18:28 +00:00
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
#ifndef AI_3DSFILEHELPER_H_INC
|
|
|
|
#define AI_3DSFILEHELPER_H_INC
|
|
|
|
|
2008-06-01 12:46:17 +00:00
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
#include "SpatialSort.h"
|
2008-08-28 17:35:36 +00:00
|
|
|
#include "SmoothingGroups.h"
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2008-08-08 15:18:28 +00:00
|
|
|
namespace Assimp {
|
2008-10-31 19:32:00 +00:00
|
|
|
namespace D3DS {
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2008-09-12 20:25:11 +00:00
|
|
|
#include "./../include/Compiler/pushpack1.h"
|
2008-08-08 15:18:28 +00:00
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
2008-10-31 19:32:00 +00:00
|
|
|
/** Discreet3DS class: Helper class for loading 3ds files. Defines chunks
|
2008-05-05 12:36:31 +00:00
|
|
|
* and data structures.
|
|
|
|
*/
|
2008-10-31 19:32:00 +00:00
|
|
|
class Discreet3DS
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-11-16 21:56:45 +00:00
|
|
|
private:
|
2008-10-31 19:32:00 +00:00
|
|
|
inline Discreet3DS() {}
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2008-11-16 21:56:45 +00:00
|
|
|
public:
|
|
|
|
|
2008-05-09 17:24:28 +00:00
|
|
|
//! data structure for a single chunk in a .3ds file
|
2008-05-05 12:36:31 +00:00
|
|
|
struct Chunk
|
|
|
|
{
|
2008-09-12 20:25:11 +00:00
|
|
|
uint16_t Flag;
|
|
|
|
uint32_t Size;
|
2008-05-05 12:36:31 +00:00
|
|
|
} PACK_STRUCT;
|
|
|
|
|
|
|
|
|
2008-05-09 17:24:28 +00:00
|
|
|
//! Used for shading field in material3ds structure
|
|
|
|
//! From AutoDesk 3ds SDK
|
2008-05-05 12:36:31 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
2008-06-22 10:09:26 +00:00
|
|
|
// translated to gouraud shading with wireframe active
|
2008-08-28 17:35:36 +00:00
|
|
|
Wire = 0x0,
|
2008-06-22 10:09:26 +00:00
|
|
|
|
|
|
|
// if this material is set, no vertex normals will
|
|
|
|
// be calculated for the model. Face normals + gouraud
|
2008-08-28 17:35:36 +00:00
|
|
|
Flat = 0x1,
|
2008-06-22 10:09:26 +00:00
|
|
|
|
|
|
|
// standard gouraud shading
|
2008-08-28 17:35:36 +00:00
|
|
|
Gouraud = 0x2,
|
2008-06-22 10:09:26 +00:00
|
|
|
|
|
|
|
// phong shading
|
2008-08-28 17:35:36 +00:00
|
|
|
Phong = 0x3,
|
2008-06-22 10:09:26 +00:00
|
|
|
|
|
|
|
// cooktorrance or anistropic phong shading ...
|
|
|
|
// the exact meaning is unknown, if you know it
|
|
|
|
// feel free to tell me ;-)
|
2008-08-28 17:35:36 +00:00
|
|
|
Metal = 0x4,
|
2008-05-09 17:24:28 +00:00
|
|
|
|
|
|
|
// required by the ASE loader
|
2008-08-28 17:35:36 +00:00
|
|
|
Blinn = 0x5
|
2008-05-05 12:36:31 +00:00
|
|
|
} shadetype3ds;
|
|
|
|
|
2008-11-30 22:27:20 +00:00
|
|
|
// 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
|
|
|
|
} ;
|
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
|
2008-08-09 22:39:57 +00:00
|
|
|
// ********************************************************************
|
|
|
|
// Basic chunks which can be found everywhere in the file
|
2008-05-05 12:36:31 +00:00
|
|
|
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
|
2008-08-09 22:39:57 +00:00
|
|
|
// ********************************************************************
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2008-06-22 10:09:26 +00:00
|
|
|
// Unknown and ignored. Possibly a chunk used by PROJ (
|
|
|
|
// Discreet 3DS max Project File)?
|
2008-05-05 12:36:31 +00:00
|
|
|
CHUNK_PRJ = 0xC23D,
|
|
|
|
|
|
|
|
// Unknown. Possibly a reference to an external .mli file?
|
|
|
|
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,
|
|
|
|
|
2008-08-09 22:39:57 +00:00
|
|
|
// ********************************************************************
|
2008-05-05 12:36:31 +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,
|
2008-08-09 22:39:57 +00:00
|
|
|
// ********************************************************************
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
// 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_SPOTLIGHT = 0x4610,
|
|
|
|
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,
|
|
|
|
|
2008-08-09 22:39:57 +00:00
|
|
|
// ********************************************************************
|
2008-05-05 12:36:31 +00:00
|
|
|
// 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,
|
2008-05-25 22:29:05 +00:00
|
|
|
CHUNK_MAT_SHININESS_PERCENT = 0xA041 ,
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
// 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,
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
// Holds shininess data.
|
2008-05-05 12:36:31 +00:00
|
|
|
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,
|
|
|
|
|
2008-06-03 21:50:53 +00:00
|
|
|
// Tiling flags for 3DS files
|
|
|
|
CHUNK_MAT_MAP_TILING = 0xa351,
|
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// Specifies the file name of a texture
|
|
|
|
CHUNK_MAPFILE = 0xA300,
|
2008-06-03 21:50:53 +00:00
|
|
|
|
|
|
|
// Specifies whether a materail requires two-sided rendering
|
|
|
|
CHUNK_MAT_TWO_SIDE = 0xA081,
|
2008-08-09 22:39:57 +00:00
|
|
|
// ********************************************************************
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
// Main keyframer chunk. Contains translation/rotation/scaling data
|
|
|
|
CHUNK_KEYFRAMER = 0xB000,
|
|
|
|
|
|
|
|
// Supported sub chunks
|
|
|
|
CHUNK_TRACKINFO = 0xB002,
|
|
|
|
CHUNK_TRACKOBJNAME = 0xB010,
|
2008-10-31 19:32:00 +00:00
|
|
|
CHUNK_TRACKDUMMYOBJNAME = 0xB011,
|
2008-05-05 12:36:31 +00:00
|
|
|
CHUNK_TRACKPIVOT = 0xB013,
|
|
|
|
CHUNK_TRACKPOS = 0xB020,
|
|
|
|
CHUNK_TRACKROTATE = 0xB021,
|
|
|
|
CHUNK_TRACKSCALE = 0xB022,
|
|
|
|
|
2008-08-09 22:39:57 +00:00
|
|
|
// ********************************************************************
|
2008-05-05 12:36:31 +00:00
|
|
|
// Keyframes for various other stuff in the file
|
2008-10-31 19:32:00 +00:00
|
|
|
// Partially ignored
|
2008-05-05 12:36:31 +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,
|
2008-11-30 22:27:20 +00:00
|
|
|
CHUNK_FRAMES = 0xB008,
|
2008-08-09 22:39:57 +00:00
|
|
|
// ********************************************************************
|
2008-11-30 22:27:20 +00:00
|
|
|
|
|
|
|
// 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
|
2008-05-05 12:36:31 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Helper structure representing a 3ds mesh face */
|
2008-08-28 17:35:36 +00:00
|
|
|
struct Face : public FaceWithSmoothingGroup
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
|
|
|
};
|
2008-11-16 21:56:45 +00:00
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Helper structure representing a texture */
|
|
|
|
struct Texture
|
|
|
|
{
|
2008-05-09 17:24:28 +00:00
|
|
|
//! Default constructor
|
2008-05-05 12:36:31 +00:00
|
|
|
Texture()
|
2008-11-16 21:56:45 +00:00
|
|
|
: mOffsetU (0.0f)
|
2008-08-08 15:18:28 +00:00
|
|
|
, mOffsetV (0.0f)
|
2008-11-16 21:56:45 +00:00
|
|
|
, mScaleU (1.0f)
|
|
|
|
, mScaleV (1.0f)
|
2008-08-08 15:18:28 +00:00
|
|
|
, mRotation (0.0f)
|
|
|
|
, mMapMode (aiTextureMapMode_Wrap)
|
2008-09-11 20:50:15 +00:00
|
|
|
, iUVSrc (0)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
|
|
|
mTextureBlend = std::numeric_limits<float>::quiet_NaN();
|
|
|
|
}
|
2008-08-08 15:18:28 +00:00
|
|
|
|
|
|
|
//! Specifies the blend factor for the texture
|
2008-05-05 12:36:31 +00:00
|
|
|
float mTextureBlend;
|
|
|
|
|
2008-05-09 17:24:28 +00:00
|
|
|
//! Specifies the filename of the texture
|
2008-05-05 12:36:31 +00:00
|
|
|
std::string mMapName;
|
|
|
|
|
2008-05-09 17:24:28 +00:00
|
|
|
//! Specifies texture coordinate offsets/scaling/rotations
|
2008-05-05 12:36:31 +00:00
|
|
|
float mOffsetU;
|
|
|
|
float mOffsetV;
|
2008-11-16 21:56:45 +00:00
|
|
|
float mScaleU;
|
|
|
|
float mScaleV;
|
2008-05-05 12:36:31 +00:00
|
|
|
float mRotation;
|
|
|
|
|
2008-06-03 21:50:53 +00:00
|
|
|
//! Specifies the mapping mode to be used for the texture
|
|
|
|
aiTextureMapMode mMapMode;
|
|
|
|
|
2008-05-09 17:24:28 +00:00
|
|
|
//! Used internally
|
2008-05-05 12:36:31 +00:00
|
|
|
bool bPrivate;
|
|
|
|
int iUVSrc;
|
|
|
|
};
|
2008-11-16 21:56:45 +00:00
|
|
|
|
|
|
|
#include "./../include/Compiler/poppack1.h"
|
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Helper structure representing a 3ds material */
|
|
|
|
struct Material
|
|
|
|
{
|
2008-05-09 17:24:28 +00:00
|
|
|
//! Default constructor. Builds a default name for the material
|
2008-05-05 12:36:31 +00:00
|
|
|
Material()
|
|
|
|
:
|
2008-10-31 19:32:00 +00:00
|
|
|
mDiffuse (0.6f,0.6f,0.6f), // FIX ... we won't want object to be black
|
2008-05-05 12:36:31 +00:00
|
|
|
mSpecularExponent (0.0f),
|
2008-09-12 20:25:11 +00:00
|
|
|
mShininessStrength (1.0f),
|
2008-10-31 19:32:00 +00:00
|
|
|
mShading(Discreet3DS::Gouraud),
|
2008-05-05 12:36:31 +00:00
|
|
|
mTransparency (1.0f),
|
|
|
|
mBumpHeight (1.0f),
|
2008-11-30 22:27:20 +00:00
|
|
|
mTwoSided (false)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
|
|
|
static int iCnt = 0;
|
2008-06-22 10:09:26 +00:00
|
|
|
|
|
|
|
char szTemp[128];
|
2008-08-08 15:18:28 +00:00
|
|
|
sprintf(szTemp,"UNNAMED_%i",iCnt++);
|
2008-06-22 10:09:26 +00:00
|
|
|
mName = szTemp;
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
|
|
|
|
2008-05-09 17:24:28 +00:00
|
|
|
//! Name of the material
|
2008-05-05 12:36:31 +00:00
|
|
|
std::string mName;
|
2008-05-09 17:24:28 +00:00
|
|
|
//! Diffuse color of the material
|
2008-05-05 12:36:31 +00:00
|
|
|
aiColor3D mDiffuse;
|
2008-05-09 17:24:28 +00:00
|
|
|
//! Specular exponent
|
2008-05-05 12:36:31 +00:00
|
|
|
float mSpecularExponent;
|
2008-05-25 22:29:05 +00:00
|
|
|
//! Shininess strength, in percent
|
|
|
|
float mShininessStrength;
|
2008-05-09 17:24:28 +00:00
|
|
|
//! Specular color of the material
|
2008-05-05 12:36:31 +00:00
|
|
|
aiColor3D mSpecular;
|
2008-05-09 17:24:28 +00:00
|
|
|
//! Ambient color of the material
|
2008-05-05 12:36:31 +00:00
|
|
|
aiColor3D mAmbient;
|
2008-05-09 17:24:28 +00:00
|
|
|
//! Shading type to be used
|
2008-10-31 19:32:00 +00:00
|
|
|
Discreet3DS::shadetype3ds mShading;
|
2008-05-09 17:24:28 +00:00
|
|
|
//! Opacity of the material
|
2008-05-05 12:36:31 +00:00
|
|
|
float mTransparency;
|
2008-05-09 17:24:28 +00:00
|
|
|
//! Diffuse texture channel
|
2008-05-05 12:36:31 +00:00
|
|
|
Texture sTexDiffuse;
|
2008-05-09 17:24:28 +00:00
|
|
|
//! Opacity texture channel
|
2008-05-05 12:36:31 +00:00
|
|
|
Texture sTexOpacity;
|
2008-05-09 17:24:28 +00:00
|
|
|
//! Specular texture channel
|
2008-05-05 12:36:31 +00:00
|
|
|
Texture sTexSpecular;
|
2008-05-09 17:24:28 +00:00
|
|
|
//! Bump texture channel
|
2008-05-05 12:36:31 +00:00
|
|
|
Texture sTexBump;
|
2008-05-09 17:24:28 +00:00
|
|
|
//! Emissive texture channel
|
2008-05-05 12:36:31 +00:00
|
|
|
Texture sTexEmissive;
|
2008-05-09 17:24:28 +00:00
|
|
|
//! Shininess texture channel
|
2008-05-05 12:36:31 +00:00
|
|
|
Texture sTexShininess;
|
2008-06-01 12:46:17 +00:00
|
|
|
//! Scaling factor for the bump values
|
2008-05-05 12:36:31 +00:00
|
|
|
float mBumpHeight;
|
2008-05-09 17:24:28 +00:00
|
|
|
//! Emissive color
|
2008-05-05 12:36:31 +00:00
|
|
|
aiColor3D mEmissive;
|
2008-06-01 12:46:17 +00:00
|
|
|
//! Ambient texture channel
|
|
|
|
//! (used by the ASE format)
|
|
|
|
Texture sTexAmbient;
|
2008-06-03 21:50:53 +00:00
|
|
|
//! True if the material must be rendered from two sides
|
|
|
|
bool mTwoSided;
|
2008-05-05 12:36:31 +00:00
|
|
|
};
|
2008-11-16 21:56:45 +00:00
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Helper structure to represent a 3ds file mesh */
|
2008-10-31 19:32:00 +00:00
|
|
|
struct Mesh : public MeshWithSmoothingGroups<D3DS::Face>
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-05-09 17:24:28 +00:00
|
|
|
//! Default constructor
|
2008-05-05 12:36:31 +00:00
|
|
|
Mesh()
|
|
|
|
{
|
|
|
|
static int iCnt = 0;
|
2008-06-22 10:09:26 +00:00
|
|
|
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
// Generate a default name for the mesh
|
2008-06-22 10:09:26 +00:00
|
|
|
char szTemp[128];
|
2008-08-08 15:18:28 +00:00
|
|
|
::sprintf(szTemp,"UNNAMED_%i",iCnt++);
|
2008-06-22 10:09:26 +00:00
|
|
|
mName = szTemp;
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
2008-05-09 17:24:28 +00:00
|
|
|
|
|
|
|
//! Name of the mesh
|
2008-05-05 12:36:31 +00:00
|
|
|
std::string mName;
|
|
|
|
|
2008-05-09 17:24:28 +00:00
|
|
|
//! Texture coordinates
|
2008-11-16 21:56:45 +00:00
|
|
|
std::vector<aiVector3D> mTexCoords;
|
2008-05-09 17:24:28 +00:00
|
|
|
|
|
|
|
//! Face materials
|
2008-05-05 12:36:31 +00:00
|
|
|
std::vector<unsigned int> mFaceMaterials;
|
|
|
|
|
2008-05-09 17:24:28 +00:00
|
|
|
//! Local transformation matrix
|
2008-05-05 12:36:31 +00:00
|
|
|
aiMatrix4x4 mMat;
|
|
|
|
};
|
2008-10-31 19:32:00 +00:00
|
|
|
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** 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
|
|
|
|
float 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;}
|
|
|
|
|
2008-11-30 22:27:20 +00:00
|
|
|
bool operator > (const aiFloatKey& o) const
|
|
|
|
{return mTime < o.mTime;}
|
|
|
|
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
#endif
|
|
|
|
};
|
2008-10-31 19:32:00 +00:00
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Helper structure to represent a 3ds file node */
|
|
|
|
struct Node
|
|
|
|
{
|
|
|
|
Node()
|
2008-05-25 22:29:05 +00:00
|
|
|
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
: mHierarchyPos (0)
|
|
|
|
, mHierarchyIndex (0)
|
2008-05-25 22:29:05 +00:00
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
|
|
|
static int iCnt = 0;
|
2008-06-22 10:09:26 +00:00
|
|
|
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
// Generate a default name for the node
|
2008-06-22 10:09:26 +00:00
|
|
|
char szTemp[128];
|
2008-08-08 15:18:28 +00:00
|
|
|
::sprintf(szTemp,"UNNAMED_%i",iCnt++);
|
2008-06-22 10:09:26 +00:00
|
|
|
mName = szTemp;
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
aRotationKeys.reserve (20);
|
|
|
|
aPositionKeys.reserve (20);
|
|
|
|
aScalingKeys.reserve (20);
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
|
|
|
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
~Node()
|
|
|
|
{
|
|
|
|
for (unsigned int i = 0; i < mChildren.size();++i)
|
|
|
|
delete mChildren[i];
|
|
|
|
}
|
|
|
|
|
2008-05-09 17:24:28 +00:00
|
|
|
//! Pointer to the parent node
|
2008-05-05 12:36:31 +00:00
|
|
|
Node* mParent;
|
2008-05-09 17:24:28 +00:00
|
|
|
|
|
|
|
//! Holds all child nodes
|
2008-05-05 12:36:31 +00:00
|
|
|
std::vector<Node*> mChildren;
|
2008-05-09 17:24:28 +00:00
|
|
|
|
|
|
|
//! Name of the node
|
2008-05-05 12:36:31 +00:00
|
|
|
std::string mName;
|
2008-05-09 17:24:28 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
//! Dummy nodes: real name to be combined with the $$$DUMMY
|
|
|
|
std::string mDummyName;
|
|
|
|
|
2008-05-09 17:24:28 +00:00
|
|
|
//! Position of the node in the hierarchy (tree depth)
|
2008-05-05 12:36:31 +00:00
|
|
|
int16_t mHierarchyPos;
|
2008-05-09 17:24:28 +00:00
|
|
|
|
|
|
|
//! Index of the node
|
2008-05-05 12:36:31 +00:00
|
|
|
int16_t mHierarchyIndex;
|
|
|
|
|
2008-07-10 16:49:01 +00:00
|
|
|
//! 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;
|
2008-10-31 19:32:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
// 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;
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2008-07-10 16:49:01 +00:00
|
|
|
//! Pivot position loaded from the file
|
|
|
|
aiVector3D vPivot;
|
|
|
|
|
2008-05-09 17:24:28 +00:00
|
|
|
//! Add a child node, setup the right parent node for it
|
|
|
|
//! \param pc Node to be 'adopted'
|
2008-05-05 12:36:31 +00:00
|
|
|
inline Node& push_back(Node* pc)
|
|
|
|
{
|
|
|
|
mChildren.push_back(pc);
|
|
|
|
pc->mParent = this;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** Helper structure analogue to aiScene */
|
|
|
|
struct Scene
|
|
|
|
{
|
2008-05-09 17:24:28 +00:00
|
|
|
//! List of all materials loaded
|
|
|
|
//! NOTE: 3ds references materials globally
|
2008-05-05 12:36:31 +00:00
|
|
|
std::vector<Material> mMaterials;
|
2008-05-09 17:24:28 +00:00
|
|
|
|
|
|
|
//! List of all meshes loaded
|
2008-05-05 12:36:31 +00:00
|
|
|
std::vector<Mesh> mMeshes;
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
//! List of all cameras loaded
|
|
|
|
std::vector<aiCamera*> mCameras;
|
|
|
|
|
|
|
|
//! List of all lights loaded
|
|
|
|
std::vector<aiLight*> mLights;
|
|
|
|
|
2008-05-09 17:24:28 +00:00
|
|
|
//! Pointer to the root node of the scene
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
// --- moved to main class
|
|
|
|
// Node* pcRootNode;
|
2008-05-05 12:36:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
} // end of namespace D3DS
|
2008-05-05 12:36:31 +00:00
|
|
|
} // end of namespace Assimp
|
|
|
|
|
2008-08-08 18:25:55 +00:00
|
|
|
#endif // AI_XFILEHELPER_H_INC
|