December 03, 2020, 08:28:37 PM

Author Topic: [bb] Basic Multiple Orthographic Camera Views by _PJ_ [ 1+ years ago ]  (Read 589 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
Title : Basic Multiple Orthographic Camera Views
Author : _PJ_
Posted : 1+ years ago

Description : Gives a working, orthographic projection of a scene in wireframe with separate camera viewports fro Top View, Side View and Front View, but also adding a rendered, elevated camera view.

The code is quite static as is, but should be easy to incorporate the principle to any given scenario.


Code :
Code: BlitzBasic
  1. Graphics3D 800,600
  2. SetBuffer BackBuffer() ; Set Scene
  3.  
  4. cone=CreateCone(6)    ;Set example entities
  5. cube=CreateCube()     ;Set example Entities
  6.  
  7. EntityColor cube,255,128,128 ;add effects to entities
  8. EntityColor cone,128,128,64  ;add effects to entities
  9.  
  10. effectlight=CreateLight(1)   ; add lighting
  11. PositionEntity effectlight,40,30,40  ; set lighting
  12. PointEntity effectlight,cube ; etc. etc.
  13.  
  14. ;TOP VIEW CAMERA
  15. topcam=CreateCamera() ;create camera
  16. CameraViewport topcam,0,(GraphicsHeight()/2),GraphicsWidth()/2,(GraphicsHeight()/2); set viewport
  17. CameraProjMode topcam,2 ; make view orthogonal
  18.  
  19. ;SIDE VIEW CAMERA
  20. sidecam=CreateCamera()
  21. CameraViewport sidecam,0,0,GraphicsWidth()/2,GraphicsHeight()/2
  22. CameraProjMode sidecam,2
  23.  
  24. ;FRONT VIEW CAMERA
  25. frontcam=CreateCamera()
  26. CameraViewport frontcam,GraphicsWidth()/2,0,width,GraphicsHeight()/2
  27. CameraProjMode frontcam,2
  28.  
  29. rendercam=CreateCamera()
  30. CameraViewport rendercam,GraphicsWidth()/2,GraphicsHeight()/2,GraphicsWidth()/2,GraphicsHeight()/2
  31.  
  32.  
  33. ;Set object positions
  34. PositionEntity cone,50,0,50
  35.  
  36. PositionEntity cube,52,0,50
  37.  
  38. PositionEntity topcam, 51,10,50
  39. PositionEntity sidecam, 61,0,50
  40. PositionEntity frontcam, 51,0,60
  41. PositionEntity rendercam, 56,5,55
  42.  
  43. ;point cameras
  44. PointEntity topcam,cone
  45. TurnEntity topcam,0,0,180
  46. PointEntity sidecam,cone
  47. PointEntity frontcam,cone
  48. PointEntity rendercam,cone
  49.  
  50. EntityParent topcam,cone
  51. EntityParent sidecam,cone
  52. EntityParent frontcam,cone
  53. EntityParent rendercam,cone
  54.  
  55.  
  56. ;MAIN LOOP
  57. While Not KeyDown(1)
  58.  
  59. ;movement by cursor keys
  60. TranslateEntity cone,(KeyDown(208)-KeyDown(200)),0,0
  61. TranslateEntity cone,0,0,(KeyDown(203)-KeyDown(205))
  62.  
  63. ;Rendering
  64. WireFrame True
  65.  
  66.  
  67. HideEntity rendercam
  68. ShowEntity sidecam
  69. ShowEntity topcam
  70. ShowEntity frontcam
  71.  
  72. RenderWorld
  73. Flip
  74.  
  75. WireFrame False
  76.  
  77. ShowEntity rendercam
  78. HideEntity sidecam
  79. HideEntity topcam
  80. HideEntity frontcam
  81.  
  82. RenderWorld
  83. Flip
  84.  
  85. Wend
  86.  
  87. ;END OF PROGRAM
  88.  
  89. ;EndGraphics
  90. End


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal