Jump to content

Collide with heightmap


DesignVibe
 Share

Recommended Posts

Hi guys

I've "nearly" completed a project and come to a stage where I have a height map and a flying steampunk ship ("yep I'm a steampunk fanatic") anyways, I have a stretched sphere surrounding the ship and I wish to use that as the collision point to the heightmap.

I have used rays and it work really well but I would like more of a realistic collision i.e. When the ship hits a mountain head on, instead of going up and over the mountain I would like it to collide and to move left or right 

http://www.babylonjs-playground.com/#1L0CBO#2

I remember on a previous submission @RaananW made an impressive playground for a car to travel over a heightmap. which I tried to understand, however for a newbie its a little complex :wacko:

http://www.babylonjs-playground.com/#UGMIH#3

any help or advice would be greatly appreciated :)

 

Link to comment
Share on other sites

When using a ground mesh, it is better to consider using getHeightAtCoordinates() and getNormalAtCoordinates() (if you need the normal to implement your own behavior) that are far more faster than the ray method

http://doc.babylonjs.com/classes/2.3/GroundMesh#getheightatcoordinates-x-z-rarr-number

http://doc.babylonjs.com/classes/2.3/GroundMesh#getnormalatcoordinates-x-z-rarr-vector3-classes-2-3-vector3-

 

here is a demo of the use of these both methods : http://babylonjs.com/Demos/Boom/

Link to comment
Share on other sites

Hi @jerome

I have searched quite a few posts and found that you are the ultimate master of using getHeightAtCoordinates() and getNormalAtCoordinates(). I still find it a little confusing but with these posts I think I might be able to learn quite a few tricks:

from what I've seen I really do like this system as it saves time and RAM but trying to understand how I can use it to detect a mesh colliding upon a key-press (with world/local translation) instead of an animation is a little over complex, I'm sure I'll get there though :D

Link to comment
Share on other sites

Or use physics! :)

If the (truly wonderful) mathematical solution is enough for you, use it. But if you need true collisions you will have to use the physics engine...

Let us know if this is enough, and if not let's try using physics. Which is a lot of fun, once you know how it's done. Just like a good magic trick.

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