Lighting problem

Blitz3D Forums/Blitz3D Programming/Lighting problem

Ross C(Posted 2003) [#1]
hey, was testing out code to scale some vertex points and i can't seem to get the mesh to light.

Graphics3D 800,600
SetBuffer BackBuffer()


cam=CreatePivot()
camera=CreateCamera(cam)
PositionEntity camera,0,0,-10

light=CreateLight()

sphere=CreateSphere()

mesh = CreateMesh()
surf = CreateSurface(mesh)

scale#=1

v0 = AddVertex (surf, -1, 1, 0.5)
v1 = AddVertex (surf,  1, 1, 0.5)
v2 = AddVertex (surf, -1,-1, 0.5)
v3 = AddVertex (surf,  1,-1, 0.5)

v4 = AddVertex (surf,  0.5,8  , 0)
v5 = AddVertex (surf,  -8 ,0.5, 0)


Dim vert#(3,2)
vert(0,0)=-1
vert(0,1)=1
vert(0,2)=-0.5

vert(1,0)=1
vert(1,1)=1
vert(1,2)=-0.5

vert(2,0)=-1
vert(2,1)=-1
vert(2,2)=-0.5

vert(3,0)=1
vert(3,1)=-1
vert(3,2)=-0.5

tri = AddTriangle (surf,v0,v1,v2)
tri1= AddTriangle (surf,v1,v3,v2)
tri2= AddTriangle (surf,v0,v4,v1)
tri3= AddTriangle (surf,v0,v2,v5)

;TurnEntity cam,-80,0,0

EntityFX mesh,16
brush=CreateBrush()
BrushColor brush,200,10,200
BrushShininess brush,1
PaintEntity mesh,brush

While Not KeyHit(1)
	
	
	If KeyDown(200) Then
		scale=scale+0.1
		For loop=0 To 3
			VertexCoords(surf,loop,vert(loop,0)*scale, vert(loop,1)*scale, vert(loop,2)*scale)
		Next
	ElseIf KeyDown(208) Then
		scale=scale-0.1
		For loop=0 To 3
			VertexCoords(surf,loop,vert(loop,0)*scale, vert(loop,1)*scale, vert(loop,2)*scale)
		Next
	End If
	
	If KeyDown(203) Then TurnEntity cam,1,0,0
	If KeyDown(205) Then TurnEntity cam,-1,0,0
	
	TurnEntity light,1,1,0
	
	UpdateWorld
	RenderWorld
	Text 0,0," UP and DOWN to scale mesh. LEFT and RIGHT to rotate.
	Flip
Wend
End



Shambler(Posted 2003) [#2]
Stick updatenormals() in here..


UpdateNormals(mesh)
EntityFX mesh,16




Ross C(Posted 2003) [#3]
:) Thanks for that :D