Struct gemini_engine::elements3d::view3d::Transform3D
source · pub struct Transform3D {
pub translation: Vec3D,
pub rotation: Vec3D,
pub scale: Vec3D,
}Expand description
The Transform3D struct is used to manipulate the position of objects in 3D space
Fields§
§translation: Vec3DThe position of the object in 3D space
rotation: Vec3DThe rotation of the object, applied in radians
scale: Vec3DThe object’s scale
Implementations§
source§impl Transform3D
impl Transform3D
sourcepub const fn new_trs(translation: Vec3D, rotation: Vec3D, scale: Vec3D) -> Self
pub const fn new_trs(translation: Vec3D, rotation: Vec3D, scale: Vec3D) -> Self
Create a Transform3D with chosen translation, rotation and scale
sourcepub const fn new_tr(translation: Vec3D, rotation: Vec3D) -> Self
pub const fn new_tr(translation: Vec3D, rotation: Vec3D) -> Self
Create a Transform3D with chosen translation and rotation
Examples found in repository?
examples/spinning-cube.rs (line 13)
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
fn main() {
let mut view = View::new(350, 90, ColChar::BACKGROUND);
let mut viewport = Viewport::new(
Transform3D::new_tr(Vec3D::new(0.0, 0.0, 5.0), Vec3D::new(-0.5, 0.3, 0.0)),
FOV,
view.center(),
);
let cube = Mesh3D::default_cube();
fps_gameloop!(
{
view.clear();
viewport.transform.rotation.y -= 0.05;
},
{
view.blit(
&viewport.render(vec![&cube], DisplayMode::Solid),
Wrapping::Ignore,
);
view.display_render().unwrap();
},
FPS,
|elapsed: gameloop::Duration, frame_skip| {
println!(
"Elapsed: {:.2?}µs | Frame skip: {}",
elapsed.as_micros(),
frame_skip
);
}
);
}Trait Implementations§
source§impl Clone for Transform3D
impl Clone for Transform3D
source§fn clone(&self) -> Transform3D
fn clone(&self) -> Transform3D
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for Transform3D
impl Debug for Transform3D
source§impl Default for Transform3D
impl Default for Transform3D
source§impl Mul<Vec3D> for Transform3D
impl Mul<Vec3D> for Transform3D
source§impl Mul for Transform3D
impl Mul for Transform3D
§type Output = Transform3D
type Output = Transform3D
The resulting type after applying the
* operator.impl Copy for Transform3D
Auto Trait Implementations§
impl RefUnwindSafe for Transform3D
impl Send for Transform3D
impl Sync for Transform3D
impl Unpin for Transform3D
impl UnwindSafe for Transform3D
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more