Languages & Coding > PureBasic

Pure Basic How to use a height map for terrain

(1/3) > >>

Pfaber11:
Well I think the title pretty much says it . I have many height maps that I have previously used in AGK2 so don't need to know that . What I would like to know is how to use one to create a 3D world in Pure Basic . A simple terrain if you like . Can't seem to find much info on it . Thanks for reading .

RemiD:
have you seen this ?
https://www.purebasic.com/documentation/

https://www.purebasic.com/documentation/terrain/index.html

Naughty Alien:

--- Code: ---    ;- Terrain definition
    SetupTerrains(LightID(Light), 3000, #PB_Terrain_NormalMapping)
    ; initialize terrain
    CreateTerrain(0, 513, 12000, 600, 3, "TerrainGroup", "dat")
    ; set all texture will be use when terrrain will be constructed
    AddTerrainTexture(0,  0, 100, "dirt_grayrocky_diffusespecular.jpg",  "dirt_grayrocky_normalheight.jpg")
    AddTerrainTexture(0,  1,  30, "grass_green-01_diffusespecular.jpg", "grass_green-01_normalheight.jpg")
    AddTerrainTexture(0,  2, 200, "growth_weirdfungus-03_diffusespecular.jpg", "growth_weirdfungus-03_normalheight.jpg")
   
    ; Build terrains
    For ty = #TerrainMiniY To #TerrainMaxiY
      For tx = #TerrainMiniX To #TerrainMaxiX
        Imported = DefineTerrainTile(0, tx, ty, "terrain513.png", ty % 2, tx % 2) 
      Next
    Next 
    BuildTerrain(0) 
   
    InitBlendMaps()
    UpdateTerrain(0)

--- End code ---

Pfaber11:
Well I have not had any success yet . Here is my latest code I have been working on . The examples are not very clear to follow but anyway this is what I came up with . If anyone can see where I'm going wrong I would be most grateful , Thanks for reading .

--- Code: ---Debug LoadTexture(6,"mazeblank.png")
Debug LoadTexture(7,"brick.png")
Debug CreateMaterial(8,TextureID(6))
Debug AddMaterialLayer(8,TextureID(7),#PB_Material_Add)

Debug CreateTerrain(0, 513, 12000, 2, 2, "amaze12.png", "dat")
BuildTerrain(0)
RenderWorld()
FlipBuffers()
--- End code ---

Pfaber11:
Hi naughty alien had a look at that code and looks pretty complex . I think I am close with that code I put up And I'll be keeping at it until I start getting some results . Looked through the help files and examples but still it alludes me . Anyway have a nice evening and thanks for the response .

Navigation

[0] Message Index

[#] Next page

Go to full version