Permalink
Browse files

Initial version.

  • Loading branch information...
aerique committed Jun 17, 2009
0 parents commit c56339147c03fac2a1aa9e4586394e71eff2b957
Showing with 555 additions and 0 deletions.
  1. +32 −0 LICENSE
  2. +54 −0 README.1st
  3. +35 −0 README.MinGW
  4. +24 −0 buclet.asd
  5. +60 −0 examples/hello-world.lisp
  6. +4 −0 examples/run-hello-world-ccl-mingw.sh
  7. +3 −0 examples/run-hello-world.sh
  8. +43 −0 src/buclet.lisp
  9. +279 −0 src/cffi.lisp
  10. +21 −0 src/package.lisp
32 LICENSE
@@ -0,0 +1,32 @@
+The BSD License
+
+Copyright (c) 2009, Erik Winkels
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ * The name of its contributor may not be used to endorse or
+ promote products derived from this software without specific
+ prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,54 @@
+
+ What you need and should know to get the example running
+ ========================================================
+
+ General
+ -------
+ The startup scripts (the *.sh and *.bat files) expect to be
+ run from the examples directory.
+
+ Before you try to compile Bullet yourself try running the
+ example with the libraries that are in the Buclet lib
+ directory.
+
+ Linux
+ -----
+ The Linux startup is written and tested using SBCL
+ (1.0.25.debian at the time of writing) and expects to find
+ 'sbcl' in the path.
+
+ It also expects to find necessary Bullet libraries in either
+ /usr/local/lib or the Buclet lib directory.
+
+ All these options are set in the *.sh file and can be changed
+ there.
+
+ If the libraries that come with the Buclet distribution don't
+ work for you, you'll need to compile Bullet yourself.
+ Download the source from:
+ http://code.google.com/p/bullet/downloads/list (you'll need
+ "bullet-2.74.tgz").
+
+ You also need the replace Bullet-C-API.cpp and Bullet-C-Api.h
+ with the ones mentioned in comment 6:
+ http://code.google.com/p/bullet/issues/detail?id=43#c6
+
+ Configure, compile and install in /usr/local.
+
+ Windows
+ -------
+ The Windows startup script is written and tested using Clozure
+ CL and expects to find 'wx86cl' in the path.
+
+ All libraries are expected to be found in the lib directory of
+ the Buclet distribution.
+
+ All these settings are in the *.bat file and can be changed
+ there.
+
+ If the libraries that come with the Buclet distribution don't
+ work for you, you'll need to compile Bullet yourself using
+ MinGW. Check the README.MinGW file for more information.
+
+
+ Erik Winkels, 2009-06-02
@@ -0,0 +1,35 @@
+
+ This README is aimed at Windows users. If you're on a Unix
+ system I'm expecting you to be able to take care of yourself
+ and also expect you're using a distribution with a fairly
+ complete and non-retarded packaging system.
+
+ If your libs directory is empty you'll either to download them
+ from the homepage or you can try to compile them yourself in
+ which case you'll need to download and install MinGW, MSYS and
+ CMake:
+
+ o CMake: http://www.cmake.org/cmake/resources/software.html#latest
+ o MinGW: http://sourceforge.net/project/showfiles.php?group_id=2435&package_id=240780
+ o MSYS: http://sourceforge.net/project/showfiles.php?group_id=2435&package_id=24963
+ http://sourceforge.net/project/downloading.php?group_id=2435&filename=MSYS-1.0.10.exe&a=14697658
+
+ Install MinGW first and then MSYS. Use MSYS version 1.0.10.
+ There's guides and information on www.mingw.org if needed.
+ (http://www.mingw.org/wiki/HOWTO_Install_the_MinGW_GCC_Compiler_Suite)
+
+ If all of this is done you can issue:
+
+ > cmake -G "MSYS Makefiles"
+
+ (not "MinGW Makefiles"!)
+
+ and then:
+
+ > make
+
+ and if everything goes right (probably not) it should end up
+ in the lib directory.
+
+
+ Erik Winkels, 2009-06-02
@@ -0,0 +1,24 @@
+;;;; -*- Mode: LISP; Syntax: COMMON-LISP -*-
+;;;;
+;;;; buclet.asd
+;;;;
+;;;; author: Erik Winkels (aerique@xs4all.nl)
+;;;;
+;;;; See the LICENSE file in the Buclet root directory for more info.
+
+(in-package :cl-user)
+
+(defpackage :buclet-system
+ (:use :cl :asdf))
+
+(in-package :buclet-system)
+
+(asdf:defsystem :buclet
+ :version "2.74.1"
+ :components
+ ((:module src
+ :components
+ ((:file "package")
+ (:file "buclet" :depends-on ("package"))
+ (:file "cffi" :depends-on ("package" "buclet")))))
+ :depends-on (:cffi))
@@ -0,0 +1,60 @@
+;;;; -*- Mode: LISP; Syntax: COMMON-LISP -*-
+;;;;
+;;;; hello-world.lisp
+;;;;
+;;;; author: Erik Winkels (aerique@xs4all.nl)
+;;;;
+;;;; See the LICENSE file in the clois-lane root directory for more info.
+;;;;
+;;;; See: http://www.continuousphysics.com/mediawiki-1.5.8/index.php?title=Hello_World
+
+;;; Packages
+
+(asdf :buclet)
+(in-package :buclet)
+
+
+;;; Variables
+
+(defparameter *dynamics-world* nil)
+(defparameter *fall-rigid-body* nil)
+(defparameter *fall-shape* nil)
+(defparameter *ground-rigid-body* nil)
+(defparameter *ground-shape* nil)
+(defparameter *physics-sdk* nil)
+
+
+;;; Functions
+
+(defun start-simulation ()
+ (set-position *fall-rigid-body* '(0.0 50.0 0.0))
+ (set-orientation *fall-rigid-body* '(0.0 0.0 0.0 1.0))
+ (loop for i from 0 to 300
+ with sim-step = (/ 1.0 60.0)
+ do (step-simulation *dynamics-world* sim-step)
+ (format t "~A: sphere Y position: ~A~%"
+ i (second (get-position *fall-rigid-body*)))
+ (sleep sim-step)))
+
+
+;;; Initialisation
+
+(setf *physics-sdk* (new-bullet-sdk))
+(setf *dynamics-world* (create-dynamics-world *physics-sdk*))
+
+(setf *ground-shape* (new-static-plane-shape '(0.0 1.0 0.0) 1.0))
+(setf *ground-rigid-body* (create-rigid-body 0.0 *ground-shape*))
+(set-position *ground-rigid-body* '(0.0 -1.0 0.0))
+(set-orientation *ground-rigid-body* '(0.0 0.0 0.0 1.0))
+(add-rigid-body *dynamics-world* *ground-rigid-body*)
+
+(setf *fall-shape* (new-sphere-shape 1.0))
+(setf *fall-rigid-body* (create-rigid-body 1.0 *fall-shape*))
+(set-position *fall-rigid-body* '(0.0 50.0 0.0))
+(set-orientation *fall-rigid-body* '(0.0 0.0 0.0 1.0))
+(add-rigid-body *dynamics-world* *fall-rigid-body*)
+
+
+;;; Main Program
+
+(start-simulation)
@@ -0,0 +1,4 @@
+#! /bin/sh
+
+PATH=$PATH:../lib;
+wx86cl.exe --load hello-world.lisp --eval "(in-package :buclet)";
@@ -0,0 +1,3 @@
+#! /bin/sh
+
+sbcl --load hello-world.lisp --eval "(in-package :buclet)";
@@ -0,0 +1,43 @@
+;;;; -*- Mode: LISP; Syntax: COMMON-LISP -*-
+;;;;
+;;;; buclet.lisp
+;;;;
+;;;; author: Erik Winkels (aerique@xs4all.nl)
+;;;;
+;;;; See the LICENSE file in the Buclet root directory for more info.
+
+(in-package :buclet)
+
+
+;;; Bullet Foreign Libraries
+
+(define-foreign-library bullet-dynamics
+ (:windows "libBulletDynamics.dll")
+ (:unix "libBulletDynamics.so")
+ (t "libBulletDynamics"))
+
+(define-foreign-library bullet-collision
+ (:windows "libBulletCollision.dll")
+ (:unix "libBulletCollision.so")
+ (t "libBulletCollision"))
+
+(define-foreign-library linear-math
+ (:windows "libLinearMath.dll")
+ (:unix "libLinearMath.so")
+ (t "libLinearMath"))
+
+;; The order is important!
+(use-foreign-library linear-math)
+(format t "~&[buclet] foreign library linear-math loaded~%")
+
+(use-foreign-library bullet-collision)
+(format t "~&[buclet] foreign library bullet-collision loaded~%")
+
+(use-foreign-library bullet-dynamics)
+(format t "~&[buclet] foreign library bullet-dynamics loaded~%")
+
+
+;;; Functions
+
+(defun quit ()
+ (cl-user::quit))
Oops, something went wrong.

0 comments on commit c563391

Please sign in to comment.