MiniB3D Thread 2

BlitzMax Modules Forums/MiniB3D/MiniB3D Thread 2

Maybe I am doing something wrong, but it seems to me that lights are not working correctly. Use this code to test (cone simulates light, use numpad 1-2, 4-5, 7-8 to movelight in x-y-z).

Import "../MiniB3D.bmx"

Local width=640,height=480,depth=16,mode=0

Graphics3D width,height,depth,mode

Local cam=CreateCamera()
PositionEntity cam,0,10,-25

Local light=CreateLight(2)

Local ent=LoadAnimMesh("media/zombie.b3d")

Local cx#=0
Local cy#=0
Local cz#=0

Local pitch#=0
Local yaw#=0
Local roll#=0

Local px#, py#, pz#, lx#, ly#, lz#

Local anim_time#=0

' used by fps code
Local old_ms=MilliSecs()
Local renders
Local fps

Local sp = createcone(32)

Local liteRange# = 25
lightrange light, liteRange
positionentity light, 0, 0, 0
positionentity sp, 0, 0, 0

While Not KeyDown(KEY_ESCAPE)		

	If KeyHit(KEY_ENTER) Then DebugStop

	' control camera

	If KeyDown(KEY_UP) Then cz#=cz#+1.0
	If KeyDown(KEY_LEFT) Then cx#=cx#-1.0
	If KeyDown(KEY_RIGHT) Then cx#=cx#+1.0
	If KeyDown(KEY_DOWN) Then cz#=cz#-1.0
	
	If KeyDown(KEY_W) Then pitch#=pitch#-1.0
	If KeyDown(KEY_A) Then yaw#=yaw#+1.0
	If KeyDown(KEY_S) Then pitch#=pitch#+1.0
	If KeyDown(KEY_D) Then yaw#=yaw#-1.0

'	MoveEntity cam,cx#*0.5,cy#*0.5,cz#*0.5
'	RotateEntity cam,pitch#,yaw#,roll#
	
	cx#=0
	cy#=0
	cz#=0

	'

	If KeyDown(KEY_MINUS) Then anim_time#=anim_time#-0.1
	If KeyDown(KEY_EQUALS) Then anim_time#=anim_time#+0.1
	
	SetAnimTime(ent,anim_time#)

	MoveEntity cam,cx#,cy#,cz#
	RotateEntity ent,pitch#,yaw#,roll#

	cx#=0
	cy#=0
	cz#=0

	If KeyDown(KEY_NUM1) Then px#=px#-1.0
	If KeyDown(KEY_NUM2) Then px#=px#+1.0
	If KeyDown(KEY_NUM4) Then py#=py#+1.0
	If KeyDown(KEY_NUM5) Then py#=py#-1.0
	If KeyDown(KEY_NUM7) Then pz#=pz#-1.0
	If KeyDown(KEY_NUM8) Then pz#=pz#+1.0
	
	If KeyHit(KEY_SPACE) Then liteRange:+2
	lightrange light, liteRange

	positionentity light, px, py, pz
	positionentity sp, px, py, pz

	pointentity light, ent
	pointentity sp, ent
	
	
	lx:+px ; ly:+py ; lz:+pz

'	px = 0 ; py = 0 ; pz = 0

	RenderWorld
	renders=renders+1

	' calculate fps
	If MilliSecs()-old_ms>=1000
		old_ms=MilliSecs()
		fps=renders
		renders=0
	EndIf
	
	DebugText 0,0,"+/- to animate"
	DebugText 0,20,"FPS: "+String(fps)
	DebugText 0,40,"anim_time#: "+String(anim_time#)

	DebugText 0,100,"x: "+px
	DebugText 0,120,"y: "+py
	DebugText 0,140,"z: "+pz

	DebugText 0,200,"LR: "+liteRange

	Flip

Wend
End