trimeshloader  1.0.0
Flexible ANSI C trimeshloader 3DS/OBJ
trimeshloader.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2007-2017 Gero Mueller <post@geromueller.de>
3  *
4  * This software is provided 'as-is', without any express or implied
5  * warranty. In no event will the authors be held liable for any damages
6  * arising from the use of this software.
7  *
8  * Permission is granted to anyone to use this software for any purpose,
9  * including commercial applications, and to alter it and redistribute it
10  * freely, subject to the following restrictions:
11  *
12  * 1. The origin of this software must not be misrepresented; you must not
13  * claim that you wrote the original software. If you use this software
14  * in a product, an acknowledgment in the product documentation would be
15  * appreciated but is not required.
16  *
17  * 2. Altered source versions must be plainly marked as such, and must not be
18  * misrepresented as being the original software.
19  *
20  * 3. This notice may not be removed or altered from any source
21  * distribution.
22  */
23 
29 #ifndef TRIMESH_LOADER_H
30 #define TRIMESH_LOADER_H
31 
32 #include "tlobj.h"
33 #include "tl3ds.h"
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 #ifndef TRIMESH_LOADER_EXPORT
40  #define TRIMESH_LOADER_API
41 #else
42  #define TRIMESH_LOADER_API extern
43 #endif
44 
45 
51 typedef struct tlObject
52 {
54  char *name;
55 
57  unsigned int face_index;
58 
60  unsigned int face_count;
61 
62 } tlObject;
63 
65 #define TL_FVF_XYZ 1
66 
68 #define TL_FVF_UV 2
69 
71 #define TL_FVF_NORMAL 4
72 
74 typedef struct tlMaterial
75 {
77  char *name;
78 
80  float ambient[4], diffuse[4], specular[4];
81 
83  float shininess;
84 
85 } tlMaterial;
86 
88 typedef struct tlMaterialReference
89 {
91  char *name;
92 
94  unsigned int face_index;
95 
97  unsigned int face_count;
98 
100 
102 typedef struct tlTrimesh
103 {
105  float *vertices;
106 
108  unsigned int vertex_count;
109 
111  unsigned int vertex_format;
112 
114  unsigned int vertex_size;
115 
117  unsigned short *faces;
118 
120  unsigned int face_count;
121 
124 
126  unsigned int object_count;
127 
130 
132  unsigned int material_count;
133 
136 
139 
140 } tlTrimesh;
141 
142 
148 TRIMESH_LOADER_API tlTrimesh *tlLoad3DS( const char*filename, unsigned int vertex_format );
149 
150 
156 TRIMESH_LOADER_API tlTrimesh *tlLoadOBJ( const char*filename, unsigned int vertex_format );
157 
163 TRIMESH_LOADER_API tlTrimesh *tlCreateTrimeshFromObjState( tlObjState *state, unsigned int vertex_format );
164 
170 TRIMESH_LOADER_API tlTrimesh *tlCreateTrimeshFrom3dsState( tl3dsState *state, unsigned int vertex_format );
171 
173 
179 TRIMESH_LOADER_API tlTrimesh *tlLoadTrimesh( const char*filename, unsigned int vertex_format );
180 
185 
190 #ifdef __cplusplus
191 }
192 #endif
193 
194 #endif /*TRIMESHLOADER_H_*/
TRIMESH_LOADER_API tlTrimesh * tlCreateTrimeshFromObjState(tlObjState *state, unsigned int vertex_format)
Create an a tlTrimesh structure from a tlObjState.
Structure describing a Material (Colors and/or Texture)
Definition: trimeshloader.h:74
unsigned short * faces
pointer to the face (triangle) indices (3 unsigned shorts)
Definition: trimeshloader.h:117
unsigned int vertex_size
size/stride of each vertex, in bytes
Definition: trimeshloader.h:114
unsigned int material_count
number of materials
Definition: trimeshloader.h:132
unsigned int object_count
number of objects
Definition: trimeshloader.h:126
char * name
Name of the Object.
Definition: trimeshloader.h:54
Structure describing an Object (or SubMesh, Batch)
Definition: trimeshloader.h:51
TRIMESH_LOADER_API tlTrimesh * tlLoad3DS(const char *filename, unsigned int vertex_format)
Load a 3DS file in an tlTrimesh structure.
Trimeshloader OBJ parser public header file.
unsigned int vertex_count
number of vertices
Definition: trimeshloader.h:108
Structure describing an Trimesh (index triangle list) containing objects, vertices (point...
Definition: trimeshloader.h:102
float shininess
Shininess.
Definition: trimeshloader.h:83
unsigned int face_index
First face in the index list.
Definition: trimeshloader.h:94
tlObject * objects
list of objects in this trimesh
Definition: trimeshloader.h:123
float * vertices
pointer to the vertex data
Definition: trimeshloader.h:105
struct tlObjState tlObjState
Definition: tlobj.h:46
tlMaterial * materials
list of materials in this trimesh
Definition: trimeshloader.h:129
TRIMESH_LOADER_API void tlTrimeshCreateNormals(tlTrimesh *trimesh)
struct tl3dsState tl3dsState
Structure describing the parsing state.
Definition: tl3ds.h:47
#define TRIMESH_LOADER_API
Definition: trimeshloader.h:40
TRIMESH_LOADER_API tlTrimesh * tlLoadOBJ(const char *filename, unsigned int vertex_format)
Load a OBJ file in an tlTrimesh structure.
char * name
Name of the Material.
Definition: trimeshloader.h:77
TRIMESH_LOADER_API tlTrimesh * tlLoadTrimesh(const char *filename, unsigned int vertex_format)
Load an 3DS or OBJ file in an tlTrimesh structure.
unsigned int face_count
number of faces
Definition: trimeshloader.h:120
tlMaterialReference * material_references
list of references to materials in this trimesh
Definition: trimeshloader.h:135
TRIMESH_LOADER_API void tlDeleteTrimesh(tlTrimesh *trimesh)
Delete an previously loaded tlTrimesh object.
unsigned int face_count
Face count.
Definition: trimeshloader.h:97
unsigned int face_index
First face in the index list.
Definition: trimeshloader.h:57
Structure describing the reference to a Material.
Definition: trimeshloader.h:88
Trimeshloader 3DS parser public header file.
TRIMESH_LOADER_API tlTrimesh * tlCreateTrimeshFrom3dsState(tl3dsState *state, unsigned int vertex_format)
Create an a tlTrimesh structure from a tl3dsState.
unsigned int material_reference_count
number of references to materials
Definition: trimeshloader.h:138
unsigned int vertex_format
format of the vertices
Definition: trimeshloader.h:111
char * name
Name of the Material.
Definition: trimeshloader.h:91
unsigned int face_count
Face count.
Definition: trimeshloader.h:60