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: Kv6Voxel 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: u32Voxlap-style flags bitfield. See SPRITE_FLAG_NO_SHADING,
SPRITE_FLAG_KFA, SPRITE_FLAG_INVISIBLE,
SPRITE_FLAG_NO_Z.
Implementations§
Source§impl Sprite
impl Sprite
Sourcepub fn axis_aligned(kv6: Kv6, pos: [f32; 3]) -> Sprite
pub fn axis_aligned(kv6: Kv6, pos: [f32; 3]) -> Sprite
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]);Sourcepub fn carve_sphere_with_colfunc<S, C>(
&mut self,
centre: [i32; 3],
radius: u32,
solid: S,
colfunc: C,
)
pub fn carve_sphere_with_colfunc<S, C>( &mut self, centre: [i32; 3], radius: u32, solid: S, colfunc: C, )
Carve a sphere out of this sprite’s voxel model, controlling
the colour of the interior the cut exposes. Thin delegate to
Kv6::carve_sphere_with_colfunc — centre / radius,
solid, and colfunc are all in kv6-local voxel
coordinates (the sprite pose p/s/h/f is untouched). See
that method for why the solid occupancy predicate is required.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Sprite
impl RefUnwindSafe for Sprite
impl Send for Sprite
impl Sync for Sprite
impl Unpin for Sprite
impl UnsafeUnpin for Sprite
impl UnwindSafe for Sprite
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more