Debian Codegraph @

debian/missing-sources/nalgebra/examples/mvp.rs

raw
1 #![allow(unused_variables)]
2
3 extern crate nalgebra as na;
4
5 use na::{Isometry3, Perspective3, Point3, Vector3};
6 use std::f32::consts;
7
8 fn main() {
9 // Our object is translated along the x axis.
10 let model = Isometry3::new(Vector3::x(), na::zero());
11
12 // Our camera looks toward the point (1.0, 0.0, 0.0).
13 // It is located at (0.0, 0.0, 1.0).
14 let eye = Point3::new(0.0, 0.0, 1.0);
15 let target = Point3::new(1.0, 0.0, 0.0);
16 let view = Isometry3::look_at_rh(&eye, &target, &Vector3::y());
17
18 // A perspective projection.
19 let projection = Perspective3::new(16.0 / 9.0, consts::PI / 2.0, 1.0, 1000.0);
20
21 // The combination of the model with the view is still an isometry.
22 let model_view = view * model;
23
24 // Convert everything to a `Matrix4` so that they can be combined.
25 let mat_model_view = model_view.to_homogeneous();
26
27 // Combine everything.
28 let model_view_projection = projection.as_matrix() * mat_model_view;
29 }