dbawel Posted October 11, 2016 Share Posted October 11, 2016 Hello, How might I apply constant movement using oimo.js such as would occur in an asteroid field - where no object stops moving? That is not the task, but best describes it. By the way I do have borders so the objects are contained. But even if I set no friction and a restitution of 1, no matter how I've tried to apply the impulse, I cannot keep to objects moving. There is no gravity in the scene. Thanks, DB Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted October 11, 2016 Share Posted October 11, 2016 playground? Quote Link to comment Share on other sites More sharing options...
Dad72 Posted October 11, 2016 Share Posted October 11, 2016 Hi, you have activated the physical and adjust gravity? var gravityVector = new BABYLON.Vector3(0,-9.81, 0); var physicsPlugin = new BABYLON.CannonJSPlugin(); scene.enablePhysics(gravityVector, physicsPlugin); Can be an example on the playground would be nice. Have you seen the tutorials? http://doc.babylonjs.com/tutorials/Adding_Your_Own_Physics_Engine_Plugin_to_Babylon.js and http://doc.babylonjs.com/overviews/Using_The_Physics_Engine Quote Link to comment Share on other sites More sharing options...
dbawel Posted October 12, 2016 Author Share Posted October 12, 2016 Hi @Dad72 I can't include any gravity, and have spent considerable years working with physics in openGL and now working in webGL - so I truly appriciate the input. And yes, I include and have adapted every possible usage of the code you provided. However, what I can write that I know will work is way too much code (more work than I believe should be necessary) - as there must be a way to provide a constant impulse to objects without gravity, and control each object with an imposter on random vectors. Thank you so much for looking at this, and if you can find any examples of constantly moving meshes using Oimo.js on the playground utilizing imposters and colisions, I'd be really happy. Otherwise, I'll provide the link to my scene, which is basically an adaptation of David Roussets' @davrous oimo.js demo on babylon.js demos. I'm too stupid to look at Oimo and get a constant impule to work. Thanks, DB Quote Link to comment Share on other sites More sharing options...
Dad72 Posted October 12, 2016 Share Posted October 12, 2016 I do not have much experience the physical. Here is an example on the pulse PG. http://www.babylonjs-playground.com/#26LQEZ#26 Here the pulse is constant in the z axis. But imagining the edges with collisions, one can add a refund sphere and recovering the collision event to change the axis of the pulse (x, y or z) and / or orientation (vector3). These are just ideas. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted October 12, 2016 Share Posted October 12, 2016 You can use applyForce, or change the the velocity manually with imposterBody.velocity. Let me see if I can pull up my experiment showing different ways to apply force. Give me a few mins and ill edit this post with a playground. And I cant find the playground maybe @Wingnut has it book marked (it was the one with three boxes and three spheres inside them being bounced around by different functions like force and impulse and direct)... we really need to get the playground directory site up and running so many lost playgrounds that answer all these questions Quote Link to comment Share on other sites More sharing options...
Dad72 Posted October 12, 2016 Share Posted October 12, 2016 33 minutes ago, Pryme8 said: we really need to get the playground directory site up and running so many lost playgrounds that answer all these questions Completely agree. It's not easy to find all the examples made on the PG. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted October 12, 2016 Share Posted October 12, 2016 I think I may tailor NeatFlax from being tutorials to being just a repo of PG's with tags for search ability by topic and a little preview image and description. Dad72 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted October 12, 2016 Share Posted October 12, 2016 Hi girls. I believe Captain @Temechon has already started such a list. http://doc.babylonjs.com/generals/playgrounds It just needs a whole lot of fleshing. I think thumbnail images would be implausible, but we can see that each entry in Temechon's list... has his wonderful "mouseover eyeball" feature, and that eliminates the need for thumbnails. A keywords column might be wise. This is a situation that needs MASSIVE community involvement/participation. It is also VERY susceptible to misspellings, as we see with Wingnut's lone "Mirors" playground demo. Perhaps, a higher priority would be... to somehow allow periods in our docs site playground search. For example, a playground search for BABYLON.BrickProceduralTexture returns 1000 hits (a failed search)... whereas a search for BrickProceduralTexture returns 406 hits. All in all, making our playground search uber-powerful... would be a nice step in the right direction... I would think. But all "find the right playground" ideas... are good ideas. But, this is not on-topic. DB... yeah... you can gather an array of active imposters (physics rigid bodies)... and iterate through them periodically, applying random body.linearVelocity or applyImpulse. And yes, velocity DOES diminish over time, so you need to "whack" your imposters periodically, to keep them moving (spray them with random velocity juice). ian 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted October 12, 2016 Share Posted October 12, 2016 51 minutes ago, Wingnut said: I think thumbnail would be implausible Nope let me know when your ready for it, and ill make a async function to grab all the previews from running the scene in a hidden element on a subthread for a set time and then grabbing the screen context from the hidden canvas and pushing it to a scaled image URI component on what ever link. I got's y'all. And the current Playground database is cool... but yeah... give me a few days of free time here... Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted October 12, 2016 Share Posted October 12, 2016 '.' Sounds like this is regex based. One temp solution might be to escape .e.g 'BABYLON\.BrickProceduralTexture' BTW, since we are trampling all over the original purpose of this thread, where is the search button on the playground? Dad72 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted October 12, 2016 Share Posted October 12, 2016 2 minutes ago, JCPalmer said: '.' Sounds like this is regex based. One temp solution might be to escape .e.g 'BABYLON\.BrickProceduralTexture' BTW, since we are trampling all over the original purpose of this thread, where is the search button on the playground? Once I get NeatFlax up and running, ill see about pushing an update to the playground to include a search box to search the database ill compile with an AJAX request, and send the results back as a popup div. I don't know if it will get approved, but my last change to the playground did so well see. BTW sorry @dbawelfor changing the topic, umm If you PM me ill directly help you with your question through out the day. Quote Link to comment Share on other sites More sharing options...
fenomas Posted October 12, 2016 Share Posted October 12, 2016 21 hours ago, dbawel said: How might I apply constant movement using oimo.js such as would occur in an asteroid field - where no object stops moving? That is not the task, but best describes it. By the way I do have borders so the objects are contained. But even if I set no friction and a restitution of 1, no matter how I've tried to apply the impulse, I cannot keep to objects moving. There is no gravity in the scene. If the scene has no gravity or friction, a single impulse should make an object move forever, with no further action. If that's not happening, the issue is probably with the implementation, not the physics - e.g. objects are static instead of dynamic, or or the physics engine's tick function isn't getting called, or the like. I don't think anyone can help with such issues without seeing the code. Also, a constant impulse is just a force - if you want to apply a constant effect over many frames I think you'll want a force, rather than an impulse. (Though the question of whether the objects continue moving is the same either way.) Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted October 12, 2016 Share Posted October 12, 2016 So we can go back to the original topic at hand, please move the playground conversation to this thread. Quote Link to comment Share on other sites More sharing options...
dbawel Posted October 12, 2016 Author Share Posted October 12, 2016 Hello all, Thank you for all your input. I found a playground scene and modified it as I have in my scene. As you can see, even though there is no friction; the sheres don't bounce off the border objects, but stick to them. I need the spheres to be in constsnt motion with colisions enabled. http://www.babylonjs-playground.com/#1MJ09V#3 As always, thank you for taking a look. And @Pryme8 - no worries, I appriciate your driving the discussion back to issue at hand. And the other topic is certainly valid. Cheers, DB Quote Link to comment Share on other sites More sharing options...
fenomas Posted October 13, 2016 Share Posted October 13, 2016 Looks like a bug somewhere in the oimo plugin - restitution not getting applied, or it's getting overwritten, ignored, etc. Changing your demo to use CannonJS makes it work as expected. http://www.babylonjs-playground.com/#1MJ09V#4 Quote Link to comment Share on other sites More sharing options...
dbawel Posted October 13, 2016 Author Share Posted October 13, 2016 @fenomas - Thank you for the effort as well as the new PG scene. I had tried Cannon.js, however I was using scene.enablePhysics(null, new BABYLON.CannonJSPlugin()); and not scene.enablePhysics(new BABYLON.Vector3(0, 0, 0), new BABYLON.CannonJSPlugin()); I don't know why this makes a difference, but cannon.js fails unless you define the vectors for the engine - whereas this isn't necessary for using oimo.js and wasn't for cannon.js in the past. But I should have given up days ago as restitution has an effect in oimo.js, but obviously the plugin is broken currently - or incompatible with babylon 2.5. So now the main issue for me is how to apply a constant velocity or force - as collisions still bring all objects to rest in short time with no movement - I applyImpulse() - at a later point in time however I haven't been able to work out the math correctly - so it's a mess. The reason I was using Oimo is that I could maintain some constant motion without additional code. Thanks much, DB Quote Link to comment Share on other sites More sharing options...
dbawel Posted October 13, 2016 Author Share Posted October 13, 2016 As expected, a restitution of 1.0 or slightly above (1.05) keeps the spheres in motion. I had way overcomplicated my code when restitution wasn't working accurately in oimo.js. So again, thank you for all of your help, and "hopefully" I'll be able to get this working to the client's satisfaction. Cheers, DB Quote Link to comment Share on other sites More sharing options...
adam Posted October 18, 2016 Share Posted October 18, 2016 It works if you set the oimo world scale to 1: http://www.babylonjs-playground.com/#1MJ09V#9 Pryme8 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted October 18, 2016 Share Posted October 18, 2016 Scaling up to like say 100 on everything on your scene helps as well, Omio likes bigger numbers then 0-1's Quote Link to comment Share on other sites More sharing options...
adam Posted October 18, 2016 Share Posted October 18, 2016 If the world scale is 100 it likes bigger numbers. edit: Maybe you are right. Anyway, we know that it doesn't like small numbers when world scale is 100. Quote Link to comment Share on other sites More sharing options...
fenomas Posted October 18, 2016 Share Posted October 18, 2016 Wow, that's really weird. Apparently by default it scales everything by 100 - looks like it's something to do with working will with three.js. scene.getPhysicsEngine().getPhysicsPlugin().world.worldscale(1) That seems to fix things. Probably ought to be added to the default oimo BJS plugin? Also - how in the world does a scaling factor of just 100 induce rounding errors? dbawel 1 Quote Link to comment Share on other sites More sharing options...
dbawel Posted October 18, 2016 Author Share Posted October 18, 2016 @adam - I tried to switch back to Oimo, but there is still a bug - as the spheres eventually get stuck against the walls unnaturally - where this isn't the case using cannon. So this is definately an improvement, but it is still unusable for my project, and I hope we can find out where the bug is as I personally prefer Oimo as the rotation behaviors are much improved over cannon. Thanks, DB Quote Link to comment Share on other sites More sharing options...
adam Posted October 18, 2016 Share Posted October 18, 2016 @dbawel Did you change the restitution to 1 for the walls and spheres when you were testing oimo? Quote Link to comment Share on other sites More sharing options...
adam Posted October 18, 2016 Share Posted October 18, 2016 Also in that demo your impulse is applied in the z direction. 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.