Skip to content
Jakob Flierl edited this page Jun 20, 2016 · 18 revisions

00-hello-cmdline.gif

A simple Bullet Physics Playground scene consists of a Lua script that defines the basic objects in the physics world. See demo/basic/00-hello-cmdline.lua to get started:

a white plane in the x-z dimension

p = Plane(0,1,0,0,100)   -- <x,y,z> up vector, mass, dim (for OpenGL preview)
p.col = "#fff"           -- white color
v:add(p)                 -- add it to the bpp view

a red sphere

s = Sphere(1,10)           -- 2 diameter, 10 mass
s.col = "red"
s.pos = btVector3(0,10,0)  -- position the sphere 10 units above the plane
v:add(s)

a camera

v.cam.pos  = btVector3(100,100,100)   -- cam position
v.cam.look = btVector3(0,5,0)         -- cam location

Command-line usage

  • You can run bpp from the command-line and forward the output of the Lua script to gnuplot:
$ bpp -n 200 -f demo/basic/00-hello-cmdline.lua | gnuplot -e "set terminal dumb; plot for[col=3:3] '/dev/stdin' using 1:col title columnheader(col) with lines"

  10 **-----+------+------+------+------+------+------+------+------+-----++
     + **   +      +      +      +      +      +      +      +    Y ****** +
   9 ++  *                                                                ++
     |    *                                                                |
   8 ++   **                                                              ++
     |     *                                                               |
   7 ++     *                                                             ++
     |      *                                                              |
   6 ++      *                                                            ++
   5 ++      *         ******                                             ++
     |        *       **     **                                            |
   4 ++       *      *        **                                          ++
     |        **    **         *                                           |
   3 ++        *    *           *      *****                              ++
     |          *  *            **    **    **                             |
   2 ++         * **             *   **      **    *****                  ++
     |          * *              ** **        *  **    **                  |
   1 ++          **               **           ***       ** **            ++
     +      +    * +      +      +**    +      **     +   ** ***************
   0 ++-----+------+------+------+------+------+------+------+------+-----++
     0      20     40     60     80    100    120    140    160    180    200
  • To export, render and display a 200 frames animation of the above scene with POV-Ray, run:
$ bpp -f demo/basic/00-hello-cmdline.lua -n 200 -e
$ cd export/00-hello-cmdline
$ povray +d 00-hello-cmdline.ini[720p] # see 00-hello-cmdline.ini for other presets

Create and display 00-hello-cmdline.mkv with FFmpeg and MPlayer:

$ ffmpeg -y -framerate 25 -pattern_type glob -i '*.png' -c:v libx264 -preset veryslow -qp 0 -r 25 -pix_fmt yuv420p 'anim.mkv'
$ mplayer -fs -loop 0 anim.mkv

Or, create 00-hello-cmdline.gif with ImageMagick®:

$ convert -delay 1 -limit memory 1GiB -loop 0 -layers optimize *.png 00-hello-cmdline.gif

What's next?