pub struct Vector3D<S = f32, U = ()> {
pub x: S,
pub y: S,
pub z: S,
/* private fields */
}Expand description
3D vector.
Fields§
§x: S§y: S§z: SImplementations§
Source§impl<S, U> Vector3D<S, U>
impl<S, U> Vector3D<S, U>
Sourcepub const fn new(x: S, y: S, z: S) -> Self
pub const fn new(x: S, y: S, z: S) -> Self
Examples found in repository?
examples/screenshot.rs (line 167)
163 fn frame(&mut self) -> Result<(), T::Error> {
164 let (width, height) = (self.width as f32, self.height as f32);
165 let proj = Transform3D::perspective(60.0f32, width / height, 0.01, 30.0);
166 let view = Transform3D::<f32>::look_at(
167 Vector3D::new(0.0, 1.5, 9.0),
168 Vector3D::new(0.0, 0.0, 0.0),
169 Vector3D::new(0.0, 1.0, 0.0),
170 );
171 let view_proj = proj * view;
172
173 self.rx += 0.01;
174 self.ry += 0.03;
175
176 let model = Transform3D::rotation(self.ry, Vector3D::new(0., 1.0, 0.))
177 * Transform3D::<f32>::rotation(self.rx, Vector3D::new(1.0, 0., 0.));
178
179 let vs_params = display_shader::Uniforms {
180 mvp: view_proj * model,
181 };
182 let mut frame = self.backend.frame();
183
184 frame.begin_pass(
185 self.offscreen_pass,
186 gfx::PassAction::clear(gfx::color::Rgba::BLACK),
187 );
188 frame.apply_pipeline(&self.offscreen_pipeline)?;
189 frame.apply_bindings(&self.offscreen_bind)?;
190 frame.apply_uniforms(&vs_params)?;
191 frame.draw(0, 3, 1)?;
192 frame.end_pass();
193
194 frame.begin_default_pass(gfx::PassAction::clear(gfx::color::Rgba::BLACK));
195 frame.apply_pipeline(&self.display_pipeline)?;
196 frame.apply_bindings(&self.display_bind)?;
197 frame.draw(0, 6, 1)?;
198 frame.end_pass();
199 frame.commit();
200
201 Ok(())
202 }More examples
examples/offscreen.rs (line 32)
28 fn frame(&mut self) -> Result<(), Self::Error> {
29 let (width, height) = (self.width as f32, self.height as f32);
30 let proj = Transform3D::perspective(60.0f32, width / height, 0.01, 100.);
31 let view = Transform3D::<f32>::look_at(
32 Vector3D::new(0.0, 1.5, 9.0),
33 Vector3D::new(0.0, 0.0, 0.0),
34 Vector3D::new(0.0, 1.0, 0.0),
35 );
36 let view_proj = proj * view;
37
38 self.rx += 0.01;
39 self.ry += 0.03;
40
41 let model = Transform3D::rotation(self.ry, Vector3D::new(0., 1.0, 0.))
42 * Transform3D::<f32>::rotation(self.rx, Vector3D::new(1.0, 0., 0.));
43 let vs_params = display_shader::Uniforms {
44 mvp: view_proj * model,
45 };
46 let mut frame = self.backend.frame();
47
48 // Offscreen pass.
49 frame.begin_pass(
50 self.offscreen_pass,
51 gfx::PassAction::clear(gfx::color::Rgba::WHITE),
52 );
53 frame.apply_pipeline(&self.offscreen_pipeline)?;
54 frame.apply_bindings(&self.offscreen_bind)?;
55 frame.apply_uniforms(&vs_params)?;
56 frame.draw(0, 36, 1)?;
57 frame.end_pass();
58
59 // Display pass.
60 frame.begin_default_pass(gfx::PassAction::clear(gfx::color::Rgba::new(
61 0.0, 0., 0.45, 1.,
62 )));
63 frame.apply_pipeline(&self.display_pipeline)?;
64 frame.apply_bindings(&self.display_bind)?;
65 frame.apply_uniforms(&vs_params)?;
66 frame.draw(0, 36, 1)?;
67 frame.end_pass();
68 frame.commit();
69
70 Ok(())
71 }Trait Implementations§
Source§impl Mul<Vector3D> for Transform3D<f32>
Transform a Vector3D with a Transform3D.
impl Mul<Vector3D> for Transform3D<f32>
Transform a Vector3D with a Transform3D.
use ombre::math::*;
let m = Transform3D::from_translation(Vector3D::new(8., 8., 0.));
let v = Vector3D::new(1., 1., 0.);
assert_eq!(m * v, Vector3D::new(9., 9., 0.));impl<S: Copy, U: Copy> Copy for Vector3D<S, U>
impl<S: Eq, U: Eq> Eq for Vector3D<S, U>
impl<S, U> StructuralPartialEq for Vector3D<S, U>
Auto Trait Implementations§
impl<S, U> Freeze for Vector3D<S, U>where
S: Freeze,
impl<S, U> RefUnwindSafe for Vector3D<S, U>where
S: RefUnwindSafe,
U: RefUnwindSafe,
impl<S, U> Send for Vector3D<S, U>
impl<S, U> Sync for Vector3D<S, U>
impl<S, U> Unpin for Vector3D<S, U>
impl<S, U> UnwindSafe for Vector3D<S, U>where
S: UnwindSafe,
U: UnwindSafe,
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