Jump to content

Gravity with Heightfields


jodo
 Share

Recommended Posts

How can I get my mesh moving around on a height field when using Oimo Plugin in Babylon js?

 

This is "working":

Render.prototype.createScene = function(){    this.ground = BABYLON.Mesh.CreateGroundFromHeightMap("ground", "textures/heightMap.png", 50, 50, 100, 0, 2, this.scene, false, onGroundCreated);}function onGroundCreated(ground){    ground.setPhysicsState(BABYLON.PhysicsEngine.BoxImpostor, {friction:0, mass: 0,  move : false });}

The problem is, as the Imposter is a Box, my Mesh moves just on top of the height field.

 

In this tutorial:

https://blogs.msdn.microsoft.com/davrous/2014/11/18/understanding-collisions-physics-by-building-a-cool-webgl-babylon-js-demo-with-oimo-js/

It states four different possibilitys for colliders. Box, Sphere, Capsule and Mesh. Is Capsule and Mesh also available in the Babylon OimoJSPlugin? Because I guess thats what I would need to move around the height field i guess. Or maybe there are other valid options for that problem.

Link to comment
Share on other sites

Hi Jodo, welcome to the forum.  As far as I know, OimoJS heightMap/displaceMap physics is not yet active, and the CannonJS mesh imposter is new for us, and now being tested. 

 

Recently, CannonJS was used to do a heightMap physics application in BJS...  http://www.html5gamedevs.com/topic/18125-heightmap-with-the-physics-engine/  (thanks to our friend and hero Raanan). 

 

Some of our local mad scientists played with it more... read starting here...  http://www.html5gamedevs.com/topic/2571-the-wingnut-chronicles/page-35#entry103212

 

Mad scientist Ian is trying to make a game like Perplexus, so Ian REALLY needed mesh imposters... and Raanan to the rescue again.  http://www.html5gamedevs.com/topic/19192-mesh-impostors-on-3d-object-like-path/#entry108964  - read down until you see http://raananweber.com/physics/ demo  (spacebar, + A/D keys).

 

To come to the point, we don't have the OimoJS heightmap activated yet, as far as I know.  The CannonJS mesh imposter/heightMap is activated and working, but it is REAL new for us, here.  We could use your help.

 

Lastly, we should be real nice to Raanan... because he does LOTS of things around here besides making major advancements in our physics features.  We could use ten more Raanans around here, so, try to be gentle if you make requests of him.  Oimo CAN do heightMap physics, as we can see on Oimo's demo pages, but notice this comment... http://www.html5gamedevs.com/topic/18125-heightmap-with-the-physics-engine/page-2#entry103134

 

Friend and superhero Temechon, who developed most of our physics plugin code... also has important things to say... http://www.html5gamedevs.com/topic/8061-physic-test-oimojs/#entry48153

 

If you can help us with this, Jodo, it would be EXCELLENT.  http://lo-th.github.io/Oimo.js/test_terrain.html  -  Get that working in BabylonJS, and you will be a bigtime hero, Jodo.  :)  Meantime, I think CannonJS heightMap physics is the best we can offer you.  Sorry.  Be well.

Link to comment
Share on other sites

Hi all,

 

@Wingnut - Thanks! I wanna show my mom what you wrote :) I think we need ten more of you to help people all the time! and to create those crazy-good demos...

 

About Oimo vs. Cannon - Oimo has only Box and Sphere impostors. The newest version just added cylinders, which I will add pretty soon (once the new version is stable). The way the heightmap is implemented in OimoJS is using a lot of spheres and boxes that simulate a heightmap. This is wonderful for certain surfaces, but very problematic for very complex surfaces. You can see in the demo, that some spheres are "stuck" where you would expect them to slide down. This is the reason. And this is where Cannon comes to the rescue. Heightmap and Mesh impostors were implemented / improved exactly for that reason. 

 

I remember reading once that you (wingnut) said that you prefer Oimo - I do too (I actually wrote that in part 2 of the MSDN Magazine article) but Cannon is much more advanced - containers, springs (coming soon. very soon :) ), heightmaps, meshes, planes, a lot of fun. If a very simple-yet-powerful physics engine is needed - Oimo would be my first choice. But if complex meshes are needed, there is no escape from using cannon - which is an amazing physics engine! just a bit different.

Link to comment
Share on other sites

Thanks Raanan, that's very nice of you to say, and thanks for the words about the physics engines.  We have seen a few comments from users such as "it's all in slow motion".  Do you think we will see even more comments like those... when we ask more of the engines?   Something tells me that as we activate these less-than-primitive impostors, our speeds will drop, and our users will become discouraged.

 

I don't know.  I'm not at all qualified to speak on these subjects.  Sometimes I think our strife to serve mobile devices... cripples our chances of getting high-speed physics for the average home user.  Sometimes I want to say "to hell with mobile crap, I want fluid dynamics on my desktop", and I'm willing to install the Freon coolers and physics-dedicated PC boards to get it.  Why should we have to hold the hand of the hand-helds?  Are the mobile devices actually dragging-down the desktop fun?

 

*shrug*  I'm not sure where things are going.  Thoughts, anyone?  Be well.

Link to comment
Share on other sites

Slow motion is probably the physics engine's doing - It would be great to see what exactly is meant here. It is always possible that we update the steps incorrectly!

 

A physics-enabled game is, of course, more CPU intensive. I believe that it is possible to get good performance, even when using mesh or heightmap impostors. of course, the best performance will be reaches if only sphers and meshes are used, but this is rather limited.

Oimo and cannon allows us to link meshes together - link a few spheres and boxes together, to simulate a complex mesh. This is always a possibility. I played quite a lot with Oimo and compound objects. Oimo's and Cannon's performance are quite the same. Using compound vs. mesh imposter is all up to the developer. It is a question of mesh complexity (for example, try adding physics to a knotted torus - it is too complex). The developer should implement the minimum needed impostors - this will provide the best performance.

 

I remember you wrote something about HORSE implementation - I have created a simple HORSE game once (will continue developing it when I have the time :) ) and have simulated a ring using spheres - this works wonderfully. there was no need for a mesh impostor. But this is a ring. not a complex mesh. 

 

The web has its limitations. after all, we are working in a closed container (the browser) which is the component that communicates with the operating system. native will always be a bit better. a web developer must understand that and live with these constraints. It is constantly getting better. each new version the JS engine is faster and more reliable. And once more and more WebGL games will surface, the browsers' vendors will optimize 3D functionality as well. This will happen in the near future, I am 100% sure of that!

Link to comment
Share on other sites

Thanks Wingnut for all that research on that part, was great to read through all of that. I am quite new to whole webGL stuff and there is still so much things I need to get my head around.

 

What I ended up doing for now is using the built in physics by looking at this example: http://www.castorengine.com/babylon/moveCharacter/ which I found here http://www.html5gamedevs.com/topic/10904-move-mesh-with-physics-without-apply-impulse/.

For now this is sufficient for my needs, but I sure will play around with the physics engines later on. Keep up the great work!

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