OSG3DSLoader.cpp File Reference

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include "OSG3DSLoader.h"

Go to the source code of this file.

Defines

#define SEEK_START   1900
#define SEEK_CURSOR   1901
#define COLOR_F   0x0010
#define COLOR_24   0x0011
#define LIN_COLOR_24   0x0012
#define LIN_COLOR_F   0x0013
#define INT_PERCENTAGE   0x0030
#define FLOAT_PERCENTAGE   0x0031
#define AMBIENT_LIGHT   0x2100
#define MAIN3DS   0x4D4D
#define EDIT3DS   0x3D3D
#define KFDATA   0xB000
#define KFHDR   0xB00A
#define OBJECT_NODE_TAG   0xB002
#define NODE_HDR   0xB010
#define PIVOT   0xB013
#define POS_TRACK_TAG   0xB020
#define ROT_TRACK_TAG   0xB021
#define SCL_TRACK_TAG   0xB022
#define MAT_ENTRY   0xAFFF
#define MAT_NAME   0xA000
#define MAT_AMBIENT   0xA010
#define MAT_DIFFUSE   0xA020
#define MAT_SPECULAR   0xA030
#define MAT_SHININESS   0xA040
#define MAT_SHIN2PCT   0xA041
#define MAT_TRANSPARENCY   0xA050
#define MAT_SHADING   0xA100
#define MAT_TWO_SIDE   0xA081
#define MAT_ADDITIVE   0xA083
#define MAT_WIRE   0xA085
#define MAT_FACEMAP   0xA088
#define MAT_WIRESIZE   0xA087
#define MAT_DECAL   0xA082
#define MAT_TEXMAP   0xA200
#define MAT_MAPNAME   0xA300
#define MAT_MAP_TILING   0xA351
#define MAT_MAP_USCALE   0xA354
#define MAT_MAP_VSCALE   0xA356
#define MAT_MAP_UOFFSET   0xA358
#define MAT_MAP_VOFFSET   0xA35A
#define MAT_MAP_ANG   0xA35C
#define MAT_TEX2MAP   0xA33A
#define MAT_OPACMAP   0xA210
#define MAT_BUMPMAP   0xA230
#define MAT_SPECMAP   0xA204
#define MAT_SHINMAP   0xA33C
#define MAT_REFLMAP   0xA220
#define MAT_ACUBIC   0xA310
#define EDIT_OBJECT   0x4000
#define OBJ_TRIMESH   0x4100
#define OBJ_LIGHT   0x4600
#define OBJ_CAMERA   0x4700
#define CAM_RANGES   0x4720
#define LIT_OFF   0x4620
#define LIT_SPOT   0x4610
#define LIT_INRANGE   0x4659
#define LIT_OUTRANGE   0x465A
#define TRI_VERTEXLIST   0x4110
#define TRI_VERTEXOPTIONS   0x4111
#define TRI_FACELIST   0x4120
#define TRI_MAT_GROUP   0x4130
#define TRI_SMOOTH_GROUP   0x4150
#define TRI_FACEMAPPING   0x4140
#define TRI_MATRIX   0x4160
#define TRI_TEXTURE_INFO   0x4170
#define SPOTLIGHT   0x4610
#define MAX_SHARED_TRIS   100

Functions

LVector3 _4to3 (const LVector4 &vec)
LVector3 AddVectors (const LVector3 &a, const LVector3 &b)
LVector3 SubtractVectors (const LVector3 &a, const LVector3 &b)
float VectorLength (const LVector3 &vec)
LVector3 NormalizeVector (const LVector3 &vec)
LVector3 CrossProduct (const LVector3 &a, const LVector3 &b)
void LoadIdentityMatrix (LMatrix4 &m)
LVector4 VectorByMatrix (const LMatrix4 &m, const LVector4 &vec)

Variables

LColor3 black = {0, 0, 0}
LVector3 zero3 = {0, 0, 0}
LVector4 zero4 = {0, 0, 0, 0}
LMap emptyMap = {0, "", 1, 1, 0, 0, 0, 0}

Define Documentation

#define SEEK_START   1900

Definition at line 16 of file OSG3DSLoader.cpp.

Referenced by L3DS::GotoChunk(), L3DS::Seek(), and L3DS::SkipChunk().

#define SEEK_CURSOR   1901

Definition at line 17 of file OSG3DSLoader.cpp.

Referenced by L3DS::Seek().

#define COLOR_F   0x0010

Definition at line 21 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadColor(), and L3DS::ReadLight().

#define COLOR_24   0x0011

Definition at line 22 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadColor(), and L3DS::ReadLight().

#define LIN_COLOR_24   0x0012

Definition at line 23 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadColor(), and L3DS::ReadLight().

#define LIN_COLOR_F   0x0013

Definition at line 24 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadColor(), and L3DS::ReadLight().

#define INT_PERCENTAGE   0x0030

Definition at line 27 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadMap(), and L3DS::ReadPercentage().

#define FLOAT_PERCENTAGE   0x0031

Definition at line 28 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadPercentage().

#define AMBIENT_LIGHT   0x2100

Definition at line 31 of file OSG3DSLoader.cpp.

#define MAIN3DS   0x4D4D

Definition at line 33 of file OSG3DSLoader.cpp.

Referenced by L3DS::Read3DS().

#define EDIT3DS   0x3D3D

Definition at line 34 of file OSG3DSLoader.cpp.

Referenced by L3DS::Read3DS().

#define KFDATA   0xB000

Definition at line 37 of file OSG3DSLoader.cpp.

Referenced by L3DS::Read3DS().

#define KFHDR   0xB00A

Definition at line 38 of file OSG3DSLoader.cpp.

#define OBJECT_NODE_TAG   0xB002

Definition at line 39 of file OSG3DSLoader.cpp.

Referenced by L3DS::Read3DS().

#define NODE_HDR   0xB010

Definition at line 40 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadKeyframeData().

#define PIVOT   0xB013

Definition at line 41 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadKeyframeData().

#define POS_TRACK_TAG   0xB020

Definition at line 42 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadKeyframeData().

#define ROT_TRACK_TAG   0xB021

Definition at line 43 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadKeyframeData().

#define SCL_TRACK_TAG   0xB022

Definition at line 44 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadKeyframeData().

#define MAT_ENTRY   0xAFFF

Definition at line 47 of file OSG3DSLoader.cpp.

Referenced by L3DS::Read3DS().

#define MAT_NAME   0xA000

Definition at line 48 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadMaterial().

#define MAT_AMBIENT   0xA010

Definition at line 49 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadMaterial().

#define MAT_DIFFUSE   0xA020

Definition at line 50 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadMaterial().

#define MAT_SPECULAR   0xA030

Definition at line 51 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadMaterial().

#define MAT_SHININESS   0xA040

Definition at line 52 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadMaterial().

#define MAT_SHIN2PCT   0xA041

Definition at line 53 of file OSG3DSLoader.cpp.

#define MAT_TRANSPARENCY   0xA050

Definition at line 54 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadMaterial().

#define MAT_SHADING   0xA100

Definition at line 55 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadMaterial().

#define MAT_TWO_SIDE   0xA081

Definition at line 56 of file OSG3DSLoader.cpp.

#define MAT_ADDITIVE   0xA083

Definition at line 57 of file OSG3DSLoader.cpp.

#define MAT_WIRE   0xA085

Definition at line 58 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadMaterial().

#define MAT_FACEMAP   0xA088

Definition at line 59 of file OSG3DSLoader.cpp.

#define MAT_WIRESIZE   0xA087

Definition at line 60 of file OSG3DSLoader.cpp.

#define MAT_DECAL   0xA082

Definition at line 61 of file OSG3DSLoader.cpp.

#define MAT_TEXMAP   0xA200

Definition at line 62 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadMaterial().

#define MAT_MAPNAME   0xA300

Definition at line 63 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadMap(), and L3DS::ReadMaterial().

#define MAT_MAP_TILING   0xA351

Definition at line 64 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadMap().

#define MAT_MAP_USCALE   0xA354

Definition at line 65 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadMap().

#define MAT_MAP_VSCALE   0xA356

Definition at line 66 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadMap().

#define MAT_MAP_UOFFSET   0xA358

Definition at line 67 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadMap().

#define MAT_MAP_VOFFSET   0xA35A

Definition at line 68 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadMap().

#define MAT_MAP_ANG   0xA35C

Definition at line 69 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadMap().

#define MAT_TEX2MAP   0xA33A

Definition at line 70 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadMaterial().

#define MAT_OPACMAP   0xA210

Definition at line 71 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadMaterial().

#define MAT_BUMPMAP   0xA230

Definition at line 72 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadMaterial().

#define MAT_SPECMAP   0xA204

Definition at line 73 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadMaterial().

#define MAT_SHINMAP   0xA33C

Definition at line 74 of file OSG3DSLoader.cpp.

#define MAT_REFLMAP   0xA220

Definition at line 75 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadMaterial().

#define MAT_ACUBIC   0xA310

Definition at line 76 of file OSG3DSLoader.cpp.

#define EDIT_OBJECT   0x4000

Definition at line 78 of file OSG3DSLoader.cpp.

Referenced by L3DS::Read3DS().

#define OBJ_TRIMESH   0x4100

Definition at line 79 of file OSG3DSLoader.cpp.

Referenced by L3DS::Read3DS().

#define OBJ_LIGHT   0x4600

Definition at line 80 of file OSG3DSLoader.cpp.

Referenced by L3DS::Read3DS().

#define OBJ_CAMERA   0x4700

Definition at line 81 of file OSG3DSLoader.cpp.

Referenced by L3DS::Read3DS().

#define CAM_RANGES   0x4720

Definition at line 83 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadCamera().

#define LIT_OFF   0x4620

Definition at line 85 of file OSG3DSLoader.cpp.

#define LIT_SPOT   0x4610

Definition at line 86 of file OSG3DSLoader.cpp.

#define LIT_INRANGE   0x4659

Definition at line 87 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadLight().

#define LIT_OUTRANGE   0x465A

Definition at line 88 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadLight().

#define TRI_VERTEXLIST   0x4110

Definition at line 90 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadMesh().

#define TRI_VERTEXOPTIONS   0x4111

Definition at line 91 of file OSG3DSLoader.cpp.

#define TRI_FACELIST   0x4120

Definition at line 92 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadFaceList(), and L3DS::ReadMesh().

#define TRI_MAT_GROUP   0x4130

Definition at line 93 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadFaceList().

#define TRI_SMOOTH_GROUP   0x4150

Definition at line 94 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadFaceList().

#define TRI_FACEMAPPING   0x4140

Definition at line 95 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadMesh().

#define TRI_MATRIX   0x4160

Definition at line 96 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadMesh().

#define TRI_TEXTURE_INFO   0x4170

Definition at line 97 of file OSG3DSLoader.cpp.

#define SPOTLIGHT   0x4610

Definition at line 99 of file OSG3DSLoader.cpp.

Referenced by L3DS::ReadLight().

#define MAX_SHARED_TRIS   100

Definition at line 103 of file OSG3DSLoader.cpp.


Function Documentation

LVector3 _4to3 ( const LVector4 vec  ) 

Definition at line 117 of file OSG3DSLoader.cpp.

References LVector3::x, LVector4::x, LVector3::y, LVector4::y, LVector3::z, and LVector4::z.

Referenced by LMesh::CalcNormals(), and LMesh::GetTriangle2().

00118 {
00119     LVector3 t;
00120     t.x = vec.x;
00121     t.y = vec.y;
00122     t.z = vec.z;
00123     return t;
00124 }

LVector3 AddVectors ( const LVector3 a,
const LVector3 b 
)

Definition at line 126 of file OSG3DSLoader.cpp.

References LVector3::x, LVector3::y, and LVector3::z.

00127 {
00128     LVector3 t;
00129     t.x = a.x+b.x;
00130     t.y = a.y+b.y;
00131     t.z = a.z+b.z;
00132     return t;
00133 }

LVector3 SubtractVectors ( const LVector3 a,
const LVector3 b 
)

Definition at line 135 of file OSG3DSLoader.cpp.

References LVector3::x, LVector3::y, and LVector3::z.

Referenced by LMesh::CalcNormals(), and LMesh::GetTriangle2().

00136 {
00137     LVector3 t;
00138     t.x = a.x-b.x;
00139     t.y = a.y-b.y;
00140     t.z = a.z-b.z;
00141     return t;
00142 }

float VectorLength ( const LVector3 vec  ) 

Definition at line 144 of file OSG3DSLoader.cpp.

References LVector3::x, LVector3::y, and LVector3::z.

Referenced by NormalizeVector().

00145 {
00146     return float(sqrt(vec.x*vec.x + vec.y*vec.y+vec.z*vec.z));
00147 }

LVector3 NormalizeVector ( const LVector3 vec  ) 

Definition at line 149 of file OSG3DSLoader.cpp.

References VectorLength(), LVector3::x, LVector3::y, and LVector3::z.

Referenced by LMesh::CalcNormals(), LMesh::CalcTextureSpace(), and LMesh::GetTriangle2().

00150 {
00151     float a = VectorLength(vec);
00152     if (a == 0)
00153         return vec;
00154     float b = 1/a;
00155     LVector3 v;
00156     v.x = vec.x*b;
00157     v.y = vec.y*b;
00158     v.z = vec.z*b;
00159     return v;
00160 }

LVector3 CrossProduct ( const LVector3 a,
const LVector3 b 
)

Definition at line 162 of file OSG3DSLoader.cpp.

References LVector3::x, LVector3::y, and LVector3::z.

Referenced by LMesh::CalcNormals(), LMesh::CalcTextureSpace(), and LMesh::GetTriangle2().

00163 {
00164     LVector3 v;
00165     v.x = a.y*b.z - a.z*b.y;
00166     v.y = a.z*b.x - a.x*b.z;
00167     v.z = a.x*b.y - a.y*b.x;
00168     return v;
00169 }

void LoadIdentityMatrix ( LMatrix4 m  ) 

Definition at line 171 of file OSG3DSLoader.cpp.

References LMatrix4::_11, LMatrix4::_12, LMatrix4::_13, LMatrix4::_14, LMatrix4::_21, LMatrix4::_22, LMatrix4::_23, LMatrix4::_24, LMatrix4::_31, LMatrix4::_32, LMatrix4::_33, LMatrix4::_34, LMatrix4::_41, LMatrix4::_42, LMatrix4::_43, and LMatrix4::_44.

Referenced by LMesh::Clear().

00172 {
00173     m._11 = 1.0f;
00174     m._12 = 0.0f;
00175     m._13 = 0.0f;
00176     m._14 = 0.0f;
00177
00178     m._21 = 0.0f;
00179     m._22 = 1.0f;
00180     m._23 = 0.0f;
00181     m._24 = 0.0f;
00182
00183     m._31 = 0.0f;
00184     m._32 = 0.0f;
00185     m._33 = 1.0f;
00186     m._34 = 0.0f;
00187
00188     m._41 = 0.0f;
00189     m._42 = 0.0f;
00190     m._43 = 1.0f;
00191     m._44 = 0.0f;
00192 }

LVector4 VectorByMatrix ( const LMatrix4 m,
const LVector4 vec 
)

Definition at line 194 of file OSG3DSLoader.cpp.

References LMatrix4::_11, LMatrix4::_12, LMatrix4::_13, LMatrix4::_14, LMatrix4::_21, LMatrix4::_22, LMatrix4::_23, LMatrix4::_24, LMatrix4::_31, LMatrix4::_32, LMatrix4::_33, LMatrix4::_34, LMatrix4::_41, LMatrix4::_42, LMatrix4::_43, LMatrix4::_44, LVector4::w, LVector4::x, LVector4::y, and LVector4::z.

Referenced by LMesh::TransformVertices().

00195 {
00196     LVector4 res;
00197     res.x = m._11*vec.x + m._12*vec.y + m._13*vec.z + m._14*vec.w;
00198     res.y = m._21*vec.x + m._22*vec.y + m._23*vec.z + m._24*vec.w;
00199     res.z = m._31*vec.x + m._32*vec.y + m._33*vec.z + m._34*vec.w;
00200     res.w = m._41*vec.x + m._42*vec.y + m._43*vec.z + m._44*vec.w;
00201     if (res.w != 0)
00202     {
00203         float b =  1/res.w;
00204         res.x *= b;
00205         res.y *= b;
00206         res.z *= b;
00207         res.w = 1;
00208     }
00209     else
00210         res.w = 1;
00211
00212     return res;
00213 }


Variable Documentation

LColor3 black = {0, 0, 0}

Definition at line 109 of file OSG3DSLoader.cpp.

LVector3 zero3 = {0, 0, 0}

Definition at line 111 of file OSG3DSLoader.cpp.

LVector4 zero4 = {0, 0, 0, 0}

Definition at line 113 of file OSG3DSLoader.cpp.

LMap emptyMap = {0, "", 1, 1, 0, 0, 0, 0}

Definition at line 115 of file OSG3DSLoader.cpp.