FitMesh.htm 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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>FitMesh mesh,x#,y#,z#,width#,height#,depth#[,uniform]</h1>
  8. <h1>Parameters</h1>
  9. <table>
  10. <tr>
  11. <td>
  12. mesh - mesh handle <br />
  13. x# - x position of mesh <br />
  14. y# - y position of mesh <br />
  15. z# - z position of mesh <br />
  16. width# - width of mesh <br />
  17. height# - height of mesh <br />
  18. depth# - depth of mesh <br />
  19. uniform (optional) - if true, the mesh will be scaled by the same amounts in x, y and z, so will not be distorted. Defaults to false.
  20. </td>
  21. </tr>
  22. </table>
  23. <h1>Description</h1>
  24. <table>
  25. <tr>
  26. <td>
  27. Scales and translates all vertices of a mesh so that the mesh occupies the specified box. <br />
  28. <br />
  29. Do not use a width#, height# or depth# value of 0, otherwise all mesh data will be destroyed and your mesh will not be displayed. Use a value of 0.001 instead for a flat mesh along one axis.
  30. <br>
  31. <br>
  32. See also: <a class=small href=ScaleMesh.htm>ScaleMesh</a>, <a class=small href=ScaleEntity.htm>ScaleEntity</a>.
  33. </td>
  34. </tr>
  35. </table>
  36. <h1><a href=../3d_examples/FitMesh.bb>Example</a></h1>
  37. <table>
  38. <tr>
  39. <td>
  40. ; FitMesh Example <br />
  41. ; --------------- <br />
  42. <br />
  43. ; In this example we will demonstrate the use of the FitMesh command. <br />
  44. <br />
  45. ; First we will use FitMesh on a semi-transparent blue box. This will represent the dimensions we will <br />
  46. ; be using with FitMesh. <br />
  47. <br />
  48. ; Then we will use these dimensions on a red cone, so that it appears to fit inside the box when the <br />
  49. ; space bar is pressed. <br />
  50. <br />
  51. ; The first time the space bar is pressed a uniform FitMesh will be performed, which means the cone <br />
  52. ; will be scaled equally along all axis so that at least one axis fits the dimensions specified. <br />
  53. <br />
  54. ; The second time the space bar is pressed a non-unifrom FitMesh will be performed, meaning the cone <br />
  55. ; will be scaled non-equally along all axes so that all axes fit the dimensions specified. <br />
  56. <br />
  57. Graphics3D 640,480 <br />
  58. SetBuffer BackBuffer() <br />
  59. <br />
  60. camera=CreateCamera() <br />
  61. light=CreateLight() <br />
  62. <br />
  63. ; Create cube <br />
  64. cube=CreateCube() <br />
  65. <br />
  66. ; Set cube colour to blue <br />
  67. EntityColor cube,0,0,255 <br />
  68. <br />
  69. ; Make cube semi-transparent so we will be able to see cone inside it later <br />
  70. EntityAlpha cube,0.5 <br />
  71. <br />
  72. ; Use FitMesh on cube to make it a cuboid <br />
  73. FitMesh cube,-1,-.5,-1,2,1,2 <br />
  74. <br />
  75. ; Position cube in front of camera so we can see it <br />
  76. PositionEntity cube,0,-1,5 <br />
  77. <br />
  78. ; Create cone <br />
  79. cone=CreateCone() <br />
  80. <br />
  81. ; Set cone color to red <br />
  82. EntityColor cone,255,0,0 <br />
  83. <br />
  84. ; Position cone in front of camera so we can see it <br />
  85. PositionEntity cone,0,-1,5 <br />
  86. <br />
  87. ; Set uniform value to 1 so when space is first pressed, FitMesh will be uniform <br />
  88. uniform=1 <br />
  89. <br />
  90. While Not KeyDown(1) <br />
  91. <br />
  92. ; If space bar pressed.... <br />
  93. If KeyHit(57)=True <br />
  94. <br />
  95. ; Set syntax string to show syntax useage <br />
  96. syntax$="FitMesh cone,-1,-.5,-1,2,1,2,"+uniform <br />
  97. <br />
  98. ; Use FitMesh with cone, using same values as used with cube earlier. Cone should now fit in cube. <br />
  99. FitMesh cone,-1,-.5,-1,2,1,2,uniform <br />
  100. <br />
  101. ; Change uniform value from 1 to 0 so when space bar is pressed again FitMesh will be non-uniform <br />
  102. uniform=0 <br />
  103. <br />
  104. EndIf <br />
  105. <br />
  106. RenderWorld <br />
  107. <br />
  108. Text 0,0,"Press space to use uniform FitMesh with cone" <br />
  109. Text 0,20,"Press space again to use non-uniform FitMesh with cone" <br />
  110. Text 0,40,syntax$ <br />
  111. <br />
  112. Flip <br />
  113. <br />
  114. Wend <br />
  115. <br />
  116. End
  117. </td>
  118. </tr>
  119. </table>
  120. <br>
  121. <a target=_top href=../index.htm>Index</a><br>
  122. <br>
  123. Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=FitMesh&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
  124. </html>