Jump to content

oimo.js constant impulse


dbawel
 Share

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.:blink:

Thanks,

DB

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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).  :)

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

@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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

@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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...