EntityInView.htm 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <html>
  2. <head>
  3. <title>Blitz3D Docs</title>
  4. <link rel=stylesheet href=../css/commands.css type=text/css>
  5. </head>
  6. <body>
  7. <h1>EntityInView ( entity,camera )</h1>
  8. <h1>Parameters</h1>
  9. <table>
  10. <tr>
  11. <td>
  12. entity - entity handle <br />
  13. camera - camera handle
  14. </td>
  15. </tr>
  16. </table>
  17. <h1>Description</h1>
  18. <table>
  19. <tr>
  20. <td>
  21. Returns true if the specified entity is visible to the specified camera. <br />
  22. <br />
  23. If the entity is a mesh, its bounding box will be checked for visibility. <br />
  24. <br />
  25. For all other types of entities, only their centre position will be checked.
  26. </td>
  27. </tr>
  28. </table>
  29. <h1><a href=../3d_examples/EntityInView.bb>Example</a></h1>
  30. <table>
  31. <tr>
  32. <td>
  33. ; EntityInView Example <br />
  34. ; -------------------- <br />
  35. <br />
  36. Graphics3D 640,480 <br />
  37. SetBuffer BackBuffer() <br />
  38. <br />
  39. camera=CreateCamera() <br />
  40. PositionEntity camera,0,2,-10 <br />
  41. <br />
  42. light=CreateLight() <br />
  43. RotateEntity light,90,0,0 <br />
  44. <br />
  45. plane=CreatePlane() <br />
  46. ground_tex=LoadTexture("media/Chorme-2.bmp") <br />
  47. EntityTexture plane,ground_tex <br />
  48. <br />
  49. cube=CreateCube() <br />
  50. cube_tex=LoadTexture("media/b3dlogo.jpg") <br />
  51. EntityTexture cube,cube_tex <br />
  52. PositionEntity cube,0,1,0 <br />
  53. <br />
  54. While Not KeyDown( 1 ) <br />
  55. <br />
  56. If KeyDown( 205 )=True Then TurnEntity camera,0,-1,0 <br />
  57. If KeyDown( 203 )=True Then TurnEntity camera,0,1,0 <br />
  58. If KeyDown( 208 )=True Then MoveEntity camera,0,0,-0.05 <br />
  59. If KeyDown( 200 )=True Then MoveEntity camera,0,0,0.05 <br />
  60. <br />
  61. ; Use camera project to get 2D coordinates from 3D coordinates of cube <br />
  62. CameraProject(camera,EntityX(cube),EntityY(cube),EntityZ(cube)) <br />
  63. <br />
  64. RenderWorld <br />
  65. <br />
  66. ; If cube is in view then draw text, if not then draw nothing otherwise text will be drawn at 0,0 <br />
  67. If EntityInView(cube,camera)=True <br />
  68. <br />
  69. ; Use ProjectedX() and ProjectedY() to get 2D coordinates from when CameraProject was used. <br />
  70. ; Use these coordinates to draw text at a 2D position, on top of a 3D scene. <br />
  71. Text ProjectedX#(),ProjectedY#(),"Cube" <br />
  72. <br />
  73. EndIf <br />
  74. <br />
  75. Text 0,0,"Use cursor keys to move about" <br />
  76. Text 0,20,"ProjectedX: "+ProjectedX#() <br />
  77. Text 0,40,"ProjectedY: "+ProjectedY#() <br />
  78. Text 0,60,"ProjectedZ: "+ProjectedZ#() <br />
  79. Text 0,80,"EntityInView: "+EntityInView(cube,camera) <br />
  80. <br />
  81. Flip <br />
  82. <br />
  83. Wend <br />
  84. <br />
  85. End
  86. </td>
  87. </tr>
  88. </table>
  89. <br>
  90. <a target=_top href=../index.htm>Index</a><br>
  91. <br>
  92. Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=EntityInView&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
  93. </html>