Struct amethyst_core::transform::components::Transform [−][src]
pub struct Transform {
pub rotation: Quaternion<f32>,
pub scale: Vector3<f32>,
pub translation: Vector3<f32>,
}Local position, rotation, and scale (from parent if it exists).
Used for rendering position and orientation.
The transforms are preformed in this order: scale, then rotation, then translation.
Fields
rotation: Quaternion<f32>
Quaternion [w (scalar), x, y, z]
scale: Vector3<f32>
Scale vector [x, y, z]
translation: Vector3<f32>
Translation/position vector [x, y, z]
Methods
impl Transform[src]
impl TransformⓘImportant traits for &'a mut Rpub fn look_at(&mut self, position: Point3<f32>, up: Vector3<f32>) -> &mut Self[src]
pub fn look_at(&mut self, position: Point3<f32>, up: Vector3<f32>) -> &mut SelfMakes the entity point towards position.
up says which direction the entity should be 'rolled' to once it is pointing at
position. If up is parallel to the direction the entity is looking, the result will be
garbage.
This function only works with respect to the coordinate system of its parent, so when used with an object that's not a sibling it will not do what you expect.
Examples
let mut t = Transform::default(); // No rotation by default assert_eq!(t.rotation, Quaternion::one()); // look up with up pointing backwards t.look_at(Point3::new(0.0, 1.0, 0.0), Vector3::new(0.0, 0.0, 1.0)); // our rotation should match the angle from straight ahead to straight up let rotation = Quaternion::from_arc( Vector3::new(0.0, 0.0, -1.0), Vector3::new(0.0, 1.0, 0.0), None); assert_eq!(t.rotation, rotation);
pub fn matrix(&self) -> Matrix4<f32>[src]
pub fn matrix(&self) -> Matrix4<f32>Returns the local object matrix for the transform.
Combined with the parent's GlobalTransform component it gives
the global (or world) matrix for the current entity.
pub fn orientation(&self) -> Orientation[src]
pub fn orientation(&self) -> OrientationConvert this transform's rotation into an Orientation, guaranteed to be 3 unit orthogonal vectors
ⓘImportant traits for &'a mut Rpub fn move_global(&mut self, translation: Vector3<f32>) -> &mut Self[src]
pub fn move_global(&mut self, translation: Vector3<f32>) -> &mut SelfMove relatively to its current position.
ⓘImportant traits for &'a mut Rpub fn move_local(&mut self, translation: Vector3<f32>) -> &mut Self[src]
pub fn move_local(&mut self, translation: Vector3<f32>) -> &mut SelfMove relatively to its current position and orientation.
Equivalent to rotating the translation before applying.
ⓘImportant traits for &'a mut Rpub fn move_along_global(
&mut self,
direction: Vector3<f32>,
distance: f32
) -> &mut Self[src]
pub fn move_along_global(
&mut self,
direction: Vector3<f32>,
distance: f32
) -> &mut SelfMove a distance along an axis.
It will not move in the case where the axis is zero, for any distance.
ⓘImportant traits for &'a mut Rpub fn move_along_local(
&mut self,
direction: Vector3<f32>,
distance: f32
) -> &mut Self[src]
pub fn move_along_local(
&mut self,
direction: Vector3<f32>,
distance: f32
) -> &mut SelfMove a distance along an axis.
It will not move in the case where the axis is zero, for any distance.
ⓘImportant traits for &'a mut Rpub fn move_forward(&mut self, amount: f32) -> &mut Self[src]
pub fn move_forward(&mut self, amount: f32) -> &mut SelfMove forward relative to current position and orientation.
ⓘImportant traits for &'a mut Rpub fn move_backward(&mut self, amount: f32) -> &mut Self[src]
pub fn move_backward(&mut self, amount: f32) -> &mut SelfMove backward relative to current position and orientation.
ⓘImportant traits for &'a mut Rpub fn move_right(&mut self, amount: f32) -> &mut Self[src]
pub fn move_right(&mut self, amount: f32) -> &mut SelfMove right relative to current position and orientation.
ⓘImportant traits for &'a mut Rpub fn move_left(&mut self, amount: f32) -> &mut Self[src]
pub fn move_left(&mut self, amount: f32) -> &mut SelfMove left relative to current position and orientation.
ⓘImportant traits for &'a mut Rpub fn move_up(&mut self, amount: f32) -> &mut Self[src]
pub fn move_up(&mut self, amount: f32) -> &mut SelfMove up relative to current position and orientation.
ⓘImportant traits for &'a mut Rpub fn move_down(&mut self, amount: f32) -> &mut Self[src]
pub fn move_down(&mut self, amount: f32) -> &mut SelfMove down relative to current position and orientation.
ⓘImportant traits for &'a mut Rpub fn pitch_global(&mut self, angle: Deg<f32>) -> &mut Self[src]
pub fn pitch_global(&mut self, angle: Deg<f32>) -> &mut SelfPitch relatively to the world.
ⓘImportant traits for &'a mut Rpub fn pitch_local(&mut self, angle: Deg<f32>) -> &mut Self[src]
pub fn pitch_local(&mut self, angle: Deg<f32>) -> &mut SelfPitch relatively to its own rotation.
ⓘImportant traits for &'a mut Rpub fn yaw_global(&mut self, angle: Deg<f32>) -> &mut Self[src]
pub fn yaw_global(&mut self, angle: Deg<f32>) -> &mut SelfYaw relatively to the world.
ⓘImportant traits for &'a mut Rpub fn yaw_local(&mut self, angle: Deg<f32>) -> &mut Self[src]
pub fn yaw_local(&mut self, angle: Deg<f32>) -> &mut SelfYaw relatively to its own rotation.
ⓘImportant traits for &'a mut Rpub fn roll_global(&mut self, angle: Deg<f32>) -> &mut Self[src]
pub fn roll_global(&mut self, angle: Deg<f32>) -> &mut SelfRoll relatively to the world.
ⓘImportant traits for &'a mut Rpub fn roll_local(&mut self, angle: Deg<f32>) -> &mut Self[src]
pub fn roll_local(&mut self, angle: Deg<f32>) -> &mut SelfRoll relatively to its own rotation.
ⓘImportant traits for &'a mut Rpub fn rotate_global<A: Into<Rad<f32>>>(
&mut self,
axis: Vector3<f32>,
angle: A
) -> &mut Self[src]
pub fn rotate_global<A: Into<Rad<f32>>>(
&mut self,
axis: Vector3<f32>,
angle: A
) -> &mut SelfRotate relatively to the world
ⓘImportant traits for &'a mut Rpub fn rotate_local<A: Into<Rad<f32>>>(
&mut self,
axis: Vector3<f32>,
angle: A
) -> &mut Self[src]
pub fn rotate_local<A: Into<Rad<f32>>>(
&mut self,
axis: Vector3<f32>,
angle: A
) -> &mut SelfRotate relatively to the current orientation
ⓘImportant traits for &'a mut Rpub fn set_position(&mut self, position: Vector3<f32>) -> &mut Self[src]
pub fn set_position(&mut self, position: Vector3<f32>) -> &mut SelfSet the position.
ⓘImportant traits for &'a mut Rpub fn set_rotation<A>(&mut self, x: A, y: A, z: A) -> &mut Self where
A: Angle<Unitless = f32>,
Rad<f32>: From<A>, [src]
pub fn set_rotation<A>(&mut self, x: A, y: A, z: A) -> &mut Self where
A: Angle<Unitless = f32>,
Rad<f32>: From<A>, Set the rotation using Euler x, y, z.
Arguments
- x - The angle to apply around the x axis. Also known at the pitch.
- y - The angle to apply around the y axis. Also known at the yaw.
- z - The angle to apply around the z axis. Also known at the roll.
pub fn view_matrix(&self) -> Matrix4<f32>[src]
pub fn view_matrix(&self) -> Matrix4<f32>Calculates the inverse of this transform, which we need to render.
We can exploit the extra information we have to perform this inverse faster than O(n^3).
Trait Implementations
impl Clone for Transform[src]
impl Clone for Transformfn clone(&self) -> Transform[src]
fn clone(&self) -> TransformReturns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl Debug for Transform[src]
impl Debug for Transformfn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl PartialEq for Transform[src]
impl PartialEq for Transformfn eq(&self, other: &Transform) -> bool[src]
fn eq(&self, other: &Transform) -> boolThis method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &Transform) -> bool[src]
fn ne(&self, other: &Transform) -> boolThis method tests for !=.
impl Default for Transform[src]
impl Default for Transformimpl Component for Transform[src]
impl Component for Transformtype Storage = FlaggedStorage<Self, DenseVecStorage<Self>>
Associated storage type for this component.
impl CgTransform<Point3<f32>> for Transform[src]
impl CgTransform<Point3<f32>> for Transformfn one() -> Self[src]
fn one() -> SelfCreate an identity transformation. That is, a transformation which does nothing. Read more
fn look_at(eye: Point3<f32>, center: Point3<f32>, up: Vector3<f32>) -> Self[src]
fn look_at(eye: Point3<f32>, center: Point3<f32>, up: Vector3<f32>) -> SelfCreate a transformation that rotates a vector to look at center from eye, using up for orientation. Read more
fn transform_vector(&self, vec: Vector3<f32>) -> Vector3<f32>[src]
fn transform_vector(&self, vec: Vector3<f32>) -> Vector3<f32>Transform a vector using this transform.
fn inverse_transform_vector(&self, vec: Vector3<f32>) -> Option<Vector3<f32>>[src]
fn inverse_transform_vector(&self, vec: Vector3<f32>) -> Option<Vector3<f32>>Inverse transform a vector using this transform
fn transform_point(&self, point: Point3<f32>) -> Point3<f32>[src]
fn transform_point(&self, point: Point3<f32>) -> Point3<f32>Transform a point using this transform.
fn concat(&self, other: &Self) -> Self[src]
fn concat(&self, other: &Self) -> SelfCombine this transform with another, yielding a new transformation which has the effects of both. Read more
fn inverse_transform(&self) -> Option<Self>[src]
fn inverse_transform(&self) -> Option<Self>Create a transform that "un-does" this one.
fn concat_self(&mut self, other: &Self)
fn concat_self(&mut self, other: &Self)Combine this transform with another, in-place.
impl CgTransform<Point2<f32>> for Transform[src]
impl CgTransform<Point2<f32>> for Transformfn one() -> Self[src]
fn one() -> SelfCreate an identity transformation. That is, a transformation which does nothing. Read more
fn look_at(_eye: Point2<f32>, _center: Point2<f32>, _up: Vector2<f32>) -> Self[src]
fn look_at(_eye: Point2<f32>, _center: Point2<f32>, _up: Vector2<f32>) -> SelfCreate a transformation that rotates a vector to look at center from eye, using up for orientation. Read more
fn transform_vector(&self, vec: Vector2<f32>) -> Vector2<f32>[src]
fn transform_vector(&self, vec: Vector2<f32>) -> Vector2<f32>Transform a vector using this transform.
fn inverse_transform_vector(&self, vec: Vector2<f32>) -> Option<Vector2<f32>>[src]
fn inverse_transform_vector(&self, vec: Vector2<f32>) -> Option<Vector2<f32>>Inverse transform a vector using this transform
fn transform_point(&self, point: Point2<f32>) -> Point2<f32>[src]
fn transform_point(&self, point: Point2<f32>) -> Point2<f32>Transform a point using this transform.
fn concat(&self, other: &Self) -> Self[src]
fn concat(&self, other: &Self) -> SelfCombine this transform with another, yielding a new transformation which has the effects of both. Read more
fn inverse_transform(&self) -> Option<Self>[src]
fn inverse_transform(&self) -> Option<Self>Create a transform that "un-does" this one.
fn concat_self(&mut self, other: &Self)
fn concat_self(&mut self, other: &Self)Combine this transform with another, in-place.