Brutile Posted October 21, 2014 Share Posted October 21, 2014 I am trying to procedurally generate terrain heights, but with no luck. terrain = Terrain::Create(512, true); terrain->SetLayerTexture(0, Texture::Load("AddOns/Terrain Textures/mountain_grass.tex"), 0); terrain->SetLayerTexture(0, Texture::Load("AddOns/Terrain Textures/mountain_grassdot3.tex"), 1); perlinNoise = new Perlin(0); fractalNoise = new FractalNoise(0.1, 2, 1, perlinNoise); for (int y = 0; y < 512; y++) { for (int x = 0; x < 512; x++) { float height = fractalNoise->HybridMultifractal((float)x / 100.0, (float)y / 100.0, 1.0); terrain->SetHeight(x, y, height); } } terrain->Update(); terrain->UpdateHeightmap(0, 0, 512, 512); terrain->UpdateShape(); This is what I have. I'm using my own perlin noise that I know works. It doesn't seem to be setting any heights and the collision isn't working (you just fall through the terrain). As there is no documentation on this, could someone please give me a hand with this? Quote Link to comment Share on other sites More sharing options...
macklebee Posted October 21, 2014 Share Posted October 21, 2014 Assuming the terrain works similar to LE2 terrain, the height used in SetHeight() is a value between 0 and 1, where 1 was equal to the max altitude. In lua, I do not see what sets this altitude and currently I can only get the terrain to move up 1 meter. As for the collision, its working automatically for me, so not sure why it isn't for you. Edit-- I take that back... the altitude is set just like it was in LE2 - by using SetScale(). terrain:SetScale(1,10,1) will set the max altitude to 10 meters. So if your perlin noise generator sets the height between 0 and 1 then you should see results. Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Brutile Posted October 22, 2014 Author Share Posted October 22, 2014 Thanks macklebee, turns out SetScale did the trick. Not sure why there was no collision without it though? Edit: I think I was just falling onto the terrain from too high, that's why I was falling through it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.