Struct tiny_game_framework::Vector4D

source ·
pub struct Vector4D {
    pub x: f32,
    pub y: f32,
    pub z: f32,
    pub w: f32,
}

Fields§

§x: f32§y: f32§z: f32§w: f32

Implementations§

source§

impl Vector4D

source

pub fn new(x: f32, y: f32, z: f32, w: f32) -> Self

Examples found in repository?
examples/test_scene.rs (line 18)
5
6
7
8
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
fn main() {
    let mut el = EventLoop::new(500, 500);
    let mut renderer = Renderer::new();

    unsafe {
        Enable(BLEND);
        BlendFunc(SRC_ALPHA, ONE_MINUS_SRC_ALPHA); 
    }

    fn nome_aleatorio() -> String {
        format!("{:?}", rand_betw(0.0_f64, 1000.0_f64))
    }

    let mut c = Circle::new(32, Vector3D::new(0.0, 0.0, 0.0), 0.5, Vector4D::new(0.5, 1.0, 0.5, 0.2));
    c.add_to_renderer("oi", &mut renderer);
    
    let t = Triangle::new(Vector3D::new(1.0, 0.0, 0.0), 0.5, Vector4D::new(1.0, 1.0, 1.0, 0.6));
    t.add_to_renderer("trianglu", &mut renderer);

    let q = Quad::new(Vector3D::new(-1.0, 0.0, 0.0), Vector3D::new(0.5, 0.5, 0.5), Vector4D::new(0.5, 0.1, 0.1, 0.9));
    q.add_to_renderer("quda", &mut renderer);

    // let mut t = Triangle
    for i in 0..256 {
        let c = Circle::new(32, Vector3D::new(0.0, 0.0, 0.0), 0.1, Vector4D::new(1.0, 1.0, 1.0, 1.0));
        c.add_to_renderer(&format!("{:?}", i), &mut renderer);
    }
    
    let o = Once::new(); 
    let mut time: f32 = 0.0;
    while !el.window.should_close() {
        let now = std::time::Instant::now();

        el.update();
        renderer.update();

        if el.is_key_down(glfw::Key::I) {
            println!("{:?}", el.event_handler.mouse_pos.x / el.event_handler.width);
        }

        let mouse_pos = Vector3D::new(el.event_handler.mouse_pos.x / el.event_handler.width, el.event_handler.mouse_pos.y / el.event_handler.height, 0.0);

        unsafe {
            Clear(COLOR_BUFFER_BIT);

            renderer.draw();
            
            o.call_once(|| {
                for i in 0..256 {
                    renderer.destroy_mesh(&format!("{:?}", i));
                }
            });
        }

        time += now.elapsed().as_secs_f32();
    }
}
source

pub fn dot(self, other: Vector4D) -> f32

source

pub fn magnitude(self) -> f32

source

pub fn normalize(self) -> Self

Trait Implementations§

source§

impl Add for Vector4D

§

type Output = Vector4D

The resulting type after applying the + operator.
source§

fn add(self, other: Self) -> Self

Performs the + operation. Read more
source§

impl Clone for Vector4D

source§

fn clone(&self) -> Vector4D

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 Vector4D

source§

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

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

impl Div<f32> for Vector4D

§

type Output = Vector4D

The resulting type after applying the / operator.
source§

fn div(self, scalar: f32) -> Self

Performs the / operation. Read more
source§

impl Mul<Vector4D> for Matrix4x4

§

type Output = Vector4D

The resulting type after applying the * operator.
source§

fn mul(self, v: Vector4D) -> Vector4D

Performs the * operation. Read more
source§

impl Mul<f32> for Vector4D

§

type Output = Vector4D

The resulting type after applying the * operator.
source§

fn mul(self, scalar: f32) -> Self

Performs the * operation. Read more
source§

impl PartialEq for Vector4D

source§

fn eq(&self, other: &Vector4D) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Sub for Vector4D

§

type Output = Vector4D

The resulting type after applying the - operator.
source§

fn sub(self, other: Self) -> Self

Performs the - operation. Read more
source§

impl Copy for Vector4D

source§

impl StructuralPartialEq for Vector4D

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where 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 T
where 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 T
where 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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V