Struct Lines

Source
pub struct Lines;
Expand description

A line drawing class! This is an easy way to visualize lines or relationships between objects. The current implementation uses a quad strip that always faces the user, via vertex shader manipulation. https://stereokit.net/Pages/StereoKit/Lines.html

§Examples

use stereokit_rust::{maths::{Vec3, Pose, Ray}, system::{Lines, LinePoint},
                     util::{named_colors}};

let ray = Ray::new([-0.3, -0.8, 0.2], [1.0, 0.0, 0.0]);

let axis_pose = Pose::new([0.0, -0.35, 0.0], None);

filename_scr = "screenshots/lines.jpeg";
test_screenshot!( // !!!! Get a proper main loop !!!!
    Lines::add(token, [0.7, 0.7, 0.2], [ 0.7,-0.7, 0.2], named_colors::LIME, None, 0.06);
    Lines::add(token, [0.7, 0.7, 0.2], [-0.7, 0.7, 0.2], named_colors::RED, None, 0.03);

    Lines::add_list(token, &[
       LinePoint {pt: [-0.7,-0.7, 0.2].into(), thickness: 0.08, color: named_colors::FUCHSIA},
       LinePoint::new([-0.5,-0.1, 0.2], 0.08, named_colors::BLACK),
       LinePoint::new([-0.7, 0.7, 0.2], 0.01, named_colors::YELLOW),
    ]);

    Lines::add_ray(token, ray, 0.6, named_colors::RED, None, 0.08 );

    Lines::add_axis(token, axis_pose, Some(0.7), Some(0.04));
);
screenshot

Implementations§

Source§

impl Lines

Source

pub fn add<V: Into<Vec3>>( _token: &MainThreadToken, start: V, end: V, color_start: Color32, color_end: Option<Color32>, thickness: f32, )

Adds a line to the environment for the current frame. https://stereokit.net/Pages/StereoKit/Lines/Add.html

  • start - The start of the line.
  • end - The end of the line.
  • color_start - Color for the start of the line, this is embedded in the vertex color of the line.
  • color_end - Color for the end of the line, this is embedded in the vertex color of the line. If None, uses color_start.
  • thickness - The thickness of the line.

see also line_add

§Examples
use stereokit_rust::{maths::{Vec3, Pose, Ray}, system::{Lines, LinePoint},
                     util::{named_colors}};

test_steps!( // !!!! Get a proper main loop !!!!
    Lines::add(token, [0.7, 0.7, 0.2], [ 0.7,-0.7, 0.2], named_colors::LIME, None, 0.06);

    Lines::add(token, [0.7, 0.7, 0.2], [-0.7, 0.7, 0.2], named_colors::RED, None, 0.03);
);
Source

pub fn add_ray<R: Into<Ray>>( _token: &MainThreadToken, ray: R, length: f32, color_start: Color32, color_end: Option<Color32>, thickness: f32, )

Adds a line based on a ray to the environment for the current frame. https://stereokit.net/Pages/StereoKit/Lines/Add.html

  • ray - The ray we want to visualize!
  • length - How long should the ray be? Actual length will be ray.direction.Magnitude * length.
  • color_start - Color for the start of the line, this is embedded in the vertex color of the line.
  • color_end - Color for the end of the line, this is embedded in the vertex color of the line. If None, uses color_start.
  • thickness - The thickness of the line.

see also line_add

§Examples
use stereokit_rust::{maths::{Vec3, Ray}, system::{Lines, LinePoint},
                     util::{named_colors}};

// axis at the origins:
let ray1 = Ray::new(Vec3::ZERO, Vec3::X);
let ray2 = Ray::new(Vec3::ZERO, Vec3::Y);
let ray3 = Ray::new(Vec3::ZERO, Vec3::Z);


test_steps!( // !!!! Get a proper main loop !!!!
    Lines::add_ray(token, ray1, 1.0, named_colors::WHITE, Some(named_colors::RED), 0.03 );
    Lines::add_ray(token, ray2, 1.0, named_colors::WHITE, Some(named_colors::GREEN), 0.03 );
    Lines::add_ray(token, ray2, 1.0, named_colors::WHITE, Some(named_colors::BLUE), 0.03 );
);
Source

pub fn add_list(_token: &MainThreadToken, points: &[LinePoint])

Adds a line from a list of line points to the environment. This does not close the path, so if you want it closed, you’ll have to add an extra point or two at the end yourself! https://stereokit.net/Pages/StereoKit/Lines/Add.html

  • points - An array of LinePoint.

see also line_add

§Examples
use stereokit_rust::{maths::{Vec3, Pose, Ray}, system::{Lines, LinePoint},
                     util::{named_colors}};
test_steps!( // !!!! Get a proper main loop !!!!

    Lines::add_list(token, &[
       LinePoint {pt: [-0.7,-0.7, 0.2].into(), thickness: 0.08, color: named_colors::FUCHSIA},
       LinePoint::new([-0.5,-0.1, 0.2], 0.08, named_colors::BLACK),
       LinePoint::new([-0.7, 0.7, 0.2], 0.01, named_colors::YELLOW),
    ]);

);
Source

pub fn add_axis<P: Into<Pose>>( token: &MainThreadToken, at_pose: P, size: Option<f32>, thickness: Option<f32>, )

Displays an RGB/XYZ axis widget at the pose! Each line is extended along the positive direction of each axis, so the red line is +X, green is +Y, and blue is +Z. A white line is drawn along -Z to indicate the Forward vector of the pose (-Z is forward in StereoKit). https://stereokit.net/Pages/StereoKit/Lines/AddAxis.html

  • at_pose - What position and orientation do we want this axis widget at?
  • size - How long should the widget lines be, in meters? If None, has value of 1 cm
  • thickness - How thick should the lines be, in meters? If None, will use a faster renderer with a thickness of one tenth of the size.

see also line_add

§Examples
use stereokit_rust::{maths::{Vec3, Pose, Ray}, system::{Lines, LinePoint},
                     util::{named_colors}};

// Axis at the origins:
let axis_pose = Pose::IDENTITY;

test_steps!( // !!!! Get a proper main loop !!!!

    Lines::add_axis(token, axis_pose, Some(0.7), Some(0.02));

);

Auto Trait Implementations§

§

impl Freeze for Lines

§

impl RefUnwindSafe for Lines

§

impl Send for Lines

§

impl Sync for Lines

§

impl Unpin for Lines

§

impl UnwindSafe for Lines

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more