-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.txt
73 lines (63 loc) · 2.13 KB
/
README.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
OpenDE
------
A physics engine package for Haskell. Forked from
https://hackage.haskell.org/package/HODE, then started cleaning
it and adding StateVar API to match both OpenGL and OpenAL,
adding MonadIO instances, and whatever else was missing.
About ODE
---------
"ODE is an open source, high performance library for simulating
rigid body dynamics. It has advanced joint types and integrated
collision detection with friction. ODE is useful for simulating
vehicles, objects in virtual reality environments and virtual
creatures. It is currently used in many computer games, 3D
authoring tools and simulation tools. See http://www.ode.org/"
Completion
----------
[100%] Objects
[ 95%] Space
[ 70%] Body
[ 70%] Collision
[ 70%] Rotation
[ 70%] World
[ 50%] Mass
[ 10%] Tests
[ 1%] Error
[ -- ] Geom
[ -- ] Joint
Example usage
-------------
```
import qualified Physics.ODE.World as World
import qualified Physics.ODE as ODE
import qualified Physics.ODE.Geom as ODE
import qualified Physics.ODE.Body as Body
import Data.StateVar (($=!), get)
import Linear (V3)
import Control.Monad
import Control.Concurrent
main :: IO ()
main = do
let delay {- in milliseconds -} = 100000 :: Int
let dt {- in seconds -} = realToFrac delay / 10000000 :: Double
let g {- in m/s^2 -} = -9.81 :: Double
let h {- in meters -} = 20.0 :: Double
putStrLn "Starting ODE example usage."
() <- ODE.initODE
wd <- World.create
sp <- Space.create wd
bg <- Object.createSphere (Just sp) 1
mb <- Geometry.getBody bg
case mb of
Nothing -> error "No body found."
Just bb -> do
() <- World.gravity wd $=! V3 0 g 0
() <- Body.position bb $=! V3 0 h 0
Control.Monad.forM_ [1..10] $ \n -> do
________ <- Control.Concurrent.threadDelay delay
________ <- ODE.step dt wd
V3 _ y _ <- get (Body.position bb)
Prelude.putStrLn ("Ball position: "<>Prelude.show y<>"m")
() <- ODE.closeODE
putStrLn "ODE example is done."
```