MasterSplinter Posted November 4, 2015 Share Posted November 4, 2015 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); } });} Quote Link to comment Share on other sites More sharing options...
RaananW Posted November 4, 2015 Share Posted November 4, 2015 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. Quote Link to comment Share on other sites More sharing options...
MasterSplinter Posted November 5, 2015 Author Share Posted November 5, 2015 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. 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: https://25ec50416d91...1hWeVgtUDhQcVU/ 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? Quote Link to comment Share on other sites More sharing options...
RaananW Posted November 5, 2015 Share Posted November 5, 2015 Nope, it should work just fine. I'll check the link and see what's up. I actually experimented a bit with bowling lately (results in December and January) so I know it works rather well. Quote Link to comment Share on other sites More sharing options...
RaananW Posted November 5, 2015 Share Posted November 5, 2015 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! Quote Link to comment Share on other sites More sharing options...
MasterSplinter Posted November 5, 2015 Author Share Posted November 5, 2015 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? Quote Link to comment Share on other sites More sharing options...
RaananW Posted November 5, 2015 Share Posted November 5, 2015 They are being calculated automatically according to the mesh's vertex data. Quote Link to comment Share on other sites More sharing options...
MasterSplinter Posted November 5, 2015 Author Share Posted November 5, 2015 They are being calculated automatically according to the mesh's vertex data. Oh... well that's is gonna require some testing... Just one quick thought Is it possible that this could be a side effect from using a materialAtlas to group meshes? BTW Thanks for pointing my in the right direction. Quote Link to comment Share on other sites More sharing options...
RaananW Posted November 5, 2015 Share Posted November 5, 2015 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. Quote Link to comment Share on other sites More sharing options...
MasterSplinter Posted November 5, 2015 Author Share Posted November 5, 2015 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. Quote Link to comment Share on other sites More sharing options...
MasterSplinter Posted November 6, 2015 Author Share Posted November 6, 2015 This right here: http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/UV/TextureAtlas Appears to not play nice with physics engines. Quote Link to comment Share on other sites More sharing options...
RaananW Posted November 6, 2015 Share Posted November 6, 2015 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.