AddVertex.htm 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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>AddVertex ( surface,x#,y#,z#[,u#][,v#][,w#] )</h1>
  8. <h1>Parameters</h1>
  9. <table>
  10. <tr>
  11. <td>
  12. surface - surface handle <br />
  13. x# - x coordinate of vertex <br />
  14. y# - y coordinate of vertex <br />
  15. z# - z coordinate of vertex <br />
  16. u# (optional) - u texture coordinate of vertex <br />
  17. v# (optional) - v texture coordinate of vertex <br />
  18. w# (optional) - w texture coordinate of vertex - not used, included for future expansion
  19. </td>
  20. </tr>
  21. </table>
  22. <h1>Description</h1>
  23. <table>
  24. <tr>
  25. <td>
  26. Adds a vertex to the specified surface and returns the vertices' index number, starting from 0. <br />
  27. <br />
  28. x,y,z are the geometric coordinates of the vertex, and u,v,w are texture mapping coordinates. <br />
  29. <br />
  30. A vertex is a point in 3D space which is used to connect edges of a triangle together. Without any vertices, you can't have any triangles. At least three vertices are needed to create one triangle; one for each corner. <br />
  31. <br />
  32. The optional u, v and w parameters allow you to specify texture coordinates for a vertex, which will determine how any triangle created using those vertices will be texture mapped. The u, v and w parameters specified will take effect on both texture coordinate sets (0 and 1). This works on the following basis: <br />
  33. <br />
  34. The top left of an image has the uv coordinates 0,0. <br />
  35. The top right has coordinates 1,0 <br />
  36. The bottom right is 1,1. <br />
  37. The bottom left 0,1. <br />
  38. <br />
  39. Thus, uv coordinates for a vertex correspond to a point in the image. For example, coordinates 0.9,0.1 would be near the upper right corner of the image. <br />
  40. <br />
  41. So now imagine you have a normal equilateral triangle. By assigning the bottom left vertex a uv coordinate of 0,0, the bottom right a coordinate of 1,0 and the top centre 0.5,1, this will texture map the triangle with an image that fits it. <br />
  42. <br />
  43. When adding a vertex its default color is 255,255,255,255.
  44. </td>
  45. </tr>
  46. </table>
  47. <h1><a href=../3d_examples/AddVertex.bb>Example</a></h1>
  48. <table>
  49. <tr>
  50. <td>
  51. Graphics3D 640,480 <br />
  52. SetBuffer BackBuffer() <br />
  53. <br />
  54. mesh = CreateMesh() <br />
  55. surf = CreateSurface(mesh) <br />
  56. <br />
  57. v0 = AddVertex (surf, -5,-5,0, 0 ,0) <br />
  58. v1 = AddVertex (surf, 5,-5,0, 1 ,0) <br />
  59. v2 = AddVertex (surf, 0, 5,0, 0.5,1) <br />
  60. <br />
  61. tri = AddTriangle (surf,v0,v2,v1) <br />
  62. <br />
  63. cam = CreateCamera() <br />
  64. MoveEntity cam, 0,0,-7 <br />
  65. <br />
  66. RenderWorld <br />
  67. Flip <br />
  68. <br />
  69. WaitKey <br />
  70. End
  71. </td>
  72. </tr>
  73. </table>
  74. <br>
  75. <a target=_top href=../index.htm>Index</a><br>
  76. <br>
  77. Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=AddVertex&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
  78. </html>