JustPaste.it
User avatar
@anonymous · Aug 19, 2023
#include "./Bin/au3Irrlicht2.au3"
#include "WinAPI.au3"
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <GuiStatusBar.au3>
#include <Misc.au3>
#include <GuiToolbar.au3>
#include <GuiComboBoxEx.au3>
#include <GuiImageList.au3>
#include <GuiConstantsEx.au3>
#include <StaticConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <Tabconstants.au3>
#include <GuiTab.au3>
#include <UpdownConstants.au3>
#include <SliderConstants.au3>
#include <String.au3>
#include <Array.au3>
#include "./Bin/AIK.au3"
Opt("MouseCoordMode", 2)

 

;GUI Controls
Global $FPS, $FPSLabel, $CamPosLabel, $CamPos[3], $X, $Y, $Z
Global $Gui, $RenderWindow, $StatBar, $StatParts[3] = [375, 450, -1]
Global $Tab_1, $TexCombo[8], $SeedInput, $ComboHeightmapSize = "1024x1024", $ComboTerrainTexSize = "1024x1024"
Global $UpdateTerrainTextureButton, $RenderButton, $VegDensityGUI[9], $UpdateDensity
;Global Enum $idNew = 1000, $idOpen, $idSave, $idHelp
Global $TexImageList, $AddWaterCheckBox, $WaterGroup, $WaterLevelInput, $WaterLevelUpDown, $VegetationGroup
;Movement
Global $wasd, $keyCode, $KeyEvent, $MouseEvent ; $IRR_KEY_EVENT PTR
Global $XStrafe, $ZStrafe, $YStrafe, $Spin, $Tilt, $MX, $MY ; integer
Global $Pos[3], $vX[3], $vY[3], $vZ[3], $Rot[3]; $IRR_VECTOR
;
Global $Seed = 2622, $RandomSeed, $Terrain, $TerrainNode, $TerrainTexture, $TerrainTexture2, $TerrainDetail,  $TerrainDetail2, $Tiles, $Cam, $CamNode

 

Global $RavenPos[3], $Wpos[3]
;Sound
Global $EagleSound, $EagleSound2, $EagleNode, $EaglePos
Global $Item, $CurSel, $WaterLevel = 0
;Vegetation
Global $AddVegetation

 

Global $VegName [9] = ["tit2spruce", "dbl2birch"  , "dbltree" , "titspruce", "treeit"  , "dbltreeit" , "treeitspruce"      , "treeittree", "dblbirch"], _
   $VegColor[9] = ["red"   , "green", "blue", "yellow", "purple", "orange", "lightgreen", "cyan" , "skyblue"], _
   $VegSize [9] = [5, 2, 2, 6, 6, 2, 8, 6, 3], _
   $VegManager[UBound($VegName)], $VegNode[UBound($VegName)][5000], $VegTex   [UBound($VegName)], _
   $VegDensity[UBound($VegName)], $VegMesh[UBound($VegName)][5]   , $VegCoords[UBound($VegName)]

 

 

Global $XY, $ShaderMaterial

 

;ImageMagick Object
$img = ObjCreate("ImageMagickObject.MagickImage.1")

 

HotKeySet("{ESC}", "_exit")

 

;------------------------------------------------------------------------------------------------------------------
_Gui()
;_UpdateHeightMap()
_Water()
_RenderTerrain()
_Camera()
;_IrrKlang()
_Vegetation()
_Clouds()
_Sky()
;_Wildlife()
;_SkyBox()
;_Roads()
;_LakeShores()

 

WHILE _IrrRunning()

 

    _IrrBeginScene( 0, 0, 0 )

 

Switch GUIGetMsg()

 

Case $RandomSeed
$Seed = Random(0, Random(0, Random(0, Random(0, Random(0, Random(0, Random(0, Random(0, 99999999), 1), 1), 1), 1), 1), 1), 1)
GUICtrlSetData($SeedInput, $Seed)

 

Case $RenderButton
_IrrRemoveAllNodes()
_UpdateHeightMap()
_RenderTerrain()
_UpdateTerrainTexture()
_Vegetation()
_Camera()
_Water()
_Clouds()
_Sky()
_Wildlife()

 

Case $ComboHeightMapSize
_GUICtrlStatusBar_SetText ($statbar, GUICtrlRead($ComboHeightMapSize))

 

Case $UpdateTerrainTextureButton
_UpdateTerrainTexture()

 

Case $AddWaterCheckBox
If GUICtrlRead($AddWaterCheckBox) = $Gui_Unchecked Then
GUICtrlSetState($WaterGroup, $Gui_Disable)
_IrrRemoveNode($WaterNode)
Else
GUICtrlSetState($WaterGroup, $Gui_Enable)
GUICtrlSetState($AddWaterCheckBox, $Gui_Enable)
_Water()
EndIf

 

Case $AddVegetation
If GUICtrlRead($AddVegetation) = $Gui_Unchecked Then
GUICtrlSetState($VegetationGroup, $Gui_Disable)
_IrrRemoveNode($grassNode)
Else
GUICtrlSetState($VegetationGroup, $Gui_Enable)
GUICtrlSetState($AddVegetation, $Gui_Enable)
_Vegetation()
EndIf

 

Case $UpdateDensity
_Vegetation()

 

Case $WaterLevelUpDown
_IrrSetNodePosition($WaterNode, 5120, GUICtrlRead($WaterLevelInput), 5120)

 

;#cs
Case $Tab_1
Local $xpos = 1030, $ypos = 0
Switch GUICtrlRead($Tab_1)
Case 0
For $loop = 0 To 4
$TexCombo[$loop] = _GUICtrlComboBoxEx_Create ($Gui, "", $xpos + 10, 205 + $loop * 70, 86, 250)
_GUICtrlComboBoxEx_SetImageList ($TexCombo[$loop], $TexImageList)
For $x = 0 To 16
_GUICtrlComboBoxEx_AddString ($TexCombo[$loop], "./Media/TerrainTextures/Tex" & StringRight("00" & $x+1, 3) & ".png", $x, $x)
Next
Next

 

_GUICtrlComboBoxEx_SetCurSel ($TexCombo[0], 12)
_GUICtrlComboBoxEx_SetCurSel ($TexCombo[1], 12)
_GUICtrlComboBoxEx_SetCurSel ($TexCombo[2], 7)
_GUICtrlComboBoxEx_SetCurSel ($TexCombo[3], 2)
_GUICtrlComboBoxEx_SetCurSel ($TexCombo[4], 2)

 

Case Else
For $loop = 0 To 4
_GUICtrlComboBoxEx_Destroy($TexCombo[$loop])
Next

 

EndSwitch
;#ce
EndSwitch

 

GUICtrlSetData($FPSLabel, _IrrGetFPS())
_IrrGetNodePosition($Cam, $CamPos)
GUICtrlSetData($CamPosLabel, Int($CamPos[0]) & "," & Int($CamPos[1]) & "," & Int($CamPos[2]))

 

If _IsPressed("02") AND WinActive($Renderwindow) Then
_Movement()
EndIf

 

;If _IsPressed("04") AND WinActive($Renderwindow) Then
 ;       While _IsPressed("04")

 

;        WEnd
;EndIf
_IrrGetNodePosition($Cam, $Pos)
    $Pos[1] = _IrrGetTerrainTileHeight($Terrain, $Pos[0], $Pos[2])
If $Pos[1] < GUICtrlRead($WaterLevelInput) Then $Pos[1] = GUICtrlRead($WaterLevelInput) - 5
    _IrrSetNodePosition($Cam, $Pos[0], $Pos[1]+20, $Pos[2])
    _IrrDrawScene()
    _IrrEndScene()
;Sleep(5)
WEND
_IrrStop()
;Movement----------------------------------------------------------------------------------------------------------
Func _Movement()
;$RunSpeed = 2
If _IsPressed("10") Then
$RunSpeed = 5
Else
$RunSpeed = 2
EndIf

 

$MX = 0.5
$MY = 0.5
        _IrrSetMousePosition( $MX, $MY )
        _IrrGetNodePosition( $CamNode, $Pos)

 

        while _IrrKeyEventAvailable()

 

            $KeyEvent = _IrrReadKeyEvent()
$keyCode = __getKeyEvt($KeyEvent, $EVT_KEY_IKEY)
            select
            case $keyCode = $KEY_KEY_D     ; Left Arrow
                if __getKeyEvt($KeyEvent, $EVT_KEY_IDIRECTION) = $IRR_KEY_DOWN then
                    $XStrafe = $RunSpeed;5
                else
                    if $XStrafe = $RunSpeed then;5
                        $XStrafe = 0
                    endif
                endif

 

            case $keyCode = $KEY_KEY_W     ; Up Arrow
                if __getKeyEvt($KeyEvent, $EVT_KEY_IDIRECTION) = $IRR_KEY_DOWN then
                    $ZStrafe = $RunSpeed;5
else
                    if $ZStrafe = $RunSpeed then;5
                        $ZStrafe = 0

 

                    endif
                endif

 

            case $keyCode = $KEY_KEY_A     ; Right Arrow
                if __getKeyEvt($KeyEvent, $EVT_KEY_IDIRECTION) = $IRR_KEY_DOWN then
                    $XStrafe = -$RunSpeed;5
                else
                    if $XStrafe = -$RunSpeed then;-5
                        $XStrafe = 0
                    endif
                endif

 

            case $keyCode = $KEY_KEY_S     ; Down Arrow
                if __getKeyEvt($KeyEvent, $EVT_KEY_IDIRECTION) = $IRR_KEY_DOWN then
                    $ZStrafe = -$RunSpeed;5
else
                    if $ZStrafe = -$RunSpeed then;5
                        $ZStrafe = 0

 

                    endif
endif
            endselect
        wend

 

_IrrGetCameraOrientation( $Cam, $vX,$vY,$vZ)
        $Pos[0] += $vY[0] * $ZStrafe + $vY[2] * $XStrafe
$Pos[1] -= $vY[1] * ($YStrafe - 5) - $vY[1] * ($YStrafe + 5) ;+ $YStrafe;$vY[1] * $YStrafe + $vY[1] * $YStrafe
        $Pos[2] -= $vY[0] * $XStrafe - $vY[2] * $ZStrafe
        _IrrSetNodePosition($CamNode, $Pos[0], $Pos[1], $Pos[2])
        $Spin += ( $MX - 0.5 ) * 2.0
        $Tilt += ( $MY - 0.5 ) * 2.0
        if $Tilt > 1.5 then $Tilt = 1.5
        if $Tilt < -1.5 then $Tilt = -1.5
        _IrrSetCameraTarget( _
            $Cam, $Pos[0] + sin ( $Spin ) * 10000, _
            -$Tilt * 15000, _
            $Pos[2] + cos ( $Spin ) * 10000 )

 

EndFunc

 

;Gui---------------------------------------------------------------------------------------------------------------
Func _Gui()
$Gui = GUICreate("AutoScape Lite", 2180, 1096, -1, -1)

 

;File menu
   $filemenu = GUICtrlCreateMenu("File")
$new = GUICtrlCreateMenuItem("New", $filemenu)
$openg2c = GUICtrlCreateMenuItem("Open", $filemenu)
   $save = GUICtrlCreateMenuItem("Save", $filemenu)
$saveas = GUICtrlCreateMenuItem("Save As...", $filemenu)
$preferences = GUICtrlCreateMenuItem("Preferences", $filemenu)
  $seperator = GUICtrlCreateMenuItem("", $filemenu)
   $exit = GUICtrlCreateMenuItem("Exit", $filemenu)

 

;View menu
$viewmenu = GUICtrlCreateMenu("View")
  $toolbarItem = GUICtrlCreateMenuItem("Tool Bar", $viewmenu)
$statusbarItem = GUICtrlCreateMenuItem("Status Bar", $viewmenu)

 

;Tools menu
   $Toolsmenu = GUICtrlCreateMenu("Tools")
$benchmapItem = GUICtrlCreateMenuItem("Benchmap", $Toolsmenu)

 

;Options menu
$optionsmenu = GUICtrlCreateMenu("Options")
$settingsItem = GUICtrlCreateMenuItem("Settings", $optionsmenu)

 

;Help menu
  $wtf = GUICtrlCreateMenu("Wtf?")
$helpItem = GUICtrlCreateMenuItem("Help", $wtf)
$aboutItem = GUICtrlCreateMenuItem("About", $wtf)

 

;StatusBar
$statbar = _GUICtrlStatusBar_Create ($gui)
   _GUICtrlStatusBar_SetParts ($statbar, $statparts)
   _GUICtrlStatusBar_SetText ($statbar, "Ready")

 

;Tabs
Local $xpos = 1930, $ypos = 0
$tab_1 = GUICtrlCreateTab($xpos, $ypos, 250, 750, $TCS_FIXEDWIDTH + $TCS_FORCEICONLEFT ); 185, 580)

 

$hImage = _GUIImageList_Create()
_GUIImageList_AddBitMap($hImage, "./Media/Icons/terrainicon2.bmp")
_GUIImageList_AddBitMap($hImage, "./Media/Icons/terrainicon2.bmp")
_GUIImageList_AddBitMap($hImage, "./Media/Icons/terrainicon2.bmp")
_GUIImageList_AddBitMap($hImage, "./Media/Icons/terrainicon2.bmp")
_GUICtrlTab_SetImageList($tab_1, $hImage)

 

_GUICtrlTab_SetItemSize($tab_1, 30, 22)

 

_GUICtrlTab_SetPadding($tab_1, 6, 2)
; Add tabs

 

$tab_10 = GUICtrlCreateTabItem(" ")
;Scene Size

 

  GUICtrlCreateGroup ("Scene", $xpos + 5, $ypos + 30, 185, 130, -1)
  GUICtrlCreateLabel (" Seed", $xpos + 10, $ypos + 50, 100, 21, $SS_SUNKEN)
  GUICtrlSetBkColor  (-1,0xffffff)
$SeedInput = GUICtrlCreateInput ("4322", $xpos + 105, 50, 61, 21, $ES_NUMBER)
$RandomSeed = GUICtrlCreateButton("R", $xpos + 165, 50, 18, 18, $BS_FLAT)
;GUICtrlSetTip(-1, " ", "Random Seed", 1, 1)

 

    GUICtrlCreateLabel(" Terrain Size", $xpos + 10, 68, 100, 21, $SS_SUNKEN)
    GUICtrlSetBkColor(-1,0xffffff)
$ComboTerrainSize = GUICtrlCreateCombo("", $xpos + 105, 68, 80, 20, $CBS_DROPDOWNLIST)
    GUICtrlSetData(-1, "512 m²|1 km²|5 km²|10 km²|25 km²|50 km²|100 km²", "1 km²")

 

  GUICtrlCreateLabel(" HeightMap", $xpos + 10, 88, 100, 21, $SS_SUNKEN)
  GUICtrlSetBkColor(-1,0xffffff)
$ComboHeightmapSize = GUICtrlCreateCombo("", $xpos + 105, 88, 80, 20, $CBS_DROPDOWNLIST)
  GUICtrlSetData(-1, "256x256|512x512|1024x1024|2048x2048", "1024x1024")
  $RenderButton = GUICtrlCreateButton("Generate", $xpos + 65, 135, 80, 20)
  GUICtrlCreateGroup("", -99, -99, 1, 1)  ;close group
;Terrain Texture
  GUICtrlCreateGroup("Texture", $xpos + 5, $ypos + 160, 95, 425, -1)
;ComboBoxEx Imagelist
$ComboTerrainTexSize = GUICtrlCreateCombo("", $xpos + 10, 180, 85, 20, $CBS_DROPDOWNLIST)
   GUICtrlSetData(-1, "512x512|1024x1024|2048x2048|4096x4096|8192x8192", "1024x1024")

 

$TexImageList = _GUIImageList_Create (64, 64, 5, 3)
For $loop = 1 To 17
_GUIImageList_AddBitMap ($TexImageList, "./Media/TerrainTextures/Thumbs/" & StringRight("00" & $loop, 3) & ".bmp")
Next

 

For $loop = 0 To 4
$TexCombo[$loop] = _GUICtrlComboBoxEx_Create ($Gui, "", $xpos + 10, 205 + $loop * 70, 86, 250)
_GUICtrlComboBoxEx_SetImageList ($TexCombo[$loop], $TexImageList)
For $x = 0 To 16
_GUICtrlComboBoxEx_AddString ($TexCombo[$loop], "./Media/TerrainTextures/Tex" & StringRight("00" & $x+1, 3) & ".png", $x, $x)
Next
Next

 

_GUICtrlComboBoxEx_SetCurSel ($TexCombo[0], 12)
_GUICtrlComboBoxEx_SetCurSel ($TexCombo[1], 12)
_GUICtrlComboBoxEx_SetCurSel ($TexCombo[2], 7)
_GUICtrlComboBoxEx_SetCurSel ($TexCombo[3], 2)
_GUICtrlComboBoxEx_SetCurSel ($TexCombo[4], 2)
$UpdateTerrainTextureButton = GUICtrlCreateButton("Update", $xpos + 10, 560, 85, 20)
GUICtrlCreateGroup("", -99, -99, 1, 1)  ;close group

 

;Water
  $WaterGroup = GUICtrlCreateGroup("    Water", $xpos + 105, $ypos + 160, 140, 145, -1)
$AddWaterCheckBox = GUICtrlCreateCheckbox("", $xpos + 110, $ypos +162, 14, 14)
GUICtrlSetState($AddWaterCheckBox, $gui_checked)
GUICtrlCreateLabel(" Level", $xpos + 110, $ypos + 180, 75, 20, $SS_SUNKEN)
GUICtrlSetBkColor(-1,0xffffff)
 $WaterLevelInput = GUICtrlCreateInput("0", $xpos + 185, $ypos + 180, 55, 20, $ES_NUMBER)
$WaterLevelUpDown = GUICtrlCreateUpdown($WaterLevelInput, $UDS_NOTHOUSANDS)

 

GUICtrlCreateLabel(" Shininess", $xpos + 110, $ypos + 200, 75, 20, $SS_SUNKEN)
GUICtrlSetBkColor(-1,0xffffff)
 $WaterLevelInput = GUICtrlCreateInput("0", $xpos + 185, $ypos + 200, 55, 20, $ES_NUMBER)
$WaterLevelUpDown = GUICtrlCreateUpdown($WaterLevelInput, $UDS_NOTHOUSANDS)

 

GUICtrlCreateLabel(" Speed", $xpos + 110, $ypos + 220, 75, 20, $SS_SUNKEN)
GUICtrlSetBkColor(-1,0xffffff)
 $WaterLevelInput = GUICtrlCreateInput("0", $xpos + 185, $ypos + 220, 55, 20, $ES_NUMBER)
$WaterLevelUpDown = GUICtrlCreateUpdown($WaterLevelInput, $UDS_NOTHOUSANDS)

 

GUICtrlCreateLabel(" Resolution", $xpos + 110, $ypos + 240, 75, 20, $SS_SUNKEN)
GUICtrlSetBkColor(-1,0xffffff)
 $WaterLevelInput = GUICtrlCreateInput("0", $xpos + 185, $ypos + 240, 55, 20, $ES_NUMBER)
$WaterLevelUpDown = GUICtrlCreateUpdown($WaterLevelInput, $UDS_NOTHOUSANDS)
GUICtrlSetData($WaterLevelInput, -120)
GUICtrlCreateGroup("", -99, -99, 1, 1)  ;close group

 

;Vegetation
$VegetationGroup = GUICtrlCreateGroup("    Vegetation", $xpos + 105, $ypos + 305, 140, 335, -1)
  $AddVegetation = GUICtrlCreateCheckbox("", $xpos + 110, $ypos +307, 14, 14)
   GUICtrlSetState($AddVegetation, $gui_checked)

 

  GUICtrlCreateGroup("Density", $xpos + 110, $ypos + 325, 130, 240, -1)

 

For $Loop = 0 To UBound($VegName) - 1
  GUICtrlCreateLabel($VegName[$Loop], $xpos + 115, $ypos + 345 + $Loop*20, 50, 21)
$VegDensityGUI[$Loop] = GUICtrlCreateSlider($xpos + 150, $ypos + 340 + $Loop*20, 85, 20, $TBS_TOP)
  GUICtrlSetLimit(-1, 10, 0)
  GUICtrlSetData(-1, 1)
;$VegDensity[$Loop] = GUICtrlRead($VegDensityGUI[$Loop])
$UpdateDensity = GUICtrlCreateButton("Update", $xpos + 135, 538, 80, 20)
Next

 

   $FPSLabel = GUICtrlCreateLabel("FPS: ", $xpos + 20, 600)
$CamPosLabel = GUICtrlCreateLabel("Cam: ",$xpos + 20, 640, 200)
;Texture Tab
$tab_11 = GUICtrlCreateTabItem(" ")

 

;Tab
$tab_12 = GUICtrlCreateTabItem(" ")
$UpdateTerrainTextureButton1 = GUICtrlCreateButton("Update", $xpos + 65, 548, 80, 20)
;GUICtrlCreateTabItem("")
;Tab
$tab_13 = GUICtrlCreateTabItem(" ")
$UpdateTerrainTextureButton2 = GUICtrlCreateButton("Update", $xpos + 65, 548, 80, 20)
;GUICtrlCreateTabItem("")

 

;Tab Images
_GUICtrlTab_SetItemImage($tab_1, 0, 0)
_GUICtrlTab_SetItemImage($tab_1, 1, 1)
_GUICtrlTab_SetItemImage($tab_1, 2, 2)
_GUICtrlTab_SetItemImage($tab_1, 3, 3)
GUICtrlCreateTabItem("")

 

;Embed Irrlicht RenderWindow---------------------------------------------------------------------------------------
_IrrStart($IRR_EDT_direct3d9, 1920, 1080, $IRR_BITS_PER_PIXEL_32, $IRR_windowed, $IRR_SHADOWS, $IRR_CAPTURE_EVENTS, $IRR_VERTICAL_SYNC_Off)
_IrrSetWindowCaption( "AutoScape Preview")
_WinAPI_SetWindowRgn(WinGetHandle("AutoScape Preview", ""), _WinAPI_CreateRectRgn(3, 22, 1920, 1080))
WinMove("AutoScape Preview", "", -3, -22)
_WinAPI_Setparent(WinGetHandle("AutoScape Preview", ""), $Gui)
WinActivate("AutoScape Lite")
;_IrrTransparentZWrite()
_IrrSetAmbientLight(0.9,0.9,0.9)

 

;_IrrXEffectsStart( $IRR_OFF, $IRR_OFF, $IRR_ON )
;_IrrXEffectsEnableDepthPass( $IRR_ON )
;$WaterBump = _IrrGetTexture("./Media/Water/Water_0001.png")
;_IrrMakeNormalMapTexture( $WaterBump, 6.0 )
;_IrrXEffectsAddPostProcessingFromFile("./media/shaders/BloomP.glsl")
;_IrrXEffectsAddPostProcessingFromFile("./media/shaders/color_shader.glsl")
;_IrrXEffectsAddPostProcessingFromFile("./media/shaders/brightpass.glsl")
;_IrrXEffectsAddPostProcessingFromFile("./media/shaders/screenwater.glsl")

 

;_IrrXEffectsSetPostProcessingUserTexture($WaterTexture)
;_IrrXEffectsSetPostProcessingUserTexture($WaterBump)
;_IrrXEffectsSetClearColor( 255,64,64,128 )
GUISetState()
EndFunc

 

;Camera-------------------------------------------------------------------------------------------------------------
Func _Camera()
$Cam = _IrrAddCamera(100,0,0, 0,-10,0)
_IrrSetNodePosition($Cam, 5550, 500, 3000)
_IrrSetCameraClipDistance($Cam, 50000)
$CamNode = $Cam
EndFunc

 

;SkyBox------------------------------------------------------------------------------------------------
Func _SkyBox()
$SkyBox = _IrrAddSkyBoxToScene(_IrrGetTexture("./Media/SkyBox/up.jpg"), _IrrGetTexture("./Media/SkyBox/down.jpg"), _IrrGetTexture("./Media/SkyBox/right.jpg"), _IrrGetTexture("./Media/SkyBox/left.jpg"), _IrrGetTexture("./Media/SkyBox/front.jpg"), _IrrGetTexture("./Media/SkyBox/back.jpg"))
EndFunc

 

;Update HeightMap------------------------------------------------------------------------------------------------
Func _UpdateHeightMap()

 

$img.Convert("-size",GUICtrlRead($ComboHeightMapSize), _
"-seed",GUICtrlRead($SeedInput), _
"plasma:grey50-grey50", _
"-colorspace","Gray", _
"-channel","B", _
"-separate","+channel", _
"-normalize", _ ;"-fill","white","-tint","90",
"./Media/Textures/heightmaplevel.png")

 

$img.Convert("./Media/Textures/heightmaplevel.png", _
"-negate", _
"./Media/Textures/blurmap.png")
$img.Convert("./Media/Textures/heightmap.png","-fill","white","-tint","80","./Media/Textures/heightmaplevel.png")

 

$img.Convert("./Media/Textures/heightmaplevel.png", _
"./Media/Textures/blurmap.png", _
"-compose","blur", _
"-define","compose:args=10", _ ;"-set","option:compose:args","10", _
"-composite", _
"./Media/Textures/heightmap.png")

 

$Img.Convert("./Media/Textures/heightmap.png", _
"./Media/Textures/256gradas.png", _
"-clut", _
"./Media/Textures/heightmap.png")

 

EndFunc
;-----------------------------------------------------------------------------------------------------------------------
Func _UpdateTerrainTexture()
$Tiles = '"'
For $loop = 4 To 0 Step - 1
_GUICtrlComboBoxEx_GetItemText ($TexCombo[$loop], _GUICtrlComboBoxEx_GetCurSel ($TexCombo[$loop]), $item)
$Tiles &= $Item & '","'
Next
$Tiles = StringTrimRight($Tiles, 2)
$imgConvert = '$img.Convert("./Media/Textures/heightmap.png","-resize","' & GUICtrlRead($ComboTerrainTexSize) & '",' & $Tiles & ',"-virtual-pixel","tile","-fx","u[floor(4.999*u)+1]","./Media/Textures/terraintexture.png")'
Execute($imgConvert)

 

  _IrrRemoveTexture($TerrainTexture)
$TerrainTexture = _IrrGetTexture( "./Media/Textures/terraintexture.png" )
  _IrrSetNodeMaterialTexture( $Terrain, $TerrainTexture, 0 )

 

EndFunc
;-----------------------------------------------------------------------------------------------------------------------
Func _RenderTerrain()
; $Heightmap = _IrrGetImage("./Media/Textures/heightmap.png")
   $Terrain = _IrrAddTerrain( "./Media/Textures/heightmap02.png", 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 255, 255, 255, 5)
   ;$Terrain = _IrrAddTerrainTile($Heightmap, 1024, 0, 0)
   $TerrainNode = $Terrain
$TerrainTexture = _IrrGetTexture ("./Media/Textures/heightroads5.png")
  $TerrainImage = _IrrGetImage ("./Media/Textures/terraintexture.png")
  _IrrSetNodeMaterialTexture($TerrainNode, $TerrainTexture, 0)
$TerrainDetail = _IrrGetTexture ( "./Media/TerrainTextures/Tex005.png" )
  _IrrSetNodeMaterialTexture($TerrainNode, $TerrainDetail, 1)
  _IrrScaleTexture ($TerrainNode, 1.0, 500.0)
  ;_IrrSetNodeMaterialType($TerrainNode, $IRR_EMT_TRANSPARENT_ALPHA_CHANNEL_REF)
  _IrrSetNodeMaterialType   ($TerrainNode, $IRR_EMT_DETAIL_MAP)
  _IrrSetNodeMaterialFlag   ($TerrainNode, $IRR_EMF_LIGHTING, $IRR_ON)
  ;_IrrSetNodeMaterialFlag   ($TerrainNode, $IRR_EMF_BACK_FACE_CULLING, $IRR_ON)
  _IrrSetNodeMaterialFlag   ($TerrainNode, $IRR_EMF_FOG_ENABLE, $IRR_ON)
  _IrrSetNodeScale ($TerrainNode, 10.0, 10.0, 10.0)
  _IrrSetNodePosition ($TerrainNode, 0, -850, 0)
  _IrrSetFog (128,128,128, $IRR_EXPONENTIAL_FOG, 0.0, 5000.0, 1.5)

 

  ;_IrrXEffectsAddNodeToDepthPass($TerrainNode)
  ;Global $TerrainSelector = _IrrGetCollisionGroupFromTerrain( $Terrain, 3 )

 

EndFunc

 

;------------------------------------------------------------------------------------------------
Func _Water()
;$img.Convert("./Media/Textures/heightmap.png","-alpha","set","-channel","A","-evaluate","set","75%","+channel","gradient5.png","-interpolate","Spline","-clut","./Media/Textures/water3.png")
   $WaterMesh = _IrrAddHillPlaneMesh("HillPlane", 8.0, 8.0, 32, 32)
   ;$WaterMesh2 = _IrrGetMesh("./Media/Models/Roads/Road6.obj")
Global $WaterNode = _IrrAddWaterSurfaceSceneNode($WaterMesh, 2, 500, 5)
$WaterTex = _IrrGetTexture("./Media/Textures/water3.png")
_IrrSetNodeMaterialTexture($WaterNode, $WaterTex, 0)
_IrrSetNodeMaterialType($WaterNode,$IRR_EMT_TRANSPARENT_ALPHA_CHANNEL)
_IrrSetNodeMaterialFlag($WaterNode, $IRR_EMF_LIGHTING, $IRR_On)
_IrrSetNodeMaterialFlag($WaterNode, $IRR_EMF_BACK_FACE_CULLING, $IRR_OFF)
_IrrSetNodeMaterialFlag( $WaterNode, $IRR_EMF_FOG_ENABLE, $IRR_ON )
_IrrSetNodePosition($WaterNode, 5100, 0, 5100)
_IrrSetNodeScale($WaterNode, 40.0, 1.0, 40.0)
_IrrSetNodeRotation($WaterNode, 0, 180, 0)
$Material = _IrrGetMaterial($WaterNode, 0)
; _IrrMaterialVertexColorAffects( $Material, $ECM_NONE )
_IrrMaterialSetShininess ($Material, 5.0)

 

;_IrrXEffectsAddNodeToDepthPass($WaterNode)

 

EndFunc

 

;------------------------------------------------------------------------------------------------
Func _Clouds()

 

$CloudNode = _IrrAddClouds(_IrrGetTexture("./Media/Textures/cloud4.png"), 3, 1, 100)
_IrrSetNodeMaterialFlag($CloudNode, $IRR_EMF_FOG_ENABLE, $IRR_ON)
_IrrSetNodePosition($CloudNode, 0, 2000, 0)
_IrrSetNodeScale($CloudNode, 1, .02, 1 )
_IrrAddRotationAnimator($CloudNode, 0, .005, 0)

 

EndFunc
;------------------------------------------------------------------------------------------------
Func _Sun()

 

$Light = _IrrAddLight($IRR_NO_OBJECT, -10000,5000,5000, 0.99, 0.99, 0.99, 50000.0)
  ;_IrrSetNodePosition($Light, -80, 0, 0)
   $Sun = _IrrAddBillBoardToScene( 1000.0,1000.0, -10000,5000,5000 )
$SunTex = _IrrGetTexture("./Media/Textures/sun.png")
  _IrrSetNodeMaterialTexture($Sun, $SunTex, 0)
  _IrrSetNodeMaterialType($Sun,$IRR_EMT_TRANSPARENT_ALPHA_CHANNEL)
  _IrrSetNodeMaterialFlag( $Sun, $IRR_EMF_LIGHTING, $IRR_OFF )

 

EndFunc
;------------------------------------------------------------------------------------------------
Func _Sky()

 

    $Sky = _IrrGetMesh ("./Media/daynight7.3ds")
$Skytex = _IrrGetTexture ("./Media/Textures/daynight.png")
$SkyNode = _IrrAddMeshToScene ($Sky)
   _IrrSetNodeMaterialTexture($SkyNode, $Skytex, 0)
   _IrrSetNodeMaterialFlag ($SkyNode, $IRR_EMF_LIGHTING, $IRR_OFF)
   _IrrSetNodePosition ($SkyNode, 5000, 0, 5000)
   _IrrSetNodeScale ($SkyNode, 160.0, 160.0, 160.0)
   _IrrSetNodeRotation ($SkyNode, 0, 135, 90)
  $Light = _IrrAddLight ($SkyNode, 0,0,0, 0.99, 0.99, 0.99, 50000.0)
   _IrrAddChildToParent ($Light,   $SkyNode)
   _IrrSetNodePosition ($Light,   -80, 0, 0)
    $Sun = _IrrAddBillBoardToScene (1000.0,   1000.0, 0,0,0 )
$SunTex = _IrrGetTexture ("./Media/Textures/sundisk.png")
   _IrrSetNodeMaterialTexture($Sun,     $SunTex, 0)
   _IrrSetNodeMaterialType ($Sun,     $IRR_EMT_TRANSPARENT_ALPHA_CHANNEL)
   _IrrSetNodeMaterialFlag ($Sun,     $IRR_EMF_LIGHTING, $IRR_OFF )
   _IrrAddChildToParent ($Sun,     $SkyNode)
   _IrrSetNodePosition ($Sun,     -80, 0, 0)
   $Moon = _IrrAddBillBoardToScene (1000.0,    1000.0, 0,0,0 )
$MoonTex = _IrrGetTexture ("./Media/Textures/moon.png")
   _IrrSetNodeMaterialTexture($Moon,    $MoonTex, 0)
   _IrrSetNodeMaterialType ($Moon,    $IRR_EMT_TRANSPARENT_ALPHA_CHANNEL)
   _IrrSetNodeMaterialFlag ($Moon,    $IRR_EMF_LIGHTING, $IRR_OFF )
   _IrrAddChildToParent ($Moon,    $SkyNode)
   _IrrSetNodePosition ($Moon,    80, 0, 0)
   ;_IrrAddRotationAnimator ($SkyNode, 0.0, 0.03, 0.0)

 

EndFunc

 

;------------------------------------------------------------------------------------------------
Func _Wildlife()

 

;$TerrainSelector = _IrrGetCollisionGroupFromTerrain( $Terrain, 1 )
Global $EagleNode[5]
   $Eagle = _IrrGetMesh("./Media/Models/WildLife/eagle.md2")
$EagleTex = _IrrGetTexture("./Media/Models/WildLife/eagle.jpg")
_IrrSetMeshHardwareAccelerated($Eagle)
For $Loop = 0 To 4
$EagleNode[$Loop] = _IrrAddMeshToScene($Eagle)
_IrrSetNodeMaterialTexture($EagleNode[$Loop], $EagleTex, 0)
_IrrSetNodeMaterialFlag($EagleNode[$Loop], $IRR_EMF_LIGHTING, $IRR_On)
_IrrSetNodeMaterialFlag( $EagleNode[$Loop], $IRR_EMF_FOG_ENABLE, $IRR_ON )
_IrrSetNodeAnimationRange( $EagleNode[$Loop], 0, 15 )
_IrrSetNodeAnimationSpeed( $EagleNode[$Loop], Int(Random(10, 25)))
_IrrSetNodeScale($EagleNode[$Loop], 0.5, 0.5, 0.5)
_IrrSetNodeRotation($EagleNode[$Loop], 0, 270, 0)
_IrrAddRotationAnimator( $EagleNode[$Loop], 0, 0.1145, 0 )
_IrrAddFlyCircleAnimator( $EagleNode[$Loop], 4000+Int(Random(0, 1500)), 300, 3000+Int(Random(0, 1500)), 500.0, 0.0002)
;_IrrAddCollisionAnimator($TerrainSelector, $EagleNode[$Loop], 100.0, 100.0, 100.0, 0.0, 0.0, 0.0,  0.0,10.0,0.0 )
Next

 

;Raven
Global $RavenNode[10]
  $Raven = _IrrGetMesh("./Media/Models/WildLife/raven.md2")
   $RavenTex = _IrrGetTexture("./Media/Models/WildLife/raven.jpg")
   _IrrSetMeshHardwareAccelerated($Raven)
For $Loop = 0 To UBound($RavenNode) - 1
$RavenNode[$Loop] = _IrrAddMeshToScene($Raven)
_IrrSetNodeMaterialTexture($RavenNode[$Loop], $RavenTex, 0)
_IrrSetNodeMaterialFlag($RavenNode[$Loop], $IRR_EMF_LIGHTING, $IRR_On)
_IrrSetNodeMaterialFlag( $RavenNode[$Loop], $IRR_EMF_FOG_ENABLE, $IRR_ON )
_IrrSetNodeAnimationRange( $RavenNode[$Loop], 0, 15 )
_IrrSetNodeAnimationSpeed( $RavenNode[$Loop], Int(Random(20, 40)))
_IrrSetNodeScale($RavenNode[$Loop], 0.3, 0.3, 0.3)
_IrrGetNodePosition( $RavenNode[$Loop], $RavenPos )
_IrrSetNodeRotation($RavenNode[$Loop], 0, 270, 0)
_IrrAddRotationAnimator( $RavenNode[$Loop], 0, 0.1145, 0 )
_IrrAddFlyCircleAnimator( $RavenNode[$Loop], 4000+Int(Random(0, 1500)), 100+Int(Random(0, 300)), 3000+Int(Random(0, 1500)), 500.0, 0.0002)
;_IrrAddCollisionAnimator($TerrainSelector, $RavenNode[$Loop], 100.0, 100.0, 100.0, 0.0, 0.0, 0.0,  0.0,10.0,0.0 )
Next

 

;#ce
EndFunc

 

;------------------------------------------------------------------------------------------------
Func _IrrKlang()

 

$IrrKlangStart = _AIK_EngineStart("./Bin");, $ESOD_AUTO_DETECT, BitXOR($ESEO_DEFAULT_OPTIONS, $ESEO_USE_3D_BUFFERS))
   $EagleSound = _AIK_EngineAddSoundSourceFromFile("./Media/Sound/bell.wav", $ESM_AUTO_DETECT, True)
_AIK_EngineSetDefault3DSoundMinDistance(50)

 

EndFunc
;------------------------------------------------------------------------------------------------

 

;------------------------------------------------------------------------------------------------
;------------------------------------------------------------------------------------------------
Func _Vegetation()

 

$Exaggeration = 0.5
   $DummyMesh = _IrrGetMesh("./media/models/Trees/Dummy.obj")
    _IrrSetMeshHardwareAccelerated($DummyMesh)

 

ConsoleWrite("1")
#cs
For $Loop = 0 To 8

 

$img.Convert("-size","1024x1024","xc:", "-seed",String(9669 + $Loop), "+noise","Random", "-write", "mpr:random","+delete", _
"mpr:random","-channel","r","-threshold",String(GUICtrlRead($VegDensityGUI[$Loop])/10) & "%","-separate","+channel","-negate","-fill",$VegColor[$Loop],"-opaque","white","-write","mpr:" & $VegName[$Loop],"+delete", _
"./Media/Textures/heightmap.png", "-write","mpr:heightmap", "-threshold","35%", "-write","mpr:low","+delete", _
"mpr:heightmap","-threshold","55%","mpr:low","-compose","Difference","-composite","-write","mpr:treemap","+delete", _
"mpr:" & $VegName[$Loop], "mpr:treemap", "-compose","Multiply", "-composite", "-flop", "-write","mpr:treemap", "+delete", _
"mpr:treemap", "-morphology" ,"hmt","5:0,0,0,0,0 0,0,0,0,0 0,0,1,0,0 0,0,0,0,0 0,0,0,0,0","./Media/Models/Trees/" & $VegName[$Loop] & "Map.png")
Next

 

$img.Convert("./Media/Models/Trees/" & $VegName[0] & "Map.png", _
"./Media/Models/Trees/" & $VegName[1] & "Map.png","-compose","add","-composite","-write","mpr:01","+delete", _
"mpr:01","./Media/Models/Trees/" & $VegName[2] & "Map.png","-compose","add","-composite","-write","mpr:02","+delete", _
"mpr:02","./Media/Models/Trees/" & $VegName[3] & "Map.png","-compose","add","-composite","-write","mpr:03","+delete", _
"mpr:03","./Media/Models/Trees/" & $VegName[4] & "Map.png","-compose","add","-composite","-write","mpr:04","+delete", _
"mpr:04","./Media/Models/Trees/" & $VegName[5] & "Map.png","-compose","add","-composite","-write","mpr:05","+delete", _
"mpr:05","./Media/Models/Trees/" & $VegName[6] & "Map.png","-compose","add","-composite","-write","mpr:06","+delete", _
"mpr:06","./Media/Models/Trees/" & $VegName[7] & "Map.png","-compose","add","-composite","-write","mpr:07","+delete", _
"mpr:07","./Media/Models/Trees/" & $VegName[8] & "Map.png","-compose","add","-composite", _
"-morphology","hmt","5:0,0,0,0,0 0,0,0,0,0 0,0,1,0,0 0,0,0,0,0 0,0,0,0,0","-flop", _
"./Media/Textures/heightmaproads7.png","-transparent","black","-compose","add","-composite","-flop","./Media/Models/Trees/VegMap.png")

 

#ce
For $Loop = 0 To 8
$img.Convert("./Media/Models/Trees/VegMap.png","+transparent",String($VegColor[$Loop]),"-colorspace","RGB","sparse-color:./Media/Models/Trees/" & $VegName[$Loop] & ".txt")
Next

 

ConsoleWrite("1")
; "mpr:treemap", "+transparent","red"  , "-write","sparse-color:./Media/Models/Trees/" & $VegName[$Loop]   & ".txt","+delete", _
; "-size","1x1", "xc:", "-write","mpr:random","-write","mpr:treemap","-write","mpr:low", _
; "-write","mpr:" & $VegName[$Loop],"-write","mpr:heightmap"
#ce
;$img.Convert("./Media/Textures/treemap.png","-threshold","1%","-morphology","dilate","disk:2.5","-negate","-motion-blur","0x5+0","./Media/Textures/treemap2.png")
;"./Media/Textures/heightmapshadow0.png","-flop","mpr:treemap","-compose","Difference","-composite","-write","mpr:treemap","+delete", _
;$ShadowMesh = _IrrGetMesh("./Media/Textures/Shadow.obj")
;$TerrainTexture = _IrrGetTexture("./Media/Textures/terraintexture.png")
; _IrrSetNodeMaterialTexture($TerrainNode, $TerrainTexture, 0)
;$img.Convert("./Media/Textures/treemap3.png","-morphology","dilate","disk:2.5","-threshold","1%","-motion-blur","0x5+0","./Media/Textures/treemap4.png")
;$img.Convert("./Media/Textures/treemap2.png","./Media/Textures/treemap4.png","-compose","Difference","-composite","+level","50%,0","-negate","./Media/Textures/treemap4.png")
;$img.Convert("./Media/Textures/treemap4.png","-flop","./Media/Textures/terraintexture.png","-compose","Multiply","-composite","./Media/Textures/terraintexture.png")
;$img.Convert("./Media/Textures/heightmaplevel.png","./Media/Textures/terraintexture.png","-compose","Multiply","-composite","./Media/Textures/terraintexture.png")

 

Global $GroundBatch = _IrrCreateBatchingMesh()

 

For $Mesh = 0 To 8
$VegCoords[$Mesh] = _StringExplode(StringRegExpReplace(FileRead("./Media/Models/Trees/" & $VegName[$Mesh] & ".txt"), "[redgnblucyaposkihtLGSB]", ""), ", ")
   $Coords = $VegCoords[$Mesh]
;$VegTex[$Mesh] = _IrrGetTexture ("./Media/Models/Trees/" & $VegName[$Mesh] & ".png")
$VegManager[$Mesh] = _IrrAddLODManager (1, $IRR_On)
_IrrSetNodeMaterialFlag($VegManager[$Mesh], $IRR_EMF_LIGHTING, $IRR_OFF)
For $LOD = 0 To 4
$VegMesh[$Mesh][$LOD] = _IrrGetMesh       ("./Media/Models/Trees/" & $VegName[$Mesh] & $LOD+1 & ".obj")
_IrrSetMeshHardwareAccelerated($VegMesh   [$Mesh][$LOD])
_IrrAddLODMesh   ($VegManager[$Mesh],$LOD*5000, $VegMesh[$Mesh][$LOD])
Next

 

For $Count = 0 To UBound($VegCoords[$Mesh]) - 2
$XY = StringSplit($Coords[$Count],",")
$RandomSize = Int(Random($VegSize[$Mesh]-2, $VegSize[$Mesh]+3))*$Exaggeration
$VegNode[$Mesh][$Count] = _IrrAddMeshToScene ($VegMesh[$Mesh][0])
  _IrrSetNodePosition ($VegNode[$Mesh][$Count], $XY[1]*10, _IrrGetTerrainHeight($Terrain, $XY[1]*10, $XY[2]*10), $XY[2]*10)
  _IrrSetNodeScale ($VegNode[$Mesh][$Count], $RandomSize, $RandomSize,  $RandomSize)
  _IrrSetNodeRotation ($VegNode[$Mesh][$Count], 0, Int(Random(0, 359)),    0)
  _IrrSetNodeMaterialType   ($VegNode[$Mesh][$Count], $IRR_EMT_TRANSPARENT_ALPHA_CHANNEL_REF)
  _IrrSetNodeMaterialFlag   ($VegNode[$Mesh][$Count], $IRR_EMF_LIGHTING, $IRR_On)
  _IrrSetNodeMaterialFlag   ($VegNode[$Mesh][$Count], $IRR_EMF_BACK_FACE_CULLING, $IRR_OFF)
  _IrrSetNodeMaterialFlag   ($VegNode[$Mesh][$Count], $IRR_EMF_FOG_ENABLE, $IRR_ON)
  _IrrAddChildToParent ($VegNode[$Mesh][$Count], $VegManager[$Mesh])
   $VegMaterial = _IrrGetMaterial ($VegNode[$Mesh][$Count], 0)
  _IrrMaterialVertexColorAffects($VegMaterial, $ECM_DIFFUSE_AND_AMBIENT)
  $color1 = 128
  $color2 = 128
  $color3 = 128
  $color4 = 128
  ;_IrrMaterialSetDiffuseColor($VegMaterial, $color1, $color2, $color3, $color4)
  ;_IrrMaterialSetAmbientColor($VegMaterial, $color1, $color2, $color3, $color4)
  ;_IrrMaterialSetSpecularColor($VegMaterial, $color1, $color2, $color3, $color4)
  ;_IrrMaterialSetEmissiveColor($VegMaterial, $color1, $color2, $color3, $color4)
  ;_IrrXEffectsAddNodeToDepthPass($VegNode[$Mesh][$Count])

 

 

Local   $Faces[18] = [6,0,1, 6,1,2, 6,2,3, 6,3,4, 6,4,5, 6,5,0]
Local $Hexagon[7][5] = [[40,0,0,0,2],[20,-40,0,1,0],[-20,-40,0,3,0],[-40,0,0,4,2],[-20,40,0,3,4],[20,40,0,1,4],[0,0,5,2,2]]
;Local $Hexagon[7][5] = [[40,0,0,0,.5],[20,-40,0,.25,0],[-20,-40,0,.75,0],[-40,0,0,1,.5],[-20,40,0,.75,1],[20,40,0,.25,1],[0,0,5,.5,.5]]
; $VegAlt = _IrrGetTerrainHeight($Terrain, $XY[1]*10,    $XY[2]*10)
Local $Vtx = __CreateVertStruct(7)

 

For $Loop = 0 To 6
__SetVertStruct($Vtx, $Loop, $VERT_X,  $Hexagon[$Loop][0])
__SetVertStruct($Vtx, $Loop, $VERT_Y,_IrrGetTerrainHeight($Terrain,$XY[1]*10+$Hexagon[$Loop][0],$XY[2]*10+$Hexagon[$Loop][1])-_IrrGetTerrainHeight($Terrain,$XY[1]*10,$XY[2]*10)+$Hexagon[$Loop][2])
__SetVertStruct($Vtx, $Loop, $VERT_Z,  $Hexagon[$Loop][1])
__SetVertStruct($Vtx, $Loop, $VERT_TEXTUREX, $Hexagon[$Loop][3])
__SetVertStruct($Vtx, $Loop, $VERT_TEXTUREY, $Hexagon[$Loop][4])
__SetVertStruct($Vtx, $Loop, $VERT_VCOLOR, _IrrMakeARGB(0, 0, 255, 0))
Next

 

$Ground = _IrrCreateMesh ("Ground", $Vtx, $Faces)
  _IrrSetMeshHardwareAccelerated($Ground)
  _IrrAddToBatchingMesh ($GroundBatch, $Ground, $XY[1]*10, _IrrGetTerrainHeight($Terrain, $XY[1]*10, $XY[2]*10), $XY[2]*10);, 0,Random(0, 359), 0)

 

Next
Next
$GroundMesh = _IrrFinalizeBatchingMesh($GroundBatch)
  _IrrSetMeshHardwareAccelerated($GroundMesh)
$GroundNode = _IrrAddMeshToSceneAsOcttree($GroundMesh)
;$GroundNode = _IrrAddWaterSurfaceSceneNode($GroundMesh, 0.1, 500, 2 )
$GroundTex = _IrrGetTexture("./Media/TerrainTextures/leaves1.png")
  _IrrSetNodeMaterialTexture($GroundNode, $GroundTex, 0)
;_IrrAddHighLevelShaderMaterialFromFiles("./Media/Shaders/color_shaderVS.glsl", "main", $IRR_EVST_VS_1_1, "./Media/Shaders/color_shaderPS.glsl", "main", $IRR_EPST_PS_1_1, $ShaderMaterial)
;   _IrrSetNodeMaterialType   ($GroundNode, $ShaderMaterial)
  ;_IrrSetNodeMaterialFlag   ($GroundNode, $IRR_EMF_LIGHTING,   $IRR_Off)
  _IrrSetNodeMaterialFlag   ($GroundNode, $IRR_EMF_FOG_ENABLE, $IRR_ON)
  ;_IrrSetNodeMaterialFlag   ($GroundNode, $IRR_EMF_ANISOTROPIC_FILTER, $IRR_ON)

 

;GrassNode Plants
;Global $PlantName[4] = ["Grass", "Grass", "Grass", "Grass"]
Global $PlantName[4] = ["Grass", "Thistle", "Flowers", "Bushes"]
Global $PlantPatchSize[4] = [980 , 990    , 1000   , 1010 ]
Global   $PlantDensity[4] = [15000  , 1500    , 1500   , 1500 ]
Global $PlantSize[4] = [2 , 4    , 3   , 8 ]
Global $PlantWind[4] = [10 , 5    , 5   , 2 ]
Global $PlantTex[4]

 

$TerrainHeight = _IrrGetImage("./Media/Textures/heightmap.png")
 $TerrainColor = _IrrGetImage("./Media/Textures/terraintexture.png")
$PlantMap = _IrrGetImage("./Media/Textures/grassmap5.png")

 

For $Count = 0 To 3
$PlantTex[$Count] = _IrrGetTexture("./Media/Textures/" & $PlantName[$Count] & ".png")

 

For $xg = 0 To 9
    For $yg = 0 To 9
        $PlantNode = _IrrAddGrass ($Terrain, $xg, $yg, _
   $PlantPatchSize[$Count], 1.0, $IRR_On, _
   $PlantSize[$Count]/Int(Random(12, 16)), _
   $PlantDensity[$Count], 0, 0, _
   $TerrainHeight, _
   $TerrainColor, _
   $PlantMap, _
   $PlantTex[$Count])
_IrrSetGrassWind($PlantNode, $PlantWind[$Count], 20.0)
_IrrSetNodeMaterialType($PlantNode, $IRR_EMT_TRANSPARENT_ALPHA_CHANNEL_REF)
_IrrSetNodeMaterialFlag($PlantNode, $IRR_EMF_LIGHTING, $IRR_On)
_IrrSetNodeMaterialFlag($PlantNode, $IRR_EMF_FOG_ENABLE, $IRR_ON)
;_IrrXEffectsAddNodeToDepthPass($PlantNode)
Next
Next
Next
#ce
EndFunc
;------------------------------------------------------------------------------------------------
Func _LakeShores()

 

$img.Convert("./Media/Textures/heightmap.png"    , _
"-threshold"  ,"35%"    , _
"-bordercolor","black"      , _
"-border"    ,"1x1"      , _
"-fill"    ,"white"      , _
"-floodfill"  ,"+0+0","black"    , _
"-shave"    ,"1x1"      , _
"-morphology" ,"hmt","3:0,0,0 0,1,0 0,0,0", _
"./Media/Textures/heightmapLakeShores.png")

 

EndFunc
;------------------------------------------------------------------------------------------------
Func _TreeGround()
; $img.convert("")
$img.convert("heightmap.png","heightmaproads8.png","-alpha","on","-compose","blend","-define","compose:args=1","-composite","heightroads.png")

 

EndFunc

 

;------------------------------------------------------------------------------------------------

 

 

;------------------------------------------------------------------------------------------------
;------------------------------------------------------------------------------------------------
Func _Roads()

 

$RoadMesh = _IrrGetMesh   ("./Media/Models/Roads/road6.obj")
$RoadTex = _IrrGetTexture   ("./Media/Textures/terraintexture.png")
_IrrSetMeshHardwareAccelerated($RoadMesh)
$RoadNode = _IrrAddMeshToScene   ($RoadMesh)
_IrrSetNodePosition   ($RoadNode, 0, -640, 0)
_IrrSetNodeRotation   ($RoadNode, 0, 0, 0)
_IrrSetNodeScale   ($RoadNode, 100.0, 100, 100.0)
_IrrSetNodeMaterialTexture   ($RoadNode, $RoadTex, 0)
_IrrSetNodeMaterialFlag   ($RoadNode, $IRR_EMF_LIGHTING, $IRR_ON)
_IrrSetNodeMaterialFlag   ($RoadNode, $IRR_EMF_BACK_FACE_CULLING, $IRR_OFF)
_IrrSetNodeMaterialFlag   ($RoadNode, $IRR_EMF_FOG_ENABLE, $IRR_ON )
$RoadMaterial = _IrrGetMaterial   ($RoadNode, 0)
_IrrMaterialVertexColorAffects($RoadMaterial, $ECM_none)
_IrrMaterialSetAmbientColor   ($RoadMaterial, 255, 255, 255, 255)
_IrrMaterialSetDiffuseColor   ($RoadMaterial, 255, 255, 255, 255)

 

EndFunc

 

 

 

;------------------------------------------------------------------------------------------------
Func _exit()
_IrrStop()
Exit
EndFunc ; _exit