Hello World in ODE
2013-03-30 12:55
288 查看
ode用的是BSD license, 很亲善, 并且库本身质量还不错, 可以作为正经的用途.
并且API是c风格的,可以很轻松的用于其他语言.
作为熟悉引擎, 先写个最简单的小球下落作为HelloWorld.
结果就像这样:
虽然ode本身带了一个非常简单的图像引擎,不过我不打算用,
毕竟描画还是自己折腾openGL比较灵活高效,更何况已经写了objloader,至于要读模型文件,旋转平移就行了.
下面是源代码, 不知道为什么, 语法高亮失效了, 难道是我设置的问题?
连接的时候注意用g++才行,因为库用到了c++.其他的都交给pkg-config吧
并且API是c风格的,可以很轻松的用于其他语言.
作为熟悉引擎, 先写个最简单的小球下落作为HelloWorld.
结果就像这样:
Mac-mini:ode $ ./a.out 0 0 10 1 0 0 0 0 1 0 0 0 0 1 0 0 0 9.9755 1 0 0 0 0 1 0 0 0 0 1 0 0 0 9.9265 1 0 0 0 0 1 0 0 0 0 1 0 0 0 9.853 1 0 0 0 0 1 0 0 0 0 1 0 0 0 9.755 1 0 0 0 0 1 0 0 0 0 1 0 0 0 9.6325 1 0 0 0 0 1 0 0 0 0 1 0 0 0 9.4855 1 0 0 0 0 1 0 0 0 0 1 0 0 0 9.314 1 0 0 0 0 1 0 0 0 0 1 0 0 0 9.118 1 0 0 0 0 1 0 0 0 0 1 0 0 0 8.8975 1 0 0 0 0 1 0 0 0 0 1 0 0 0 8.6525 1 0 0 0 0 1 0 0 0 0 1 0 0 0 8.383 1 0 0 0 0 1 0 0 0 0 1 0 0 0 8.089 1 0 0 0 0 1 0 0 0 0 1 0 0 0 7.7705 1 0 0 0 0 1 0 0 0 0 1 0
虽然ode本身带了一个非常简单的图像引擎,不过我不打算用,
毕竟描画还是自己折腾openGL比较灵活高效,更何况已经写了objloader,至于要读模型文件,旋转平移就行了.
下面是源代码, 不知道为什么, 语法高亮失效了, 难道是我设置的问题?
Mac-mini:ode$ cat basic.d import std.stdio, ode; static dWorldID world; dBodyID ball; const dReal radius = .2; const dReal mass = 1.; static void simLoop(){ dReal* pos; dReal* r; pos = dBodyGetPosition(ball); r = dBodyGetRotation(ball); writeln(*pos,"\t",*(pos+1),"\t",*(pos+2)); foreach(i;0..3*4) write(*(r+i),((i+1)%4==0)?"\n":"\t"); writeln(); dWorldStep(world, 0.05); } void main(){ dInitODE(); world = dWorldCreate(); dWorldSetGravity(world, 0, 0, -9.8); ball = dBodyCreate(world); dMass m1; dMassSetZero(&m1); dMassSetSphereTotal(&m1, mass, radius); dBodySetMass(ball, &m1); dBodySetPosition(ball, 0,0,10); foreach(i;1..40) simLoop(); dWorldDestroy(world); dCloseODE(); }
连接的时候注意用g++才行,因为库用到了c++.其他的都交给pkg-config吧
相关文章推荐
- Eclipse Plug-in Hello world
- Hello World in Java
- Hello world in Java
- My First Hello World in PHP
- Spring 3 MVC: Create Hello World application in Spring 3.0 MVC
- Hello World in D Language
- Mistakes in Hello World
- HelloWorld Example in Xcode 4 – iPhone OS 4.3
- puts "Hello world" in VC++
- 一 Hello World in ABAP
- C++11 多线程编程《C++ Concurrency in Action》读书笔记(1)-Hello World of Concurrency in C++
- 1 Hello, world of concurrency in C++!
- Chapter 1 Hello, world of concurrency in C++!
- GTK3学习笔记2 Hello World in GTK+
- MusicXML 3.0 (1) - "Hello World" in MusicXML
- iPhone起步-1: "Hello,World!" in iPhone Development (转)
- HelloWorld in Eclipse TITAN
- HelloWorld in autoconf & automake
- [Cycle.js] Hello World in Cycle.js
- Spring 3 MVC: Create Hello World Application In Spring 3.0 MVC