Unverständlicher Fehler bei UpdateTerrainTileLayerBlend()

Fragen zu Grafik- & Soundproblemen und zur Spieleprogrammierung haben hier ihren Platz.
Benutzeravatar
Chimorin
Beiträge: 451
Registriert: 30.01.2013 16:11
Computerausstattung: MSI GTX 660 OC mit TwinFrozr III
6Gb DDR 3 RAM
AMD Phenom II X4 B55 @ 3,6GHz
Windows 7 Home Premium 64-bit

Unverständlicher Fehler bei UpdateTerrainTileLayerBlend()

Beitrag von Chimorin »

Hey,
seit geraumer Zeit plagt mich dieser Fehler im Programm und ich bekomme ihn einfach nicht raus. Als Texturen könnt ihr einfach irgendwelche nehmen, ich denke, dass das keinen Unterschied macht. Ich bin mit meinem Latein am Ende, vllt weiß jemand von euch weiter...
Ich habe versucht, das Problem zu isolieren, so taucht er immer noch auf :)
Sind trotzdem leider über 100 Zeilen, ich glaube, man kann noch die Kamera und ein paar andere Sachen raushauen...

Gruß,

Banane


PB 5.11, Win XP SP 3 x86

Code: Alles auswählen

EnableExplicit
;teilX = Tile in X direction
;teilY = Tile in Y direction
;stelle = point where the "action" is; in world units


;_________________
;|       |       |
;|  1/1  |  1/0  |
;|       |       |
;|_______|_______|
;|       |       |
;|  0/1  |  0/0  |
;|       |       |
;|_______|_______|


Structure Vektor3
  x.f
  y.f
  z.f
EndStructure


Global.i terrain, terrainX, terrainY, teilX, teilY, h, X, Y
Global.Vektor3 stelle
Global.f blendWert, ttpointy, ttpointx


#G_Heightmap = 513
#layerAnzahl = 2
#skalFaktor = 5
#weltGroesse = 2


Enumeration
  #Licht_0
EndEnumeration


InitEngine3D()
InitSprite()

OpenScreen(1920, 1080, 32, "Test_Blend_0", #PB_Screen_SmartSynchronization)

;- Licht
CreateLight(#Licht_0 ,RGB(190, 190, 190), 500, 500, 500, #PB_Light_Point)
SetLightColor(#Licht_0, #PB_Light_SpecularColor, RGB(255*0.4, 255*0.4,255*0.4)) 
AmbientColor(RGB(255*0.2, 255*0.2,255*0.2))

;- Terrain Definition
SetupTerrains(LightID(#Licht_0), 10, #PB_Terrain_NormalMapping)

terrain = CreateTerrain(#PB_Any, #G_Heightmap, 100, #skalFaktor, #layerAnzahl, "terrain", "Dat")

AddTerrainTexture(terrain, 0, 1, "Gras_0.png", "Gras_0_Normal.png")       ;-Terraintexturen
AddTerrainTexture(terrain, 1, 1, "Steinstrasse_0_1.png", "Steinstrasse_0_1_Normal.png")

TerrainLocate(terrain, 50, 0, 50 + 100 * (#weltGroesse - 1))        ;Gesamtes Terrain wird so positioniert, dass die linke untere Ecke auf 0/0 liegt.

For terrainX = 0 To #weltGroesse - 1
  For terrainY = 0 To #weltGroesse - 1
    DefineTerrainTile(terrain, terrainX, terrainY, "heightmap.png", #False, #False)
  Next
Next

BuildTerrain(terrain)


teilX = 0
teilY = 1
stelle\x = 50
stelle\z = 99.99
stelle\y = TerrainHeight(terrain, stelle\x, stelle\z)
ttpointx = TerrainTilePointX(terrain, teilX, teilY, stelle\x, stelle\y, stelle\z)
ttpointy = TerrainTilePointY(terrain, teilX, teilY, stelle\x, stelle\y, stelle\z)

For h = 0 To #layerAnzahl - 1       ;1024, weil die LayerBlendmapgröße 1024 beträgt.
  blendWert = GetTerrainTileLayerBlend(terrain, teilX, teilY, h, ttpointx * 1024, 1024 - ttpointy * 1024)
  
  If blendWert = 1
    SetTerrainTileLayerBlend(terrain, teilX, teilY, h, ttpointx * 1024, 1024 - ttpointy * 1024, 0.0)
  EndIf
Next

SetTerrainTileLayerBlend(terrain, teilX, teilY, 1, ttpointx * 1024, 1024 - ttpointy * 1024, 1.0)


teilX = 0
teilY = 0
stelle\x = 50
stelle\z = 100.01
stelle\y = TerrainHeight(terrain, stelle\x, stelle\z)
ttpointx = TerrainTilePointX(terrain, teilX, teilY, stelle\x, stelle\y, stelle\z)
ttpointy = TerrainTilePointY(terrain, teilX, teilY, stelle\x, stelle\y, stelle\z)

For h = 0 To #layerAnzahl - 1       ;1024, weil die LayerBlendmapgröße 1024 beträgt.
  blendWert = GetTerrainTileLayerBlend(terrain, teilX, teilY, h, ttpointx * 1024, 1024 - ttpointy * 1024)
  
  If blendWert = 1
    SetTerrainTileLayerBlend(terrain, teilX, teilY, h, ttpointx * 1024, 1024 - ttpointy * 1024, 0.0)
  EndIf
Next

SetTerrainTileLayerBlend(terrain, teilX, teilY, 1, ttpointx * 1024, 1024 - ttpointy * 1024, 1.0)


For X = 0 To 1
  For Y = 1 To 0 Step -1
    Debug Str(X) + "..." + Str(Y)
    UpdateTerrainTileLayerBlend(terrain, X, Y, 1)       ;-<-- Error, Speicheradresse blablabla.
    UpdateTerrainTileLayerBlend(terrain, X, Y, 0)
  Next Y
Next X

End
Zuletzt geändert von Chimorin am 29.06.2013 10:38, insgesamt 1-mal geändert.
Bild

- formerly known as Bananenfreak -
Benutzeravatar
Chimorin
Beiträge: 451
Registriert: 30.01.2013 16:11
Computerausstattung: MSI GTX 660 OC mit TwinFrozr III
6Gb DDR 3 RAM
AMD Phenom II X4 B55 @ 3,6GHz
Windows 7 Home Premium 64-bit

Re: Unverständlicher Fehler bei UpdateTerrainTileLayerBlend(

Beitrag von Chimorin »

Halli Hallo,

ich habe jetzt mal einen Code geteilt, der das Problem genau lokalisiert (Mit genau 100 Zeilen ^^). Spielt doch einmal mit den beiden Werten von "stelle\z" rum, dann seht ihr, was ich meine. Hat jemand eine Erklärung dafür?
Bild

- formerly known as Bananenfreak -
Benutzeravatar
Chimorin
Beiträge: 451
Registriert: 30.01.2013 16:11
Computerausstattung: MSI GTX 660 OC mit TwinFrozr III
6Gb DDR 3 RAM
AMD Phenom II X4 B55 @ 3,6GHz
Windows 7 Home Premium 64-bit

Re: Unverständlicher Fehler bei UpdateTerrainTileLayerBlend(

Beitrag von Chimorin »

Nächstes Mysterium:
Dieser Code (ist fast der gleiche wie oben, nur optimiert, der Fehler ist trotzdem drin) versucht den Blendwert in Y-Richtung zu erneuern, was auch funktioniert. Das Programm läuft sauber durch.

Code: Alles auswählen

EnableExplicit


Structure Vektor3
  x.f
  y.f
  z.f
EndStructure


Global.i terrain, terrainX, terrainY, teilX, teilY, h, X, Y
Global.Vektor3 stelle
Global.f blendWert, ttpointy, ttpointx


#G_Heightmap = 513
#layerAnzahl = 2
#skalFaktor = 5
#weltGroesse = 2


Enumeration
  #Licht_0
EndEnumeration


InitEngine3D()
InitSprite()

OpenScreen(1920, 1080, 32, "Test_Blend_0", #PB_Screen_SmartSynchronization)

;- Licht
CreateLight(#Licht_0 ,RGB(190, 190, 190), 500, 500, 500, #PB_Light_Point)
SetLightColor(#Licht_0, #PB_Light_SpecularColor, RGB(255*0.4, 255*0.4,255*0.4)) 
AmbientColor(RGB(255*0.2, 255*0.2,255*0.2))

;- Terrain Definition
SetupTerrains(LightID(#Licht_0), 10, #PB_Terrain_NormalMapping)

terrain = CreateTerrain(#PB_Any, #G_Heightmap, 100, #skalFaktor, #layerAnzahl, "terrain", "Dat")

AddTerrainTexture(terrain, 0, 1, "Gras_0.png", "Gras_0_Normal.png")       ;-Terraintexturen
AddTerrainTexture(terrain, 1, 1, "Steinstrasse_0_1.png", "Steinstrasse_0_1_Normal.png")

TerrainLocate(terrain, 50, 0, 50 + 100 * (#weltGroesse - 1))        ;Gesamtes Terrain wird so positioniert, dass die linke untere Ecke auf 0/0 liegt.

For terrainX = 0 To #weltGroesse - 1
  For terrainY = 0 To #weltGroesse - 1
    DefineTerrainTile(terrain, terrainX, terrainY, "heightmap.png", #False, #False)
  Next
Next

BuildTerrain(terrain)


teilX = 0
teilY = 1
stelle\z = 50
stelle\x = 99.99
stelle\y = TerrainHeight(terrain, stelle\x, stelle\z)
ttpointx = TerrainTilePointX(terrain, teilX, teilY, stelle\x, stelle\y, stelle\z)
ttpointy = TerrainTilePointY(terrain, teilX, teilY, stelle\x, stelle\y, stelle\z)

For h = 0 To #layerAnzahl - 1       ;1024, weil die LayerBlendmapgröße 1024 beträgt.
  blendWert = GetTerrainTileLayerBlend(terrain, teilX, teilY, h, ttpointx * 1024, 1024 - ttpointy * 1024)
  
  If blendWert = 1
    SetTerrainTileLayerBlend(terrain, teilX, teilY, h, ttpointx * 1024, 1024 - ttpointy * 1024, 0.0)
  EndIf
Next

SetTerrainTileLayerBlend(terrain, teilX, teilY, 1, ttpointx * 1024, 1024 - ttpointy * 1024, 1.0)


teilX = 1
teilY = 1
stelle\z = 50
stelle\x = 100.01
stelle\y = TerrainHeight(terrain, stelle\x, stelle\z)
ttpointx = TerrainTilePointX(terrain, teilX, teilY, stelle\x, stelle\y, stelle\z)
ttpointy = TerrainTilePointY(terrain, teilX, teilY, stelle\x, stelle\y, stelle\z)

For h = 0 To #layerAnzahl - 1       ;1024, weil die LayerBlendmapgröße 1024 beträgt.
  blendWert = GetTerrainTileLayerBlend(terrain, teilX, teilY, h, ttpointx * 1024, 1024 - ttpointy * 1024)
  
  If blendWert = 1
    SetTerrainTileLayerBlend(terrain, teilX, teilY, h, ttpointx * 1024, 1024 - ttpointy * 1024, 0.0)
  EndIf
Next

SetTerrainTileLayerBlend(terrain, teilX, teilY, 1, ttpointx * 1024, 1024 - ttpointy * 1024, 1.0)


For X = 0 To 1
  For Y = 1 To 0 Step -1
    Debug Str(X) + "..." + Str(Y)
    UpdateTerrainTileLayerBlend(terrain, X, Y, 1)       ;-<-- Error, Speicheradresse blablabla.
    UpdateTerrainTileLayerBlend(terrain, X, Y, 0)
  Next Y
Next X

End
Meiner Meinung nach handelt es sich hier um einen Bug, ich werde ihn ins englische Forum posten.
Bild

- formerly known as Bananenfreak -
Antworten