feat: animate helicopter using simple_heading_animation with full 3-axis rotation
This commit is contained in:
12
src/main.rs
12
src/main.rs
@@ -17,6 +17,8 @@ mod util;
|
|||||||
mod mesh;
|
mod mesh;
|
||||||
mod scene_graph;
|
mod scene_graph;
|
||||||
use scene_graph::SceneNode;
|
use scene_graph::SceneNode;
|
||||||
|
mod toolbox;
|
||||||
|
use toolbox::simple_heading_animation;
|
||||||
|
|
||||||
use glutin::event::{
|
use glutin::event::{
|
||||||
DeviceEvent,
|
DeviceEvent,
|
||||||
@@ -438,6 +440,16 @@ fn main() {
|
|||||||
let projection: glm::Mat4 =
|
let projection: glm::Mat4 =
|
||||||
glm::perspective(window_aspect_ratio, std::f32::consts::PI / 4.0, 1.0, 1000.0);
|
glm::perspective(window_aspect_ratio, std::f32::consts::PI / 4.0, 1.0, 1000.0);
|
||||||
|
|
||||||
|
// Animate helicopter root via simple_heading_animation
|
||||||
|
let heading = simple_heading_animation(elapsed);
|
||||||
|
{
|
||||||
|
let mut hr_pin = heli_root.as_mut();
|
||||||
|
unsafe {
|
||||||
|
let node = hr_pin.get_unchecked_mut();
|
||||||
|
node.position = glm::vec3(heading.x, 0.0, heading.z);
|
||||||
|
node.rotation = glm::vec3(heading.roll, heading.pitch, heading.yaw);
|
||||||
|
}
|
||||||
|
}
|
||||||
// Update rotor rotations
|
// Update rotor rotations
|
||||||
{
|
{
|
||||||
let mut mr_pin = main_rotor_node.as_mut();
|
let mut mr_pin = main_rotor_node.as_mut();
|
||||||
|
|||||||
Reference in New Issue
Block a user