Cubemap-Texturen spiegelverkehrt

Übersicht BlitzBasic Blitz3D

Neue Antwort erstellen

BlitzGames

Betreff: Cubemap-Texturen spiegelverkehrt

BeitragFr, Jan 13, 2006 10:55
Antworten mit Zitat
Benutzer-Profile anzeigen
Das hier ist mein Problem:
user posted image
Der Code sieht wie folgt aus:
Code: [AUSKLAPPEN]

Graphics3D 1024,768

terr=LoadTerrain( "Meshes\Terrain\heightmap2.bmp" )
TerrainDetail terr,4000,True
ScaleEntity terr,2,60,2
boden_tex=LoadTexture( "Meshes\Terrain\heighttex.bmp" )
boden_tex2=LoadTexture("meshes\Terrain\heighttex.jpg")
lightmap_tex=LoadTexture("Meshes\Terrain\lightmap.bmp")
ScaleTexture boden_tex,5,5 ;,90,90
ScaleTexture boden_tex2,90,90
ScaleTexture lightmap_tex,1024,1024
EntityTexture terr,boden_tex,0,1
EntityTexture terr,boden_tex2,0,2
TextureBlend boden_tex2,2
EntityTexture terr,lightmap_tex,0,3
TextureBlend lightmap_tex,2
PositionEntity terr,-400,-35,-500

    tex=CreateTexture(512,512,1+128+256)
    pWasser=CreateCube()
    EntityTexture pWasser,tex
    EntityAlpha pWasser,1
    PositionEntity pWasser,128,-8,128
    ScaleEntity pWasser,256,.01,256

Kamera=CreateCamera()
PositionEntity Kamera,15,-21.5,0
CameraRange Kamera,1,1200
CameraFogRange Kamera,940,980
CameraFogMode Kamera,True
cube_cam=CreateCamera()
HideEntity cube_cam

While Not KeyHit(1)

TerrY#=TerrainY(terr,EntityX(Kamera),EntityY(Kamera),EntityZ(Kamera))
If TerrY#<-8 Then TerrY=-8
PositionEntity Kamera,EntityX(Kamera),TerrY+2,EntityZ(Kamera)
PositionEntity pWasser,EntityX(Kamera),-8,EntityZ(Kamera)

   EntityTexture pWasser2,watertex,waterframe,1 ;Texturanimation wird um 1 Frame erhöht (= Teilbilder nach und nach aufrufen)
   waterframe = (waterframe + 1) Mod 22 ;Wassertextur-Animations-Schritt wird um 1 erhöht

UpdateWorld

HideEntity Kamera
UpdateCubemap(tex,cube_cam,pWasser)
ShowEntity Kamera


RenderWorld

If KeyDown(200) Then MoveEntity Kamera,0,0,1
If KeyDown(208) Then MoveEntity Kamera,0,0,-1
If KeyDown(203) Then TurnEntity Kamera,0,3,0
If KeyDown(205) Then TurnEntity Kamera,0,-3,0

Flip

Wend

End

Function UpdateCubemap(tex,camera,entity)

tex_sz=TextureWidth(tex)

; Show the camera we have specifically created for updating the cubemap
ShowEntity camera

; Hide entity that will have cubemap applied to it. This is so we can get cubemap from its position, without it blocking the view
HideEntity entity

; Position camera where the entity is - this is where we will be rendering views from for cubemap
PositionEntity camera,EntityX#(entity),EntityY#(entity),EntityZ#(entity)

CameraClsMode camera,False,True

; Set the camera's viewport so it is the same size as our texture - so we can fit entire screen contents into texture
CameraViewport camera,0,0,tex_sz,tex_sz

; Update cubemap

; do left view
SetCubeFace tex,0
RotateEntity camera,0,90,0
RenderWorld
CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex)
; do forward view
SetCubeFace tex,1
RotateEntity camera,0,0,0
RenderWorld
CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex)
; do right view
SetCubeFace tex,2
RotateEntity camera,0,-90,0
RenderWorld
CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex)
; do backward view
SetCubeFace tex,3
RotateEntity camera,0,180,0
RenderWorld
CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex)
; do up view
SetCubeFace tex,4
RotateEntity camera,-90,0,0
RenderWorld
CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex)
; do down view
SetCubeFace tex,5
RotateEntity camera,90,0,0
RenderWorld
CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex)

; Show entity again
ShowEntity entity

; Hide the cubemap camera
HideEntity camera

End Function

Kurze Zusammenfassung: Ich habe einen Cube erstellt, der immer unter der Kamera "mitfährt" und die Umgebung spiegelt.
Wenn jetzt der EntityPitch-Wert größer als 0 ist, so sieht man die Texturen an der Cubemap spiegelverkehrt.. was extrem dumm aussieht. Wenn der EntityPitch-Wert kleiner als 0 ist sieht man alles richtig gespiegelt.
www.blitzcase.com
www.anpfiff-spiel.de
www.fernsehtycoon.de

Neue Antwort erstellen


Übersicht BlitzBasic Blitz3D

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group