43 lines
No EOL
986 B
Text
43 lines
No EOL
986 B
Text
# ODE Voxel Physics Example
|
|
fn main() -> int do
|
|
# Initialize ODE
|
|
ode_init()
|
|
|
|
# Create world and space
|
|
let world = ode_world_create()
|
|
let space = ode_simple_space_create(0 as *()) # null parent
|
|
|
|
# Set gravity
|
|
ode_world_set_gravity(world, 0.0, -9.81, 0.0)
|
|
|
|
# Create a box body
|
|
let body = ode_body_create(world)
|
|
|
|
# Set box mass (density 1.0, size 1x1x1)
|
|
ode_body_set_box_mass(body, 1.0, 1.0, 1.0, 1.0)
|
|
|
|
# Set initial position (5 units up)
|
|
ode_body_set_position(body, 0.0, 5.0, 0.0)
|
|
|
|
# Create geometry for the box
|
|
let geom = ode_create_box_geom(space, 1.0, 1.0, 1.0)
|
|
|
|
# Attach geometry to body
|
|
ode_geom_set_body(geom, body)
|
|
|
|
# Simulate for a few steps
|
|
let mut i = 0
|
|
while i < 10 do
|
|
ode_world_step(world, 0.016) # 60 FPS
|
|
i = i + 1
|
|
end
|
|
|
|
# Clean up
|
|
ode_geom_destroy(geom)
|
|
ode_body_destroy(body)
|
|
ode_space_destroy(space)
|
|
ode_world_destroy(world)
|
|
ode_close()
|
|
|
|
0
|
|
end |