larsiii23 Posted March 11, 2015 Share Posted March 11, 2015 Hi! I'm currently working with a project where I decided to use babylon.js, and is a newbie on the framework. I have imported a BIM-model which consists of hundred of meshes into babylon, and wondered if there is a way to check collisions for all these meshes without have to get each mesh by name,var mesh = getMeshByName("meshName"); and then assign itmesh.checkCollisions = true;Is there a way to loop through all the importet meshes without getting them by name? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 12, 2015 Share Posted March 12, 2015 Hello and welcome, you can also browse the collection with scene.meshes (which is an array of all meshes in your scene) Quote Link to comment Share on other sites More sharing options...
larsiii23 Posted March 12, 2015 Author Share Posted March 12, 2015 Thanks. Exactly the solution i was hoping for I implemented the checkCollisons in the callback, like this:BABYLON.SceneLoader.ImportMesh("", "", "1932.babylon", scene, function (newMeshes, particleSystems, skeletons){for(var i=0; i<scene.meshes.length; i++) scene.meshes[i].checkCollisions=true;});After this change I feel the "game" got more laggy however. Is there a better (performance enhancing) way to this. My scene consist of a 3 floor house I want to move around in, in a fps way. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 12, 2015 Share Posted March 12, 2015 The laggyness can come from the number of collisions involved. So I suggest for complex objects to create an impostor invisible box that will represent the collision box Quote Link to comment Share on other sites More sharing options...
vahith Posted March 14, 2015 Share Posted March 14, 2015 hi Del;how we can create the invisible box for collision, i am also facing same, could you suggest me some testcase and example.. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 14, 2015 Share Posted March 14, 2015 the idea is to get mesh.getBoundingInfo().boundingBox to get the bounding box and then use Mesh.CreateBox() and define it as collidable Quote Link to comment Share on other sites More sharing options...
RaananW Posted March 14, 2015 Share Posted March 14, 2015 Check this topic here, might get you going - http://www.html5gamedevs.com/topic/13095-putting-an-object-into-a-box-of-the-size-of-the-object/ 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.