Jump to content

Any way to get heightMap incline at a certain x,z/Mesh follow curvature of heightMap


Convergence
 Share

Recommended Posts

Hello,

Is there a way to retrieve/calculate the angle (slant) of a mesh created by CreateGroundFromHeightMap() at a certain x, z coordinate? (or any mesh for that matter). 

 

The pickResult of ground.intersects(ray) does not seem to give this information, however there are a mysterious 'bu' and 'bv' property on the object, I haven't yet figured out what those mean.

 

It would be nice to know, for example, to rotate a mesh to be exactly perpendicular to the Ground it is resting on. I could of course dive into the vertices array and slog through a lof of cos() sin() and toa()s to get it, but perhaps babylon already has a neat function for that I'm overlooking?

 

Slightly related question regarding gravity and collisions:

Even if the ground is only very slightly slanted, a gravity-affected-object will already start to slide down, which can get irksome after a while. For reasonable slants this is good and realistic of course, but it would be nice if a little bit of grip could be had. 

Link to comment
Share on other sites

  • 2 months later...

I have a follow-up question; the above method only returns one float value which indicates that the face is angled, but not towards which axis, which makes it insufficient for the following scenario:

 

Say you are moving a car across a heightmap, the car should of course follow the curve of the landscape regardless of its own orientation. Is there an easy way calculate its rotation so it looks like all 4 wheels still have contact with the ground? Preferably without the use of ray.intersects() since it is rather slow and I was already able to eliminate its use from my project.

 

The 'hard' way I can think of is to dive in the ground._positions array, retrieve the applicable vertices and do some heavy trigonometry on them;  but perhaps there is an easier way?

Link to comment
Share on other sites

Hi guys!  ConV... I think you should un-answer this thread, if possible.  This is great subject... and hasn't been talked-about in this forum... enough (imho).  I assume you are NOT using a physics engine, so the slant of a "tile" is important for "coasting" the vehicle, too.  The slant under each tire can be summed, and then averaged, to see if the car would roll if in neutral gear.

 

But maybe the normal of the car body... compared to "up"... would return something usable, too.

 

I think this is a hot topic, and we could use all the car-on-heightMap fun that we can find.  :)

 

Personally, I like jumping vehicles, but that might require a physics engine... so I can get maximum tumbling carnage when I crash-land.  :)

Link to comment
Share on other sites

Hi guys!  ConV... I think you should un-answer this thread, if possible.  This is great subject... and hasn't been talked-about in this forum... enough (imho).  I assume you are NOT using a physics engine, so the slant of a "tile" is important for "coasting" the vehicle, too.  The slant under each tire can be summed, and then averaged, to see if the car would roll if in neutral gear.

 

But maybe the normal of the car body... compared to "up"... would return something usable, too.

 

I think this is a hot topic, and we could use all the car-on-heightMap fun that we can find.  :)

 

Personally, I like jumping vehicles, but that might require a physics engine... so I can get maximum tumbling carnage when I crash-land.  :)

Thanks for the reply :)

 

Actually I had already marked the thread as unresolved before replying :)  , but now it seems its 'Answered' again. Weird, I don't know what happened there. :blink:

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