use alice_physics::cloth::{Cloth, ClothConfig};
use alice_physics::math::{Fix128, Vec3Fix};
fn main() {
let mut cloth = Cloth::new_grid(
Vec3Fix::new(
Fix128::from_int(-1),
Fix128::from_int(5),
Fix128::from_int(-1),
),
Fix128::from_int(2), Fix128::from_int(2), 10, 10, Fix128::from_ratio(1, 100), );
cloth.pin_top_row(10);
cloth.config = ClothConfig {
iterations: 8,
substeps: 4,
..ClothConfig::default()
};
cloth.wind = Vec3Fix::new(Fix128::from_int(2), Fix128::ZERO, Fix128::ONE);
println!("ALICE-Physics Cloth Simulation");
println!("==============================");
println!("Particles: {}", cloth.particle_count());
println!("Pinned top row: 10 particles");
println!();
let dt = Fix128::from_ratio(1, 60);
for frame in 0..180 {
cloth.step(dt);
if frame % 30 == 0 {
let mid_bottom = 9 * 10 + 5; let pos = cloth.positions[mid_bottom];
println!(
"Frame {:3}: bottom-center y={:.4}, z={:.4}",
frame,
pos.y.to_f64(),
pos.z.to_f64(),
);
}
}
let normals = cloth.compute_normals();
println!();
println!("Simulation complete (180 frames, 3 seconds).");
println!("Final normals computed: {} vertices", normals.len());
println!("Debug: {cloth:?}");
}