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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
extern crate collada_io;
use std::fs::File;
fn main()
{
println!("Simple Geometry Example!");
let mut file = File::create("simple-geometry.dae").unwrap();
let collada: collada_io::collada::Collada = collada_io::collada::Collada {
scene: None,
visual_scenes: None,
asset: collada_io::meta::Asset::default(),
geometries: Some(vec!{
collada_io::geometry::Geometry {
id: Some("Cube-mesh".to_string()),
name: Some("Cube".to_string()),
mesh: collada_io::geometry::Mesh {
triangles: collada_io::geometry::Triangles {
vertices: "#Cube-mesh-vertices".to_string(),
normals: Some("#Cube-mesh-normals".to_string()),
tex_vertices: Some("#Cube-mesh-map-0".to_string()),
primitive: Some(vec! {
4, 0, 0, 2, 0, 1, 0, 0, 2,
2, 1, 3, 7, 1, 4, 3, 1, 5,
6, 2, 6, 5, 2, 7, 7, 2, 8,
1, 3, 9, 7, 3, 10, 5, 3, 11,
0, 4, 12, 3, 4, 13, 1, 4, 14,
4, 5, 15, 1, 5, 16, 5, 5, 17,
4, 0, 18, 6, 0, 19, 2, 0, 20,
2, 1, 21, 6, 1, 22, 7, 1, 23,
6, 2, 24, 4, 2, 25, 5, 2, 26,
1, 3, 27, 3, 3, 28, 7, 3, 29,
0, 4, 30, 2, 4, 31, 3, 4, 32,
4, 5, 33, 0, 5, 34, 1, 5, 35
}),
material: None
},
vertices: collada_io::geometry::Vertices {
id: "Cube-mesh-vertices".to_string(),
name: None,
source: "#Cube-mesh-positions".to_string()
},
sources: vec! {
collada_io::geometry::Source {
id: "Cube-mesh-positions".to_string(),
float_array: collada_io::geometry::FloatArray {
id: "Cube-mesh-positions-array".to_string(),
data: vec!{
1.0, 1.0, 1.0,
1.0, 1.0, -1.0,
1.0, -1.0, 1.0,
1.0, -1.0, -1.0,
-1.0, 1.0, 1.0,
-1.0, 1.0, -1.0,
-1.0, -1.0, 1.0,
-1.0, -1.0, -1.0
}
},
accessor: collada_io::geometry::Accessor {
params: vec! { "X".to_string(), "Y".to_string(), "Z".to_string() }
}
},
collada_io::geometry::Source {
id: "Cube-mesh-normals".to_string(),
float_array: collada_io::geometry::FloatArray {
id: "Cube-mesh-normals-array".to_string(),
data: vec!{
0.0, 0.0, 1.0,
0.0, -1.0, 0.0,
-1.0, 0.0, 0.0,
0.0, 0.0, -1.0,
1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
}
},
accessor: collada_io::geometry::Accessor {
params: vec! { "X".to_string(), "Y".to_string(), "Z".to_string() }
}
},
collada_io::geometry::Source {
id: "Cube-mesh-map-0".into(),
float_array: collada_io::geometry::FloatArray {
id: "Cube-mesh-map-0-array".into(),
data: vec!{
0.875, 0.5,
0.625, 0.75,
0.625, 0.5,
0.625, 0.75,
0.375, 1.0,
0.375, 0.75,
0.625, 0.0,
0.375, 0.25,
0.375, 0.0,
0.375, 0.5,
0.125, 0.75,
0.125, 0.5,
0.625, 0.5,
0.375, 0.75,
0.375, 0.5,
0.625, 0.25,
0.375, 0.5,
0.375, 0.25,
0.875, 0.5,
0.875, 0.75,
0.625, 0.75,
0.625, 0.75,
0.625, 1.0,
0.375, 1.0,
0.625, 0.0,
0.625, 0.25,
0.375, 0.25,
0.375, 0.5,
0.375, 0.75,
0.125, 0.75,
0.625, 0.5,
0.625, 0.75,
0.375, 0.75,
0.625, 0.25,
0.625, 0.5,
0.375, 0.5,
}
},
accessor: collada_io::geometry::Accessor {
params: vec! { "S".to_string(), "T".to_string()}
}
}
}
}
}
})
};
collada.write_to(&mut file).unwrap();
}