#Example of translating an object to origin before rotation

8 messages · Page 1 of 1 (latest)

signal citrus
#

I am working on trying to add rotation to the orthograpic example https://github.com/bevyengine/bevy/blob/v0.10.1/examples/3d/orthographic.rs

I just copied the Cube rotation one and added the Rotatable attribute to the camera which works! The only problem is it is rotating about the current axis of the camera. If I recall my 3d programming class this is because I need to translate the camera to origin then rotate it then translate it back.
Anyone have an example of translating a 3d object to the origin before rotating it that I can look at?

GitHub

A refreshingly simple data-driven game engine built in Rust - bevy/orthographic.rs at v0.10.1 · bevyengine/bevy

signal citrus
formal python
#

I'm not sure I understand what you want but maybe you could do something like
Quat::from_axis_angle(rig_transform.local_y(), angle) ?

signal citrus
formal python
#

No problem! Hope it works

signal citrus
#

Basically though I want to be able to apply a rotation about the current axis to an object that has already been translated away from the origin. Not sure if that makes it any more or less clear

formal python
#

the current axis of the object or the camera?

#

I think you rotate a transform using .rotate(Quat) (so like the transform or your object for example) it rotates it in place, relative to the transform.translate (the transform.translate wouldn't be changed). If you define the Quat using from_axis_angle it sould rotate in the direction of this axis but not around it
If you want to rotate a transform around a point using an axis you can use .rotate_around(Vec3, Quat)