Jump to content

Create ramp for ground


Dad72
 Share

Recommended Posts

Hi,

I am looking to create a ramp system. But I do not succeed in making it. Is what anybody has of idea of how?

At the moment, I raise summits which form a mountain and I wish that by choosing vertexes from top of the mountain, then the vertexes of the bottom of the mountain, this will create a ramp.

I found a sample video that looks like what I would like to do:

How can this be done?

Thank you for your help

Link to comment
Share on other sites

I start a PG of what I have until the. 

There are two modes. One for the vertex elevation and another for the ramps. It changes to line: 43 and 44 (To be changed manually) By default elevation mode is actived

The function to make the ramp is line 171

Currently I select the vertex on functions: line 129 and 150 and I save them in an array. This corresponds to the beginning of the ramp towards the end. But I'm not sure if what I have started is correct. :wacko:

I wanted to take inspiration from the function: line 279 coming from worldmonger on the site of Babylon :P

http://www.babylonjs-playground.com/#RKPBE#13

I hope there is some expert on terrain sculpture that will help me. This is the last thing of complicate with my editor.

Thank you for you help

Link to comment
Share on other sites

You have 2 variables - topPoint (at the top of the mountain) and bottomPoint (at the bottom of the mountain). Now you have to caculate distance and height difference between these two points:

var totalDistance = Math.sqrt((topPoint.x-bottomPoint.x) * (topPoint.x-bottomPoint.x) + (topPoint.z - bottomPoint.z) * (topPoint.z - bottomPoint.z));
var heightDifference = topPoint.z - bottomPoint.z;

Next you have to select which vertices you need to update, for that use https://en.wikipedia.org/wiki/Bresenham's_line_algorithm

Loop through all vertices and calculate how far from bottom point current vertex is (use first method):

var currentVertexDistance = Math.sqrt((bottomPoint.x-currentVertex.x) * (bottomPoint.x-currentVertex.x) + (bottomPoint.z - currentVertex.z) * (bottomPoint.z - currentVertex.z));

For getting proper height of current vertex you have to calculate distance ratio between current vertex and bottom point:

var heightRatio = currentVertexDistance/totalDistance;

Finally height of current vertex:

currentVertex.z = endPoint.z + heightRatio * heightDifference;

I am not sure that i wrote everything 100% correctly, but it should be something like that.

Link to comment
Share on other sites

I try another approach that is also a total failure. :(

I drop this feature that takes me too much head and I will finish no longer have hair on my head. I can not do it and I do not think I can do it tomorrow either.

You can always create ramps manually by gradually elevating the tops at the moment. So I'll settle for that. I do not have the level for that kind of "chemistry mathematics".

Link to comment
Share on other sites

SO, now...  hehe... gray scale image... used as a heightMap or displaceMap... that has a "quantized" number of available steps, yes?

256 colors of gray?  So, ramps made from gray-scale... that use our displaceMap system... will get a "steppy" ramp... yes?

But a modeled ramp... or a math-derived map... would give a much smoother ramp, yes?

Ok, just checking. 

The granularity (subdivs) of the ground... will need consideration... (duh wingy).  hmm.

Can a ramp get wider or narrower... as it ascends/descends?  (Wingy digs in his bag for some aspirin).

Link to comment
Share on other sites

Thank you Gryff, Adam and Wingnut for your support. 

Yes, Gryff I'm not the type to give up generally easily, but I feel like I run into a big wall. I do not know at all how to do and rather than do anything/to make bullshit, down I prefer to stop. My ideas exceed my skills sometimes. 

But thanks. If you get there, Adam, I would try to understand what you did for learn. Thank you for giving a try to this headache and do not you care if you do not succeed.

Link to comment
Share on other sites

Hi, it's a fun challenge! I tried my best to make something like in the video, and here are the results:

This is the standalone version. You can adjust the brush size.

http://www.babylonjs-playground.com/#RKPBE#17

Tip: enable wireframe mode on the material to see the geometry better.

This is your #13 mixed with my #17:

http://www.babylonjs-playground.com/#RKPBE#18

I saw buttons in your demo very briefly, but for some reason they usually don't show. I made the middle mouse button for 'ramp' instead, left is to make mountains.

Hopefully it is of some use to you. Good luck with your project!

Link to comment
Share on other sites

30 minutes ago, Dad72 said:

I studied the code you did. I'm impressed, I would never have done that. You made a quality system. This is really perfect.

Great thank you for helping me with this.

You're welcome, but I just thought of a more general method of doing such things, so if that works out, the ramp code may soon be obsolete

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