Problems with lighting

BlitzMax Forums/BlitzMax Beginners Area/Problems with lighting

PowerPC603(Posted 2005) [#1]
Hi,

I'm trying to create a 3D maze generator and I already wrote some functions to create 2 kinds of pathways.

I create a new mesh, add a surface to it.
After this, I add vertexes and triangles via functions.
This all works perfectly, but the mesh isn't affected by lights.

I placed a light in the scene, disabled ambient light, but no lighting effect on my mesh.
I even painted a brush onto my mesh, but still nothing.
I added a plane beneath the mesh and this is affect by the light.

How can I make my mesh light-sensitive?

Graphics3D 800, 600
SetBuffer BackBuffer()



plane = CreatePlane()
EntityColor plane, 255, 0, 0

camera = CreateCamera()
MoveEntity camera, 0, 8, 0

brush = CreateBrush(0, 255, 0)

AmbientLight 0,0,0
light = CreateLight(2)
MoveEntity light, 0, 15, 0
LightColor light, 255, 255, 255



Global MazeMesh = CreateMesh()
Global MazeSurf = CreateSurface(MazeMesh, brush)

CreateUpDown(0, 20)
CreateLeftRight(0, 20)



While Not KeyHit(1)
	If KeyDown(200) TurnEntity camera, -1, 0, 0 ; Up arrow
	If KeyDown(208) TurnEntity camera, 1, 0, 0 ; Down arrow
	If KeyDown(203) TurnEntity camera, 0, -1, 0 ; Left arrow
	If KeyDown(205) TurnEntity camera, 0, 1, 0 ; Right arrow

	If KeyDown(75) MoveEntity camera, -1, 0, 0 ; Num4
	If KeyDown(77) MoveEntity camera, 1, 0, 0 ; Num6
	If KeyDown(72) MoveEntity camera, 0, 0, 1 ; Num8
	If KeyDown(80) MoveEntity camera, 0, 0, -1 ; Num2

	RenderWorld
	Flip
Wend



Function CreateUpDown(x, z)
	; Create the left wall
	v0 = AddVertex(MazeSurf, x - 9, 0, z - 10)
	v1 = AddVertex(MazeSurf, x - 9, 0, z + 10)
	v2 = AddVertex(MazeSurf, x - 9, 5, z - 10)
	v3 = AddVertex(MazeSurf, x - 9, 5, z + 10)

	t0 = AddTriangle(MazeSurf, v0, v2, v1)
	t1 = AddTriangle(MazeSurf, v1, v2, v3)

	; Create the right wall
	v0 = AddVertex(MazeSurf, x + 9, 0, z + 10)
	v1 = AddVertex(MazeSurf, x + 9, 0, z - 10)
	v2 = AddVertex(MazeSurf, x + 9, 5, z + 10)
	v3 = AddVertex(MazeSurf, x + 9, 5, z - 10)

	t0 = AddTriangle(MazeSurf, v0, v2, v1)
	t1 = AddTriangle(MazeSurf, v1, v2, v3)
End Function

Function CreateLeftRight(x, z)
	; Create the bottom wall
	v0 = AddVertex(MazeSurf, x - 10, 0, z - 9)
	v1 = AddVertex(MazeSurf, x + 10, 0, z - 9)
	v2 = AddVertex(MazeSurf, x - 10, 5, z - 9)
	v3 = AddVertex(MazeSurf, x + 10, 5, z - 9)

	t0 = AddTriangle(MazeSurf, v0, v1, v3)
	t1 = AddTriangle(MazeSurf, v0, v3, v2)

	; Create the top wall
	v0 = AddVertex(MazeSurf, x - 10, 0, z + 9)
	v1 = AddVertex(MazeSurf, x + 10, 0, z + 9)
	v2 = AddVertex(MazeSurf, x - 10, 5, z + 9)
	v3 = AddVertex(MazeSurf, x + 10, 5, z + 9)

	t0 = AddTriangle(MazeSurf, v0, v2, v1)
	t1 = AddTriangle(MazeSurf, v1, v2, v3)
End Function



PowerPC603(Posted 2005) [#2]
Damn, wrong forum, it's for B3D.