Thanks to visit codestin.com
Credit goes to lib.haxe.org

haxebullet

Bullet physics for Haxe
https://github.com/luboslenco/haxebullet/

To install, run:

haxelib install haxebullet 1.1.0 

See using Haxelib in Haxelib documentation for more information.

README.md

haxebullet

Native Bullet 3D Physics for Haxe. Includes library file for Kha.

Package is available on haxelib:

haxelib install haxebullet

Docs

Refer to original Bullet documentation.

Remarks

Based on Bullet 2.82, works on C++ and JS targets. Using original C++ sources of Bullet and Ammo.js for JavaScript respectively. The goal of this repository is to provide top class 3D physics solution for Haxe.

The bindings are not complete but it's very easy to add missing stuff based on what's already there. Feel free to contribute!

Usage

C++ Reference

In order to get C++ build to work you need to add 'haxebullet/cpp/bullet' directory into your build process so compiler is able to find bullet sources.

JS Reference

In order to get JS build to work you need to add 'haxebullet/js/ammo/ammo.js' script either by embedding or including it with a script tag.

` hx var groundShape = BtStaticPlaneShape.create(BtVector3.create(0, 1, 0).value, 1); var groundTransform = BtTransform.create(); groundTransform.value.setIdentity(); groundTransform.value.setOrigin(BtVector3.create(0, -1, 0).value); var centerOfMassOffsetTransform = BtTransform.create(); centerOfMassOffsetTransform.value.setIdentity(); var groundMotionState = BtDefaultMotionState.create(groundTransform.value, centerOfMassOffsetTransform.value);

var groundRigidBodyCI = BtRigidBodyConstructionInfo.create(0.01, groundMotionState, groundShape, BtVector3.create(0, 0, 0).value); var groundRigidBody = BtRigidBody.create(groundRigidBodyCI.value); dynamicsWorld.value.addRigidBody(groundRigidBody);

var fallShape = BtSphereShape.create(1); var fallTransform = BtTransform.create(); fallTransform.value.setIdentity(); fallTransform.value.setOrigin(BtVector3.create(0, 50, 0).value); var centerOfMassOffsetFallTransform = BtTransform.create(); centerOfMassOffsetFallTransform.value.setIdentity(); var fallMotionState = BtDefaultMotionState.create(fallTransform.value, centerOfMassOffsetFallTransform.value);

var fallInertia = BtVector3.create(0, 0, 0); fallShape.value.calculateLocalInertia(1, fallInertia.value); var fallRigidBodyCI = BtRigidBodyConstructionInfo.create(1, fallMotionState, fallShape, fallInertia.value); var fallRigidBody = BtRigidBody.create(fallRigidBodyCI.value); dynamicsWorld.value.addRigidBody(fallRigidBody);

for (i in 0...3000) {

dynamicsWorld.value.stepSimulation(1 / 60);

var trans = BtTransform.create();
var m = fallRigidBody.value.getMotionState();
m.value.getWorldTransform(trans.value);
trace(trans.getOrigin().y());

}

// .destroy()...

Contributors
Lubos
Version
1.1.0
Published
10 years ago
License
MIT

All libraries are free

Every month, more than a thousand developers use Haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on GitHub!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on GitHub