cameraprojmode.bmx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. ' cameraprojmode.bmx
  2. ' from minib3d examples
  3. Strict
  4. Framework b3d.b3dglgraphics
  5. Graphics3D 800,600,0
  6. Local camera:TCamera=CreateCamera()
  7. PositionEntity camera,0,0,-10
  8. Local light:TLight=CreateLight()
  9. RotateEntity light,0,0,0
  10. ' create cube 1, near to camera
  11. Local cube1:TMesh=CreateCube()
  12. EntityColor cube1,255,0,0
  13. PositionEntity cube1,0,0,0
  14. ' create cube 2, same size as cube 1 but further away
  15. Local cube2:TMesh=CreateCube()
  16. EntityColor cube2,0,255,0
  17. PositionEntity cube2,5,5,5
  18. ' camera proj mode value
  19. Local Mode%=1, zoom#
  20. While Not KeyDown(KEY_ESCAPE)
  21. ' If spacebar pressed then change mode value
  22. If KeyHit(KEY_SPACE)=True Then Mode=Mode+1 ; If Mode=3 Then Mode=0
  23. ' If mode value = 2 (orthagraphic), then reduce zoom value To 0.1
  24. If Mode=2 Then zoom=0.1 Else zoom=1
  25. ' set camera projection mode using mode value
  26. CameraProjMode camera,Mode
  27. ' set camera zoom using zoom value
  28. CameraZoom camera,zoom
  29. RenderWorld
  30. Text 0,0,"Press spacebar to change the camera project mode"
  31. Text 0,20,"CameraProjMode camera,"+Mode
  32. Text 0,40,"CameraZoom camera,"+zoom
  33. Flip
  34. Wend
  35. End