Search the Community
Showing results for tags 'impostors'.
-
I attach model. And test project (look below). You don't need any server to test it. Just export project zip file and run html in browser! Original exported ToB file is in directory. (I change this file by hand (some lines in code) and seve it in ProjectTest/js/ToB/1/ModelFInish.js. What I would like to achive is to add BoxImpostors on each box/cube/mesh which is named as BoxCollider* Note: There are boxes which have instances !!! When I change code by hand and save in ProjectTest/js/ToB/1/ModelFInish.js. I setup scene in file indexToB.html I add code (for both physics, you can test/try/run any of this but you should comment one of each. scene.enablePhysics( new BABYLON.Vector3(0, -10, 0), new BABYLON.CannonJSPlugin() ); //scene.enablePhysics( new BABYLON.Vector3(0,-10,0), new BABYLON.OimoJSPlugin() ); MAIN PROBLEM HERE IS WHY COLLISION BETWEEN "Ball" AND "BoxCollider.135" DOES NOT WORK! AM I MISSING ANYTHING? WHAT IS THE PROBLEM? CAN ANYBODY TAKE A LOOK AND HELP ME SOLVE THE PROBLEM? IT WILL BE VERY GOOD TO TAKE A LOOK AN TEST IT ALSO INSTANCES AND PHYSICS IMPOSTORS! IF YOU CAN FIND A PROBLEM WHY COLLISION NOT WORKS AND THAN IF YOU CAN CHANGE/FIX CODE OF ToB EXPORTER SO THAT COLLISION DEFINED IN BLENDER FILE AND/OR CHECKCOLLISION CAN BE PROPERLY GENERATED WHEN WE EXPORT FROM .BLENDER TO ToB .JS THAN THIS COULD BE VERY GOOD EXPORTER WITH COLLISIONS FOR BABYLONJS !!! PLEASE LET ME KNOW IF ANYBODY FIND A ERROR IN CODE AND IF AUTOR OF ToB EXPORTER CAN FIX/ADD/REPAIR EXPORTER SO THAT COLLISION/IMPOSTORS CODE IN JS WILL BE SO THAT COLLISION WILL WORKS IN BABYLONJS WHEN WE IMPORT "ModelFInish.initScene(scene);" ToB .js file. What I have change in code by hand! ProjectTest/js/ToB/1/ModelFInish.js Ball: ----- //this.setPhysicsState({ impostor: 1, mass: 1, friction: .5, restitution: 0}); this.physicsImpostor = new BABYLON.PhysicsImpostor( this, BABYLON.PhysicsImpostor.SphereImpostor, { mass : 0.2, friction : 0.5, restitution : 0 }, scene); And Box collider under Ball and its instances BoxCollider.134 or BoxCollider_134 is main box mesh and it have its instances. I also add checkCollisions = true;! I change (this boxes/cubes should be colliders/BoxImpostors with mass 0 (I also add //this.setPhysicsState({ impostor: 2, mass: 0, friction: .5, restitution: 0}); this.checkCollisions = true; this.physicsImpostor = new BABYLON.PhysicsImpostor( this, BABYLON.PhysicsImpostor.BoxImpostor, { mass : 0, friction : 0.5, restitution : 0.5 }, scene); and.. // add below two lines instance.checkCollisions = true; instance.physicsImpostor = new BABYLON.PhysicsImpostor( instance, BABYLON.PhysicsImpostor.BoxImpostor, { mass : 0.0, friction : 1, restitution : 0 }, --------------------------------------------- var BoxCollider_134 = (function (_super) { __extends(BoxCollider_134, _super); function BoxCollider_134(name, scene, materialsRootDir, source) { _super.call(this, name, scene, null, source, true); if (!materialsRootDir) { materialsRootDir = "./"; } defineMaterials(scene, materialsRootDir); //embedded version check var cloning = source && source !== null; var load = _B.Tools.Now; var geo = 0; var shape = 0; this.position.x = 0; this.position.y = 0; this.position.z = 0; this.rotation.x = 0; this.rotation.y = 0; this.rotation.z = 0; this.scaling.x = 1; this.scaling.y = 1; this.scaling.z = 1; this.id = this.name; this.billboardMode = 0; this.isVisible = false; //always false; evaluated again at bottom this.setEnabled(true); // add below line this.checkCollisions = true; this.receiveShadows = false; this.castShadows = false; if (!scene.isPhysicsEnabled()) { scene.enablePhysics(); } //this.setPhysicsState({ impostor: 2, mass: 0, friction: .5, restitution: 0}); this.checkCollisions = true; this.physicsImpostor = new BABYLON.PhysicsImpostor( this, BABYLON.PhysicsImpostor.BoxImpostor, { mass : 0, friction : 0.5, restitution : 0.5 }, scene); if (!cloning){ geo = _B.Tools.Now; this.setVerticesData(_B.VertexBuffer.PositionKind, new Float32Array([ -5,.5,-5,-5,-.5,5,-5,-.5,-5,-5,.5,5,5,-.5,5,-5,-.5,5,5,.5,5,5,-.5,-5,5,-.5,5,5,.5,-5,-5,-.5,-5,5,-.5,-5,5,-.5,5,-5,-.5,-5,-5,-.5,5,-5,.5,5,5,.5,-5 ,5,.5,5,-5,.5,-5,-5,.5,5,-5,-.5,5,-5,.5,5,5,.5,5,5,-.5,5,5,.5,5,5,.5,-5,5,-.5,-5,5,.5,-5,-5,.5,-5,-5,-.5,-5,5,-.5,5,5,-.5,-5,-5,-.5,-5,-5,.5,5 ,-5,.5,-5,5,.5,-5 ]), false); var _i;//indices & affected indices for shapekeys _i = new Uint32Array(36); CONTIG(_i, 0, 0, 35); this.setIndices(_i); this.setVerticesData(_B.VertexBuffer.NormalKind, new Float32Array([ -1,0,0,-1,0,0,-1,0,0,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,0,0,-1,0,0,-1,0,0,-1,0,-1,0,0,-1,0,0,-1,0,0,1,0,0,1,0 ,0,1,0,-1,0,0,-1,0,0,-1,0,0,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,0,0,-1,0,0,-1,0,0,-1,0,-1,0,0,-1,0,0,-1,0,0,1,0 ,0,1,0,0,1,0 ]), false); geo = (_B.Tools.Now - geo) / 1000; this.subMeshes = []; new _B.SubMesh(0, 0, 36, 0, 36, this); if (scene._selectionOctree) { scene.createOrUpdateSelectionOctree(); } } if (this.postConstruction) this.postConstruction(); load = (_B.Tools.Now - load) / 1000; _B.Tools.Log("defined mesh: " + this.name + (cloning ? " (cloned)" : "") + " completed: " + load.toFixed(2) + ", geometry: " + geo.toFixed(2) + ", skey: " + shape.toFixed(2) + " secs"); if (matLoaded && !_sceneTransitionName){ if (typeof this.grandEntrance == "function") this.grandEntrance(); else makeVisible(this); } else waitingMeshes.push(this); } BoxCollider_134.prototype.dispose = function (doNotRecurse) { _super.prototype.dispose.call(this, doNotRecurse); if (this.skeleton) this.skeleton.dispose(); }; BoxCollider_134.prototype.makeInstances = function (positionOffset) { var instance; instance = this.createInstance("BoxCollider.129"); instance.position.x = 0; instance.position.y = 0; instance.position.z = -10; instance.rotation.x = 0; instance.rotation.y = 0; instance.rotation.z = 0; instance.scaling.x = 1; instance.scaling.y = 1; instance.scaling.z = 1; // add below two lines instance.checkCollisions = true; instance.physicsImpostor = new BABYLON.PhysicsImpostor( instance, BABYLON.PhysicsImpostor.BoxImpostor, { mass : 0.0, friction : 1, restitution : 0 }, scene); if (positionOffset) instance.position.addInPlace(positionOffset); instance.checkCollisions = false; instance = this.createInstance("BoxCollider.100"); instance.position.x = 29.5438; instance.position.y = -2.3742; instance.position.z = 0; instance.rotation.x = 0; instance.rotation.y = 0; instance.rotation.z = 0; instance.scaling.x = 1; instance.scaling.y = 1; instance.scaling.z = 1; // add below two lines instance.checkCollisions = true; instance.physicsImpostor = new BABYLON.PhysicsImpostor( instance, BABYLON.PhysicsImpostor.BoxImpostor, { mass : 0.0, friction : 1, restitution : 0 }, scene); if (positionOffset) instance.position.addInPlace(positionOffset); instance.checkCollisions = false; instance = this.createInstance("BoxCollider.095"); instance.position.x = 29.4404; instance.position.y = 2.5005; instance.position.z = -10.0006; instance.rotation.x = 0; instance.rotation.y = 0; instance.rotation.z = 0; instance.scaling.x = 1; instance.scaling.y = 1; instance.scaling.z = 1; // add below two lines instance.checkCollisions = true; instance.physicsImpostor = new BABYLON.PhysicsImpostor( instance, BABYLON.PhysicsImpostor.BoxImpostor, { mass : 0.0, friction : 1, restitution : 0 }, scene); if (positionOffset) instance.position.addInPlace(positionOffset); instance.checkCollisions = false; instance = this.createInstance("BoxCollider.078"); instance.position.x = -39.0553; instance.position.y = 5.1819; instance.position.z = 0; instance.rotation.x = 0; instance.rotation.y = 0; instance.rotation.z = 0; instance.scaling.x = 1; instance.scaling.y = 1; instance.scaling.z = 1; // add below two lines instance.checkCollisions = true; instance.physicsImpostor = new BABYLON.PhysicsImpostor( instance, BABYLON.PhysicsImpostor.BoxImpostor, { mass : 0.0, friction : 1, restitution : 0 }, scene); if (positionOffset) instance.position.addInPlace(positionOffset); instance.checkCollisions = false; instance = this.createInstance("BoxCollider.073"); instance.position.x = -39.1818; instance.position.y = -4.9811; instance.position.z = -9.9322; instance.rotation.x = 0; instance.rotation.y = 0; instance.rotation.z = 0; instance.scaling.x = 1; instance.scaling.y = 1; instance.scaling.z = 1; // add below two lines instance.checkCollisions = true; instance.physicsImpostor = new BABYLON.PhysicsImpostor( instance, BABYLON.PhysicsImpostor.BoxImpostor, { mass : 0.0, friction : 1, restitution : 0 }, scene); if (positionOffset) instance.position.addInPlace(positionOffset); //instance.checkCollisions = false; instance.checkCollisions = true; }; return BoxCollider_134; })(BABYLON.Mesh); ModelFInish.BoxCollider_134 = BoxCollider_134; @JCPalmer @gryff @Deltakosh @RaananW ProjectTest.zip Model.zip
-
If we model some visual models whit some tools (Bablyon,Max,Unity,....) and add box colliders around model. Is there any showcase how to do model and add colliders on model? Is there any exporter which know to export "model+model's colliders", and is there any BabylonJS importer which is capable to import "model+models's colliders"? Do BabylonJS has ONLY importers/loaders which know ONLY import/load model? Can any of this file format (FBX,, glTF, OBJ, .babylon, ToB .js....) export "model+model's collider" I would like such exporter/importer which is capable to import model_with_it's_colliders. exporter(blender,3DMax,Unity,...) importer(BabylonJS file loader) I don't want to hard code or adding colliders whit hard codeing in babylonJS. I would like to model with (blender,max3d,unity..) and than just import/load all things (model and colliders) in BabylonJS from one file (FBX,babylon,glTF...) I would like that modeling and adding colliders will be separately/independently from BabylonJS coding. BabylonJS Importer should do all for us (so importing model and setup colliders) (our final scene build in 3d modeling tool -blender,max3d,unity...) Any advice? Any infos? Any Help? Greetings Ian
-
Hi, Can you please tell me which type of impostors does Oimo.js with Babylon.js support?I use babylon.js and oimo.js I read this instructions herehttps://blogs.msdn.microsoft.com/davrous/2014/11/18/understanding-collisions-physics-by-building-a-cool-webgl-babylon-js-demo-with-oimo-js/ On this page is mention thatthere are 4 impostors:1. Box2. Sphere3. Capsule4. MeshWhich of this 4 impostors are supported in oimo.js ???Which js implement collision oimo.js or babylon.js ??? With Blender I did:I create some simple path and one ball.I set physic collisions and rigid.Path objec has Mesh - collision (Mesh Impostor). In blender animations works fine.I attach file "path_example.zip" I try "http://www.babylonjs.com/sandbox/" and load "path_example.babylon"Babylon sendbox doesn't work as it works in blender. Does Oimo.js doesn't support Mesh Impostor ? Which file implement Impostor or collision? Do babylon.js implemennt this or oimo.js? Is there any other solution to solve this. I would like to rotate path object (rotate throught all axises x, y, z) at runtime in babylon game engine. It is possible to solve this withouth Mesh-Impostor (Mesh collision shape on Path). I don't want to have static path. I would like to rotate it and I would like to use physic on ball and path objects. Is there any other possible sollution.Can I create colider-boxes around path and join this colider-boxes to one collider-object, because I would liketo rotate all box colliders as one model at runtime (I don't want to have seperated collider-boxes and static path!) Pleas help me. Can give me any advice or hint? Thanx path_example.zip