2012年9月23日日曜日

Installation of Open Dynamics Engine to iMac

Introduction 

Recently I installed the Open Dynamics Engine(ODE) to my iMac and compiled its sample program on the Xcode. In this page, I describe my procedure to do so.

Development Environment 

  1. iMac
  2. Mac OS X 10.8.1
  3. Processor:3.06GHz Intel Core 2 Duo
  4. Memory:4GB
  5. Xcode4.4.1

Installation 

It's simple because the Macports supports the ODE. The ODE consists of two libraries:
  1. the library to calculate the rigid body dynamics, which is called "ode"
  2. the library to draw the dynamics by use of the OpenGL, which is called "drawstuff"
The Macports installs only "ode." As I also want to use "drawstuff", I downloaded the source code of ODE from here. Here are its installation instructions. At this point, the script warned that there is no libtoolize. I enabled statements from the 36th line to the 38th one in autogen.sh. The comments in the script tell us that the libtoolize corresponds to glibtoolize in Mac. I tried again. In turn, it's successful. The procedure compiles not only the "drawstuff" but also the "ode." I don't need the "ode" because it's already installed by the Macports. I manually copied the "drawstuff" as follows: The preparation to compile a sample program is completed.

Interface of ODE 

Here is the following statement: Though the library itself is written in C++, it appears that the library is more in favor of being used through the C interfaces. But, my favorite language is C++...

Sample Program 

Here is a beginner course of the ODE in Japanses. Using C++, I rewrote the sample source code "サンプルプログラム6マルチ" in the 6th chapter of the course. This page gives us an explanation about the C interfaces, but I could not find the corresponding page to the C++ ones. Fortunately the "ode" library provides us with the header file "odecpp.h." It helps me rewrite the sample in the C++. My source code is as follows: A path in the 10th line is the path to a directory included in the ODE source code.

Compile Options 

Header Search Path:
Path Purpose
/opt/local/include/ to include ode header
/usr/local/include/ to include drawstuff header

Library Search Path:
Path Purpose
/opt/local/lib to find "ode" library
/usr/local/lib to find the "drawstuff" library

Other Linker Flags:
-lode -ldrawstuff -framework OpenGL -framework GLUT

Apple LLVM compiler 4.0 - Language:
C++ Language Dialect C++11 [-std=c++11]
C++ Standard Library libc++ (LLVM C++ standard library with C++11 support)

Run 

Red balls fall to the ground, and bounce. The variable contact.surface.bounce in the 55th line corresponds to the reflection coefficient. When it equals to 1, the completely-elastic collision is realized. The range is [0, 1].

1 件のコメント: