ProjectedZ.htm 2.4 KB

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