Jump to content

Heightmap Terrain and Physics?


thephox1982
 Share

Recommended Posts

I see that a flat terrain generated using CreateGround stops my object from falling through but terrain generated using CreateGroundFromHeightMap objects simply fall through using both basic phsyics and cannon.js which leads me to wonder if heightmap terrain even supports physics yet or not.

Link to comment
Share on other sites

MeshImpostor using cannon doesn't support heightfield yet and Babylon.js only supports plane, cube and sphere using cannon.js apparently according to documentation. I was hoping for another way like raycast, but that doesn't even exist in the documentation so it appears I am unable to use Babylon for developing an MMO game short of having all flat terrain. x.x

 

Is there any potential way of finding the height from a heightfield terrain to an object, that at least can provide a way to calculate where to move the object (actor, car, mount, etc) in relation to the ground as this technically is all that would be needed, say a function to report back the Y location of X number of nearby vertexes or faces.

Link to comment
Share on other sites

Hi 'thephox1982'... welcome to the forum.  I am a newbie to webGL physics, but I have done a few torture tests.  A 'MMO' with javascript and webGL, huh?  Well, I guess if you're going to have a dream, it might as well be a big one.  :)  Have you ever played a game/sim called Stunt Rally?  I think it is written in C#, and it is a single player game, with a vehicle, and height-mapped terrain.  And, it is pretty laggy... and C-sharp runs substantially faster than JS.

 

Speaking of laggy, have you seen the cubicVR vehicle physics demo ?  It uses ramps and jumps instead of height-mapped ground, and it is SERIOUSLY laggy.  And you want to have height-mapped terrain physics, and lots of users in the scene, too?

 

I think you are asking the world of the cannon.js physics engine.  I do not nomally make comments like this.  I tend to promote users and dreams, no matter how 'pie in the sky' large they are.  But your dream, phew, that's a big one.  May I suggest that you use a flat area in the middle of your rolling landscape, and install a physics-active ground plane in 'the plains' area of your scene, and do some tests with ramps, barrels, and a couple of physics active vehicles... as a proof of concept? 

 

Cannon.js is a fast and small physics engine, but you are still dealing with JS, and I have a feeling that you are going to be disappointed with the performance.  But in the same breath, I think you could use a 'plausibility study' regarding your whopper-sized dream and goal.

 

I hope I did not offend you.  It is great to think big and dream big... but JS still has limitations that you should probably take into account.  Maybe dad72's information will help give you an alternative method that is feasible.  Sorry that I was not more optimitistic or helpful.  We would love for you to have the stars and the moon, but for now, the best we have is 'down to Earth'.  :)

 

Be well, good luck.

Link to comment
Share on other sites

Making MMO is possible if all optimized models, scene, animation, very little physical, do not too large textures (512 max) and compress (DDS is supported or jpg). Do not create too much big ground too, better create more portal to another scene. Use the LOD (function coming) all over your belongings.

 

also do not expect millions of players. if you happen to 30 players, it will be already good.

 

as game server, Node.js

Link to comment
Share on other sites

Hi 'thephox1982'... welcome to the forum.  I am a newbie to webGL physics, but I have done a few torture tests.  A 'MMO' with javascript and webGL, huh?  Well, I guess if you're going to have a dream, it might as well be a big one.  :)  Have you ever played a game/sim called Stunt Rally?  I think it is written in C#, and it is a single player game, with a vehicle, and height-mapped terrain.  And, it is pretty laggy... and C-sharp runs substantially faster than JS.

 

Speaking of laggy, have you seen the cubicVR vehicle physics demo ?  It uses ramps and jumps instead of height-mapped ground, and it is SERIOUSLY laggy.  And you want to have height-mapped terrain physics, and lots of users in the scene, too?

 

I think you are asking the world of the cannon.js physics engine.  I do not nomally make comments like this.  I tend to promote users and dreams, no matter how 'pie in the sky' large they are.  But your dream, phew, that's a big one.  May I suggest that you use a flat area in the middle of your rolling landscape, and install a physics-active ground plane in 'the plains' area of your scene, and do some tests with ramps, barrels, and a couple of physics active vehicles... as a proof of concept? 

 

Cannon.js is a fast and small physics engine, but you are still dealing with JS, and I have a feeling that you are going to be disappointed with the performance.  But in the same breath, I think you could use a 'plausibility study' regarding your whopper-sized dream and goal.

 

I hope I did not offend you.  It is great to think big and dream big... but JS still has limitations that you should probably take into account.  Maybe dad72's information will help give you an alternative method that is feasible.  Sorry that I was not more optimitistic or helpful.  We would love for you to have the stars and the moon, but for now, the best we have is 'down to Earth'.  :)

 

Be well, good luck.

 

 

By the way you describe simple things (I have already seen work just fine including a rally racing game made in HTML 5) are all laggy, I question your graphics performance and such and I'm on a AMD Vision built in graphics, that game in question was running at above 50FPS.
 
There is no reason an MMO can't run fine with HTML5 if one knows what they are doing and takes advantage of load on demand methods such as loading what is needed in to memory just before it is in render distance, etc.
 
I accidently clicked Report and submitted that statment as a report because I didn't notice it wasn't a "reply" button as normally that is where a reply button is found on forums, lol, come find there is none, only quote button for replying to someone specifically. >.>
Link to comment
Share on other sites

 

Making MMO is possible if all optimized models, scene, animation, very little physical, do not too large textures (512 max) and compress (DDS is supported or jpg). Do not create too much big ground too, better create more portal to another scene. Use the LOD (function coming) all over your belongings.
 
also do not expect millions of players. if you happen to 30 players, it will be already good.
 
as game server, Node.js

 

 

 

I was debating using Node.js as game server, either that or C#, but that is the server which doesn't matter so much here.

As for the suggestion of picking, I'll keep that in mind but I am going with three.js due to it's vast amount of features and it supporting what I need to get done, Babylon is just not ready for MMO yet, however if it was I'd have gone with it as it is easier to work with I am finding, it was more enjoyable and straight forward.

 

As for the terrain bit, I will be going a new concept route, a load and unload on demand, say little sectors in a grid 256x256, 8 loaded at a time (2048x2048sm worth loaded at a given time), as the player moves out of one grid it loads it's neighbors and unloads any that are now unused while the player doesn't see it as it is out of range, this will also load in the new grids items to memory but not render until within distance, I have dubbed this "Seamless Terrain and Object Load on Demand" (STO-LOD). With this it also becomes possible to create an ever growing world as it manages memory well enough, so one could for instance as a game manager push new terrain they have developed to the server which then sends it out as a behind the scenes client update and have it load in to all the clients without them having to reload, this is my planned route and it works in theory, I am confident it will in practice.

 

Thanks for the input guys!

Link to comment
Share on other sites

  • 2 months later...
But I was wondering. It is possible that the terrain mesh detects the collision with object (character)? This could may be help, but I don't know if this would cost dear or not.

 

I start a think for my project or I get soon a need to handle everything collision, gravity, physics.

Link to comment
Share on other sites

 

But I was wondering. It is possible that the terrain mesh detects the collision with object (character)? This could may be help, but I don't know if this would cost dear or not.
 
I start a think for my project or I get soon a need to handle everything collision, gravity, physics.

 

 

I'm sorry but I don't understand what you mean.

The way I have my code setup for detecting terrain collision is based from the player character model, it checks in real time the distance between the detected vertices of the terrain mesh Y (vertical axis), if the character is below that it places the character above it, it has no performance impact and it isn't noticeable visually as it does the correction before the new frame is rendered.

 

Also as far as physics is concerned, you could write your own bit like I am using raycasting as from what I've seen is that not one HTML5 based physics engine out there (at least for free) has huge performance issues with convex hull type objects or don't support it at all, so I gave up that route and found I can easily do it with raycasting then expand it to emulate gravity when jumping and falling from high places. If choosing this route do the emulation math in a new thread using a web worker. As a rule of thumb I try to do any complex math and also any repeat math processes in a math thread for performance reasons.

 

Also kinda not related but kinda related, if using Math.PI more than once in your code, make it a global and reuse it as PI doesn't change, so I have code like; var rotation_z = PI * 0.5;

Rather than; var rotation_z = Math.PI * 0.5;

Do this especially when in a render loop so that PI doesn't need to be calculated each frame!

Link to comment
Share on other sites

Sorry I build sentences a little complicated in french to translate in English sometimes.

 

But you understand what I mean. I wonder for my project which is also to make a MMORPG coupled to a Editor "CastorEngine".

 

I am interested in your solution, if you want well tell me more, or give examples.

 

Thank you
Link to comment
Share on other sites

 

Sorry I build sentences a little complicated in french to translate in English sometimes.
 
But you understand what I mean. I wonder for my project which is also to make a MMORPG coupled to a Editor "CastorEngine".
 
I am interested in your solution, if you want well tell me more, or give examples.
 
Thank you

 

 

Well I don't yet have an exact solution per se, but once I get something constructed I'll try and remember to update here more about how I did it.

Also if you are interested you could help out with my MMO or at least look at the code as it develops and take from it, it's open source! :-)

See my signature for more information.

Link to comment
Share on other sites

hi there,

 

in these days i'm trying to make a game physics plugin for three.js, and it might be helpful

 

WASD to move, Space to jump, mouse drag to rotate.

plus, mesh importer is available

http://yomotsu.github.io/threefield.js/example/5_terrain.html

 

it still needed optimization tough...

you can see the code, and feel fee to send pull requests

https://github.com/yomotsu/threefield.js

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