88 lines
No EOL
2.4 KiB
Markdown
88 lines
No EOL
2.4 KiB
Markdown
# ODE Physics Engine Integration
|
|
|
|
## ✅ ODE Integration Complete
|
|
|
|
Full Open Dynamics Engine (ODE) support has been integrated into suicmez for 3D physics simulation, perfect for voxel games!
|
|
|
|
## Available ODE Functions
|
|
|
|
### Initialization and Cleanup
|
|
- `ode_init()` - Initialize the ODE library
|
|
- `ode_close()` - Clean up ODE resources
|
|
|
|
### World Management
|
|
- `ode_world_create()` - Create a new physics world
|
|
- `ode_world_destroy(world)` - Destroy a physics world
|
|
- `ode_world_set_gravity(world, x, y, z)` - Set world gravity
|
|
- `ode_world_step(world, stepsize)` - Advance physics simulation
|
|
|
|
### Rigid Bodies
|
|
- `ode_body_create(world)` - Create a new rigid body
|
|
- `ode_body_destroy(body)` - Destroy a rigid body
|
|
- `ode_body_set_position(body, x, y, z)` - Set body position
|
|
- `ode_body_set_linear_vel(body, x, y, z)` - Set linear velocity
|
|
|
|
### Mass and Geometry
|
|
- `ode_body_set_box_mass(body, density, lx, ly, lz)` - Set box-shaped mass
|
|
- `ode_create_box_geom(space, lx, ly, lz)` - Create box collision geometry
|
|
- `ode_geom_set_body(geom, body)` - Attach geometry to body
|
|
- `ode_geom_destroy(geom)` - Destroy geometry
|
|
|
|
### Collision Spaces
|
|
- `ode_simple_space_create(parent)` - Create collision space
|
|
- `ode_space_destroy(space)` - Destroy collision space
|
|
|
|
## Example Usage
|
|
|
|
```sui
|
|
# Initialize physics
|
|
ode_init()
|
|
|
|
# Create world with gravity
|
|
let world = ode_world_create()
|
|
let space = ode_simple_space_create(0 as *()) # null parent
|
|
ode_world_set_gravity(world, 0.0, -9.81, 0.0)
|
|
|
|
# Create a falling voxel/box
|
|
let body = ode_body_create(world)
|
|
ode_body_set_box_mass(body, 1.0, 1.0, 1.0, 1.0) # 1x1x1 meter box
|
|
ode_body_set_position(body, 0.0, 5.0, 0.0) # Start 5 units up
|
|
|
|
let geom = ode_create_box_geom(space, 1.0, 1.0, 1.0)
|
|
ode_geom_set_body(geom, body)
|
|
|
|
# Simulate physics
|
|
let mut i = 0
|
|
while i < 100 do
|
|
ode_world_step(world, 0.016) # 60 FPS
|
|
i = i + 1
|
|
end
|
|
|
|
# Cleanup
|
|
ode_geom_destroy(geom)
|
|
ode_body_destroy(body)
|
|
ode_space_destroy(space)
|
|
ode_world_destroy(world)
|
|
ode_close()
|
|
```
|
|
|
|
## Compilation
|
|
|
|
Use the updated compile scripts which now include ODE:
|
|
|
|
```bash
|
|
./compile.sh tests/your_ode_program.sui
|
|
./compile_and_run.sh tests/your_ode_program.sui
|
|
```
|
|
|
|
## ODE Version
|
|
|
|
Currently using: **ODE 0.16.6**
|
|
|
|
- Real-time rigid body dynamics
|
|
- Collision detection
|
|
- Joint constraints
|
|
- Stable simulation for games
|
|
|
|
All ODE features are now available through suicmez for building physics-based voxel games!</content>
|
|
<parameter name="filePath">ODE_INTEGRATION.md |