Solved Difficult programming/logic question

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

kaz

Coder
Full Member
Nobleman
Apr 3, 2013
160
1,183
7
So I'm trying to develop a randomly generated terrain using vertices and then making a surface out of them connecting triangles(2) to make a solid 4 cornered piece of land.
My logic is confusing me and then derailing my train of thought.
I'm looking for a less complicated way of approaching this.

Here's my style

size = 30
name[500]

For(x=0;x<size;x++){
For(z=0;z<size;x++){
y=y-(rand(-1,1))
addvertex(name[x+z],x,y,z)
}
}

The result is not what I want nor what I can work with to create bigger lands if the y value for the x(1) goes down and the x(2) goes upwards.

I thought of another way but this would require an array inside an array so I could grab each any every point/vertex then comparing it to the one that will be next to it to keep the ground within a -1 through 1 point of the last; leaving the code a mess.
I drew a image to make it clear in my head. result;

coding this would be a pain in the ass and be hard to work with if I wanted to modify.



Anyone have a better way of doing this, I have all the coding down and drawings already set up.
I just want to know how I would randomize the Y axis but still create a realistic texture, similar to minecraft style of generation.


Thanks for reading!
 

kaz

Coder
Full Member
Nobleman
Apr 3, 2013
160
1,183
7
solved it,


perlin noise:
2d perlin noise


The white pixels are height and black are lower.

3d perlin noise requires pasting perlin noises on others, this will allow overhangs and caves underneath the terrain.
 
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Similar threads

Community Mods