Jump to content

Oimo Behaviour with Imported Meshes


MasterSplinter
 Share

Recommended Posts

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);        }    });}
Link to comment
Share on other sites

Could you try with 2.3? Some parts of the plugin were already rewritten. Would be good to know if changing to cannon made any difference. 

 

move:false doesn't quite work, I think the documentation needs to be fixed. mass:0 would cause the mesh to stay in place. So your plane (i assume it's the ground) should have mass : 0, and the pins can rest on it.

Link to comment
Share on other sites

They are all flying in one direction now with oimo... I'll fiddle with the cannon release and see what happens.

 

Looks like it may be the exporter -- I'm going to look at the json file.

 

Untitled_zpsckfewg0h.jpg
Untitled2_zpsvmxtbg5w.jpg
 
The json file shows everything is positioned at 0 on the Y axis and the vertices look like they begin at 0 -- altho reading all that point data is pretty painful.
 
Updated the link:
 
 
Some strange behavior with cannon -- however, I removed the blender plane and added a ground plane and positioned it at -1.3 on the y axis and it works better.  When I switch it over to oimo it works the best but I still have the pins crashing through the plane.  Does this mean the boximpostor is malformed?
Link to comment
Share on other sites

Hi

 

Debugged your scene a bit. It seems like the bounding boxes of the pins are huge. ca. 4,4,12 bounding boxes.

If you lower the ground to -2.5 you will see they no longer "fly" up, but they do fly aside. This is due to the bounding box being way too big and them being too close to one another. I have no idea why it is (haven't checked that), but this is where you will have to start looking.

 

Hope it helped somehow!

Link to comment
Share on other sites

Hi

 

Debugged your scene a bit. It seems like the bounding boxes of the pins are huge. ca. 4,4,12 bounding boxes.

If you lower the ground to -2.5 you will see they no longer "fly" up, but they do fly aside. This is due to the bounding box being way too big and them being too close to one another. I have no idea why it is (haven't checked that), but this is where you will have to start looking.

 

Hope it helped somehow!

Where are the bounding boxes assigned in babylon?

Link to comment
Share on other sites

not sure what materialAtlas is, but grouping meshes would usually make their bounding box bigger, yes. Both physics engines require the bounding box (or sphere) to be correct, otherwise they can't calculate the body movements correctly.

It was a way I was trying to do batch baking in blender but I think as a side effect I think it was grouping the meshes.  I figured this would be ignored by the exporter but maybe not...  Definitely think this may have been the problem.

Link to comment
Share on other sites

Just a small note - it would probably not play nice with the native collision system as well.

The bounding boxes of each mesh are simply too big. I would say the wrong positions are being exported. I looked in the exported .babylon file. Take pin1 as example - the first point is 0,0,0 , the last point is 0,0,25 . Which explains why the bounding box's center is 12.5 . But i doubt your pins should be so big.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...