Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  How to add noise  (Read 685 times)
0 Members and 1 Guest are viewing this topic.
Offline Ging3rtoby

Junior Member


Medals: 1
Projects: 1



« Posted 2014-01-09 17:34:46 »

Hi this is my voxel engine so far...

This is my chunk class - http://pastebin.com/W64LSh07
This is my main game class - http://pastebin.com/axULjzRt

Could someone please tell me how to add random noise to this engine, so my voxels have different heights thus making random generation, I have looked a simplex noise i just dont know how to add it to my engine

Thanks Toby
Offline Sabomoth

Junior Member


Medals: 1
Exp: 2 years



« Reply #1 - Posted 2014-01-09 18:02:05 »

http://www.java-gaming.org/topics/generating-perlin-noise/31605/view.html
http://www.java-gaming.org/topics/libgdx-2d-top-down-procedurally-generated-terrain/30281/view.html
http://www.java-gaming.org/topics/libgdx-2d-top-down-procedurally-generated-terrain/30281/view.html
http://www.java-gaming.org/topics/generating-2d-perlin-noise/31637/view.html


Several threads on it. Simply use the result as a heightmap.
Offline Ging3rtoby

Junior Member


Medals: 1
Projects: 1



« Reply #2 - Posted 2014-01-09 18:55:07 »

These help a bit but i need some help on how to add these to my code
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline jonjava
« Reply #3 - Posted 2014-01-09 19:28:37 »

Noise is a bunch of values related to each other. In your case, it seems like you want to add these values to your heights.

So just do that.

Create a noise map and add its values to your your blocks height value. How big should the noise map be? Preferably the same size as your game map. Makes sense right?

e.g. it could look like this for a 2d map:

1  
2  
3  
4  
5  
for (int i = 0; i < map_width; i++) {
  for (int j = 0; j < map_height; j++) {
    gameMap[i][j].height = noiseMap[i][j];
  }
}

Offline philfrei
« Reply #4 - Posted 2014-01-09 19:46:20 »

To add to Jonjova's answer:

for each [i,j], you would execute the following call:
1  
double noiseValue = SimplexNoise.noise(i * widthFactor, j * heightFactor);


This will return values that range from -1 to 1. How you convert those values to ones that are useful for your voxels is up to you. The two most common strategies are scaling ("smooth" noise) and applying an Abs function to the results prior to scaling ("turbulent" noise).

The values widthFactor and hightFactor above are used to control how quickly the values transition. With SimplexNoise, progressing integers tend to just generate unrelated, random values. I'd try using a factor such as 1/128 (give or take a power of two) as then you will get the transitions between the random peaks.

To get more interesting effects, you will have to make multiple calls to the function at differing width/height factors, and weight the various answers depending on the frequency content you desire. Also, the noise result can be used to permute another function such as a sin or radial gradient.

"Greetings my friends! We are all interested in the future, for that is where you and I are going to spend the rest of our lives!" -- The Amazing Criswell
Offline Ging3rtoby

Junior Member


Medals: 1
Projects: 1



« Reply #5 - Posted 2014-01-09 20:18:17 »

Ok have no idea but what the hell
Offline Ging3rtoby

Junior Member


Medals: 1
Projects: 1



« Reply #6 - Posted 2014-01-09 20:33:15 »

Whats the game map array I havent got that
Offline Sabomoth

Junior Member


Medals: 1
Exp: 2 years



« Reply #7 - Posted 2014-01-09 21:29:01 »

How do you create your map? The map array is what contains the data that will be rendered as your map. For example an array of floats with the values -1 to 1 as described below. You then tell the game to go trough every single post in the array and render all numbers between lets say -1 to -0.40 as a dirt block, -0.40 to -0 as grass, etc etc.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Riven (20 views)
2014-07-29 18:09:19

Riven (13 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (31 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (42 views)
2014-07-24 01:59:36

Riven (42 views)
2014-07-23 21:16:32

Riven (28 views)
2014-07-23 21:07:15

Riven (29 views)
2014-07-23 20:56:16

ctomni231 (60 views)
2014-07-18 06:55:21
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!