Where is the light gone ?

Blitz3D Forums/Blitz3D Beginners Area/Where is the light gone ?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

If i use createcube(), the cube will be affected by light/lightrange.
But if i create my own cubemesh nothing happens.
I tried different flags for LoadBrush, BrushFx etc but nothing seems to work.

Here is an example.
Simply change file$ to any texturefile and change
the 'if 1=1' to 'if 1=0' to see the differences to createcube().
Use the spacebar then to change the lightrange.
Any Idea ?


Graphics3D 640,480

camera = CreateCamera()
MoveEntity camera,0,0,-5

;ChangeDir "F:\programming\Blitz3D\samples\"
Global file$="gfx/1.jpg"

;CHANGE to 1=1 to use cubebox !
If 1=1 then
ball = Create_cubebox() ;no light here !?
Else
ball = CreateCube() ;light ok
brush = LoadBrush(file$,flag)
PaintEntity ball,brush
EndIf

lite = CreateLight(3)
MoveEntity lite,5,0,-5
PointEntity lite,ball

range# = 0.5
LightRange lite,range

While Not KeyDown(1)
TurnEntity ball,0.4,0.4,0.0
RenderWorld:Flip
If KeyHit(57) Then ; hit SPACEBAR to increase light range
range = range + 0.5
LightRange lite,range
EndIf
Wend

End




Function create_cubebox()
mesh = CreateMesh()

flag = 49

;front face
brush = LoadBrush(file$,flag,1,1)
BrushFX brush,2
BrushShininess brush,0.5

surface = CreateSurface(mesh,brush)

AddVertex surface,-1,+1,-1,0,0
AddVertex surface,+1,+1,-1,1,0
AddVertex surface,+1,-1,-1,1,1
AddVertex surface,-1,-1,-1,0,1
AddTriangle surface,0,1,2
AddTriangle surface,0,2,3
FreeBrush brush

;right face
brush = LoadBrush(file$,flag)

surface = CreateSurface(mesh,brush)
AddVertex surface,+1,+1,-1,0,0
AddVertex surface,+1,+1,+1,1,0
AddVertex surface,+1,-1,+1,1,1
AddVertex surface,+1,-1,-1,0,1
AddTriangle surface,0,1,2
AddTriangle surface,0,2,3
FreeBrush brush

;back face
brush = LoadBrush(file$,flag)

surface = CreateSurface(mesh,brush)
AddVertex surface,+1,+1,+1,0,0
AddVertex surface,-1,+1,+1,1,0
AddVertex surface,-1,-1,+1,1,1
AddVertex surface,+1,-1,+1,0,1
AddTriangle surface,0,1,2
AddTriangle surface,0,2,3
FreeBrush brush

;left face
brush = LoadBrush(file$,flag)
surface = CreateSurface(mesh,brush)
AddVertex surface,-1,+1,+1,0,0
AddVertex surface,-1,+1,-1,1,0
AddVertex surface,-1,-1,-1,1,1
AddVertex surface,-1,-1,+1,0,1
AddTriangle surface,0,1,2
AddTriangle surface,0,2,3
FreeBrush brush


;top face
brush = LoadBrush(file$,flag)
surface = CreateSurface(mesh,brush)
AddVertex surface,-1,+1,+1,0,1
AddVertex surface,+1,+1,+1,0,0
AddVertex surface,+1,+1,-1,1,0
AddVertex surface,-1,+1,-1,1,1
AddTriangle surface,0,1,2
AddTriangle surface,0,2,3
FreeBrush brush

;bottom face
brush = LoadBrush(file$,flag)
surface = CreateSurface(mesh,brush)
AddVertex surface,-1,-1,-1,1,0
AddVertex surface,+1,-1,-1,1,1
AddVertex surface,+1,-1,+1,0,1
AddVertex surface,-1,-1,+1,0,0
AddTriangle surface,0,1,2
AddTriangle surface,0,2,3

FreeBrush brush

Return mesh

End Function