|
let child_transform = Transformation { |
|
translation: [ |
|
transform.translation[0] + object.transform.translation[0], |
|
transform.translation[1] + object.transform.translation[1], |
|
transform.translation[2] + object.transform.translation[2], |
|
], |
|
rotation: object.transform.rotation, |
|
scale: object.transform.scale, |
|
}; |
This is my favourite comment in the repo.
I'd suggest using a library like glam for matrix maths, it's still nice and fast.
fn physis_transform_to_affine3a(transformation: &Transformation) -> Affine3A {
let translation = Vec3::from(transformation.translation);
let scale = Vec3::from(transformation.scale);
let rotation = Quat::from_euler(
EulerRot::XYZ,
transformation.rotation[0],
transformation.rotation[1],
transformation.rotation[2],
);
Affine3A::from_scale_rotation_translation(scale, rotation, translation)
}
pub fn process_layer(&mut self, layer: &Layer, world: Affine3A) -> MeshCollection {
let mut collection = MeshCollection::default();
for object in &layer.objects {
let local = world * physis_transform_to_affine3a(&object.transform);
...
let meshes = layer_processor.process_layer(layer, Affine3A::IDENTITY);
That's some similar code I've used in the past.
Kawari/tools/navimesh/src/main.rs
Lines 480 to 488 in 4e98cd7
This is my favourite comment in the repo.
I'd suggest using a library like glam for matrix maths, it's still nice and fast.
That's some similar code I've used in the past.