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]) -> Self
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]);