Struct tiny_game_framework::Vector3D
source · pub struct Vector3D {
pub x: f32,
pub y: f32,
pub z: f32,
}
Fields§
§x: f32
§y: f32
§z: f32
Implementations§
source§impl Vector3D
impl Vector3D
pub const ZERO: Vector3D = _
sourcepub fn new(x: f32, y: f32, z: f32) -> Self
pub fn new(x: f32, y: f32, z: 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();
}
}
pub fn magnitude(self) -> f32
pub fn dot(vec1: Vector3D, vec2: Vector3D) -> f32
pub fn cross(vec1: Vector3D, vec2: Vector3D) -> Vector3D
pub fn normalize(self) -> Vector3D
Trait Implementations§
source§impl PartialEq for Vector3D
impl PartialEq for Vector3D
impl Copy for Vector3D
impl StructuralPartialEq for Vector3D
Auto Trait Implementations§
impl Freeze for Vector3D
impl RefUnwindSafe for Vector3D
impl Send for Vector3D
impl Sync for Vector3D
impl Unpin for Vector3D
impl UnwindSafe for Vector3D
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