Benj Terrain LOD method help.

I have made a simple terrain out of terrain.party and placed it at Benj’s LOD system.
Original thread:

Is it possible to export the generated terrain to an obj file?
I tried to make a terrain out of the heightmap but it doesn’t match the generated terrain.
The physics terrain also doesn’t match the visible terrain…

I think that this is the best terrain LOD system in Blender and i believe that it should be implemented more.

Here is the blend:
https://www.dropbox.com/sh/vflqxpabdwxdnji/AAALM3dsRjpbhtgZI9EOzU-qa?dl=0

File size is big because of the 20482048 images for the terrain.
Original size was 4096
4096.

Is it possible to export the generated terrain to an obj file?

Ergh, that’ll involve writing a custom exporter in Python. I see you’ve already loaded the heightmap in blender. I’d just do File -> Export -> Wavefront. It’ll be up to whatever engine you’re using to texture it from the stencil map.

The physics terrain also doesn’t match the visible terrain…

The physics mesh needs more resolution. I’d subdivide another time or 2, then experiment with decimate to bring down the poly count. That said, this terrain system has a script that automatically updates a small high-res physics mesh around the player. The instructions weren’t updated when that feature was added.

I think that this is the best terrain LOD system in Blender and i believe that it should be implemented more.

Totally agree

I like this :smiley:

With more resolution it ends up like this.


Benj original blend uses the image below to calculate the physics mesh and it is 99% accurate.
I read something about perlin noise for terrain images…
I am using the blender game engine ONLY because i love it, but love hurts!

How am i gonna do this???


Is this wrectified editor an addon that you have to pay for it?

It is a WIP still however I outline how I made it here.

https://www.linkedin.com/pulse/world-building-jacob-merrill

I want to sell it as a addon, once it’s more complete.

until then

  1. I add a grid of tiles - (for x in range(xrange): for y in range(yrange): add tiles and move to position.

  2. I use mathutils.noise to generate the terrain

  3. I use a KD tree of all vertex, to create a dictionary
    if str(vertex.worldPosition) not in dictionary -> create entry (put all vertex in .05 radius in list using kdtree)
    (this creates ‘edges’ kinda)

if the vertex has been done already skip it.

  1. recalculate normals of faces, than average normals across edges

5 -> take all data about tiles and put in a new dictionary
{ str([int(tile.worldPosition.x,int(tile.worldPosition.y)]):TileVertextDataTuple }

6 - a KD tree is built from the worldPositions stored in the dictionary

7 - all tiles in a radius of the actor are loaded in / out (I use a property in the data tuple to tell if the tile exists) if the property==False (no tile is loaded) if the tile is occupied it will be a KX_GameObect.

8 - all tiles in a small radius of the actor (or the mouse hitpoint) are built into a ‘micro kdtree’ that is small so it can update fast. this kdtree is used to edit the terrain.

9 -> when tiles are unloaded any changes are updated to the dictionary

10 -> pickle the level.

https://docs.blender.org/api/blender_python_api_2_71_release/mathutils.kdtree.html

https://docs.blender.org/api/blender_python_api_2_71_release/mathutils.noise.html?highlight=noise#mathutils.noise.fractal

https://docs.blender.org/api/blender_python_api_2_71_release/mathutils.geometry.html?highlight=normal#mathutils.geometry.normal

Very nice info, but beyond my blender level…
I will give it a try as soon as i finish my current project.

@BluePrintRandom
maybe I did miss understood you. but how did you save more than the position of an vertex in the kd_tree?
or is this an other dict?

I only save the position but to save the vertex(DATA) like color in an kd tree it would be pretty nice

I use a indexed list sometimes, or a dictionary depending on the use.

The kdtree gives you the entry,
Using the entry in the list you get.
List[entry] = [storedData]

I also use a kdtree for choosing tiles to load using a dictionary,
tile = dict[str(int(pos.x),int(pos.y))]

and I use kdtree/ indexed list to edit mesh in runtime.

how did you use than “kd_tree.find_range(position_vector, range_float)”?

is the output (co, index, dist) the same as normal or how did I have to modify this?

and how did I access the storedData is it like an dict?

example: [K, X for X in dict.items() if X == color_vector] to get all keys by an value in that case color (dict == kd_tree)?

ps: by knowing that this is not the normal use of an dict (yes, yes turn the key, value pair, the old story)

Co = vector position (in a grid you can use this a key for a dictionary) to recall a tuple.
str(int(Co. X), int(Co.y)) is the key that I use to snag the tuple in my dictionary grid.

Index = in a list you can use this as a index to recall a tuple.

I think one could use a 2d array to store data, may be faster than a dictionary.