@@ -97,7 +97,7 @@ TinyObjLoader is successfully used in ...
97
97
98
98
* [ ] Fix obj_sticker example.
99
99
* [ ] More unit test codes.
100
- * [ ] Texture options
100
+ * [x ] Texture options
101
101
* [ ] Normal vector generation
102
102
* [ ] Support smoothing groups
103
103
@@ -107,10 +107,76 @@ Licensed under MIT license.
107
107
108
108
## Usage
109
109
110
+ ### Data format
111
+
110
112
` attrib_t ` contains single and linear array of vertex data(position, normal and texcoord).
113
+
114
+ ```
115
+ attrib_t::vertices => 3 floats per vertex
116
+
117
+ v[0] v[1] v[2] v[3] v[n-1]
118
+ +-----------+-----------+-----------+-----------+ +-----------+
119
+ | x | y | z | x | y | z | x | y | z | x | y | z | .... | x | y | z |
120
+ +-----------+-----------+-----------+-----------+ +-----------+
121
+
122
+ attrib_t::normals => 3 floats per vertex
123
+
124
+ n[0] n[1] n[2] n[3] n[n-1]
125
+ +-----------+-----------+-----------+-----------+ +-----------+
126
+ | x | y | z | x | y | z | x | y | z | x | y | z | .... | x | y | z |
127
+ +-----------+-----------+-----------+-----------+ +-----------+
128
+
129
+ attrib_t::texcoords => 2 floats per vertex
130
+
131
+ t[0] t[1] t[2] t[3] t[n-1]
132
+ +-----------+-----------+-----------+-----------+ +-----------+
133
+ | u | v | u | v | u | v | u | v | .... | u | v |
134
+ +-----------+-----------+-----------+-----------+ +-----------+
135
+
136
+ ```
137
+
111
138
Each ` shape_t ` does not contain vertex data but contains array index to ` attrib_t ` .
112
139
See ` loader_example.cc ` for more details.
113
140
141
+
142
+ ```
143
+
144
+ mesh_t::indices => array of vertex indices.
145
+
146
+ +----+----+----+----+----+----+----+----+----+----+ +--------+
147
+ | i0 | i1 | i2 | i3 | i4 | i5 | i6 | i7 | i8 | i9 | ... | i(n-1) |
148
+ +----+----+----+----+----+----+----+----+----+----+ +--------+
149
+
150
+ Each index has an array index to attrib_t::vertices, attrib_t::normals and attrib_t::texcoords.
151
+
152
+ mesh_t::num_face_vertices => array of the number of vertices per face(e.g. 3 = triangle, 4 = quad , 5 or more = N-gons).
153
+
154
+
155
+ +---+---+---+ +---+
156
+ | 3 | 4 | 3 | ...... | 3 |
157
+ +---+---+---+ +---+
158
+ | | | |
159
+ | | | +-----------------------------------------+
160
+ | | | |
161
+ | | +------------------------------+ |
162
+ | | | |
163
+ | +------------------+ | |
164
+ | | | |
165
+ |/ |/ |/ |/
166
+
167
+ mesh_t::indices
168
+
169
+ | face[0] | face[1] | face[2] | | face[n-1] |
170
+ +----+----+----+----+----+----+----+----+----+----+ +--------+--------+--------+
171
+ | i0 | i1 | i2 | i3 | i4 | i5 | i6 | i7 | i8 | i9 | ... | i(n-3) | i(n-2) | i(n-1) |
172
+ +----+----+----+----+----+----+----+----+----+----+ +--------+--------+--------+
173
+
174
+ ```
175
+
176
+ Note that when ` triangulate ` flas is true in ` tinyobj::LoadObj() ` argument, ` num_face_vertices ` are all filled with 3(triangle).
177
+
178
+ #### Example code
179
+
114
180
``` c++
115
181
#define TINYOBJLOADER_IMPLEMENTATION // define this in only * one* .cc
116
182
#include "tiny_obj_loader.h"
0 commit comments