diff --git a/Cargo.toml b/Cargo.toml index 508c5f2..dd47078 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libfj" -version = "0.6.0" +version = "0.6.1" authors = ["NGnius (Graham) "] edition = "2018" description = "An unofficial collection of APIs used in FreeJam games and mods" diff --git a/src/convert/mod.rs b/src/convert/mod.rs index e1fc8b1..657fafc 100644 --- a/src/convert/mod.rs +++ b/src/convert/mod.rs @@ -5,4 +5,4 @@ #[cfg(feature = "robocraft")] mod robocraft_3d; #[cfg(feature = "robocraft")] -pub use robocraft_3d::{cubes_to_model, cubes_to_model_with_lut}; +pub use robocraft_3d::{cubes_to_model, cubes_to_model_with_lut, cube_rotation_to_quat}; diff --git a/src/convert/robocraft_3d.rs b/src/convert/robocraft_3d.rs index 5979471..2cc305c 100644 --- a/src/convert/robocraft_3d.rs +++ b/src/convert/robocraft_3d.rs @@ -32,6 +32,11 @@ const ROTATIONS: [Euler>; 24] = [ Euler{x: Deg(-90.0), y: Deg(180.0), z: Deg(0.0)}, // 23 ]; +/// Convert a Robocraft robot's orientation enum into a physical rotation +pub fn cube_rotation_to_quat(orientation: u8) -> Quaternion { + ROTATIONS[orientation as usize].into() +} + /// Convert a Robocraft robot to a 3D model in Wavefront OBJ format. pub fn cubes_to_model(robot: robocraft::Cubes) -> obj::Obj { cubes_to_model_with_lut(robot, default_model_lut) @@ -47,7 +52,7 @@ pub fn cubes_to_model_with_lut Vec>>(robot: robocr // generate simple cube for every block // TODO rotate blocks let vertices = lut(cube.id); // Use lookup table to find correct id <-> block translation - let rotation: Quaternion<_> = ROTATIONS[cube.orientation as usize].into(); + let rotation: Quaternion<_> = cube_rotation_to_quat(cube.orientation); positions.extend::>( vertices.clone().into_iter().vertex(|v| {