dav74 Posted January 5, 2014 Share Posted January 5, 2014 Hi and happy new year, will there be an announcement (on this forum or on twitter....) when the implementation of the physics engine will be effective ? thank you jiweigang1 1 Quote Link to comment Share on other sites More sharing options...
gwenael Posted January 5, 2014 Share Posted January 5, 2014 Happy new year. Deltakosh released 1.8.0 which integrates cannon.js.More about it here: http://blogs.msdn.com/b/eternalcoding/archive/2013/12/19/create-wonderful-interactive-games-for-the-web-using-webgl-and-a-physics-engine-babylon-js-amp-cannon-js.aspx Quote Link to comment Share on other sites More sharing options...
dav74 Posted January 5, 2014 Author Share Posted January 5, 2014 Shame on me, i'm so sorry for my stupid question thank you gwenael But...i've another question : is it possible to apply a force (vector) on an object ? Quote Link to comment Share on other sites More sharing options...
gwenael Posted January 5, 2014 Share Posted January 5, 2014 Haven't played with it so far. Sorry. First, check if it's possible with cannon.js Quote Link to comment Share on other sites More sharing options...
dav74 Posted January 6, 2014 Author Share Posted January 6, 2014 @gwenael : thank you for your answerobviously, it's possible to apply a force with cannon.js gwenael 1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 7, 2014 Share Posted January 7, 2014 And yes you can and the line you need:BABYLON.Mesh.prototype.applyImpulse = function(force, contactPoint) { Wingnut 1 Quote Link to comment Share on other sites More sharing options...
dav74 Posted January 7, 2014 Author Share Posted January 7, 2014 @Deltakosh ok, thank you, i'm going to look at Quote Link to comment Share on other sites More sharing options...
dav74 Posted January 9, 2014 Author Share Posted January 9, 2014 My results are very strange when i use (other things works very well ) :sphere.applyImpulse(new BABYLON.Vector3(15,0,0),new BABYLON.Vector3(0,0,0));my mesh goes to the right (all is ok), but after few seconds, it goes to the left !! all my code :var canvas = document.getElementById("renderCanvas");var engine = new BABYLON.Engine(canvas, true);var scene = new BABYLON.Scene(engine);var camera = new BABYLON.ArcRotateCamera("ArcRotateCamera",0,1.3,100, new BABYLON.Vector3(0, 0, 0), scene);camera.attachControl(canvas);var light = new BABYLON.PointLight("pointLumineux1", new BABYLON.Vector3(100, 100, 0), scene); var ground=BABYLON.Mesh.CreateBox("sol",100,scene);ground.scaling.y=0.001var sphere=BABYLON.Mesh.CreateSphere("sph",20,6,scene);sphere.position=new BABYLON.Vector3(0,4,0);scene.enablePhysics();scene.setGravity(new BABYLON.Vector3(0,-10,0)); sphere.setPhysicsState({ impostor: BABYLON.PhysicsEngine.SphereImpostor, mass: 1 });ground.setPhysicsState({ impostor: BABYLON.PhysicsEngine.BoxImpostor, mass: 0, friction: 0.5, restitution: 0 });sphere.applyImpulse(new BABYLON.Vector3(0,0,15),new BABYLON.Vector3(0,0,0));engine.runRenderLoop(function () { scene.render(); });thank you for your help Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 10, 2014 Share Posted January 10, 2014 could you try with a less powerful force? Quote Link to comment Share on other sites More sharing options...
dav74 Posted January 10, 2014 Author Share Posted January 10, 2014 Hello Deltakosh,same problem with a less powerful force, same problem with a force on x (forward then back) ! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 10, 2014 Share Posted January 10, 2014 I have to see that. Could you create a small jsfiddle? Quote Link to comment Share on other sites More sharing options...
dav74 Posted January 11, 2014 Author Share Posted January 11, 2014 it's done : http://jsfiddle.net/dav74130/RFmWz/4/ thank you for your help Quote Link to comment Share on other sites More sharing options...
gwenael Posted January 11, 2014 Share Posted January 11, 2014 dav74, please replace your external ressources links by the following ones: https://rawgithub.com/BabylonJS/Babylon.js/v1.8.0/cannon.jshttps://rawgithub.com/BabylonJS/Babylon.js/v1.8.0/babylon.1.8.0.js No '.' between 'raw' and 'github' so the file are served with the right mime type (thanks to the proxy rawgithub.com)'master' is replaced by 'v1.8.0' so your jsfiddle will work as long as the tag is not deleted on GitHub whereas if the master branch is updated with a new version of babylonJS (babylon.1.8.1.js), the link is not valid anymore. Quote Link to comment Share on other sites More sharing options...
gwenael Posted January 11, 2014 Share Posted January 11, 2014 http://jsfiddle.net/gwenaelhagenmuller/jtLJG/1/ Zaidar 1 Quote Link to comment Share on other sites More sharing options...
dav74 Posted January 11, 2014 Author Share Posted January 11, 2014 @gwenael : thank you for your help http://jsfiddle.net/dav74130/RFmWz/4/ gwenael 1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 11, 2014 Share Posted January 11, 2014 Sounds logic to me as the impulse made the sphere rotating in the opposite direction Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 11, 2014 Share Posted January 11, 2014 Try with a box to see it rotating Quote Link to comment Share on other sites More sharing options...
dav74 Posted January 11, 2014 Author Share Posted January 11, 2014 i apply impulse to the sphere center (0,0,0). I should have a translation, no ? I think that i haven't understood applyImpulse's use, i'm going to wait documentation or tutorial edit : with no friction on ground, all is ok (i think that i had a "retro effect" (with friction)) other question : how to stop the impulse ? (or how long lasts the impulse ?) thank you for your help Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 14, 2014 Share Posted January 14, 2014 The impluse trans;it a force that need to be removed by friction or collisions Quote Link to comment Share on other sites More sharing options...
gwenael Posted January 14, 2014 Share Posted January 14, 2014 I made a post you could be interested by: http://www.html5gamedevs.com/topic/3083-spaces-world-parent-pivot-local/?p=19938 And here the result with your example: http://jsfiddle.net/gwenaelhagenmuller/4QgPm/ Quote Link to comment Share on other sites More sharing options...
Boz Posted May 4, 2014 Share Posted May 4, 2014 Hello !I get the same "problem" than Dav. I noticed when you apply a vertical impulse on a sphere like this : sphere.applyImpulse(new BABYLON.Vector3(0,5,0), new BABYLON.Vector3(0,0,0)), there are 2 differents results : - if the sphere is located at (0,0,0) point, all is ok, the sphere jumps and stops.- if the sphere is elsewhere, like (5,0,0), it jumps and start rolling along x axis.- if the sphere is elsewhere, like (0,0,5), it jumps and start rolling along z axis.The speed the sphere is rolling is according to the power of the impulse. I use babylonjs 1.11Thanks for your feedback Quote Link to comment Share on other sites More sharing options...
Dad72 Posted May 4, 2014 Share Posted May 4, 2014 Hi, This behavior seems normal. I have not read any of the subject, but from what you explain, I see no problem. Quote Link to comment Share on other sites More sharing options...
Boz Posted May 4, 2014 Share Posted May 4, 2014 The fact is when I apply an impulse like (0, 5, 0), I just want my sphere to go up, if I want it to go up AND right I have to apply an impulse like (5, 5, 0)I thought the impulse did not depend of the position of your mesh. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted May 4, 2014 Share Posted May 4, 2014 Hi You are correct, Pouet. Position of the sphere should not matter. It might be wise to use SOME contact point vector... to ensure a direction. For a +y impulse... maybe do this. sphere.applyImpulse(new BABYLON.Vector3(0,5,0), new BABYLON.Vector3(0,-.1,0)) This puts the impulse contact point UNDER the center of the sphere, and may give you more predictable behavior from the impulse. In many ways, a contactPoint vector is a direction vector... and a direction vector of 0,0,0 is a un-set and confused vector. It is like asking a sphere to point the way home. Not much information available. heh Just a thought. Good luck. Please report your discoveries. Thanks! Quote Link to comment Share on other sites More sharing options...
kidandcat Posted June 13, 2014 Share Posted June 13, 2014 I got it!! just: sphere.applyImpulse(new BABYLON.Vector3(0,5,0), sphere.position); 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.