Below is the Marble Tower sample linked from the Babylon.js Feature Demos page.
Marble Tower ammo.js Demo
This sample uses ammo.js for physics.
I wanted to know if there was a Havok version of this, but I haven’t been able to find one.
Anyone know if there is a sample for the Havok version?
I tried to port from ammo.js to Havok following the rules below.
However, the attempt did not work because I could not figure out how to do some of the replacements.
I need to do more research on Havok and Physics API v2.
There is a shapetype for the convex hull.
and for the noimpostor, you can combine multiple shapes using the shape container.
also xxx.physicsImpostor ⇒ xxx.physicsAggregate no, but you can get the physicsBody from the mesh or transform
I have tried to figure out the gimmick of the rocker but it still seems to take a while. I will look into it again over the weekend.
I tried to port from HingeJoint to HingeConstraint but I still don’t understand what the difference is between the arguments.
Perhaps I need to look into the differences in functionality between the different versions.
Hi - im trying to migrate to havok - running into this same question. Using ammo, i had:
a) create a physicsroot mesh
b) created a collider (sphere or box)
c) added my mesh and the collider to the physicsroot
d) added the NoImpostor to the physicsroot.
Cedric, i’m not totally following your suggestion above. What would be the migration to the following code for the no-imposter part?
myCollider = BABYLON.CreateSphere("myCollider");
myCollider.physicsImpostor = new BABYLON.PhysicsAggregate(myCollider, BABYLON.PhysicsShapeType.SPHERE, {'mass': 0, 'friction': friction,'restitution': restitution}, this.scene);
let physicsRoot = new BABYLON.Mesh("physicsRoot_"+ myMesh.name, this.scene);
physicsRoot.addChild(myMesh);
physicsRoot.addChild(myCollider);
physicsRoot.physicsImpostor = new BABYLON.PhysicsImpostor(physicsRoot, BABYLON.PhysicsImpostor.NoImpostor, {'mass': mass, 'friction': friction,'restitution': restitution}, this.scene);
so the new approach is:
a) create a physics shape
b) bind that shape to the mesh *
so my new code is:
this._gravityCheckList.forEach(function(mesh_name) {
let mymesh = this.scene.getMeshByName(mesh_name);
this.addBody(mymesh);
}.bind(this));
//Add body
Enviro.prototype.addBody = function(mesh) {
const shape = new BABYLON.PhysicsShapeConvexHull(
mesh, // mesh from which to produce the convex hull
this.scene // scene of the shape
);
this.bindBodyShape(mesh, shape);
if (this.debug){
this.viewer = new BABYLON.Debug.PhysicsViewer(this.scene); //debug physics
this.viewer.showBody(mesh.physicsBody);
}
}
//bind body to shape
Enviro.prototype.bindBodyShape = function(mesh, shape) {
this.mlog.log('Enviro-bindBodyShape', {'mesh':mesh}, 6);
let physicsMaterial = { friction: 0.2, restitution: 0.3 };
var body = new BABYLON.PhysicsBody(
mesh,
BABYLON.PhysicsMotionType.DYNAMIC,
false,
this.scene
);
shape.material = physicsMaterial;
body.shape = shape;
body.setMassProperties({
mass: 1,
});
}
Just wanted to say that I really like your idea of reviving this historical demo and re-use it to introduce Havok.
I think the base of this demo deserves it and would do for a nice ‘remake’.
So, I’d like to thank you for your efforts and then,… just, let me know when it’s ready