Skip to main content

Sprite

Struct Sprite 

Source
pub struct Sprite {
    pub kv6: Kv6,
    pub p: [f32; 3],
    pub s: [f32; 3],
    pub h: [f32; 3],
    pub f: [f32; 3],
    pub flags: u32,
}
Expand description

A KV6 voxel sprite positioned in world space.

Mirror of voxlap’s vx5sprite for the kv6 case (flags & SPRITE_FLAG_KFA == 0; see SPRITE_FLAG_KFA). Owns its Kv6 by value. p / s / h / f are voxlap’s per-axis world-space basis: s is the kv6.xsiz direction, h the ysiz direction, f the zsiz direction. For an axis-aligned sprite, s = [1,0,0], h = [0,1,0], f = [0,0,1].

Fields§

§kv6: Kv6

Voxel data + bounding-box pivots. Loaded from a .kv6 file via crate::kv6::parse or built procedurally.

§p: [f32; 3]

World-space position of the sprite’s pivot (xpiv, ypiv, zpiv inside the kv6 maps to this point).

§s: [f32; 3]

World-space basis vector for the kv6’s local +x. Length scales the sprite along that axis (typically 1.0 for unit-scale).

§h: [f32; 3]

World-space basis vector for the kv6’s local +y.

§f: [f32; 3]

World-space basis vector for the kv6’s local +z.

§flags: u32

Implementations§

Source§

impl Sprite

Source

pub fn axis_aligned(kv6: Kv6, pos: [f32; 3]) -> Self

Convenience constructor for an axis-aligned sprite at world position pos. Basis is identity, flags = 0 (kv6 + normal shading + visible + z-tested).

§Examples
use roxlap_formats::kv6::Kv6;
use roxlap_formats::sprite::Sprite;

// ... after `let kv6 = kv6::parse(&bytes)?;` or similar:
let sprite = Sprite::axis_aligned(kv6, [1024.0, 1024.0, 100.0]);
assert_eq!(sprite.flags, 0);
assert_eq!(sprite.s, [1.0, 0.0, 0.0]);

Trait Implementations§

Source§

impl Clone for Sprite

Source§

fn clone(&self) -> Sprite

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Sprite

Source§

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

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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

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.