Hey everyone,
I made a pretty basic scene in blender few bowling pins and a plane. As a still it seems to render fine. But, when I attach oimo the pins seem to shoot all over the place. The face on the floor either disappears or I get crazy artifacts. I had previously tried using a blender cube mesh for the floor (the pins sank halfway into the floor when I did this)... Is there something I am missing? Also, the move:false property doesn't seem to work with oimo.
And if I looked at the position on myloader.mesh[0].position it seems to be moving all over the place (I think this may relate to the weird artifacts I was getting).
Does this relate to importing meshes from blender and adding physics to them?
When I crank up the properties of the meshes it seems to have no effect...
Any help or suggestions would be appreciated.
Example:
https://25ec50416d915381f564e8e072111117f4bfc2ab-www.googledrive.com/host/0B7OlMPbfskONY1hWeVgtUDhQcVU/
Thanks in advance!
if (BABYLON.Engine.isSupported()) {
var canvas = document.getElementById("rencanvas");
var engine = new BABYLON.Engine(canvas, true);
var meshesColliderList = [];
var myloader;
BABYLON.SceneLoader.Load("", "bowl.babylon", engine, function (newScene) {
// Wait for textures and shaders to be ready
newScene.executeWhenReady(function () {
// Attach camera to canvas inputs
newScene.enablePhysics(new BABYLON.Vector3(0, -10, 0), new BABYLON.OimoJSPlugin());
//newScene.enablePhysics(new BABYLON.Vector3(0, -10, 0), new BABYLON.CannonJSPlugin());
newScene.activeCamera.checkCollisions = true;
newScene.activeCamera.applyGravity = true;
newScene.activeCamera.collisionsEnabled = true;
newScene.activeCamera.attachControl(canvas);
newScene.gravity = new BABYLON.Vector3(0, -9.8, 0);
checkColliders(newScene);
myloader = newScene;
console.log(myloader);
//addListeners(myloader);
// Once the scene is loaded, just register a render loop to render it
engine.runRenderLoop(function () {
myloader.render();
});
});
}, function (progress) {
// To do: give progress feedback to user
});
}
function checkColliders(newScene) {
for (var i = 0; i < newScene.meshes.length; i++) {
if (newScene.meshes[i].id == "Plane") {
newScene.meshes[i].setPhysicsState({
impostor: BABYLON.PhysicsEngine.PlaneImpostor,
mass: 1,
friction: 2,
restitution: 0.1,
move: false
});
}
else {
newScene.meshes[i].setPhysicsState({
impostor: BABYLON.PhysicsEngine.BoxImpostor,
mass: 1,
friction: 2,
restitution: 0.1,
move: false
});
meshesColliderList.push(newScene.meshes[i]);
}
}
}
function addListeners(myLoader) {
canvas.addEventListener("mousedown", function (evt) {
var pickResult = myLoader.pick(evt.clientX, evt.clientY);
if (pickResult.hit) {
var dir = pickResult.pickedPoint.subtract(myLoader.activeCamera.position);
dir.normalize();
pickResult.pickedMesh.applyImpulse(dir.scale(1), pickResult.pickedPoint);
console.log(pickResult);
}
});
}