|
texture - texture handle (must be created with the cubic environment map flag, 128) mode - how the cubemap is applied to an entity 1: reflection (default) 2: normal 3: position |
|
Sets how a cubemap texture is mapped onto the entities that wear it. Mode 1, reflection, is the one games nearly always want: the face shown at each point depends on the camera and the surface angle, so the object looks like polished chrome reflecting its surroundings. Mode 2, normal, picks the face straight from each vertex's normal - the view direction no longer matters. Mode 3, position, uses the direction from the camera to the surface point instead. Modes 2 and 3 are mostly for special effects and debugging a cubemap's contents. All three modes work in Original and Extended on the DirectX 12 runtime. Directions use world axes by default. Add 4 to the mode (5, 6 or 7) to use camera axes instead, matching classic Blitz3D. Ordinary texture UV coordinates and TexturePosition, TextureScale and TextureRotate do not affect cubemaps. See also: SetCubeFace, CreateTexture, EntityTexture, TextureBlend. |
; SetCubeMode Example
; -------------------
Graphics3D 640,480,0,2
SetBuffer BackBuffer()
camera=CreateCamera()
PositionEntity camera,0,1,-4
light=CreateLight()
RotateEntity light,45,45,0
; Flag 128 = cubic environment map, flag 256 = keep it drawable
cube_tex=CreateTexture(128,128,128+256)
; Paint all six faces. Each side has a different sky colour and clouds.
For face=0 To 5
SetCubeFace cube_tex,face
SetBuffer TextureBuffer(cube_tex)
ClsColor 60+face*25,130,230
If face=5 Then ClsColor 70,140,60
Cls
If face<4
Color 70,140,60
Rect 0,64,128,64,1
EndIf
If face<>5
Color 255,255,255
Rect 12+face*10,24,24,16,1
Rect 72,12+face*8,32,18,1
EndIf
Next
SetBuffer BackBuffer()
; A shiny pickup that wears the cubemap
ball=CreateSphere(16)
PositionEntity ball,0,1,0
EntityTexture ball,cube_tex
EntityFX ball,1
mode=1
SetCubeMode cube_tex,mode
While Not KeyDown(1)
; Keys 1/2/3 choose how the cubemap is applied
If KeyHit(2)
mode=1
SetCubeMode cube_tex,mode
EndIf
If KeyHit(3)
mode=2
SetCubeMode cube_tex,mode
EndIf
If KeyHit(4)
mode=3
SetCubeMode cube_tex,mode
EndIf
TurnEntity ball,0,1,0
; 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
name$="reflection (default)"
If mode=2 Then name$="normal"
If mode=3 Then name$="position"
Text 0,0,"1/2/3: cubemap mode Arrows: camera Esc: exit"
Text 0,20,"SetCubeMode cube_tex,"+mode+" - "+name$
Text 0,40,"Reflection follows the view and surface; normal follows the surface."
Text 0,60,"Position uses the direction from the camera to each surface point."
Flip
Wend
End