Blitz3D+ Command Reference

SkyBoxTexture entity,texture[,frame]

Parameters

entity - skybox entity returned by CreateSkyBox

texture - new 2:1 equirectangular sky image

frame (optional) - frame of an animated texture; 0 (default)

Description

Changes the image shown by a skybox.

Swap skies without recreating the entity - day to dusk to night, or a weather change rolling in. The entity must have been created with CreateSkyBox; anything else raises a runtime error, as does an out-of-range animation frame.

Remember that materials lit through BrushEnvironmentMap do not follow automatically: if reflections should match the new sky, update the environment map on those brushes too.

Requires Extended mode.

See also: CreateSkyBox, SkyBoxIntensity, BrushEnvironmentMap, LoadTexture.

Example

; SkyBoxTexture Example
; ---------------------
; Requires Extended mode.

Graphics3D 640,480,0,2
SetBuffer BackBuffer()

camera=CreateCamera()
PositionEntity camera,0,1,-5

light=CreateLight()
RotateEntity light,35,-30,0

; Draw a daytime sky: blue with a sun
day=CreateTexture(128,64,1+8+32)
SetBuffer TextureBuffer(day)
ClsColor 50,120,240
Cls
Color 255,235,150
Oval 90,8,14,14,True
SetBuffer BackBuffer()

; Draw a night sky: near-black with stars
SeedRnd MilliSecs()
night=CreateTexture(128,64,1+8+32)
SetBuffer TextureBuffer(night)
ClsColor 5,5,30
Cls
Color 255,255,255
For i=1 To 60
    Plot Rand(0,127),Rand(0,63)
Next
SetBuffer BackBuffer()

sky=CreateSkyBox(day)

; A ground slab for scale
ground=CreateCube()
ScaleEntity ground,4,0.1,4
PositionEntity ground,0,-1,2
EntityColor ground,60,110,50

is_day=True

While Not KeyDown(1)

    ; Press Space to swap the sky image
    If KeyHit(57) Then is_day=Not is_day

    ; Change the image shown by the existing skybox entity
    If is_day Then SkyBoxTexture sky,day Else SkyBoxTexture sky,night

    ; Arrow keys move the camera
    If KeyDown(200) Then MoveEntity camera,0,0,0.1
    If KeyDown(208) Then MoveEntity camera,0,0,-0.1
    If KeyDown(203) Then TurnEntity camera,0,1,0
    If KeyDown(205) Then TurnEntity camera,0,-1,0

    RenderWorld

    Color 255,255,255
    Text 0,0,"Space: day / night   Arrow keys: move camera   Esc: exit"
    If is_day Then Text 0,20,"SkyBoxTexture sky,day" Else Text 0,20,"SkyBoxTexture sky,night"

    Flip

Wend

End

Index