diff options
author | Alon Zakai <alonzakai@gmail.com> | 2011-05-01 12:15:48 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2011-05-01 12:15:48 -0700 |
commit | 8a532a38aa5044060276650bb4df3ea95dd6519a (patch) | |
tree | 20f2c712aeed3d5756c7581fc7332207bb86a75f /demos/webgl/bullet_glue.js | |
parent | 954b5d83dac515007883af39c838406d31f468e9 (diff) |
bullet demo v2
Diffstat (limited to 'demos/webgl/bullet_glue.js')
-rw-r--r-- | demos/webgl/bullet_glue.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/demos/webgl/bullet_glue.js b/demos/webgl/bullet_glue.js new file mode 100644 index 00000000..614ee3c3 --- /dev/null +++ b/demos/webgl/bullet_glue.js @@ -0,0 +1,44 @@ +/**
+ Glue for Bullet demo.
+ */
+
+var Bullet = Module;
+
+//print = function(text) {
+// throw 'fail: ' + text;
+//}
+
+function prepareBulletDemo() {
+ __Z10zz_preparev();
+}
+
+function simulateBulletDemo(dt) {
+ __ZN23btDiscreteDynamicsWorld14stepSimulationEfif(Bullet.IHEAP[_zz_dynamicsWorld], dt, 2, 1/60)
+}
+
+var tempVector3 = _malloc(40);
+var tempQuaternion = _malloc(50);
+
+var QUANTUM = 1;
+
+function readBulletObject(i, pos, quat) {
+ // TODO: Do not create new objects all the time
+ __Z7zz_readiR9btVector3R12btQuaternion(i, tempVector3, tempQuaternion);
+ pos[0] = Bullet.FHEAP[tempVector3+0*QUANTUM];
+ pos[1] = Bullet.FHEAP[tempVector3+1*QUANTUM];
+ pos[2] = Bullet.FHEAP[tempVector3+2*QUANTUM];
+ quat.x = Bullet.FHEAP[tempQuaternion+0*QUANTUM];
+ quat.y = Bullet.FHEAP[tempQuaternion+1*QUANTUM];
+ quat.z = Bullet.FHEAP[tempQuaternion+2*QUANTUM];
+ quat.w = Bullet.FHEAP[tempQuaternion+3*QUANTUM];
+}
+
+function restartBullet() {
+ run([]);
+ prepareBulletDemo();
+}
+
+// Startup
+
+prepareBulletDemo();
+
|