Struct gemini_engine::elements3d::Mesh3D
source · pub struct Mesh3D {
pub transform: Transform3D,
pub vertices: Vec<Vec3D>,
pub faces: Vec<Face>,
}
Expand description
The struct for a Mesh3D object, containing a position, rotation, collection of vertices and collection of Face
s with indices to the vertex collection.
Fields§
§transform: Transform3D
§vertices: Vec<Vec3D>
§faces: Vec<Face>
Implementations§
source§impl Mesh3D
impl Mesh3D
sourcepub fn default_cube() -> Self
pub fn default_cube() -> Self
The gemini_engine equivalent of Blender’s default cube. Has side lengths of 2
Examples found in repository?
examples/spinning-cube.rs (line 18)
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
);
}
);
}
sourcepub fn gimbal() -> Self
pub fn gimbal() -> Self
A gimbal to help you orient in gemini_engine’s 3D space. The orientation is as follows (from the default Viewport
)
- X (red) increases as you move to the right
- Y (green) increases as you move up
- Z (blue) increases as you move away from the viewport
Think of it like Blender’s axes but with Y and Z swapped.
This Mesh does not render in DisplayMode::SOLID
(see DisplayMode
documentation)
pub fn new( transform: Transform3D, vertices: Vec<Vec3D>, faces: Vec<Face> ) -> Self
Trait Implementations§
source§impl ViewElement3D for Mesh3D
impl ViewElement3D for Mesh3D
source§fn get_transform(&self) -> Transform3D
fn get_transform(&self) -> Transform3D
This should return the object’s transform
source§fn get_vertices(&self) -> &[Vec3D]
fn get_vertices(&self) -> &[Vec3D]
This should return all of the object’s vertices
Auto Trait Implementations§
impl RefUnwindSafe for Mesh3D
impl Send for Mesh3D
impl Sync for Mesh3D
impl Unpin for Mesh3D
impl UnwindSafe for Mesh3D
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