Jump to content
  • Advertisement
Sign in to follow this  
carl granberg

Noise function

This topic is 2589 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


I read the book<Programming Rts game programming with directx>I find a function Name is Noise,they are shown as below the are use to produce random height use for Terrain!if someone undertstand the code please explain to me!


float Noise(int x)
{
x = (x<<13) ^ x;
return (1.0 - ((x * (x*x * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0);
}

float CosInterpolate(float v1, float v2, float a)
{
float angle = a * D3DX_PI;
float prc = (1.0f - cos(angle)) * 0.5f;
return v1*(1.0f - prc) + v2*prc;
}

Share this post


Link to post
Share on other sites
Advertisement

I read the book<Programming Rts game programming with directx>I find a function Name is Noise,they are shown as below the are use to produce random height use for Terrain!if someone undertstand the code please explain to me!


float Noise(int x)
{
x = (x<<13) ^ x;
return (1.0 - ((x * (x*x * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0);
}

float CosInterpolate(float v1, float v2, float a)
{
float angle = a * D3DX_PI;
float prc = (1.0f - cos(angle)) * 0.5f;
return v1*(1.0f - prc) + v2*prc;
}




well, it's probably not exactly this:
http://freespace.vir...ls/m_perlin.htm (look at the end to skip the math)
http://en.wikipedia....ki/Perlin_noise
but it's at least probably something similar.
Just a function to calculate noise that some mathematician made up and it works great for making "realistic" terrain or clouds or things like that procedurally.

Share this post


Link to post
Share on other sites
why does no man give me an correct answer ,I need to buid na desert terrain /jungle terrain,so it is random height or use some special picture,so please first give me some noise function use in Rts 4
game produce differnt terrain!please email me at [email="frankluna11@yahoo.com"]frankluna11@yahoo.com[/email]

Share this post


Link to post
Share on other sites

why does no man give me an correct answer ,I need to buid na desert terrain /jungle terrain,so it is random height or use some special picture,so please first give me some noise function use in Rts 4
game produce differnt terrain!please email me at [email="frankluna11@yahoo.com"]frankluna11@yahoo.com[/email]


You need to ask a more specific question. What is it about the code you posted that you don't understand? Have you considered that the book you are using may not be the right place to start if you cannot understand the code it contains. Perhaps pick up a basic C++ coding book and then come back to this RTS book when you have learnt some more about coding.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!