-
Notifications
You must be signed in to change notification settings - Fork 173
/
obj.rs
38 lines (31 loc) · 1.24 KB
/
obj.rs
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
extern crate kiss3d;
extern crate nalgebra as na;
use kiss3d::light::Light;
use kiss3d::window::Window;
use na::{Translation3, UnitQuaternion, Vector3};
use std::f32;
use std::path::Path;
fn main() {
let mut window = Window::new("Kiss3d: obj");
// Teapot
let obj_path = Path::new("media/teapot/teapot.obj");
let mtl_path = Path::new("media/teapot");
let mut teapot = window.add_obj(obj_path, mtl_path, Vector3::new(0.001, 0.001, 0.001));
teapot.append_translation(&Translation3::new(0.0, -0.05, -0.2));
// Rust logo
let obj_path = Path::new("media/rust_logo/rust_logo.obj");
let mtl_path = Path::new("media/rust_logo");
let mut rust = window.add_obj(obj_path, mtl_path, Vector3::new(0.05, 0.05, 0.05));
rust.prepend_to_local_rotation(&UnitQuaternion::from_axis_angle(
&Vector3::x_axis(),
-f32::consts::FRAC_PI_2,
));
rust.set_color(0.0, 0.0, 1.0);
window.set_light(Light::StickToCamera);
let rot_teapot = UnitQuaternion::from_axis_angle(&Vector3::y_axis(), 0.014);
let rot_rust = UnitQuaternion::from_axis_angle(&Vector3::y_axis(), -0.014);
while window.render() {
teapot.prepend_to_local_rotation(&rot_teapot);
rust.prepend_to_local_rotation(&rot_rust);
}
}