generate my terrain, using a system of points

Started by Santiago, May 02, 2023, 02:44:22

Previous topic - Next topic

Santiago

Hi, I have a question for you.

I am wanting to generate my terrain, using a system of points that generate the contour of the earth.

I know how to create the mesh, and the vertices of the contour, so that it generates a vertical "wall", which would be the mesh that joins the water with the land, but I don't know how to fill the land with triangles.

I saw that there is an ear method, but I wouldn't be understanding it.

Do you recommend any tutorial to be able to generate polygons that fill a contour?

my idea is
create vertices from coordinate points
generate the internal polygon that would be the earth
and generate a 1 meter wall, which represents the height of my stage.

in blue i have my line of coast

Midimaster

#1
Using the Terrain() feature is no option for you?

With Terrain you can paint a B/W-image in any Paint app. The lighter a pixel is, the higher is the terain.

In your case you would paint the contour first with GRAY, then fill the inner area with WHITE. save the image. When you load this as a terrain in Blitz3D you would see a flat island suroundet the the sea.

Without terrain heights and without texture:
ScreenshotTerra2.png

With terrain heights and texture:

ScreenshotTerra.png

Graphics3D 800,600

light=CreateLight(2)
MoveEntity light, 0,100,-100
TurnEntity light,45,0,0

Global Terrain=LoadTerrain("terrain2.png")
ScaleEntity terrain, 1,20,1
TerrainDetail terrain,16000,True
MoveEntity Terrain,0,-16.9,0

Global Texture=LoadTexture("mountain.jpg")
ScaleTexture Texture,100,100
EntityTexture Terrain, Texture

Global Sea=CreatePlane()
EntityColor Sea, 0,0,255

Camera=CreatePivot()
Lens=CreateCamera(Camera)
MoveEntity camera, 100,35,200
TurnEntity lens,15,0,0

;WireFrame True
Repeat
    DebugLog EntityX(camera)
    If KeyDown(200) Then MoveEntity Camera,0,+1,0
    If KeyDown(208) Then MoveEntity Camera,0,-1,0
    If KeyDown(203) Then TurnEntity Camera,0,+1,0
    If KeyDown(205) Then TurnEntity Camera,0,-1,0
    UpdateWorld()
    RenderWorld()

    Flip 1
Until KeyHit(1)

You need this images from the attachment to run the example:
...back from Egypt

markcwm

Hi Santiago,

I certainly don't know how to do it but there are several 3d modellers that do this sort of thing and there probably is open source code available. I would guess it involves subdivision and some kind of analysis of edge angles, but a technique like that would be slower in realtime than Terrains due to the huge number of calculations required for it.

Santiago

Hi, thanks for the answers!

The method of using an image is good, but I have to do it using a dotted line. and not being limited to the resolution of images, I prefer to avoid using textures, since being "vector" I don't have resolution problems both in small details and in immense ones, in case I want to make a line of 2000 meters and then a small curve of 50cm.

I managed to make the line in my editor.
In the video game I managed to make the wall 1 meter high by creating triangles, but at the moment the only way to fill the upper face with triangles, that is, the terrain, is by joining all the triangles to a central point, but that is not a good solution .

I'm looking for examples in code-archives, to see if there is something.
and at the same time I'm trying to understand the methods that there are to fill with triangles, it shouldn't be that difficult, but I still can't find the logic to the solution.


i have my hope in this method, working to solve how to do it

QuoteThe method for filling a polygon with triangles is called Delaunay triangulation.

Delaunay triangulation is a method of dividing a polygonal surface into non-overlapping triangles in an optimal way, that is, that minimizes the smallest angle between the sides of the triangle. This method is commonly used in computer graphics and image processing to generate triangular meshes for smoothing, rendering, and geometric analysis.

To apply Delaunay triangulation to a polygon, the vertices of the polygon are taken as points in a plane and Delaunay triangulation is performed at these points to obtain a mesh of triangles that covers the polygon. Triangles outside the polygon outline can then be removed to get the final non-overlapping triangle-filled polygon mesh.


Santiago

i think this is the best solution, i going to do it in Blitz3D.


3DzForMe

This is good stuff Santiago, can't beat a little 3D terrain generation code  ;D - and in the tool of choice, Good ole' Blitz3D  8)
BLitz3D, IDEal, AGK Studio, BMax, Java Code, Cerberus
Recent Hardware: Dell Laptop
Oldest Hardware: Commodore Amiga 1200 with 1084S Monitor & Blitz Basic 2.1