I started a tutorial to learn about 3D engines, so far so good. The thing is I decided to do it on nalgebra an rust instead of using tools I feel comfortable with. 2x experience but 3x difficulty.
During the MVP matrix creation I did something like this:
- mapped vertices and positions data to Point3, and rotation data to Rotation3
- Didn’t use Vector3 at all
Now I translated the bottom part of the tutorial (Called << The most important part: the Device object>>) to this rust code:
let world_matrix = mesh.rotation * Translation3::new(mesh.position.x,mesh.position.y,mesh.position.z);
// The combination of the model with the view is still an isometry.
let model_view = view * world_matrix;
// Convert everything to a `Matrix4` so that they can be combined.
let mat_model_view = model_view.to_homogeneous();
// Combine everything.
let model_view_projection = projection.as_matrix() * mat_model_view;
the rotation and the translation give me an isometry, which -by reading the documentation- I guess is correct. The problem is that I don’t have a way to multiply view* world_matrix.
This is the error I get:
error[E0277]: cannot multiply
soft_engine::na::Isometry<f32, soft_engine::na::U3, soft_engine::na::Rotation<f32, soft_engine::na::U3>>
tosoft_engine::na::Isometry<f32, soft_engine::na::U3, soft_engine::na::Unit<soft_engine::na::Quaternion<f32>>>
→ src/soft_engine.rs:86:35
|
86 | let model_view = view * world_matrix;
| ^ no implementation forsoft_engine::na::Isometry<f32, soft_engine::na::U3, soft_engine::na::Unit<soft_engine::na::Quaternion<f32>>> * soft_engine::na::Isometry<f32, soft_engine::na::U3, soft_engine::na::Rotation<f32, soft_engine::na::U3>>
|
= help: the traitstd::ops::Mul<soft_engine::na::Isometry<f32, soft_engine::na::U3, soft_engine::na::Rotation<f32, soft_engine::na::U3>>>
is not implemented forsoft_engine::na::Isometry<f32, soft_engine::na::U3, soft_engine::na::Unit<soft_engine::na::Quaternion<f32>>>
Do I have to call .to_homogeneous() on both (view and world_matrix) and remove the mat_model_view declaration?
is there a simpler way of representing this and I’m just thinking it wrong from the beggining?
And final question. once I have the model_view_projection matrix, how do I project the Point3? (is Point3 correct or would it be better to use Vector3?)
Thank you in advance