flag.bb 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. Global info1$="Flag demo"
  2. Global info2$="Features mesh deformation"
  3. Include "../start.bb"
  4. Const segs=128,width#=4,depth#=.125
  5. mesh=CreateMesh()
  6. surf=CreateSurface( mesh )
  7. For k=0 To segs
  8. x#=Float(k)*width/segs-width/2
  9. u#=Float(k)/segs
  10. AddVertex surf,x,1,0,u,0
  11. AddVertex surf,x,-1,0,u,1
  12. Next
  13. For k=0 To segs-1
  14. AddTriangle surf,k*2,k*2+2,k*2+3
  15. AddTriangle surf,k*2,k*2+3,k*2+1
  16. Next
  17. b=LoadBrush( "b3dlogo.jpg" )
  18. PaintSurface surf,b
  19. camera=CreateCamera()
  20. PositionEntity camera,0,0,-5
  21. light=CreateLight()
  22. TurnEntity light,45,45,0
  23. While Not KeyHit(1)
  24. ph#=MilliSecs()/4
  25. cnt=CountVertices(surf)-1
  26. For k=0 To cnt
  27. x#=VertexX(surf,k)
  28. y#=VertexY(surf,k)
  29. z#=Sin(ph+x*300)*depth
  30. VertexCoords surf,k,x,y,z
  31. Next
  32. UpdateNormals mesh
  33. If KeyDown(26) TurnEntity camera,0,1,0
  34. If KeyDown(27) TurnEntity camera,0,-1,0
  35. If KeyDown(30) MoveEntity camera,0,0,.1
  36. If KeyDown(44) MoveEntity camera,0,0,-.1
  37. If KeyDown(203) TurnEntity mesh,0,1,0,True
  38. If KeyDown(205) TurnEntity mesh,0,-1,0,True
  39. If KeyDown(200) TurnEntity mesh,1,0,0,True
  40. If KeyDown(208) TurnEntity mesh,-1,0,0,True
  41. UpdateWorld
  42. RenderWorld
  43. Flip
  44. Wend
  45. End