Test the interface
Former-commit-id: 1d6faf7c33382998c671c6ecc0d8d9f963660522
This commit is contained in:
parent
3d19ed6111
commit
254366314f
@ -132,7 +132,6 @@ fn make_cube() -> (Vec<Face>, Vec<Vertex>) {
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let (faces, vertices) = make_cube();
|
let (faces, vertices) = make_cube();
|
||||||
|
|
||||||
let vertex = |face, vert| {
|
let vertex = |face, vert| {
|
||||||
let vs: &[u32; 3] = &faces[face];
|
let vs: &[u32; 3] = &faces[face];
|
||||||
&vertices[vs[vert] as usize]
|
&vertices[vs[vert] as usize]
|
||||||
@ -163,5 +162,6 @@ fn main() {
|
|||||||
);
|
);
|
||||||
assert_eq!(true, ret);
|
assert_eq!(true, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("{:#?}", new_vertices);
|
println!("{:#?}", new_vertices);
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@ -1,185 +0,0 @@
|
|||||||
{
|
|
||||||
"accessors": [
|
|
||||||
{
|
|
||||||
"bufferView": 0,
|
|
||||||
"componentType": 5126,
|
|
||||||
"count": 406,
|
|
||||||
"type": "VEC2",
|
|
||||||
"max": [
|
|
||||||
0.9824978,
|
|
||||||
-0.00462793233
|
|
||||||
],
|
|
||||||
"min": [
|
|
||||||
0.00678020436,
|
|
||||||
-0.997018039
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"bufferView": 1,
|
|
||||||
"componentType": 5126,
|
|
||||||
"count": 406,
|
|
||||||
"type": "VEC3",
|
|
||||||
"max": [
|
|
||||||
0.9959669,
|
|
||||||
0.974968433,
|
|
||||||
0.9986338
|
|
||||||
],
|
|
||||||
"min": [
|
|
||||||
-0.995177031,
|
|
||||||
-0.9995665,
|
|
||||||
-0.9988549
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"bufferView": 2,
|
|
||||||
"componentType": 5126,
|
|
||||||
"count": 406,
|
|
||||||
"type": "VEC4",
|
|
||||||
"max": [
|
|
||||||
0.929839253,
|
|
||||||
0.998867154,
|
|
||||||
0.9930595,
|
|
||||||
1.0
|
|
||||||
],
|
|
||||||
"min": [
|
|
||||||
-0.999970555,
|
|
||||||
-0.999693751,
|
|
||||||
-0.995075762,
|
|
||||||
1.0
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"bufferView": 3,
|
|
||||||
"componentType": 5126,
|
|
||||||
"count": 406,
|
|
||||||
"type": "VEC3",
|
|
||||||
"max": [
|
|
||||||
0.02128091,
|
|
||||||
0.06284806,
|
|
||||||
0.0138090011
|
|
||||||
],
|
|
||||||
"min": [
|
|
||||||
-0.02128091,
|
|
||||||
-4.773855E-05,
|
|
||||||
-0.013809
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"bufferView": 4,
|
|
||||||
"componentType": 5123,
|
|
||||||
"count": 2046,
|
|
||||||
"type": "SCALAR",
|
|
||||||
"max": [
|
|
||||||
405
|
|
||||||
],
|
|
||||||
"min": [
|
|
||||||
0
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"asset": {
|
|
||||||
"generator": "glTF Tools for Unity",
|
|
||||||
"version": "2.0"
|
|
||||||
},
|
|
||||||
"bufferViews": [
|
|
||||||
{
|
|
||||||
"buffer": 0,
|
|
||||||
"byteLength": 3248
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"buffer": 0,
|
|
||||||
"byteOffset": 3248,
|
|
||||||
"byteLength": 4872
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"buffer": 0,
|
|
||||||
"byteOffset": 8120,
|
|
||||||
"byteLength": 6496
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"buffer": 0,
|
|
||||||
"byteOffset": 14616,
|
|
||||||
"byteLength": 4872
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"buffer": 0,
|
|
||||||
"byteOffset": 19488,
|
|
||||||
"byteLength": 4092
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"buffers": [
|
|
||||||
{
|
|
||||||
"uri": "Avocado.bin",
|
|
||||||
"byteLength": 23580
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"images": [
|
|
||||||
{
|
|
||||||
"uri": "Avocado_baseColor.png"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"uri": "Avocado_roughnessMetallic.png"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"uri": "Avocado_normal.png"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"meshes": [
|
|
||||||
{
|
|
||||||
"primitives": [
|
|
||||||
{
|
|
||||||
"attributes": {
|
|
||||||
"TEXCOORD_0": 0,
|
|
||||||
"NORMAL": 1,
|
|
||||||
"TANGENT": 2,
|
|
||||||
"POSITION": 3
|
|
||||||
},
|
|
||||||
"indices": 4,
|
|
||||||
"material": 0
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "Avocado"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"materials": [
|
|
||||||
{
|
|
||||||
"pbrMetallicRoughness": {
|
|
||||||
"baseColorTexture": {
|
|
||||||
"index": 0
|
|
||||||
},
|
|
||||||
"metallicRoughnessTexture": {
|
|
||||||
"index": 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"normalTexture": {
|
|
||||||
"index": 2
|
|
||||||
},
|
|
||||||
"name": "2256_Avocado_d"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"nodes": [
|
|
||||||
{
|
|
||||||
"mesh": 0,
|
|
||||||
"name": "Avocado"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"scene": 0,
|
|
||||||
"scenes": [
|
|
||||||
{
|
|
||||||
"nodes": [
|
|
||||||
0
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"textures": [
|
|
||||||
{
|
|
||||||
"source": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": 2
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@ -1 +0,0 @@
|
|||||||
d785dd82e0c6344c7b8ea21b3bf5836fdaf05762
|
|
||||||
File diff suppressed because it is too large
Load Diff
@ -1 +0,0 @@
|
|||||||
d5f560b94a3a8f04d6f8b6e9513d7dcfad9eaca3
|
|
||||||
@ -1 +0,0 @@
|
|||||||
6f3a8b2309c64a078456423015adb8095bb8a159
|
|
||||||
@ -1 +0,0 @@
|
|||||||
73f90d59794e139e876b34d48ee1f29671bfdba2
|
|
||||||
@ -1 +0,0 @@
|
|||||||
b83cff933c3502a5f176780e8dc7a437e5449f21
|
|
||||||
144
test-data/compare-with-generate-example
Normal file
144
test-data/compare-with-generate-example
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
0: { v: [0.500000, -0.500000, 0.500000], vn: [0.577350, -0.577350, 0.577350], vt: [0.000000, 0.000000], vx: [0.408248, 0.816497, 0.408248, -1.000000] }
|
||||||
|
1: { v: [0.500000, -0.500000, 0.500000], vn: [0.577350, -0.577350, 0.577350], vt: [0.000000, 0.000000], vx: [0.408248, 0.816497, 0.408248, -1.000000] }
|
||||||
|
2: { v: [0.500000, -0.500000, -0.500000], vn: [0.577350, -0.577350, -0.577350], vt: [0.000000, 1.000000], vx: [0.408248, 0.816497, -0.408248, -1.000000] }
|
||||||
|
3: { v: [0.500000, -0.500000, -0.500000], vn: [0.577350, -0.577350, -0.577350], vt: [0.000000, 1.000000], vx: [0.408248, 0.816497, -0.408248, -1.000000] }
|
||||||
|
4: { v: [0.500000, 0.000000, 0.000000], vn: [1.000000, 0.000000, 0.000000], vt: [0.500000, 0.500000], vx: [0.000000, 1.000000, 0.000000, -1.000000] }
|
||||||
|
5: { v: [0.500000, 0.000000, 0.000000], vn: [1.000000, 0.000000, 0.000000], vt: [0.500000, 0.500000], vx: [0.000000, 1.000000, 0.000000, -1.000000] }
|
||||||
|
6: { v: [0.500000, -0.500000, -0.500000], vn: [0.577350, -0.577350, -0.577350], vt: [0.000000, 1.000000], vx: [0.408248, 0.816497, -0.408248, -1.000000] }
|
||||||
|
7: { v: [0.500000, -0.500000, -0.500000], vn: [0.577350, -0.577350, -0.577350], vt: [0.000000, 1.000000], vx: [0.408248, 0.816497, -0.408248, -1.000000] }
|
||||||
|
8: { v: [0.500000, 0.500000, -0.500000], vn: [0.577350, 0.577350, -0.577350], vt: [1.000000, 1.000000], vx: [-0.408248, 0.816497, 0.408248, -1.000000] }
|
||||||
|
9: { v: [0.500000, 0.500000, -0.500000], vn: [0.577350, 0.577350, -0.577350], vt: [1.000000, 1.000000], vx: [-0.408248, 0.816497, 0.408248, -1.000000] }
|
||||||
|
10: { v: [0.500000, 0.000000, 0.000000], vn: [1.000000, 0.000000, 0.000000], vt: [0.500000, 0.500000], vx: [0.000000, 1.000000, 0.000000, -1.000000] }
|
||||||
|
11: { v: [0.500000, 0.000000, 0.000000], vn: [1.000000, 0.000000, 0.000000], vt: [0.500000, 0.500000], vx: [0.000000, 1.000000, 0.000000, -1.000000] }
|
||||||
|
12: { v: [0.500000, 0.500000, -0.500000], vn: [0.577350, 0.577350, -0.577350], vt: [1.000000, 1.000000], vx: [-0.408248, 0.816497, 0.408248, -1.000000] }
|
||||||
|
13: { v: [0.500000, 0.500000, -0.500000], vn: [0.577350, 0.577350, -0.577350], vt: [1.000000, 1.000000], vx: [-0.408248, 0.816497, 0.408248, -1.000000] }
|
||||||
|
14: { v: [0.500000, 0.500000, 0.500000], vn: [0.577350, 0.577350, 0.577350], vt: [1.000000, 0.000000], vx: [-0.408248, 0.816497, -0.408248, -1.000000] }
|
||||||
|
15: { v: [0.500000, 0.500000, 0.500000], vn: [0.577350, 0.577350, 0.577350], vt: [1.000000, 0.000000], vx: [-0.408248, 0.816497, -0.408248, -1.000000] }
|
||||||
|
16: { v: [0.500000, 0.000000, 0.000000], vn: [1.000000, 0.000000, 0.000000], vt: [0.500000, 0.500000], vx: [0.000000, 1.000000, 0.000000, -1.000000] }
|
||||||
|
17: { v: [0.500000, 0.000000, 0.000000], vn: [1.000000, 0.000000, 0.000000], vt: [0.500000, 0.500000], vx: [0.000000, 1.000000, 0.000000, -1.000000] }
|
||||||
|
18: { v: [0.500000, 0.500000, 0.500000], vn: [0.577350, 0.577350, 0.577350], vt: [1.000000, 0.000000], vx: [-0.408248, 0.816497, -0.408248, -1.000000] }
|
||||||
|
19: { v: [0.500000, 0.500000, 0.500000], vn: [0.577350, 0.577350, 0.577350], vt: [1.000000, 0.000000], vx: [-0.408248, 0.816497, -0.408248, -1.000000] }
|
||||||
|
20: { v: [0.500000, -0.500000, 0.500000], vn: [0.577350, -0.577350, 0.577350], vt: [0.000000, 0.000000], vx: [0.408248, 0.816497, 0.408248, -1.000000] }
|
||||||
|
21: { v: [0.500000, -0.500000, 0.500000], vn: [0.577350, -0.577350, 0.577350], vt: [0.000000, 0.000000], vx: [0.408248, 0.816497, 0.408248, -1.000000] }
|
||||||
|
22: { v: [0.500000, 0.000000, 0.000000], vn: [1.000000, 0.000000, 0.000000], vt: [0.500000, 0.500000], vx: [0.000000, 1.000000, 0.000000, -1.000000] }
|
||||||
|
23: { v: [0.500000, 0.000000, 0.000000], vn: [1.000000, 0.000000, 0.000000], vt: [0.500000, 0.500000], vx: [0.000000, 1.000000, 0.000000, -1.000000] }
|
||||||
|
24: { v: [-0.500000, 0.500000, 0.500000], vn: [-0.577350, 0.577350, 0.577350], vt: [1.000000, 0.000000], vx: [0.408248, 0.816497, -0.408248, 1.000000] }
|
||||||
|
25: { v: [-0.500000, 0.500000, 0.500000], vn: [-0.577350, 0.577350, 0.577350], vt: [1.000000, 0.000000], vx: [0.408248, 0.816497, -0.408248, 1.000000] }
|
||||||
|
26: { v: [-0.500000, 0.500000, -0.500000], vn: [-0.577350, 0.577350, -0.577350], vt: [1.000000, 1.000000], vx: [0.408248, 0.816497, 0.408248, 1.000000] }
|
||||||
|
27: { v: [-0.500000, 0.500000, -0.500000], vn: [-0.577350, 0.577350, -0.577350], vt: [1.000000, 1.000000], vx: [0.408248, 0.816497, 0.408248, 1.000000] }
|
||||||
|
28: { v: [-0.500000, 0.000000, 0.000000], vn: [-1.000000, 0.000000, 0.000000], vt: [0.500000, 0.500000], vx: [0.000000, 1.000000, 0.000000, 1.000000] }
|
||||||
|
29: { v: [-0.500000, 0.000000, 0.000000], vn: [-1.000000, 0.000000, 0.000000], vt: [0.500000, 0.500000], vx: [0.000000, 1.000000, 0.000000, 1.000000] }
|
||||||
|
30: { v: [-0.500000, 0.500000, -0.500000], vn: [-0.577350, 0.577350, -0.577350], vt: [1.000000, 1.000000], vx: [0.408248, 0.816497, 0.408248, 1.000000] }
|
||||||
|
31: { v: [-0.500000, 0.500000, -0.500000], vn: [-0.577350, 0.577350, -0.577350], vt: [1.000000, 1.000000], vx: [0.408248, 0.816497, 0.408248, 1.000000] }
|
||||||
|
32: { v: [-0.500000, -0.500000, -0.500000], vn: [-0.577350, -0.577350, -0.577350], vt: [0.000000, 1.000000], vx: [-0.408248, 0.816497, -0.408248, 1.000000] }
|
||||||
|
33: { v: [-0.500000, -0.500000, -0.500000], vn: [-0.577350, -0.577350, -0.577350], vt: [0.000000, 1.000000], vx: [-0.408248, 0.816497, -0.408248, 1.000000] }
|
||||||
|
34: { v: [-0.500000, 0.000000, 0.000000], vn: [-1.000000, 0.000000, 0.000000], vt: [0.500000, 0.500000], vx: [0.000000, 1.000000, 0.000000, 1.000000] }
|
||||||
|
35: { v: [-0.500000, 0.000000, 0.000000], vn: [-1.000000, 0.000000, 0.000000], vt: [0.500000, 0.500000], vx: [0.000000, 1.000000, 0.000000, 1.000000] }
|
||||||
|
36: { v: [-0.500000, -0.500000, -0.500000], vn: [-0.577350, -0.577350, -0.577350], vt: [0.000000, 1.000000], vx: [-0.408248, 0.816497, -0.408248, 1.000000] }
|
||||||
|
37: { v: [-0.500000, -0.500000, -0.500000], vn: [-0.577350, -0.577350, -0.577350], vt: [0.000000, 1.000000], vx: [-0.408248, 0.816497, -0.408248, 1.000000] }
|
||||||
|
38: { v: [-0.500000, -0.500000, 0.500000], vn: [-0.577350, -0.577350, 0.577350], vt: [0.000000, 0.000000], vx: [-0.408248, 0.816497, 0.408248, 1.000000] }
|
||||||
|
39: { v: [-0.500000, -0.500000, 0.500000], vn: [-0.577350, -0.577350, 0.577350], vt: [0.000000, 0.000000], vx: [-0.408248, 0.816497, 0.408248, 1.000000] }
|
||||||
|
40: { v: [-0.500000, 0.000000, 0.000000], vn: [-1.000000, 0.000000, 0.000000], vt: [0.500000, 0.500000], vx: [0.000000, 1.000000, 0.000000, 1.000000] }
|
||||||
|
41: { v: [-0.500000, 0.000000, 0.000000], vn: [-1.000000, 0.000000, 0.000000], vt: [0.500000, 0.500000], vx: [0.000000, 1.000000, 0.000000, 1.000000] }
|
||||||
|
42: { v: [-0.500000, -0.500000, 0.500000], vn: [-0.577350, -0.577350, 0.577350], vt: [0.000000, 0.000000], vx: [-0.408248, 0.816497, 0.408248, 1.000000] }
|
||||||
|
43: { v: [-0.500000, -0.500000, 0.500000], vn: [-0.577350, -0.577350, 0.577350], vt: [0.000000, 0.000000], vx: [-0.408248, 0.816497, 0.408248, 1.000000] }
|
||||||
|
44: { v: [-0.500000, 0.500000, 0.500000], vn: [-0.577350, 0.577350, 0.577350], vt: [1.000000, 0.000000], vx: [0.408248, 0.816497, -0.408248, 1.000000] }
|
||||||
|
45: { v: [-0.500000, 0.500000, 0.500000], vn: [-0.577350, 0.577350, 0.577350], vt: [1.000000, 0.000000], vx: [0.408248, 0.816497, -0.408248, 1.000000] }
|
||||||
|
46: { v: [-0.500000, 0.000000, 0.000000], vn: [-1.000000, 0.000000, 0.000000], vt: [0.500000, 0.500000], vx: [0.000000, 1.000000, 0.000000, 1.000000] }
|
||||||
|
47: { v: [-0.500000, 0.000000, 0.000000], vn: [-1.000000, 0.000000, 0.000000], vt: [0.500000, 0.500000], vx: [0.000000, 1.000000, 0.000000, 1.000000] }
|
||||||
|
48: { v: [0.500000, 0.500000, 0.500000], vn: [0.577350, 0.577350, 0.577350], vt: [0.000000, 0.000000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
49: { v: [0.500000, 0.500000, 0.500000], vn: [0.577350, 0.577350, 0.577350], vt: [0.000000, 0.000000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
50: { v: [0.500000, 0.500000, -0.500000], vn: [0.577350, 0.577350, -0.577350], vt: [0.000000, 1.000000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
51: { v: [0.500000, 0.500000, -0.500000], vn: [0.577350, 0.577350, -0.577350], vt: [0.000000, 1.000000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
52: { v: [0.000000, 0.500000, 0.000000], vn: [0.000000, 1.000000, 0.000000], vt: [0.000000, 0.500000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
53: { v: [0.000000, 0.500000, 0.000000], vn: [0.000000, 1.000000, 0.000000], vt: [0.000000, 0.500000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
54: { v: [0.500000, 0.500000, -0.500000], vn: [0.577350, 0.577350, -0.577350], vt: [0.000000, 1.000000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
55: { v: [0.500000, 0.500000, -0.500000], vn: [0.577350, 0.577350, -0.577350], vt: [0.000000, 1.000000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
56: { v: [-0.500000, 0.500000, -0.500000], vn: [-0.577350, 0.577350, -0.577350], vt: [0.000000, 1.000000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
57: { v: [-0.500000, 0.500000, -0.500000], vn: [-0.577350, 0.577350, -0.577350], vt: [0.000000, 1.000000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
58: { v: [0.000000, 0.500000, 0.000000], vn: [0.000000, 1.000000, 0.000000], vt: [0.000000, 0.500000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
59: { v: [0.000000, 0.500000, 0.000000], vn: [0.000000, 1.000000, 0.000000], vt: [0.000000, 0.500000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
60: { v: [-0.500000, 0.500000, -0.500000], vn: [-0.577350, 0.577350, -0.577350], vt: [0.000000, 1.000000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
61: { v: [-0.500000, 0.500000, -0.500000], vn: [-0.577350, 0.577350, -0.577350], vt: [0.000000, 1.000000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
62: { v: [-0.500000, 0.500000, 0.500000], vn: [-0.577350, 0.577350, 0.577350], vt: [0.000000, 0.000000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
63: { v: [-0.500000, 0.500000, 0.500000], vn: [-0.577350, 0.577350, 0.577350], vt: [0.000000, 0.000000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
64: { v: [0.000000, 0.500000, 0.000000], vn: [0.000000, 1.000000, 0.000000], vt: [0.000000, 0.500000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
65: { v: [0.000000, 0.500000, 0.000000], vn: [0.000000, 1.000000, 0.000000], vt: [0.000000, 0.500000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
66: { v: [-0.500000, 0.500000, 0.500000], vn: [-0.577350, 0.577350, 0.577350], vt: [0.000000, 0.000000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
67: { v: [-0.500000, 0.500000, 0.500000], vn: [-0.577350, 0.577350, 0.577350], vt: [0.000000, 0.000000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
68: { v: [0.500000, 0.500000, 0.500000], vn: [0.577350, 0.577350, 0.577350], vt: [0.000000, 0.000000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
69: { v: [0.500000, 0.500000, 0.500000], vn: [0.577350, 0.577350, 0.577350], vt: [0.000000, 0.000000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
70: { v: [0.000000, 0.500000, 0.000000], vn: [0.000000, 1.000000, 0.000000], vt: [0.000000, 0.500000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
71: { v: [0.000000, 0.500000, 0.000000], vn: [0.000000, 1.000000, 0.000000], vt: [0.000000, 0.500000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
72: { v: [-0.500000, -0.500000, 0.500000], vn: [-0.577350, -0.577350, 0.577350], vt: [0.000000, 0.000000], vx: [-0.408248, 0.816497, 0.408248, 1.000000] }
|
||||||
|
73: { v: [-0.500000, -0.500000, 0.500000], vn: [-0.577350, -0.577350, 0.577350], vt: [0.000000, 0.000000], vx: [-0.408248, 0.816497, 0.408248, 1.000000] }
|
||||||
|
74: { v: [-0.500000, -0.500000, -0.500000], vn: [-0.577350, -0.577350, -0.577350], vt: [0.000000, 1.000000], vx: [-0.408248, 0.816497, -0.408248, 1.000000] }
|
||||||
|
75: { v: [-0.500000, -0.500000, -0.500000], vn: [-0.577350, -0.577350, -0.577350], vt: [0.000000, 1.000000], vx: [-0.408248, 0.816497, -0.408248, 1.000000] }
|
||||||
|
76: { v: [0.000000, -0.500000, 0.000000], vn: [0.000000, -1.000000, 0.000000], vt: [0.000000, 0.500000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
77: { v: [0.000000, -0.500000, 0.000000], vn: [0.000000, -1.000000, 0.000000], vt: [0.000000, 0.500000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
78: { v: [-0.500000, -0.500000, -0.500000], vn: [-0.577350, -0.577350, -0.577350], vt: [0.000000, 1.000000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
79: { v: [-0.500000, -0.500000, -0.500000], vn: [-0.577350, -0.577350, -0.577350], vt: [0.000000, 1.000000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
80: { v: [0.500000, -0.500000, -0.500000], vn: [0.577350, -0.577350, -0.577350], vt: [0.000000, 1.000000], vx: [0.408248, 0.816497, -0.408248, -1.000000] }
|
||||||
|
81: { v: [0.500000, -0.500000, -0.500000], vn: [0.577350, -0.577350, -0.577350], vt: [0.000000, 1.000000], vx: [0.408248, 0.816497, -0.408248, -1.000000] }
|
||||||
|
82: { v: [0.000000, -0.500000, 0.000000], vn: [0.000000, -1.000000, 0.000000], vt: [0.000000, 0.500000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
83: { v: [0.000000, -0.500000, 0.000000], vn: [0.000000, -1.000000, 0.000000], vt: [0.000000, 0.500000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
84: { v: [0.500000, -0.500000, -0.500000], vn: [0.577350, -0.577350, -0.577350], vt: [0.000000, 1.000000], vx: [0.408248, 0.816497, -0.408248, -1.000000] }
|
||||||
|
85: { v: [0.500000, -0.500000, -0.500000], vn: [0.577350, -0.577350, -0.577350], vt: [0.000000, 1.000000], vx: [0.408248, 0.816497, -0.408248, -1.000000] }
|
||||||
|
86: { v: [0.500000, -0.500000, 0.500000], vn: [0.577350, -0.577350, 0.577350], vt: [0.000000, 0.000000], vx: [0.408248, 0.816497, 0.408248, -1.000000] }
|
||||||
|
87: { v: [0.500000, -0.500000, 0.500000], vn: [0.577350, -0.577350, 0.577350], vt: [0.000000, 0.000000], vx: [0.408248, 0.816497, 0.408248, -1.000000] }
|
||||||
|
88: { v: [0.000000, -0.500000, 0.000000], vn: [0.000000, -1.000000, 0.000000], vt: [0.000000, 0.500000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
89: { v: [0.000000, -0.500000, 0.000000], vn: [0.000000, -1.000000, 0.000000], vt: [0.000000, 0.500000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
90: { v: [0.500000, -0.500000, 0.500000], vn: [0.577350, -0.577350, 0.577350], vt: [0.000000, 0.000000], vx: [0.408248, 0.816497, 0.408248, -1.000000] }
|
||||||
|
91: { v: [0.500000, -0.500000, 0.500000], vn: [0.577350, -0.577350, 0.577350], vt: [0.000000, 0.000000], vx: [0.408248, 0.816497, 0.408248, -1.000000] }
|
||||||
|
92: { v: [-0.500000, -0.500000, 0.500000], vn: [-0.577350, -0.577350, 0.577350], vt: [0.000000, 0.000000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
93: { v: [-0.500000, -0.500000, 0.500000], vn: [-0.577350, -0.577350, 0.577350], vt: [0.000000, 0.000000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
94: { v: [0.000000, -0.500000, 0.000000], vn: [0.000000, -1.000000, 0.000000], vt: [0.000000, 0.500000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
95: { v: [0.000000, -0.500000, 0.000000], vn: [0.000000, -1.000000, 0.000000], vt: [0.000000, 0.500000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
96: { v: [-0.500000, 0.500000, 0.500000], vn: [-0.577350, 0.577350, 0.577350], vt: [0.000000, 0.000000], vx: [0.816497, 0.408248, 0.408248, -1.000000] }
|
||||||
|
97: { v: [-0.500000, 0.500000, 0.500000], vn: [-0.577350, 0.577350, 0.577350], vt: [0.000000, 0.000000], vx: [0.816497, 0.408248, 0.408248, -1.000000] }
|
||||||
|
98: { v: [-0.500000, -0.500000, 0.500000], vn: [-0.577350, -0.577350, 0.577350], vt: [0.000000, 1.000000], vx: [0.816497, -0.408248, 0.408248, -1.000000] }
|
||||||
|
99: { v: [-0.500000, -0.500000, 0.500000], vn: [-0.577350, -0.577350, 0.577350], vt: [0.000000, 1.000000], vx: [0.816497, -0.408248, 0.408248, -1.000000] }
|
||||||
|
100: { v: [0.000000, 0.000000, 0.500000], vn: [0.000000, 0.000000, 1.000000], vt: [0.500000, 0.500000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
101: { v: [0.000000, 0.000000, 0.500000], vn: [0.000000, 0.000000, 1.000000], vt: [0.500000, 0.500000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
102: { v: [-0.500000, -0.500000, 0.500000], vn: [-0.577350, -0.577350, 0.577350], vt: [0.000000, 1.000000], vx: [0.816497, -0.408248, 0.408248, -1.000000] }
|
||||||
|
103: { v: [-0.500000, -0.500000, 0.500000], vn: [-0.577350, -0.577350, 0.577350], vt: [0.000000, 1.000000], vx: [0.816497, -0.408248, 0.408248, -1.000000] }
|
||||||
|
104: { v: [0.500000, -0.500000, 0.500000], vn: [0.577350, -0.577350, 0.577350], vt: [1.000000, 1.000000], vx: [0.816497, 0.408248, -0.408248, -1.000000] }
|
||||||
|
105: { v: [0.500000, -0.500000, 0.500000], vn: [0.577350, -0.577350, 0.577350], vt: [1.000000, 1.000000], vx: [0.816497, 0.408248, -0.408248, -1.000000] }
|
||||||
|
106: { v: [0.000000, 0.000000, 0.500000], vn: [0.000000, 0.000000, 1.000000], vt: [0.500000, 0.500000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
107: { v: [0.000000, 0.000000, 0.500000], vn: [0.000000, 0.000000, 1.000000], vt: [0.500000, 0.500000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
108: { v: [0.500000, -0.500000, 0.500000], vn: [0.577350, -0.577350, 0.577350], vt: [1.000000, 1.000000], vx: [0.816497, 0.408248, -0.408248, -1.000000] }
|
||||||
|
109: { v: [0.500000, -0.500000, 0.500000], vn: [0.577350, -0.577350, 0.577350], vt: [1.000000, 1.000000], vx: [0.816497, 0.408248, -0.408248, -1.000000] }
|
||||||
|
110: { v: [0.500000, 0.500000, 0.500000], vn: [0.577350, 0.577350, 0.577350], vt: [1.000000, 0.000000], vx: [0.816497, -0.408248, -0.408248, -1.000000] }
|
||||||
|
111: { v: [0.500000, 0.500000, 0.500000], vn: [0.577350, 0.577350, 0.577350], vt: [1.000000, 0.000000], vx: [0.816497, -0.408248, -0.408248, -1.000000] }
|
||||||
|
112: { v: [0.000000, 0.000000, 0.500000], vn: [0.000000, 0.000000, 1.000000], vt: [0.500000, 0.500000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
113: { v: [0.000000, 0.000000, 0.500000], vn: [0.000000, 0.000000, 1.000000], vt: [0.500000, 0.500000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
114: { v: [0.500000, 0.500000, 0.500000], vn: [0.577350, 0.577350, 0.577350], vt: [1.000000, 0.000000], vx: [0.816497, -0.408248, -0.408248, -1.000000] }
|
||||||
|
115: { v: [0.500000, 0.500000, 0.500000], vn: [0.577350, 0.577350, 0.577350], vt: [1.000000, 0.000000], vx: [0.816497, -0.408248, -0.408248, -1.000000] }
|
||||||
|
116: { v: [-0.500000, 0.500000, 0.500000], vn: [-0.577350, 0.577350, 0.577350], vt: [0.000000, 0.000000], vx: [0.816497, 0.408248, 0.408248, -1.000000] }
|
||||||
|
117: { v: [-0.500000, 0.500000, 0.500000], vn: [-0.577350, 0.577350, 0.577350], vt: [0.000000, 0.000000], vx: [0.816497, 0.408248, 0.408248, -1.000000] }
|
||||||
|
118: { v: [0.000000, 0.000000, 0.500000], vn: [0.000000, 0.000000, 1.000000], vt: [0.500000, 0.500000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
119: { v: [0.000000, 0.000000, 0.500000], vn: [0.000000, 0.000000, 1.000000], vt: [0.500000, 0.500000], vx: [1.000000, 0.000000, 0.000000, -1.000000] }
|
||||||
|
120: { v: [0.500000, 0.500000, -0.500000], vn: [0.577350, 0.577350, -0.577350], vt: [1.000000, 0.000000], vx: [0.816497, -0.408248, 0.408248, 1.000000] }
|
||||||
|
121: { v: [0.500000, 0.500000, -0.500000], vn: [0.577350, 0.577350, -0.577350], vt: [1.000000, 0.000000], vx: [0.816497, -0.408248, 0.408248, 1.000000] }
|
||||||
|
122: { v: [0.500000, -0.500000, -0.500000], vn: [0.577350, -0.577350, -0.577350], vt: [1.000000, 1.000000], vx: [0.816497, 0.408248, 0.408248, 1.000000] }
|
||||||
|
123: { v: [0.500000, -0.500000, -0.500000], vn: [0.577350, -0.577350, -0.577350], vt: [1.000000, 1.000000], vx: [0.816497, 0.408248, 0.408248, 1.000000] }
|
||||||
|
124: { v: [0.000000, 0.000000, -0.500000], vn: [0.000000, 0.000000, -1.000000], vt: [0.500000, 0.500000], vx: [1.000000, 0.000000, 0.000000, 1.000000] }
|
||||||
|
125: { v: [0.000000, 0.000000, -0.500000], vn: [0.000000, 0.000000, -1.000000], vt: [0.500000, 0.500000], vx: [1.000000, 0.000000, 0.000000, 1.000000] }
|
||||||
|
126: { v: [0.500000, -0.500000, -0.500000], vn: [0.577350, -0.577350, -0.577350], vt: [1.000000, 1.000000], vx: [0.816497, 0.408248, 0.408248, 1.000000] }
|
||||||
|
127: { v: [0.500000, -0.500000, -0.500000], vn: [0.577350, -0.577350, -0.577350], vt: [1.000000, 1.000000], vx: [0.816497, 0.408248, 0.408248, 1.000000] }
|
||||||
|
128: { v: [-0.500000, -0.500000, -0.500000], vn: [-0.577350, -0.577350, -0.577350], vt: [0.000000, 1.000000], vx: [0.816497, -0.408248, -0.408248, 1.000000] }
|
||||||
|
129: { v: [-0.500000, -0.500000, -0.500000], vn: [-0.577350, -0.577350, -0.577350], vt: [0.000000, 1.000000], vx: [0.816497, -0.408248, -0.408248, 1.000000] }
|
||||||
|
130: { v: [0.000000, 0.000000, -0.500000], vn: [0.000000, 0.000000, -1.000000], vt: [0.500000, 0.500000], vx: [1.000000, 0.000000, 0.000000, 1.000000] }
|
||||||
|
131: { v: [0.000000, 0.000000, -0.500000], vn: [0.000000, 0.000000, -1.000000], vt: [0.500000, 0.500000], vx: [1.000000, 0.000000, 0.000000, 1.000000] }
|
||||||
|
132: { v: [-0.500000, -0.500000, -0.500000], vn: [-0.577350, -0.577350, -0.577350], vt: [0.000000, 1.000000], vx: [0.816497, -0.408248, -0.408248, 1.000000] }
|
||||||
|
133: { v: [-0.500000, -0.500000, -0.500000], vn: [-0.577350, -0.577350, -0.577350], vt: [0.000000, 1.000000], vx: [0.816497, -0.408248, -0.408248, 1.000000] }
|
||||||
|
134: { v: [-0.500000, 0.500000, -0.500000], vn: [-0.577350, 0.577350, -0.577350], vt: [0.000000, 0.000000], vx: [0.816497, 0.408248, -0.408248, 1.000000] }
|
||||||
|
135: { v: [-0.500000, 0.500000, -0.500000], vn: [-0.577350, 0.577350, -0.577350], vt: [0.000000, 0.000000], vx: [0.816497, 0.408248, -0.408248, 1.000000] }
|
||||||
|
136: { v: [0.000000, 0.000000, -0.500000], vn: [0.000000, 0.000000, -1.000000], vt: [0.500000, 0.500000], vx: [1.000000, 0.000000, 0.000000, 1.000000] }
|
||||||
|
137: { v: [0.000000, 0.000000, -0.500000], vn: [0.000000, 0.000000, -1.000000], vt: [0.500000, 0.500000], vx: [1.000000, 0.000000, 0.000000, 1.000000] }
|
||||||
|
138: { v: [-0.500000, 0.500000, -0.500000], vn: [-0.577350, 0.577350, -0.577350], vt: [0.000000, 0.000000], vx: [0.816497, 0.408248, -0.408248, 1.000000] }
|
||||||
|
139: { v: [-0.500000, 0.500000, -0.500000], vn: [-0.577350, 0.577350, -0.577350], vt: [0.000000, 0.000000], vx: [0.816497, 0.408248, -0.408248, 1.000000] }
|
||||||
|
140: { v: [0.500000, 0.500000, -0.500000], vn: [0.577350, 0.577350, -0.577350], vt: [1.000000, 0.000000], vx: [0.816497, -0.408248, 0.408248, 1.000000] }
|
||||||
|
141: { v: [0.500000, 0.500000, -0.500000], vn: [0.577350, 0.577350, -0.577350], vt: [1.000000, 0.000000], vx: [0.816497, -0.408248, 0.408248, 1.000000] }
|
||||||
|
142: { v: [0.000000, 0.000000, -0.500000], vn: [0.000000, 0.000000, -1.000000], vt: [0.500000, 0.500000], vx: [1.000000, 0.000000, 0.000000, 1.000000] }
|
||||||
|
143: { v: [0.000000, 0.000000, -0.500000], vn: [0.000000, 0.000000, -1.000000], vt: [0.500000, 0.500000], vx: [1.000000, 0.000000, 0.000000, 1.000000] }
|
||||||
114
test-data/cube.obj
Normal file
114
test-data/cube.obj
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
v 0.5 -0.5 0.5
|
||||||
|
v 0.5 -0.5 -0.5
|
||||||
|
v 0.5 0.5 -0.5
|
||||||
|
v 0.5 0.5 0.5
|
||||||
|
v 0.5 0 0
|
||||||
|
v -0.5 0.5 0.5
|
||||||
|
v -0.5 0.5 -0.5
|
||||||
|
v -0.5 -0.5 -0.5
|
||||||
|
v -0.5 -0.5 0.5
|
||||||
|
v -0.5 0 0
|
||||||
|
v 0.5 0.5 0.5
|
||||||
|
v 0.5 0.5 -0.5
|
||||||
|
v -0.5 0.5 -0.5
|
||||||
|
v -0.5 0.5 0.5
|
||||||
|
v 0 0.5 0
|
||||||
|
v -0.5 -0.5 0.5
|
||||||
|
v -0.5 -0.5 -0.5
|
||||||
|
v 0.5 -0.5 -0.5
|
||||||
|
v 0.5 -0.5 0.5
|
||||||
|
v 0 -0.5 0
|
||||||
|
v -0.5 0.5 0.5
|
||||||
|
v -0.5 -0.5 0.5
|
||||||
|
v 0.5 -0.5 0.5
|
||||||
|
v 0.5 0.5 0.5
|
||||||
|
v 0 0 0.5
|
||||||
|
v 0.5 0.5 -0.5
|
||||||
|
v 0.5 -0.5 -0.5
|
||||||
|
v -0.5 -0.5 -0.5
|
||||||
|
v -0.5 0.5 -0.5
|
||||||
|
v 0 0 -0.5
|
||||||
|
vn 0.57735026 -0.57735026 0.57735026
|
||||||
|
vn 0.57735026 -0.57735026 -0.57735026
|
||||||
|
vn 0.57735026 0.57735026 -0.57735026
|
||||||
|
vn 0.57735026 0.57735026 0.57735026
|
||||||
|
vn 1 0 0
|
||||||
|
vn -0.57735026 0.57735026 0.57735026
|
||||||
|
vn -0.57735026 0.57735026 -0.57735026
|
||||||
|
vn -0.57735026 -0.57735026 -0.57735026
|
||||||
|
vn -0.57735026 -0.57735026 0.57735026
|
||||||
|
vn -1 0 0
|
||||||
|
vn 0.57735026 0.57735026 0.57735026
|
||||||
|
vn 0.57735026 0.57735026 -0.57735026
|
||||||
|
vn -0.57735026 0.57735026 -0.57735026
|
||||||
|
vn -0.57735026 0.57735026 0.57735026
|
||||||
|
vn 0 1 0
|
||||||
|
vn -0.57735026 -0.57735026 0.57735026
|
||||||
|
vn -0.57735026 -0.57735026 -0.57735026
|
||||||
|
vn 0.57735026 -0.57735026 -0.57735026
|
||||||
|
vn 0.57735026 -0.57735026 0.57735026
|
||||||
|
vn 0 -1 0
|
||||||
|
vn -0.57735026 0.57735026 0.57735026
|
||||||
|
vn -0.57735026 -0.57735026 0.57735026
|
||||||
|
vn 0.57735026 -0.57735026 0.57735026
|
||||||
|
vn 0.57735026 0.57735026 0.57735026
|
||||||
|
vn 0 0 1
|
||||||
|
vn 0.57735026 0.57735026 -0.57735026
|
||||||
|
vn 0.57735026 -0.57735026 -0.57735026
|
||||||
|
vn -0.57735026 -0.57735026 -0.57735026
|
||||||
|
vn -0.57735026 0.57735026 -0.57735026
|
||||||
|
vn 0 0 -1
|
||||||
|
vt 0 0
|
||||||
|
vt 0 1
|
||||||
|
vt 1 1
|
||||||
|
vt 1 0
|
||||||
|
vt 0.5 0.5
|
||||||
|
vt 1 0
|
||||||
|
vt 1 1
|
||||||
|
vt 0 1
|
||||||
|
vt 0 0
|
||||||
|
vt 0.5 0.5
|
||||||
|
vt 0 0
|
||||||
|
vt 0 1
|
||||||
|
vt 0 1
|
||||||
|
vt 0 0
|
||||||
|
vt 0 0.5
|
||||||
|
vt 0 0
|
||||||
|
vt 0 1
|
||||||
|
vt 0 1
|
||||||
|
vt 0 0
|
||||||
|
vt 0 0.5
|
||||||
|
vt 0 0
|
||||||
|
vt 0 1
|
||||||
|
vt 1 1
|
||||||
|
vt 1 0
|
||||||
|
vt 0.5 0.5
|
||||||
|
vt 1 0
|
||||||
|
vt 1 1
|
||||||
|
vt 0 1
|
||||||
|
vt 0 0
|
||||||
|
vt 0.5 0.5
|
||||||
|
f 1/1/1 2/2/2 5/5/5
|
||||||
|
f 2/2/2 3/3/3 5/5/5
|
||||||
|
f 3/3/3 4/4/4 5/5/5
|
||||||
|
f 4/4/4 1/1/1 5/5/5
|
||||||
|
f 6/6/6 7/7/7 10/10/10
|
||||||
|
f 7/7/7 8/8/8 10/10/10
|
||||||
|
f 8/8/8 9/9/9 10/10/10
|
||||||
|
f 9/9/9 6/6/6 10/10/10
|
||||||
|
f 11/11/11 12/12/12 15/15/15
|
||||||
|
f 12/12/12 13/13/13 15/15/15
|
||||||
|
f 13/13/13 14/14/14 15/15/15
|
||||||
|
f 14/14/14 11/11/11 15/15/15
|
||||||
|
f 16/16/16 17/17/17 20/20/20
|
||||||
|
f 17/17/17 18/18/18 20/20/20
|
||||||
|
f 18/18/18 19/19/19 20/20/20
|
||||||
|
f 19/19/19 16/16/16 20/20/20
|
||||||
|
f 21/21/21 22/22/22 25/25/25
|
||||||
|
f 22/22/22 23/23/23 25/25/25
|
||||||
|
f 23/23/23 24/24/24 25/25/25
|
||||||
|
f 24/24/24 21/21/21 25/25/25
|
||||||
|
f 26/26/26 27/27/27 30/30/30
|
||||||
|
f 27/27/27 28/28/28 30/30/30
|
||||||
|
f 28/28/28 29/29/29 30/30/30
|
||||||
|
f 29/29/29 26/26/26 30/30/30
|
||||||
BIN
test-data/gen
BIN
test-data/gen
Binary file not shown.
BIN
test-data/gen2
BIN
test-data/gen2
Binary file not shown.
@ -1,45 +0,0 @@
|
|||||||
|
|
||||||
extern crate gltf;
|
|
||||||
|
|
||||||
use std::io::Write;
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let path = "test-data/Avocado.gltf";
|
|
||||||
let gltf = gltf::Import::from_path(path).sync().unwrap();
|
|
||||||
let mesh = gltf.meshes().nth(0).unwrap();
|
|
||||||
let primitive = mesh.primitives().nth(0).unwrap();
|
|
||||||
let positions: Vec<[f32; 3]> = primitive.positions().unwrap().collect();
|
|
||||||
let normals: Vec<[f32; 3]> = primitive.normals().unwrap().collect();
|
|
||||||
let mut tex_coords: Vec<[f32; 2]> = vec![];
|
|
||||||
let mut indices: Vec<u16> = vec![];
|
|
||||||
match primitive.tex_coords(0).unwrap() {
|
|
||||||
gltf::mesh::TexCoords::F32(iter) => tex_coords.extend(iter),
|
|
||||||
_ => unreachable!(),
|
|
||||||
}
|
|
||||||
match primitive.indices().unwrap() {
|
|
||||||
gltf::mesh::Indices::U16(iter) => indices.extend(iter),
|
|
||||||
_ => unreachable!(),
|
|
||||||
}
|
|
||||||
|
|
||||||
let file = std::fs::File::create("Avocado.obj").unwrap();
|
|
||||||
let mut writer = std::io::BufWriter::new(file);
|
|
||||||
for position in &positions {
|
|
||||||
writeln!(writer, "v {} {} {}", position[0], position[1], position[2]);
|
|
||||||
}
|
|
||||||
for normal in &normals {
|
|
||||||
writeln!(writer, "vn {} {} {}", normal[0], normal[1], normal[2]);
|
|
||||||
}
|
|
||||||
for tex_coord in &tex_coords {
|
|
||||||
writeln!(writer, "vt {} {}", tex_coord[0], tex_coord[1]);
|
|
||||||
}
|
|
||||||
let mut i = indices.iter();
|
|
||||||
while let (Some(v0), Some(v1), Some(v2)) = (i.next(), i.next(), i.next()) {
|
|
||||||
writeln!(
|
|
||||||
writer,
|
|
||||||
"f {}/{}/{} {}/{}/{} {}/{}/{}",
|
|
||||||
v0, v0, v0,
|
|
||||||
v1, v1, v1,
|
|
||||||
v2, v2, v2,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Binary file not shown.
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -52,18 +51,6 @@ struct input {
|
|||||||
size_t nr_faces;
|
size_t nr_faces;
|
||||||
} input;
|
} input;
|
||||||
|
|
||||||
struct output {
|
|
||||||
// Borrows from `positions`, `normals`, and `tex_coords`.
|
|
||||||
struct vertex *vertices;
|
|
||||||
|
|
||||||
// Owned.
|
|
||||||
struct tangent *tangents;
|
|
||||||
|
|
||||||
// Number of entries in `vertices` and `tangents`.
|
|
||||||
// Equal to `3 * input.nr_faces`.
|
|
||||||
size_t nr_vertices;
|
|
||||||
} output;
|
|
||||||
|
|
||||||
void print_vec2(float (*t)[2]) {
|
void print_vec2(float (*t)[2]) {
|
||||||
printf("[%f, %f]", (*t)[0], (*t)[1]);
|
printf("[%f, %f]", (*t)[0], (*t)[1]);
|
||||||
}
|
}
|
||||||
@ -86,17 +73,17 @@ int get_num_vertices_of_face(const SMikkTSpaceContext *x, int f) {
|
|||||||
|
|
||||||
void get_position(const SMikkTSpaceContext *x, float *dst, int f, int v) {
|
void get_position(const SMikkTSpaceContext *x, float *dst, int f, int v) {
|
||||||
float (*src)[3] = input.faces[f].vertices[v].position;
|
float (*src)[3] = input.faces[f].vertices[v].position;
|
||||||
memcpy(dst, src, sizeof(*src));
|
memcpy(dst, *src, 3 * sizeof(float));
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_normal(const SMikkTSpaceContext *x, float *dst, int f, int v) {
|
void get_normal(const SMikkTSpaceContext *x, float *dst, int f, int v) {
|
||||||
float (*src)[3] = input.faces[f].vertices[v].normal;
|
float (*src)[3] = input.faces[f].vertices[v].normal;
|
||||||
memcpy(dst, src, sizeof(*src));
|
memcpy(dst, *src, 3 * sizeof(float));
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_tex_coord(const SMikkTSpaceContext *x, float *dst, int f, int v) {
|
void get_tex_coord(const SMikkTSpaceContext *x, float *dst, int f, int v) {
|
||||||
float (*src)[2] = input.faces[f].vertices[v].tex_coord;
|
float (*src)[2] = input.faces[f].vertices[v].tex_coord;
|
||||||
memcpy(dst, src, sizeof(*src));
|
memcpy(dst, *src, 2 * sizeof(float));
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_tspace_basic(
|
void set_tspace_basic(
|
||||||
@ -111,11 +98,14 @@ void set_tspace_basic(
|
|||||||
|
|
||||||
struct vertex *in = &input.faces[f].vertices[v];
|
struct vertex *in = &input.faces[f].vertices[v];
|
||||||
|
|
||||||
output.vertices[i].position = in->position;
|
printf("%d: { v: ", i);
|
||||||
output.vertices[i].normal = in->normal;
|
print_vec3(in->position);
|
||||||
output.vertices[i].tex_coord = in->tex_coord;
|
printf(", vn: ");
|
||||||
memcpy(output.tangents[i].v, t, 3 * sizeof(float));
|
print_vec3(in->normal);
|
||||||
output.tangents[i].s = s;
|
printf(", vt: ");
|
||||||
|
print_vec2(in->tex_coord);
|
||||||
|
printf(", vx: [%f, %f, %f, %f] }", t[0], t[1], t[2], s);
|
||||||
|
puts("");
|
||||||
|
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
@ -130,22 +120,19 @@ void set_tspace(
|
|||||||
int f,
|
int f,
|
||||||
int v
|
int v
|
||||||
) {
|
) {
|
||||||
assert(!"unreachable");
|
set_tspace_basic(x, t, op != 0 ? 1.0f : -1.0f, f, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
input.nr_vertices = 406;
|
input.nr_vertices = 30;
|
||||||
input.nr_faces = 682;
|
input.nr_faces = 24;
|
||||||
output.nr_vertices = 3 * input.nr_faces;
|
|
||||||
|
|
||||||
input.positions = calloc(input.nr_vertices, sizeof(*input.positions));
|
input.positions = calloc(input.nr_vertices, sizeof(*input.positions));
|
||||||
input.normals = calloc(input.nr_vertices, sizeof(*input.normals));
|
input.normals = calloc(input.nr_vertices, sizeof(*input.normals));
|
||||||
input.tex_coords = calloc(input.nr_vertices, sizeof(*input.tex_coords));
|
input.tex_coords = calloc(input.nr_vertices, sizeof(*input.tex_coords));
|
||||||
input.faces = calloc(input.nr_faces, sizeof(*input.faces));
|
input.faces = calloc(input.nr_faces, sizeof(*input.faces));
|
||||||
output.vertices = calloc(output.nr_vertices, sizeof(*output.vertices));
|
|
||||||
output.tangents = calloc(output.nr_vertices, sizeof(*output.tangents));
|
|
||||||
|
|
||||||
FILE *fi = fopen("Avocado.obj", "rb");
|
FILE *fi = fopen("cube.obj", "rb");
|
||||||
assert(fi);
|
assert(fi);
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
|
|
||||||
@ -205,7 +192,7 @@ int main() {
|
|||||||
.m_getNormal = get_normal,
|
.m_getNormal = get_normal,
|
||||||
.m_getTexCoord = get_tex_coord,
|
.m_getTexCoord = get_tex_coord,
|
||||||
.m_setTSpaceBasic = set_tspace_basic,
|
.m_setTSpaceBasic = set_tspace_basic,
|
||||||
.m_setTSpace = NULL,
|
.m_setTSpace = set_tspace,
|
||||||
};
|
};
|
||||||
SMikkTSpaceContext context = {
|
SMikkTSpaceContext context = {
|
||||||
.m_pInterface = &interface,
|
.m_pInterface = &interface,
|
||||||
@ -214,32 +201,11 @@ int main() {
|
|||||||
|
|
||||||
genTangSpaceDefault(&context);
|
genTangSpaceDefault(&context);
|
||||||
|
|
||||||
printf("{\n \"vlist\": [\n");
|
|
||||||
for (size_t i = 0; i < output.nr_vertices; ++i) {
|
|
||||||
printf(" {\"v\": ");
|
|
||||||
print_vec3(output.vertices[i].position);
|
|
||||||
printf(", \"vn\": ");
|
|
||||||
print_vec3(output.vertices[i].normal);
|
|
||||||
printf(", \"vt\": ");
|
|
||||||
print_vec2(output.vertices[i].tex_coord);
|
|
||||||
printf(", \"vx\": ");
|
|
||||||
print_tangent(&output.tangents[i]);
|
|
||||||
if (i == output.nr_vertices - 1) {
|
|
||||||
printf("}\n");
|
|
||||||
} else {
|
|
||||||
printf("},\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
printf(" ]\n}");
|
|
||||||
|
|
||||||
fclose(fi);
|
fclose(fi);
|
||||||
free(input.positions);
|
free(input.positions);
|
||||||
free(input.normals);
|
free(input.normals);
|
||||||
free(input.tex_coords);
|
free(input.tex_coords);
|
||||||
free(input.faces);
|
free(input.faces);
|
||||||
free(output.vertices);
|
|
||||||
free(output.tangents);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,250 +0,0 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "mikktspace.h"
|
|
||||||
|
|
||||||
struct tangent {
|
|
||||||
// Vector.
|
|
||||||
float v[3];
|
|
||||||
|
|
||||||
// Sign.
|
|
||||||
float s;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct vertex {
|
|
||||||
// Borrows from `input.positions`.
|
|
||||||
float (*position)[3];
|
|
||||||
|
|
||||||
// Borrows from `input.positions`.
|
|
||||||
float (*normal)[3];
|
|
||||||
|
|
||||||
// Borrows from `input.positions`.
|
|
||||||
float (*tex_coord)[2];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct face {
|
|
||||||
// Borrows from `positions`, `normals`, and `tex_coords`.
|
|
||||||
struct vertex vertices[3];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct input {
|
|
||||||
// Owned.
|
|
||||||
float (*positions)[3];
|
|
||||||
|
|
||||||
// Owned.
|
|
||||||
float (*normals)[3];
|
|
||||||
|
|
||||||
// Owned.
|
|
||||||
float (*tex_coords)[2];
|
|
||||||
|
|
||||||
// Borrows from `positions`, `normals`, and `tex_coords`.
|
|
||||||
struct face *faces;
|
|
||||||
|
|
||||||
// Number of entries in `positions`, `normals`, and `tex_coords`.
|
|
||||||
size_t nr_vertices;
|
|
||||||
|
|
||||||
// Number of entries in `faces`.
|
|
||||||
size_t nr_faces;
|
|
||||||
} input;
|
|
||||||
|
|
||||||
struct output {
|
|
||||||
// Borrows from `positions`, `normals`, and `tex_coords`.
|
|
||||||
struct vertex *vertices;
|
|
||||||
|
|
||||||
// Owned.
|
|
||||||
struct tangent *tangents;
|
|
||||||
|
|
||||||
// Number of entries in `vertices` and `tangents`.
|
|
||||||
// Equal to `3 * input.nr_faces`.
|
|
||||||
size_t nr_vertices;
|
|
||||||
} output;
|
|
||||||
|
|
||||||
void print_vec2(float (*t)[2]) {
|
|
||||||
printf("%f %f", (*t)[0], (*t)[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
void print_vec3(float (*t)[3]) {
|
|
||||||
printf("%f %f %f", (*t)[0], (*t)[1], (*t)[2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
void print_tangent(const struct tangent *t) {
|
|
||||||
printf("%f %f %f %f", t->v[0], t->v[1], t->v[2], t->s);
|
|
||||||
}
|
|
||||||
|
|
||||||
int get_num_faces(const SMikkTSpaceContext *x) {
|
|
||||||
return input.nr_faces;
|
|
||||||
}
|
|
||||||
|
|
||||||
int get_num_vertices_of_face(const SMikkTSpaceContext *x, int f) {
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
void get_position(const SMikkTSpaceContext *x, float *dst, int f, int v) {
|
|
||||||
float (*src)[3] = input.faces[f].vertices[v].position;
|
|
||||||
memcpy(dst, src, sizeof(*src));
|
|
||||||
}
|
|
||||||
|
|
||||||
void get_normal(const SMikkTSpaceContext *x, float *dst, int f, int v) {
|
|
||||||
float (*src)[3] = input.faces[f].vertices[v].normal;
|
|
||||||
memcpy(dst, src, sizeof(*src));
|
|
||||||
}
|
|
||||||
|
|
||||||
void get_tex_coord(const SMikkTSpaceContext *x, float *dst, int f, int v) {
|
|
||||||
float (*src)[2] = input.faces[f].vertices[v].tex_coord;
|
|
||||||
memcpy(dst, src, sizeof(*src));
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_tspace_basic(
|
|
||||||
const SMikkTSpaceContext *x,
|
|
||||||
const float *t,
|
|
||||||
float s,
|
|
||||||
int f,
|
|
||||||
int v
|
|
||||||
) {
|
|
||||||
// The index of the last output (vertex, tangent) pair.
|
|
||||||
static int i = 0;
|
|
||||||
|
|
||||||
struct vertex *in = &input.faces[f].vertices[v];
|
|
||||||
|
|
||||||
output.vertices[i].position = in->position;
|
|
||||||
output.vertices[i].normal = in->normal;
|
|
||||||
output.vertices[i].tex_coord = in->tex_coord;
|
|
||||||
memcpy(output.tangents[i].v, t, 3 * sizeof(float));
|
|
||||||
output.tangents[i].s = s;
|
|
||||||
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_tspace(
|
|
||||||
const SMikkTSpaceContext *x,
|
|
||||||
const float *t,
|
|
||||||
const float *b,
|
|
||||||
float mag_s,
|
|
||||||
float mag_t,
|
|
||||||
tbool op,
|
|
||||||
int f,
|
|
||||||
int v
|
|
||||||
) {
|
|
||||||
assert(!"unreachable");
|
|
||||||
}
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
input.nr_vertices = 406;
|
|
||||||
input.nr_faces = 682;
|
|
||||||
output.nr_vertices = 3 * input.nr_faces;
|
|
||||||
|
|
||||||
input.positions = calloc(input.nr_vertices, sizeof(*input.positions));
|
|
||||||
input.normals = calloc(input.nr_vertices, sizeof(*input.normals));
|
|
||||||
input.tex_coords = calloc(input.nr_vertices, sizeof(*input.tex_coords));
|
|
||||||
input.faces = calloc(input.nr_faces, sizeof(*input.faces));
|
|
||||||
output.vertices = calloc(output.nr_vertices, sizeof(*output.vertices));
|
|
||||||
output.tangents = calloc(output.nr_vertices, sizeof(*output.tangents));
|
|
||||||
|
|
||||||
{
|
|
||||||
FILE *fi = fopen("Avocado.obj", "rb");
|
|
||||||
assert(fi);
|
|
||||||
char buffer[1024];
|
|
||||||
|
|
||||||
for (size_t i = 0; i < input.nr_vertices; ++i) {
|
|
||||||
fgets(buffer, sizeof(buffer), fi);
|
|
||||||
sscanf(
|
|
||||||
buffer,
|
|
||||||
"v %f %f %f",
|
|
||||||
&input.positions[i][0],
|
|
||||||
&input.positions[i][1],
|
|
||||||
&input.positions[i][2]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t i = 0; i < input.nr_vertices; ++i) {
|
|
||||||
fgets(buffer, sizeof(buffer), fi);
|
|
||||||
sscanf(
|
|
||||||
buffer,
|
|
||||||
"vn %f %f %f",
|
|
||||||
&input.normals[i][0],
|
|
||||||
&input.normals[i][1],
|
|
||||||
&input.normals[i][2]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t i = 0; i < input.nr_vertices; ++i) {
|
|
||||||
fgets(buffer, sizeof(buffer), fi);
|
|
||||||
sscanf(
|
|
||||||
buffer,
|
|
||||||
"vt %f %f",
|
|
||||||
&input.tex_coords[i][0],
|
|
||||||
&input.tex_coords[i][1]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t i = 0; i < input.nr_faces; ++i) {
|
|
||||||
fgets(buffer, sizeof(buffer), fi);
|
|
||||||
int v[3];
|
|
||||||
sscanf(
|
|
||||||
buffer,
|
|
||||||
"f %d/%d/%d %d/%d/%d %d/%d/%d",
|
|
||||||
&v[0], &v[0], &v[0],
|
|
||||||
&v[1], &v[1], &v[1],
|
|
||||||
&v[2], &v[2], &v[2]
|
|
||||||
);
|
|
||||||
for (size_t j = 0; j < 3; ++j) {
|
|
||||||
input.faces[i].vertices[j].position = &input.positions[v[j] - 1];
|
|
||||||
input.faces[i].vertices[j].normal = &input.normals[v[j] - 1];
|
|
||||||
input.faces[i].vertices[j].tex_coord = &input.tex_coords[v[j] - 1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(fi);
|
|
||||||
}
|
|
||||||
|
|
||||||
SMikkTSpaceInterface interface = {
|
|
||||||
.m_getNumFaces = get_num_faces,
|
|
||||||
.m_getNumVerticesOfFace = get_num_vertices_of_face,
|
|
||||||
.m_getPosition = get_position,
|
|
||||||
.m_getNormal = get_normal,
|
|
||||||
.m_getTexCoord = get_tex_coord,
|
|
||||||
.m_setTSpaceBasic = set_tspace_basic,
|
|
||||||
.m_setTSpace = NULL,
|
|
||||||
};
|
|
||||||
SMikkTSpaceContext context = {
|
|
||||||
.m_pInterface = &interface,
|
|
||||||
.m_pUserData = NULL,
|
|
||||||
};
|
|
||||||
|
|
||||||
genTangSpaceDefault(&context);
|
|
||||||
|
|
||||||
for (size_t i = 0; i < output.nr_vertices; ++i) {
|
|
||||||
printf("v ");
|
|
||||||
print_vec3(output.vertices[i].position);
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t i = 0; i < output.nr_vertices; ++i) {
|
|
||||||
printf("vn ");
|
|
||||||
print_vec3(output.vertices[i].normal);
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
int k = 1;
|
|
||||||
for (size_t i = 0; i < output.nr_vertices / 3; ++i) {
|
|
||||||
int v0 = k++;
|
|
||||||
int v1 = k++;
|
|
||||||
int v2 = k++;
|
|
||||||
printf("f %d//%d %d//%d %d//%d\n", v0, v0, v1, v1, v2, v2);
|
|
||||||
}
|
|
||||||
|
|
||||||
free(input.positions);
|
|
||||||
free(input.normals);
|
|
||||||
free(input.tex_coords);
|
|
||||||
free(input.faces);
|
|
||||||
free(output.vertices);
|
|
||||||
free(output.tangents);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Binary file not shown.
Loading…
Reference in New Issue
Block a user