OK, here's a demo using the above library.
- Save the above code as LIB_show_normals.bb
- Save the following code into the same folder as the lib, before running.
- Save the above code as LIB_show_normals.bb
- Save the following code into the same folder as the lib, before running.
; ; Simple demonstration of LIB_show_normals.bb library usage ; ; by big10p (A.K.A. Chris Chadwick) 2004. ; ; Written with Blitz3D v1.86 ; Graphics3D 800,600,32 SetBuffer BackBuffer() Include "LIB_show_normals.bb" WireFrame 0 AntiAlias 0 SeedRnd MilliSecs() Global frame_count% Global fps% Global slowest_fps% Global fps_timeout% Global frame_time% Global slowest_frame% Global frame_start% fps_timer = CreateTimer(60) slowmo% = False wiref% = False ent_scale# = 1.0 ent_scaler# = 0.01 cam = CreateCamera() PositionEntity cam,0,0,-10 light = CreateLight() piv = CreatePivot() PositionEntity piv,0,1,0 RotateEntity piv,-30,0,0 cube = CreateCube(piv) PositionEntity cube,0,0,5 EntityFX cube,16 show_normals(cube,0,255,0) ball = CreateSphere(8,piv) PositionEntity ball,-5,0,0 EntityFX ball,16 show_normals(ball) cone = CreateCone(32,1,piv) UpdateNormals cone ; B3D cone encap normals are wrong! Remove this line to see. PositionEntity cone,0,0,-5 EntityFX cone,16 show_normals(cone,255,0,0) cylinder = CreateCylinder(16,1,piv) PositionEntity cylinder,5,0,0 EntityFX cylinder,16 show_normals(cylinder,255,255,0) ; --- Main loop --- While Not KeyHit(1) frame_start = MilliSecs() If KeyHit(31) Then slowmo = Not slowmo If KeyHit(17) wiref = Not wiref WireFrame wiref EndIf TurnEntity piv,0,.5,.1 TurnEntity ball,.5,.5,.5 TurnEntity cone,-.5,.5,-.5 TurnEntity cube,.5,0,.5 TurnEntity cylinder,-.5,-.5,-.5 ScaleEntity ball,1,ent_scale,1 ScaleEntity cone,ent_scale,1,ent_scale ScaleEntity cube,1,ent_scale,1 ScaleEntity cylinder,1,ent_scale,1 If ent_scale>2 Or ent_scale<.2 Then ent_scaler = -ent_scaler ent_scale = ent_scale + ent_scaler UpdateWorld RenderWorld render_normals(cam,wiref) Text 10,10,"Press W to toggle wireframe." Text 10,25,"Press S to toggle slowmo." frame_time = MilliSecs() - frame_start WaitTimer(fps_timer) Flip(1) If slowmo Then Delay 200 Wend ClearWorld End