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 Faces with indices to the vertex collection.

Fields§

§transform: Transform3D§vertices: Vec<Vec3D>§faces: Vec<Face>

Implementations§

source§

impl Mesh3D

source

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 21)
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
42
43
44
45
46
47
48
49
fn main() {
    let mut frame_skip = false;
    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,
        Vec2D::new((view.width / 2) as isize, (view.height / 2) as isize),
    );

    let cube = Mesh3D::default_cube();

    loop {
        let now = gameloop::Instant::now();
        view.clear();

        viewport.transform.rotation.y -= 0.05;

        match frame_skip {
            true => frame_skip = false,
            false => {
                view.blit(
                    &viewport.render(vec![&cube], DisplayMode::Solid),
                    Wrapping::Ignore,
                );
                view.display_render().unwrap();
            }
        }

        let elapsed = now.elapsed();
        println!(
            "Elapsed: {:.2?}µs | Frame skip: {}",
            elapsed.as_micros(),
            frame_skip
        );

        frame_skip = gameloop::sleep_fps(FPS, Some(elapsed));
    }
}
source

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)

source

pub fn new( transform: Transform3D, vertices: Vec<Vec3D>, faces: Vec<Face> ) -> Self

Trait Implementations§

source§

impl Clone for Mesh3D

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Mesh3D

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl ViewElement3D for Mesh3D

source§

fn get_transform(&self) -> Transform3D

This should return the object’s transform
source§

fn get_vertices(&self) -> &Vec<Vec3D>

This should return all of the object’s vertices
source§

fn get_faces(&self) -> &Vec<Face>

This should return all of the object’s Faces

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.