Vertex lighting.

Blitz3D Forums/Blitz3D Programming/Vertex lighting.

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.

We've done this a few times -- seems that copyentity() is faster than creating something new from scratch but not as fast as a manual single-surface system.

When I wrote Ice-Teroids I used copyentity() on a source mesh to create particles and the surface handle for each was the same. See this:

Graphics3D 800,600,0,2
SetBuffer BackBuffer()
cam=CreateCamera() : PositionEntity cam,0,0,-50
galacticCentralPoint=CreatePivot()
light=CreateLight() : PositionEntity light,50,50,-50

Type cube
	Field entity
	Field identity
	Field description$
End Type
currentCube.cube=Null
cubeTemplate=CreateCube() : HideEntity cubeTemplate

For i=1 To 15
	currentCube=New cube
	currentCube\entity=CopyEntity(cubeTemplate,galacticCentralPoint)
	currentCube\identity=i
	currentCube\description$="Copied"
	PositionEntity currentCube\entity,Rnd(-30,30),Rnd(-30,30),Rnd(-30,30)
	EntityColor currentCube\entity,100+Rand(0,155),100+Rand(0,155),100+Rand(0,155)
Next

For i=16 To 30
	currentCube=New cube
	currentCube\entity=CreateCube(galacticCentralPoint)
	currentCube\identity=i
	currentCube\description$="Created"
	PositionEntity currentCube\entity,Rnd(-30,30),Rnd(-30,30),Rnd(-30,30)
	EntityColor currentCube\entity,100+Rand(0,155),100+Rand(0,155),100+Rand(0,155)
Next

While Not KeyHit(1)

TurnEntity galacticCentralPoint,0.2,0.5,0.8
RenderWorld

Locate 0,0
For currentCube=Each cube
	For currentSurface=1 To CountSurfaces (currentCube\entity)
		Print "Cube "+currentCube\identity+" ("+currentCube\description$+"), Surface "+currentSurface+", Handle: "+GetSurface(currentCube\entity,currentSurface)
	Next
	If currentCube\identity=15 Then Print
Next

Flip
Wend


EDIT: Slightly updated to show handle difference in created entities' surfaces.