Page 1 of 1

Do you integrate new Terrainsystem in future?

Posted: Sun Sep 21, 2014 8:14 am
by Bananenfreak
Heyho,

we already spoke in recent threads about the new terrain system. For those who missed it, here´s a Video:
http://www.youtube.com/watch?v=3DNLkKKKDX8

I have a question (to our lovely PB-team :-) ):
Do you have plans to integrate that new terrainsystem (Volumetric Terrain)?
Or do you Keep that old, normal terrainsystem?
I think keeping the old one an adding the new terrainsystem would be the best (Just my opinion).

The new terrainsystem got some nice Features, the biggest is terraindeformation in equal direction.
It´s possible to make Caves easy and realize a miningsystem like in minecraft, but just better :D

It´s just a question, I don´t want to moan about the terrainsystem. I think it´s time for this question...

Greets,

Bananenfreak

Re: Do you integrate new Terrainsystem in future?

Posted: Sun Sep 21, 2014 9:32 am
by Danilo
Bananenfreak wrote:I have a question:
Do you have plans to integrate that new terrainsystem (Volumetric Terrain)?
Are you talking to me?

Re: Do you integrate new Terrainsystem in future?

Posted: Sun Sep 21, 2014 2:02 pm
by Bananenfreak
It's an open letter to Fred, Comtois and rest of PB-Team...

Only for you, Danilo:
Are there any plans for integrating the volumetric terrain system in future?

P.S.: Still this problem with the word "you"... I have to pay more attention.

Re: Do you integrate new Terrainsystem in future?

Posted: Sun Sep 21, 2014 8:30 pm
by applePi
Bananenfreak, just now i have found that we can do holes or bumps in terrain by clicking the mouse on the terrain , look thread "Terrain collisions after modifying terrain" by Realizimo http://purebasic.fr/english/viewtopic.php?f=36&t=59899
using his procedure DoTerrainModify() with TerrainMousePick() with the example TerrainShadow.pb we can make holes or bumps, the secret is in the function SetTerrainTileHeightAtPoint()
click on terrain and it will make holes, press space key then click again then it will make bumps
as an example i have made the word purebasic as wall on the terrain
Image
this picture is from a satellite , go down and we will see a big walls making purebasic word.
tested with PB 5.31 b1
save the example to the PB\examples\3D

Code: Select all

;
; ------------------------------------------------------------
;
;   PureBasic - Terrain : Shadow
;
;    (c) Fantaisie Software
;
; ------------------------------------------------------------
Declare DoTerrainModify(tx, ty, wx.f, wy.f, wz.f, mBrushSizeTerrainSpace.f, height.f)

IncludeFile #PB_Compiler_Home + "examples/3d/Screen3DRequester.pb"

#CameraSpeed = 10
#TerrainMiniX = 0
#TerrainMiniY = 0
#TerrainMaxiX = 0
#TerrainMaxiY = 0
Define.f KeyX, KeyY, MouseX, MouseY
Global updown
Global flag = 1

Procedure Clamp(*var.float, min.f, max.f)
  If *var\f < min
    *var\f = min
  ElseIf *var\f > max
    *var\f = max
  EndIf
EndProcedure

; OpenGL needs to have CG enabled to work (Linux and OS X have OpenGL by default)
;
CompilerIf #PB_Compiler_OS <> #PB_OS_Windows Or Subsystem("OpenGL")
  Flags = #PB_Engine3D_EnableCG
CompilerEndIf

If InitEngine3D(Flags)
  
  InitSprite()
  InitKeyboard()
  InitMouse()
  
  If Screen3DRequester()
    Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Textures/"       , #PB_3DArchive_FileSystem)
    Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Textures/nvidia" , #PB_3DArchive_FileSystem)
    Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Scripts"         , #PB_3DArchive_FileSystem)
    Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/GUI"           , #PB_3DArchive_FileSystem)
    Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Packs/desert.zip", #PB_3DArchive_Zip)
    Parse3DScripts()
    
    WorldShadows(#PB_Shadow_Modulative, -1, RGB(105, 105, 105))
    
    ;- Light 
    ;
    light = CreateLight(#PB_Any ,RGB(255, 255, 255), 4000, 1200, 1000,#PB_Light_Directional)
    SetLightColor(light, #PB_Light_SpecularColor, RGB(255*0.4, 255*0.4,255*0.4)) 
    LightDirection(light ,0.55, -0.3, -0.75) 
    AmbientColor(RGB(255*0.2, 255*0.2,255*0.2))
        
    ;- Camera 
    ;
    CreateCamera(0, 0, 0, 100, 100)
    MoveCamera(0,  800, 400, 80, #PB_Absolute)
    CameraBackColor(0, RGB(5, 5, 10))
    
    
    ;----------------------------------
    ; terrain definition
    SetupTerrains(LightID(Light), 3000, #PB_Terrain_NormalMapping)
    ; initialize terrain 
    CreateTerrain(0, 513, 12000, 600, 4, "TerrainShadow", "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")
    
    ; construct terrains
    For ty = #TerrainMiniY To #TerrainMaxiY
      For tx = #TerrainMiniX To #TerrainMaxiX
        DefineTerrainTile(0, tx, ty, "terrain513.png", ty % 2, tx % 2)  
      Next
    Next  
    BuildTerrain(0)  
    
    ;InitBlendMaps
    minHeight1.f = 70
    fadeDist1.f = 40
    minHeight2.f = 70
    fadeDist2.f = 15    
    For ty = #TerrainMiniY To #TerrainMaxiY
      For tx = #TerrainMiniX To #TerrainMaxiX
        Size = TerrainTileLayerMapSize(0, tx, ty)
        For y = 0 To Size-1
          For x = 0 To Size-1
            Height.f = TerrainTileHeightAtPosition(0, tx, ty, 1, x, y)
            
            val.f = (Height - minHeight1) / fadeDist1
            Clamp(@val, 0, 1)
            SetTerrainTileLayerBlend(0, tx, ty, 1, x, y, val)
            
            val.f = (Height - minHeight2) / fadeDist2
            Clamp(@val, 0, 1)
            SetTerrainTileLayerBlend(0, tx, ty, 2, x, y, val)
          Next
        Next
        UpdateTerrainTileLayerBlend(0, tx, ty, 1)
        UpdateTerrainTileLayerBlend(0, tx, ty, 2)
      Next
    Next  
    
    ; enable shadow terrain
    TerrainRenderMode(0, 0)
        
    ; create sphere for test
    CreateSphere(1, 20.0, 50, 50)
    Global ball =CreateEntity(#PB_Any, MeshID(1), #Null)
    MoveEntity(ball, 300,60,0, #PB_Absolute)
    EntityRenderMode(ball, #PB_Entity_CastShadow)
    
    ; SkyBox
    ;
    SkyBox("desert07.jpg")
    
    ShowGUI(128, 1) ; Display the GUI, semi-transparent and display the mouse cursor
    
    Repeat
      Screen3DEvents()
      
      If ExamineKeyboard()       
        
        If KeyboardPushed(#PB_Key_Left)
          KeyX = -#CameraSpeed 
        ElseIf KeyboardPushed(#PB_Key_Right)
          KeyX = #CameraSpeed 
        Else
          KeyX = 0
        EndIf
        
        If KeyboardPushed(#PB_Key_Up)
          KeyY = -#CameraSpeed 
        ElseIf KeyboardPushed(#PB_Key_Down)
          KeyY = #CameraSpeed 
        Else
          KeyY = 0
        EndIf
        
        If KeyboardReleased(#PB_Key_Space)
          If flag = 0
            updown = 1
            flag=1
          Else
            updown = 10
            flag=0
          EndIf
        EndIf
        
          
      EndIf
      
      If ExamineMouse()
        MouseX = -MouseDeltaX() * #CameraSpeed * 0.05
        MouseY = -MouseDeltaY() * #CameraSpeed * 0.05
        
        InputEvent3D(MouseX(), MouseY(), MouseButton(#PB_MouseButton_Left))
        
        If MouseButton(#PB_MouseButton_Left)
          TerrainMousePick(0,  CameraID(0), MouseX(),  MouseY())
          ;MoveEntity(ball, PickX(), PickY()+20, PickZ(), #PB_Absolute)
          tx=PickX()
          ty=PickY()
          DoTerrainModify(0, 0, PickX(), PickY(), PickZ(), 0.004, 30) 
        EndIf
        
      EndIf
      ;CameraLocate(0, CameraX(0), PBO_GetTerrainHeight(0, CameraX(0), CameraZ(0)) + 20, CameraZ(0))
      MoveCamera  (0, KeyX, 0, KeyY)
      RotateCamera(0,  MouseY, MouseX, 0, #PB_Relative)  
      
      RenderWorld()
      FlipBuffers()
      
    Until KeyboardPushed(#PB_Key_Escape)   
    
    End 
    
  EndIf 
Else
  CompilerIf #PB_Compiler_OS <> #PB_OS_Windows Or Subsystem("OpenGL")
    ;
    ; Terrain on Linux/OSX and Windows with OpenGL needs CG toolkit from nvidia
    ; It can be freely downloaded and installed from this site: https://developer.nvidia.com/cg-toolkit-download
    ;
    MessageRequester("Error","Can't initialize engine3D (Please ensures than CG Toolkit from nvidia is correcly installed)")
  CompilerElse
    MessageRequester("Error","Can't initialize engine3D")
  CompilerEndIf
EndIf 

Procedure DoTerrainModify(tx, ty, wx.f, wy.f, wz.f, mBrushSizeTerrainSpace.f, newheight.f)
  terrainSize.f = TerrainTileSize(0, tx, ty) - 1
  Pointx.f = TerrainTilePointX(0, tx, ty, wx, wy, wz) 
  Pointy.f = TerrainTilePointY(0, tx, ty, wx, wy, wz)   
  startx = (Pointx - mBrushSizeTerrainSpace) * terrainSize
  starty = (Pointy - mBrushSizeTerrainSpace) * terrainSize
  endx   = (Pointx + mBrushSizeTerrainSpace) * terrainSize
  endy   = (Pointy + mBrushSizeTerrainSpace) * terrainSize  
  

  For y = starty To endy
    For x = startx To endx  
      SetTerrainTileHeightAtPoint(0, tx, ty, x, y, updown*newheight)      
    Next x
  Next y
  UpdateTerrain(0)
  TerrainPhysicBody(0, 2, 1)
EndProcedure

Re: Do you integrate new Terrainsystem in future?

Posted: Sun Sep 21, 2014 10:41 pm
by Andre
Cool :mrgreen:

Run's well on MacOS 10.5.8 after installing the CG toolkit from nvidia.

Re: Do you integrate new Terrainsystem in future?

Posted: Sun Sep 21, 2014 11:42 pm
by Danilo
applePi wrote:Bananenfreak, just now i have found that we can do holes or bumps in terrain by clicking the mouse on the terrain
In the video mentioned by Bananenfreak, you can see it is about caves and overhangs with volumetric terrains, not just bumps or holes.

Re: Do you integrate new Terrainsystem in future?

Posted: Mon Sep 22, 2014 7:25 am
by Bananenfreak
@applePi:
As already said by Danilo, this is normal Terrain... :?
I don´t know, do you mean something else?

I´ve already got an terraineditor here, shown in the feedbacksection:
http://www.purebasic.fr/english/viewtop ... 27&t=60454

But there are no Caves, cliffs, overhangs,... .
I want to make it possible to mine like in minecraft, but with a higher solution. Like in Starforge:
http://www.youtube.com/watch?v=zP242JIEOmg