你会如何改变陡度和循环进展。 基本上我已经制作了一个带有顶点的地形,形成一个山谷。 这些顶点的数据创建在这里:
// Divides it to a sensible height const int DIVISOR_NUMBER = 40; for (int x = 0; x < TerrainWidth; x++) { float height = Math.Abs(((float)x - ((float)TerrainWidth / 2))/ (float)DIVISOR_NUMBER); for (int y = 0; y < TerrainHeight; y++) { float copyOfHeight = height; float randomValue = random.Next(0, 3); copyOfHeight += randomValue / 10; HeightData[x, y] = copyOfHeight; } }这很好用。 但是我现在想要让山谷的两侧在第一个环路的开始和结束处更陡峭,并且山谷变得越来越接近它所获得的中心。 我有一点心理障碍,想不出一个好方法。 任何帮助,将不胜感激。
How would you go about changing the steepness as for loops progress. Essentially I've made a terrain with vertices which form a valley. The creation of the data for these vertices to use is here:
// Divides it to a sensible height const int DIVISOR_NUMBER = 40; for (int x = 0; x < TerrainWidth; x++) { float height = Math.Abs(((float)x - ((float)TerrainWidth / 2))/ (float)DIVISOR_NUMBER); for (int y = 0; y < TerrainHeight; y++) { float copyOfHeight = height; float randomValue = random.Next(0, 3); copyOfHeight += randomValue / 10; HeightData[x, y] = copyOfHeight; } }This works fine. But I now want to make the sides of the valley steeper at the start and end of the first loop and the valley flatten the closer to the center it gets. I'm having a bit of a mental block and can't think of a good way of doing it. Any help would be appreciated.
最满意答案
您可以使用平方(也称为二次)曲线。 尝试:
float offset = (float)x - (float)TerrainWidth/2; float height = offset*offset*SCALE_FACTOR;如果你仍然想在山谷的底部有一个“折痕”,你可以使你的身高加权:
float height = Math.Abs(offset) * ABS_FACTOR + offset*offset * QUADRATIC_FACTOR;You can use a squared (aka quadratic) curve for that. Try:
float offset = (float)x - (float)TerrainWidth/2; float height = offset*offset*SCALE_FACTOR;If you still want a "crease" at the bottom of the valley, you can make your height a weighted sum:
float height = Math.Abs(offset) * ABS_FACTOR + offset*offset * QUADRATIC_FACTOR;更多推荐
发布评论