Weird Light Effects

Blitz3D Forums/Blitz3D Programming/Weird Light Effects

_PJ_(Posted 2009) [#1]
Please can someone else run this and let me know if the cubes seem to change brightness at seemingly random intervals...

Graphics3D 1024,768
SetBuffer BackBuffer()

Const C_WHITE=0
Const C_RED=1
Const C_BLUE=2
Const C_GREEN=3
Const C_YELLOW=4
Const C_ORANGE=5
Const C_PURPLE=6
Const C_PINK=7

Const Shape_X=0
Const Shape_T=1
Const Shape_O=2
Const Shape_P=3
Const Shape_L=4
Const Shape_E=5
Const Shape_I=6
Const Shape_H=7
Const Shape_S=8
Const Shape_2=9
Const Shape_F=10
Const Shape_U=11
Const Shape_DOT=12

Global Shapes[13]
	Shapes[0]=18157905
	Shapes[1]=4329631
	Shapes[2]=469440
	Shapes[3]=1113663
	Shapes[11]=575039
	Shapes[12]=4096
	Shapes[6]=31744
	Shapes[4]=1082431
	Shapes[7]=18415153
	Shapes[5]=1088575
	Shapes[8]=33061951
	
AmbientLight 128,128,128

Global Spr_Glow=CreateSprite();LoadSprite("Video\T_Glo.dds")
Global Lines_Tex=CreateTexture(256,256,3);LoadTexture("Video\T_Lines.dds")

ScaleSprite Spr_Glow,2.2,2.2
;HandleSprite Spr_Glow,0.5,0.5
HideEntity Spr_Glow

Global Steps#=2.0

Global TestShape=BuildShape(Shape_P)

Global Cam=CreateCamera()
Global CamLight=CreateLight(3,Cam)

LightConeAngles CamLight,0.01,30.0
LightColor CamLight,192,160,128
LightRange CamLight,20.0

MoveEntity Cam,0,0,-10*Steps

While Not KeyDown(1)
	TurnEntity TestShape,0,0.5,0
	RenderWorld
	Flip
Wend	

;Build
Function BuildShape(Shape)
	Local ShapeFlags=Shapes[Shape]
	Local Cube
	Local ChildGlow
	Local ROW
	Local COLUMN
	
	Local Mesh 
	
	For ROW=1 To 5
		For COLUMN=1 To 5
			If (ConvertCOORDToValue(ROW,COLUMN) And (ShapeFlags))
				Cube=CreateBox(ROW,COLUMN)
				ColourBox(Cube,Shape)
				
				ChildGlow=CopyEntity(Spr_Glow,Cube)
				EntityAlpha ChildGlow,0.5
				ColourBox(ChildGlow,Shape)
				EntityParent ChildGlow,Cube,True
				PositionEntity ChildGlow,0,0,0,False
				
				If Not(Mesh)
					Mesh=Cube
				Else
					EntityParent Cube,Mesh
					AddMesh Cube,Mesh
				End If
			End If
		Next
	Next
	Return Mesh	
End Function

Function CreateBox(ROW,COLUMN)
	Local Y#=(2.5-ROW) * Steps
	Local X#=(2.5-COLUMN) * Steps
	
	Local Flag=ConvertCOORDToValue(ROW,COLUMN)
	Local Mesh=CreateCube()
	
	
	EntityFX Mesh,52	
	EntityAlpha Mesh,0.7
	EntityShininess Mesh,0.0
	
	PositionEntity Mesh,X,Y,0
	EntityTexture Mesh,Lines_Tex
	
	Return Mesh
End Function

Function ColourBox(Box,Colour)
	Select Colour
		Case C_WHITE
			EntityColor Box,224,224,224
			Case C_RED
			EntityColor Box,224,32,32
		Case C_BLUE
			EntityColor Box,32,64,224
		Case C_GREEN
			EntityColor Box,32,224,32
	End Select	
End Function

Function ConvertCOORDToValue(Row,Column)
	Return (2^(Column-1) * ((32^(Row-1))))
End Function



puki(Posted 2009) [#2]
Yep, that is completely normal though.


_PJ_(Posted 2009) [#3]
Thanks, Puki. Wasn't sure if it was a glitch with my graphics card or whatever.

I actually think it's pretty cool XD


puki(Posted 2009) [#4]
Basically, the cubes faces are fighting with each other as to who is going to be in view.


_PJ_(Posted 2009) [#5]
Ah... I stuck in:

EntityOrder ChildGlow,1

Problem solved! :)

Thanks!