TheHead.bb 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. Global info1$="The Head Demo, by Adam Gore"
  2. Include "../start.bb"
  3. Include "KBSplines.bb"
  4. Const FPS = 24
  5. Global fstep
  6. period=1000/FPS
  7. time=MilliSecs()-period
  8. headmot.Motion = New Motion
  9. eyetmot.Motion = New Motion
  10. If Load_Motion( "Head.bbm", headmot ) = False Then RuntimeError "Error loading file" : End
  11. If Load_Motion( "EyeFocus.bbm", eyetmot ) = False Then RuntimeError "Error loading file" : End
  12. camera=CreateCamera()
  13. CameraRange camera,.05,150
  14. PositionEntity camera,0,0,-1
  15. RotateEntity camera,0,0,0
  16. mesh_head = LoadMesh("Head.x")
  17. mesh_reye = LoadMesh("Eye.x",mesh_head)
  18. brush=LoadBrush( "Eye.jpg",1)
  19. BrushShininess brush,1
  20. PaintMesh mesh_reye,brush
  21. mesh_leye = CopyEntity(mesh_reye,mesh_head)
  22. piv_eyet = CreatePivot(mead_hesh)
  23. bkgd=CreateMesh()
  24. s=CreateSurface(bkgd)
  25. AddVertex s,+1,+1,+1,0,0:AddVertex s,-1,+1,+1,1,0
  26. AddVertex s,-1,-1,+1,1,1:AddVertex s,+1,-1,+1,0,1
  27. AddTriangle s,0,1,2:AddTriangle s,0,2,3
  28. ScaleMesh bkgd,130,130,100;225,225,225
  29. EntityFX bkgd,1
  30. FlipMesh bkgd
  31. EntityOrder bkgd,10
  32. PositionEntity mesh_reye,-.058,.256,-.146
  33. PositionEntity mesh_leye,.058,.256,-.146
  34. tex0=LoadTexture("Face.jpg")
  35. tex1=LoadTexture("Reflection.jpg",64)
  36. tex2=LoadTexture("Bkgd.jpg")
  37. EntityTexture mesh_head,tex0
  38. EntityTexture bkgd,tex2
  39. AmbientLight 5,5,5
  40. light1=CreateLight(1)
  41. LightColor light1,255,255,255
  42. RotateEntity light1,0,60,0
  43. light2=CreateLight(1)
  44. LightColor light2,200,0,0
  45. RotateEntity light2,-5,-95,0
  46. fstep = 1
  47. Apply_Motion(headmot,fstep,mesh_head)
  48. Apply_Motion(eyetmot,fstep,piv_eyet)
  49. While KeyHit(1)<>True
  50. Repeat
  51. elapsed=MilliSecs()-time
  52. Until elapsed
  53. ticks=elapsed/period
  54. tween#=Float(elapsed Mod period)/Float(period)
  55. For k=1 To ticks
  56. time=time+period
  57. If k=ticks Then CaptureWorld
  58. fstep = fstep + 1 : If fstep > headmot\nsteps Then fstep = 1
  59. Apply_Motion(headmot,fstep,mesh_head)
  60. Apply_Motion(eyetmot,fstep,piv_eyet)
  61. PointEntity mesh_reye,piv_eyet : PointEntity mesh_leye,piv_eyet
  62. TurnEntity bkgd,0,0,1
  63. If fstep = 574 EntityTexture mesh_head,tex1
  64. If fstep = 1 EntityTexture mesh_head,tex0
  65. UpdateWorld
  66. Next
  67. RenderWorld tween
  68. Flip
  69. Wend
  70. End