multiple lights for dot3?

Blitz3D Forums/Blitz3D Programming/multiple lights for dot3?

That's how i got it right now.... but i need help with using multiple lights...

Graphics3D 1024, 768, 32, 1
SetBuffer BackBuffer()

Global bumpvec = CreatePivot()
Global redd#, greend#, blued#

AmbientLight 0,0,0

a# = 1.0

;------------ Initialise dot3-types ----------------------
Type bumpmesh
	Field mesh		;bumpmapped mesh's handle
End Type

Type d3light
	Field light		;dot3 light's handle
	Field rng#		;dot3 light's range
End Type
;------------------------------------------------------------

;---------- Setting up the light ----------------------
pivot = CreatePivot()
light = graphics_Dot3_CreateBumpLight(10, pivot)
;lightx = CreateSphere(8, light)
;EntityFX lightx, 1
;ScaleEntity lightx, 0.1, 0.1, 0.1
;EntityColor lightx, 255,255,255
MoveEntity light, 0, 0, -6
;------ creating the mesh and apply normal map ---------------------
mesh = CreateCube()
ScaleEntity mesh, 2, 2, 2
graphics_dot3_applybumpmesh(mesh, "boden_diffuse.jpg", "boden.jpg")
UpdateNormals mesh
;--------- create a camera --------------------------------
camera = CreateCamera()
PositionEntity camera,0,0,-9.0
CameraRange camera,0.1,110
CameraClsColor camera,0,0,0

;--------- Main loop -----------------------------------------
While Not KeyHit(1)
	
	;FPS
	tt=MilliSecs()
    fps#=1000/(tt-ttold)
    ttold=tt
	
	
	;turn the mesh with cursor-keys
	If KeyDown(200) TurnEntity mesh, 70/fps,0,0
	
	If KeyDown(208) TurnEntity mesh,-70/fps,0,0	
	
	If KeyDown(205) TurnEntity mesh,0,-70/fps,0
	
	If KeyDown(203) TurnEntity mesh,0, 70/fps,0

	
	;move the light while space is pressed
	If KeyDown(57) Then
		a = a + 1
		If a = 360.0 Then a = 0
		PositionEntity light,Cos(a)*5,Sin(a)*5,-9	
	EndIf

	;Updates
	graphics_dot3_Normalupdate()
	UpdateWorld()
	RenderWorld()

    Text 10,10,"FPS: "+Int(fps#)
	
	Flip

Wend


;---------------- Functions -------------------------------------
Function graphics_Dot3_CreateBumpLight(range#, parent)	;create a light regarded by the dot3-system

	d.d3light = New d3light
	
	d\light = CreatePivot(parent)
	d\rng = range
	
	Return d\light
	
End Function

Function graphics_Dot3_ApplyBumpMesh(mesh, diffuse$, bump$)		;apply a mesh to be a normal mapped mesh (diffusemap = colormap without shades)

	bm.bumpmesh = New bumpmesh
	
	difftex = LoadTexture(diffuse, 1+256)
	bumptex = LoadTexture(bump, 1+256)
	
	bm\mesh = mesh
	
	TextureBlend bumptex, 4
	
	EntityTexture mesh, bumptex, 0, 0
	EntityTexture mesh, difftex, 0, 1
	
	EntityFX mesh, 3
	
End Function


Function graphics_dot3_Normalupdate()
For bm.bumpmesh = Each bumpmesh
	

	For d.d3light= Each d3light
	
	For n = 1 To CountSurfaces(bm\mesh)
		surf = GetSurface(bm\mesh,n)
		For v = 0 To CountVertices(surf)-1
			TFormPoint VertexX(surf,v),VertexY(surf,v),VertexZ(surf,v),bm\mesh,0
			x# = TFormedX() - EntityX(d\light)
			y# = TFormedY() - EntityY(d\light)
			z# = TFormedZ() - EntityZ(d\light)
			
			TFormNormal VertexNX(surf,v),VertexNY(surf,v),VertexNZ(surf,v),bm\mesh,0
			
			dist# = Sqr(x*x+y*y+z*z)
			Intens# = 1.0 - (dist/(d\rng*8))
			If intens < 0 Then intens = 0
			
			PositionEntity bumpvec,TFormedX(),TFormedY(),TFormedZ(),1
			AlignToVector bumpvec,TFormedX(),TFormedY(),TFormedZ(),3,1
			RotateEntity bumpvec,EntityPitch(bumpvec,1),EntityYaw(bumpvec,1),0,1
			
			TFormNormal x,y,z,0,bumpvec
				
			redd = (1.0-TFormedX())*127
			greend = (1.0-TFormedY())*127
			blued = ((1.0-TFormedZ())*127)*Intens
				
			VertexColor surf,v,redd,greend,blued		
		Next
	Next
  Next
Next
End Function


You'll need this pics:

boden.jpg:


boden_diffuse.jpg:


(b.t.w.: boden is the german word for floor)

Raitsun
(These Pictures are from Ben Cloward Homepage:
http://www.monitorstudios.com/bcloward/index.html)