-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOBJLoader.h
More file actions
80 lines (61 loc) · 2.44 KB
/
OBJLoader.h
File metadata and controls
80 lines (61 loc) · 2.44 KB
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
#ifndef __OBJLOADER_H
#define __OBJLOADER_H
#pragma once
//*********************************************************************************
#include "TGALoader.h"
//*********************************************************************************
#define RENDERFLAGS_LIGHTING 1L
#define RENDERFLAGS_FOG 1L<<1
typedef struct MATERIALstr
{
char pcName[64]; // Material's name
float pfAmbient[4]; // Ambient coefficients
float pfDiffuse[4]; // Diffuse coefficients
float pfSpecular[4]; // Specular coefficients
float pfEmission[4]; // Emission coefficients
float fShininess; // Specular shininess exponent
char pcTextureFile[MAX_PATH]; // Diffuse texture
IMAGE_DATA *pDiffuse; // Diffuse texture data
unsigned int u32RenderFlags; // Render mode
} MATERIAL;
typedef struct VERTEXstr
{
float fX, fY, fZ; // Vertex position
} VERTEX;
typedef struct TEXTURE_COORDSstr
{
float fU, fV; // Vertex'texture coordinates
} TEXTURE_COORDS;
typedef struct FACEstr
{
unsigned int pu32Vertices[3]; // Vertex'indices
unsigned int pu32UV[3]; // Texture coordinates indices
unsigned int pu32Normals[3]; // Normals indices
} FACE;
typedef struct OBJECTstr
{
unsigned int u32Material; // Material index in global materials table
unsigned int u32FirstFace; // First face index
unsigned int u32FacesCount; // Total number of faces for object
float pfMatrix[16]; // Transformation matrix
VERTEX Center; // Center's coordinates
} OBJECT;
typedef struct SCENEstr
{
OBJECT *pObjects; // Objects list
unsigned int u32ObjectsCount; // Total objects count
VERTEX *pVertices; // Global vertices table
unsigned int u32VerticesCount; // Total number of vertices
VERTEX *pNormals; // Global normals table
unsigned int u32NormalsCount; // Total number of normals
TEXTURE_COORDS *pUV; // Global UV table
unsigned int u32UVCount; // Total number of UV pairs
FACE *pFaces; // Faces'indices table
unsigned int u32FacesCount; // Total number of faces
MATERIAL *pMaterials; // Global materials table
unsigned int u32MaterialsCount; // Total number of materials
} SCENE;
//*********************************************************************************
SCENE *ReadOBJFile(const char *sFileName, bool bGenerateMissingNormals = false);
void ReleaseScene(SCENE *pScene);
#endif