Skip to main content

Module meshmod

Module meshmod 

Source
Expand description

Mesh modifiers: a Blender-style stack that reshapes an object’s mesh without touching the source model. Add MeshModifiers to an object with a Shape or a model and stack modifiers (Array, Mirror, Subdivide, Displace, Twist, Bend, Taper, Solidify) in any order.

The result is a DynamicMesh, rebuilt only when the stack or the source changes.

use kvas_engine::{prelude::*, scene::Scene, meshmod::*};
let mut scene = Scene::default();
let e = scene.spawn("Fence");
scene.world.insert(e, Shape::of(ShapeType::Cube));
scene.world.insert(e, MeshRenderer::default());
scene.world.insert(e, MeshModifiers(vec![Modifier::array(3, Vec3::new(1.5, 0.0, 0.0))]));
update(&mut scene.world);
assert_eq!(scene.world.get::<DynamicMesh>(e).unwrap().data.vertices.len(), 3 * 24);

Structs§

MeshModifiers
The modifier stack of an object, applied top to bottom.
ModifierState
Cache of what the last build used, so unchanged stacks cost nothing.
ModifierStateCell
Runtime-only marker holding the build signature (never saved).

Enums§

ModAxis
Axis a modifier works along.
Modifier
One entry of the stack. Fields are public so scripts can build stacks in code.

Functions§

assets
The asset source set with set_assets, if any.
build
Runs the stack on a source mesh.
set_assets
Tells the modifier system where to load model files from (the editor and player call this).
update
Rebuilds the DynamicMesh of every object with modifiers whose stack or source changed.