| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
- <html>
- <head>
- <title>Planes</title>
- </head>
- <body>
- <center><h1><font face="Verdana">Introduction to Meshes</font></h1></center>
- <p><font face="Verdana">Meshes are the entities you will most frequently be
- working with - unless you're writing something weird (please do...)!</font>
- </p>
- <p><font face="Verdana">Meshes are made up of vertices and triangles, and can be
- either loaded from files (perhaps the result of a 3d modeler program), or built
- 'by hand'. (assembled from within a B3d program in realtime)</font>
- </p>
- <h2><font face="Verdana"><span style="background-color: #6097C9"> Loading
- Meshes </span></font></h2>
- <p><font face="Verdana">There are 2 commands provided for loading meshes from
- files - 'LoadMesh' and 'LoadAnimMesh', both of which load a '.X' or '.3DS' file
- and return an entity. So what's the difference ?</font>
- </p>
- <p><font face="Verdana">Models stored in files are usually made up of several
- 'parts'. In the case of a character model, these parts may represent arms, legs
- etc.</font>
- </p>
- <p><font face="Verdana">In addition, files also contain animation information
- with the 'LoadAnimMesh' command. The entity returned will actually be the parent
- entity of the whole bunch of child 'parts'.</font>
- </p>
- <p><font face="Verdana">Therefore, 'LoadAnimMesh' really loads in several meshes
- !</font>
- </p>
- <p><font face="Verdana">If you don't need to animate a model, you can use 'LoadMesh'
- instead. This will 'collapse' all the parts in a mesh and return a single,
- combined mesh. The collapsed mesh will look the same as a mesh loaded with
- LoadAnimMesh, only you wont be able to animate it, and it wont have any child
- meshes.</font>
- </p>
- <p><font face="Verdana">Why bother with LoadMesh at all ? SPEED! - It's faster
- for B3D to deal with a single mesh than with multiple meshes, so if you're not
- planning to animate or doing anything tricky with a mesh, use LoadMesh.</font>
- </p>
- <h2><font face="Verdana"><span style="background-color: #6097C9"> Creating
- Meshes </span></font></h2>
- <p><font face="Verdana">Before looking closely at creating meshes, you'll need
- to know about 'Brushes' in Blitz3D. A brush is a collection of properties used
- when rendering triangles. These properties are:</font>
- </p>
- <ul>
- <li><font face="Verdana"><b>Colour</b> - The colour a triangle is rendered in.
- (see BrushColor)<br>
- </font></li>
- <li><font face="Verdana"><b>Texture</b> - From 0 to 8 texture maps that are
- used to render a triangle. (see BrushTexture)<br>
- </font></li>
- <li><font face="Verdana"><b>Alpha</b> - How transparent a triangle is. Alpha
- can range from 0 (completely transparent) to 1 (completely opaque). (see
- BrushAlpha)<br>
- </font></li>
- <li><font face="Verdana"><b>Shininess</b> - How 'shiny' a triangle is. This
- value can range from 0 (not shiny) to 1 (really shiny!). (see BrushShininess)<br>
- </font></li>
- <li><font face="Verdana"><b>Blend</b> - The blend mode used to render a
- triangle. Blend mode describes how a triangle is combined with what's
- already on the screen. (see BrushBlend)<br>
- </font></li>
- <li><font face="Verdana"><b>FX</b> - Optional special effects for rendering.
- (see BrushFX)<br>
- </font></li>
- </ul>
- <p><font face="Verdana">To create a brush, you use the CreateBrush command:</font></p>
- <table border="1" width="100%" bordercolor="#FFFFFF">
- <tr>
- <td width="14%"> </td>
- <td width="72%" bordercolor="#000000" bgcolor="#C0C0C0"> <br>
-
- <font face="Arial">;create a brush.<br>
- <b>brush=CreateBrush()</b><br></font><br>
-
- </td>
- <td width="14%"> </td>
- </tr>
- </table>
- <p><font face="Verdana">Once we have a brush, we can set its properties:</font>
- </p>
- <table border="1" width="100%" bordercolor="#FFFFFF">
- <tr>
- <td width="14%"> </td>
- <td width="72%" bordercolor="#000000" bgcolor="#C0C0C0"> <br>
-
- <font face="Arial">;a red brush.<br>
- <b>BrushColor brush,255,255,0</b></font>
- <p><font face="Arial"> a shiny red brush. <br>
- </font> <font face="Arial"><b>BrushShininess brush,1</b></font><br><br>
-
- </p>
-
- </td>
- <td width="14%"> </td>
- </tr>
- </table>
- <p><font face="Verdana">So what has all this got to do with meshes ?</font>
- </p>
- <p><font face="Verdana">Well, when I said meshes are made up of vertices and
- triangles, I sort of lied !. Meshes are actually made of 'surfaces', and
- surfaces are made up of vertices and triangles !.</font>
- </p>
- <p><font face="Verdana">When a surface is created, you provide it with a brush
- that controls how all the triangles in the surface are rendered.</font>
- </p>
- <p><font face="Verdana">So, a quick overview:</font>
- </p>
- <ul>
- <li><font face="Verdana">A mesh is made up of any number of surfaces.<br>
- </font></li>
- <li><font face="Verdana">Each surface in a mesh contains any number of
- vertices and triangles.<br>
- </font></li>
- <li><font face="Verdana">All triangles in a surface are rendered using a
- common brush.</font></li>
- </ul>
- <p><font face="Verdana">Lets dive on in and create a simple mesh:</font></p>
- <table border="1" width="100%" bordercolor="#FFFFFF">
- <tr>
- <td width="14%"> </td>
- <td width="72%" bordercolor="#000000" bgcolor="#C0C0C0"> <font face="Arial"><br>
- <b>brush=CreateBrush() </b>
- ; create a brush<br>
- <b>BrushColor
- brush,255,0,0
- </b>; a red brush</font>
- <p><font face="Arial"> <b>mesh=CreateMesh() </b>
- ; create a mesh<br>
- </font> <font face="Arial"><b> surf=CreateSurface(
- mesh,brush) </b> ; create a (red) surface</font></p>
- <p><font face="Arial"> <b>AddVertex surf,-1,1,0</b>
- ; Now, we add 4 vertices...<br>
- <b>AddVertex surf,1,1,0 <br>
- AddVertex surf,1-,1,0 <br>
- AddVertex surf,-1,-1,0</b></font></p>
- <p><font face="Arial"><b> AddTriangle
- surf,0,1,2
- </b>; and 2 triangles...<b><br>
- AddTriangle surf,0,2,3</b></font></p>
- <p><font face="Arial"><b> UpdateNormals mesh</b> </font><br><br>
-
- </p>
-
- </td>
- <td width="14%"> </td>
- </tr>
- </table>
- <p><font face="Verdana">This code will create a simple red square mesh entity.</font>
- </p>
- <p><font face="Verdana">So what's with the weird 'UpdateNormals' command at the
- end ?. Well, in order for a mesh to be correctly lit, its 'vertex normals' must
- be calculated. Without going into the gory details, the UpdateNormals command
- will do this for you. If you are aware of how normals work, you can actually set
- your own vertex normals using the VertexNormal command. If not, just remember to
- stick an 'UpdateNormals' command at the end of any mesh modifications you do, or
- else your meshes will not be correctly lit.</font>
- </p>
- <p><font face="Verdana">Note that you can create any number of surfaces you
- want. So, the same mesh can contain many differently coloured/textured/whatever
- triangles !.</font>
- </p>
- <p><font face="Verdana">Why bother with surfaces at all ?, Why not just create a
- bunch of separate meshes, each with its own rendering properties and skip all
- this surface nonsense ?. Well, again it comes down to SPEED !. It's faster for
- Blitz3D to handle multiple surfaces - which can NOT be moved or rotated as
- entities can - than it would be to handle multiple meshes.</font>
- </p>
- <h2><font face="Verdana"><span style="background-color: #6097C9"> Modifying
- Meshes </span></font></h2>
- <p>
- <font face="Verdana">
- Once you've created a mesh, there are various commands available for modifying
- the mesh in realtime. This can be used to create a range of impressive special
- effects such as waving flags, rippling water and so on.</font></p>
- <p><font face="Verdana">These commands are:</font></p>
- <ul>
- <li><font face="Verdana"><b>VertexCoords</b> - Changes the coordinates of a
- vertex.<br>
- </font></li>
- <li><font face="Verdana"><b>VertexColor</b> - Changes the colour of a vertex.<br>
- </font></li>
- <li><font face="Verdana"><b>VertexTexCoords</b> - Changes the texture mapping
- coordinates of a vertex.<br>
- </font></li>
- <li><font face="Verdana"><b>VertexNormal</b> - Changes the normal of a vertex.</font></li>
- </ul>
- <p><font face="Verdana">For more info on how to use these commands, take a look
- at the Vertex tutorial further on down the line.</font></p>
- <p><center><font color="#666666" face="Verdana">By Paul Gerfen (GamecodingUK)<br>Copyright 2001 Mark Sibly/Guildhall Leisure Ltd</font>
- </center></p>
- </body>
- </html>
|