primitives.bb 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. Global info1$="Primitives demo"
  2. Include "../start.bb"
  3. tex=CreateTexture( 64,64 )
  4. ScaleTexture tex,.125,.125
  5. SetBuffer TextureBuffer( tex )
  6. Color 64,192,255:Rect 32,0,32,32:Rect 0,32,32,32
  7. Color 255,255,255:Rect 0,0,32,32:Rect 32,32,32,32
  8. SetBuffer BackBuffer()
  9. Color 255,255,255
  10. cam=CreateCamera()
  11. PositionEntity cam,0,0,-6
  12. light=CreateLight()
  13. TurnEntity light,45,45,0
  14. segs=16
  15. rebuild=True
  16. brush=CreateBrush()
  17. BrushTexture brush,tex
  18. pivot=CreatePivot()
  19. While Not KeyHit(1)
  20. If KeyHit(17)
  21. wire=Not wire
  22. WireFrame wire
  23. EndIf
  24. If KeyHit(26)
  25. If segs>3 Then segs=segs-1:rebuild=True
  26. Else If KeyHit(27)
  27. If segs<100 Then segs=segs+1:rebuild=True
  28. EndIf
  29. If rebuild
  30. If cube FreeEntity cube
  31. If sphere FreeEntity sphere
  32. If cylinder FreeEntity cylinder
  33. If cone FreeEntity cone
  34. cube=CreateCube( pivot )
  35. PaintEntity cube,brush
  36. PositionEntity cube,-3,0,0
  37. cylinder=CreateCylinder( segs,True,pivot )
  38. PaintEntity cylinder,brush
  39. PositionEntity cylinder,1,0,0
  40. cone=CreateCone( segs,True,pivot )
  41. PaintEntity cone,brush
  42. PositionEntity cone,-1,0,0
  43. sphere=CreateSphere( segs,pivot )
  44. PaintEntity sphere,brush
  45. PositionEntity sphere,3,0,0
  46. rebuild=False
  47. EndIf
  48. If KeyDown(203) TurnEntity pivot,0,-3,0
  49. If KeyDown(205) TurnEntity pivot,0,+3,0
  50. If KeyDown(200) TurnEntity pivot,-3,0,0
  51. If KeyDown(208) TurnEntity pivot,+3,0,0
  52. If KeyDown(30) TranslateEntity pivot,0,0,-.2
  53. If KeyDown(44) TranslateEntity pivot,0,0,+.2
  54. UpdateWorld
  55. RenderWorld
  56. Text 0,0,"Segs="+segs+" - [] to adjust, 'W' for wireframe"
  57. Flip
  58. Wend
  59. End