pub struct Engine { /* private fields */ }Expand description
Voxel engine state.
Implementations§
Source§impl Engine
impl Engine
Sourcepub fn set_camera(&mut self, camera: Camera)
pub fn set_camera(&mut self, camera: Camera)
Set the camera pose (position + right/down/forward basis) the
next render uses.
Sourcepub fn camera(&self) -> Camera
pub fn camera(&self) -> Camera
The current camera pose (a copy — mutate via
set_camera).
Sourcepub fn set_sky_color(&mut self, color: u32)
pub fn set_sky_color(&mut self, color: u32)
Override the sky / background colour. Bytes are 0xAARRGGBB
where AA is the voxlap-style “brightness” channel (0x80 is
“normal” intensity, matching the engine’s other surface
colours).
Sourcepub fn sky_color(&self) -> u32
pub fn sky_color(&self) -> u32
The current sky / background colour, 0xAARRGGBB with the
voxlap-style brightness byte (see
set_sky_color).
Sourcepub fn set_fog(&mut self, color: u32, max_scan_dist: i32)
pub fn set_fog(&mut self, color: u32, max_scan_dist: i32)
Configure fog. max_scan_dist <= 0 disables fog. Otherwise
pixels at the maximum scan distance blend fully to
fog_color (low 24 bits — alpha byte ignored). Voxlap’s
vx5.maxscandist-based foglut is rebuilt downstream by
ScanScratch::set_fog.
Sourcepub fn fog_color(&self) -> u32
pub fn fog_color(&self) -> u32
The fog colour set by set_fog. Only the low
24 RGB bits are blended toward; the alpha byte is ignored.
Sourcepub fn fog_max_scan_dist(&self) -> i32
pub fn fog_max_scan_dist(&self) -> i32
Distance (PREC-scaled cells, voxlap’s vx5.maxscandist) at
which fog reaches full opacity. 0 ⇒ fog disabled.
Sourcepub fn set_side_shades(
&mut self,
top: i8,
bot: i8,
left: i8,
right: i8,
up: i8,
down: i8,
)
pub fn set_side_shades( &mut self, top: i8, bot: i8, left: i8, right: i8, up: i8, down: i8, )
Voxlap’s setsideshades(top, bot, left, right, up, down)
— per-side voxel darkening intensities. Each i8 is stamped
onto the high byte of gcsub[2..7] (downstream by
ScanScratch::set_side_shades). Pass (0,…,0) to disable
(the oracle baseline); positive values like 15 / 31 give the
directional darkening typical of voxlap’s classic games.
Sourcepub fn side_shades(&self) -> [i8; 6]
pub fn side_shades(&self) -> [i8; 6]
The per-side darkening intensities in
[top, bot, left, right, up, down] order (see
set_side_shades). All-zero ⇒ shading
off.
Sourcepub fn set_kv6col(&mut self, color: u32)
pub fn set_kv6col(&mut self, color: u32)
Sprite material colour — packed BGRA bytes, voxlap’s
vx5.kv6col. R/G/B equal triggers update_reflects’s
nolighta fast path.
Sourcepub fn kv6col(&self) -> u32
pub fn kv6col(&self) -> u32
The current sprite material colour — voxlap’s vx5.kv6col
(see set_kv6col). Defaults to
DEFAULT_KV6COL.
Sourcepub fn set_lightmode(&mut self, mode: u32)
pub fn set_lightmode(&mut self, mode: u32)
Sprite lighting mode — voxlap’s vx5.lightmode. 0 / 1 →
directional tint; 2 → point-light shading from
Engine::lights. Other values clamp to 2 in voxlap.
Sourcepub fn lightmode(&self) -> u32
pub fn lightmode(&self) -> u32
The current sprite lighting mode — voxlap’s vx5.lightmode
(see set_lightmode for the values).
Sourcepub fn add_light(&mut self, light: LightSrc)
pub fn add_light(&mut self, light: LightSrc)
Append a light source. No upper bound enforced here —
voxlap’s MAXLIGHTS (16) is the practical limit, but the
rendering math just iterates whatever’s in the slice.
Sourcepub fn clear_lights(&mut self)
pub fn clear_lights(&mut self)
Remove every light source — voxlap’s vx5.numlights = 0.
Typical per-frame pattern: clear, then re-add_light
whatever is active this frame.
Sourcepub fn lights(&self) -> &[LightSrc]
pub fn lights(&self) -> &[LightSrc]
The active point lights, in add_light
insertion order (voxlap’s vx5.lightsrc[0..numlights]).
Sourcepub fn set_sky(&mut self, sky: Option<Sky>)
pub fn set_sky(&mut self, sky: Option<Sky>)
Set the sky texture used by the textured-startsky path.
None reverts to the cheap solid-fill default.
Sourcepub fn sky(&self) -> Option<&Sky>
pub fn sky(&self) -> Option<&Sky>
The current sky texture, if one is loaded (see
set_sky). None ⇒ the solid-fill sky path.
Sourcepub fn render(
&mut self,
pixels: &mut [u32],
width: u32,
height: u32,
pitch_pixels: u32,
)
pub fn render( &mut self, pixels: &mut [u32], width: u32, height: u32, pitch_pixels: u32, )
Render one frame into the caller-owned ARGB framebuffer.
pixels is a row-major u32 buffer; pitch_pixels is the row
stride in u32 elements (which equals width for a tightly-
packed buffer, but may be larger when the host is e.g. an SDL2
streaming texture with per-row padding).
R3 is a stub that fills the visible region with sky_color.
R4 replaces this with the real raycaster.
§Panics
Panics if pixels.len() < (height as usize) * (pitch_pixels as usize) or if width > pitch_pixels — i.e. when the buffer
would not contain height rows of pitch_pixels u32 each, or
when the visible width would overflow each row.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Engine
impl RefUnwindSafe for Engine
impl Send for Engine
impl Sync for Engine
impl Unpin for Engine
impl UnsafeUnpin for Engine
impl UnwindSafe for Engine
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> 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