Support Forum       G3D Web Page     
Classes | Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | List of all members
G3D::Parse3DS Class Reference

Parses 3DS model files. More...

Classes

struct  ChunkHeader
 
class  FaceMat
 
class  Map
 A texture map. More...
 
class  Object
 
class  UniversalMaterial
 

Public Member Functions

void parse (BinaryInput &bi, const String &basePath="<AUTO>")
 

Public Attributes

BinaryInputb
 
int currentMaterial
 
int currentObject
 Index into objectArray of the object addressed by the current keyframe chunk. More...
 
Vector3 currentPivot
 
Matrix3 currentRotation
 Used in Keyframe chunk. More...
 
Vector3 currentScale
 
Vector3 currentTranslation
 
G3D::uint32 endFrame
 
int fileVersion
 Version number of the file. More...
 
Array< UniversalMaterialmaterialArray
 
Table< String, int > materialNameToIndex
 Maps material names to indices into the MaterialArray. More...
 
int meshVersion
 
Array< ObjectobjectArray
 
G3D::uint32 startFrame
 Animation start and end frames from KFFRAMES chunk. More...
 

Protected Types

enum  ChunkHeaderID {
  MAIN3DS = 0x4d4d,
  M3D_VERSION = 0x0002,
  EDIT3DS = 0x3D3D,
  MESH_VERSION = 0x3D3E,
  EDITMATERIAL = 0xAFFF,
  MATNAME = 0xA000,
  MATAMBIENT = 0xA010,
  MATDIFFUSE = 0xA020,
  MATSPECULAR = 0xA030,
  MATSHININESS = 0xA040,
  MATSHIN2PCT = 0xA041,
  MATSHIN3PC = 0xA042,
  MATTRANSPARENCY = 0xA050,
  MATXPFALL = 0xA052,
  MATREFBLUR = 0xA053,
  MATSELFILLUM = 0xA080,
  MATTWOSIDE = 0xA081,
  MATDECAL = 0xA082,
  MATADDITIVE = 0xA083,
  MATSELFILPCT = 0xA084,
  MATWIRE = 0xA085,
  MATSUPERSMP = 0xA086,
  MATWIRESIZE = 0xA087,
  MATFACEMAP = 0xA088,
  MATXPFALLIN = 0xA08A,
  MATPHONG = 0xA08C,
  MATWIREABS = 0xA08E,
  MATSHADING = 0xA100,
  MATTEXTUREMAP1 = 0xA200,
  MAT_MAP_FILENAME = 0xA300,
  MAT_MAP_TILING = 0xA351,
  MAT_MAP_USCALE = 0xA354,
  MAT_MAP_VSCALE = 0xA356,
  MAT_MAP_UOFFSET = 0xA358,
  MAT_MAP_VOFFSET = 0xA35A,
  MATTEXTUREMAP2 = 0xA33A,
  MATOPACITYMAP = 0xA210,
  MATBUMPMAP = 0xA230,
  MATGLOSSYMAP = 0xA204,
  MATSHININESSMAP = 0xA33C,
  MATEMISSIVEMAP = 0xA33D,
  MATREFLECTIONMAP = 0xA220,
  EDIT_CONFIG1 = 0x0100,
  EDIT_CONFIG2 = 0x3E3D,
  EDIT_VIEW_P1 = 0x7012,
  EDIT_VIEW_P2 = 0x7011,
  EDIT_VIEW_P3 = 0x7020,
  EDIT_VIEW1 = 0x7001,
  EDIT_BACKGR = 0x1200,
  EDIT_AMBIENT = 0x2100,
  EDITOBJECT = 0x4000,
  OBJTRIMESH = 0x4100,
  TRIVERT = 0x4110,
  TRIFACE = 0x4120,
  TRIFACEMAT = 0x4130,
  TRI_TEXCOORDS = 0x4140,
  TRISMOOTH = 0x4150,
  TRIMATRIX = 0x4160,
  EDITKEYFRAME = 0xB000,
  KFAMBIENT = 0xB001,
  KFMESHINFO = 0xB002,
  KFNAME = 0xB010,
  KFPIVOT = 0xB013,
  KFMORPHANGLE = 0xB015,
  KFTRANSLATION = 0xB020,
  KFROTATION = 0xB021,
  KFSCALE = 0xB022,
  KFCAMERA = 0xB003,
  KFCAMERATARGET = 0xB004,
  KFOMNILIGHT = 0xB005,
  KFSPOTTARGET = 0xB006,
  KFSPOTLIGHT = 0xB007,
  KFFRAMES = 0xB008,
  KFFOV = 0xB023,
  KFROLL = 0xB024,
  KFCOLOR = 0xB025,
  KFMORPH = 0xB026,
  KFHOTSPOT = 0xB027,
  KFFALLOFF = 0xB028,
  KFHIDE = 0xB029,
  KFHIERARCHY = 0xB030,
  RGBF = 0x0010,
  RGB24 = 0x0011,
  INT_PCT = 0x0030,
  FLOAT_PCT = 0x0031
}
 

Protected Member Functions

void processChunk (const ChunkHeader &prevChunkHeader)
 
Reads the next chunk from a file and processes it. More...
 
void processMapChunk (Map &map, const ChunkHeader &materialChunkHeader)
 Called from processMaterialChunk. More...
 
void processMaterialChunk (UniversalMaterial &material, const ChunkHeader &materialChunkHeader)
 Called from processChunk. More...
 
void processObjectChunk (Object &object, const ChunkHeader &objectChunkHeader)
 Called from processChunk. More...
 
void processTriMeshChunk (Object &object, const ChunkHeader &objectChunkHeader)
 Called from processObjectChunk. More...
 
Color3 read3DSColor ()
 
Read either of the 3DS color chunk types and return the result. More...
 
float read3DSPct ()
 Read a percentage chunk. More...
 
Vector3 read3DSVector ()
 
Reads a vector in the 3DS coordinate system and converts it to the G3D coordinate system. More...
 
ChunkHeader readChunkHeader ()
 
Reads the next chunk from the file and returns it. More...
 
Vector3 readLin3Track ()
 
The translation and scale information in a keyframe is packed with additional interpolation information. More...
 
Matrix3 readRotTrack ()
 
void readTCB ()
 
Reads (and ignores) TCB information from a track part of a keyframe chunk. More...
 

Detailed Description

Parses 3DS model files.

This class maps the 3DS file format to a runtime object, which is then converted to a more useful runtime format and stored in G3D::ArticulatedModel.

Referenced Code: Keyframe chunks from http://www.republika.pl/design3d/delphi/004.html
Referenced Code: MLI chunks from http://www.programmersheaven.com/zone10/cat454/941.htm
See also
G3D::ParseMTL, G3D::ParsePLY, G3D::ParseOBJ, G3D::ArticulatedModel

Member Enumeration Documentation

◆ ChunkHeaderID

Enumerator
MAIN3DS 
M3D_VERSION 
EDIT3DS 
MESH_VERSION 
EDITMATERIAL 
MATNAME 
MATAMBIENT 
MATDIFFUSE 
MATSPECULAR 
MATSHININESS 
MATSHIN2PCT 
MATSHIN3PC 
MATTRANSPARENCY 
MATXPFALL 
MATREFBLUR 
MATSELFILLUM 
MATTWOSIDE 
MATDECAL 
MATADDITIVE 
MATSELFILPCT 
MATWIRE 
MATSUPERSMP 
MATWIRESIZE 
MATFACEMAP 
MATXPFALLIN 
MATPHONG 
MATWIREABS 
MATSHADING 
MATTEXTUREMAP1 
MAT_MAP_FILENAME 
MAT_MAP_TILING 
MAT_MAP_USCALE 
MAT_MAP_VSCALE 
MAT_MAP_UOFFSET 
MAT_MAP_VOFFSET 
MATTEXTUREMAP2 
MATOPACITYMAP 
MATBUMPMAP 
MATGLOSSYMAP 
MATSHININESSMAP 
MATEMISSIVEMAP 
MATREFLECTIONMAP 
EDIT_CONFIG1 
EDIT_CONFIG2 
EDIT_VIEW_P1 
EDIT_VIEW_P2 
EDIT_VIEW_P3 
EDIT_VIEW1 
EDIT_BACKGR 
EDIT_AMBIENT 
EDITOBJECT 
OBJTRIMESH 
TRIVERT 
TRIFACE 
TRIFACEMAT 
TRI_TEXCOORDS 
TRISMOOTH 
TRIMATRIX 
EDITKEYFRAME 
KFAMBIENT 
KFMESHINFO 
KFNAME 
KFPIVOT 
KFMORPHANGLE 
KFTRANSLATION 
KFROTATION 
KFSCALE 
KFCAMERA 
KFCAMERATARGET 
KFOMNILIGHT 
KFSPOTTARGET 
KFSPOTLIGHT 
KFFRAMES 
KFFOV 
KFROLL 
KFCOLOR 
KFMORPH 
KFHOTSPOT 
KFFALLOFF 
KFHIDE 
KFHIERARCHY 
RGBF 
RGB24 
INT_PCT 
FLOAT_PCT 

Member Function Documentation

◆ parse()

void G3D::Parse3DS::parse ( BinaryInput bi,
const String basePath = "<AUTO>" 
)

◆ processChunk()

void G3D::Parse3DS::processChunk ( const ChunkHeader prevChunkHeader)
protected


Reads the next chunk from a file and processes it.

◆ processMapChunk()

void G3D::Parse3DS::processMapChunk ( Map map,
const ChunkHeader materialChunkHeader 
)
protected

Called from processMaterialChunk.

◆ processMaterialChunk()

void G3D::Parse3DS::processMaterialChunk ( UniversalMaterial material,
const ChunkHeader materialChunkHeader 
)
protected

Called from processChunk.

◆ processObjectChunk()

void G3D::Parse3DS::processObjectChunk ( Object object,
const ChunkHeader objectChunkHeader 
)
protected

Called from processChunk.

◆ processTriMeshChunk()

void G3D::Parse3DS::processTriMeshChunk ( Object object,
const ChunkHeader objectChunkHeader 
)
protected

Called from processObjectChunk.

◆ read3DSColor()

Color3 G3D::Parse3DS::read3DSColor ( )
protected


Read either of the 3DS color chunk types and return the result.

◆ read3DSPct()

float G3D::Parse3DS::read3DSPct ( )
protected

Read a percentage chunk.

◆ read3DSVector()

Vector3 G3D::Parse3DS::read3DSVector ( )
protected


Reads a vector in the 3DS coordinate system and converts it to the G3D coordinate system.

◆ readChunkHeader()

ChunkHeader G3D::Parse3DS::readChunkHeader ( )
protected


Reads the next chunk from the file and returns it.

◆ readLin3Track()

Vector3 G3D::Parse3DS::readLin3Track ( )
protected


The translation and scale information in a keyframe is packed with additional interpolation information.

This reads all of it, then throws away everything except the 3D vector.

◆ readRotTrack()

Matrix3 G3D::Parse3DS::readRotTrack ( )
protected

◆ readTCB()

void G3D::Parse3DS::readTCB ( )
protected


Reads (and ignores) TCB information from a track part of a keyframe chunk.

Member Data Documentation

◆ b

BinaryInput* G3D::Parse3DS::b

◆ currentMaterial

int G3D::Parse3DS::currentMaterial

◆ currentObject

int G3D::Parse3DS::currentObject

Index into objectArray of the object addressed by the current keyframe chunk.

◆ currentPivot

Vector3 G3D::Parse3DS::currentPivot

◆ currentRotation

Matrix3 G3D::Parse3DS::currentRotation

Used in Keyframe chunk.

◆ currentScale

Vector3 G3D::Parse3DS::currentScale

◆ currentTranslation

Vector3 G3D::Parse3DS::currentTranslation

◆ endFrame

G3D::uint32 G3D::Parse3DS::endFrame

◆ fileVersion

int G3D::Parse3DS::fileVersion

Version number of the file.

◆ materialArray

Array<UniversalMaterial> G3D::Parse3DS::materialArray

◆ materialNameToIndex

Table<String, int> G3D::Parse3DS::materialNameToIndex

Maps material names to indices into the MaterialArray.

◆ meshVersion

int G3D::Parse3DS::meshVersion

◆ objectArray

Array<Object> G3D::Parse3DS::objectArray

◆ startFrame

G3D::uint32 G3D::Parse3DS::startFrame

Animation start and end frames from KFFRAMES chunk.


documentation generated on Wed Nov 24 2021 08:01:58 using doxygen 1.8.15