page5.html 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <font face="verdana">
  2. <table border="1" width="100%" bordercolor="#FFFFFF">
  3. <tr>
  4. <td width="61%" bgcolor="#6097C9"><font face="verdana">
  5. <h1 align="left"><font color="#FFFFFF">&nbsp;Texturing</font></h1>
  6. <p align="left"><b>&nbsp;Aim</b>: How to texture an object<br>
  7. &nbsp;<b>Skill level</b>: Intermediate<br>
  8. &nbsp;<b>Files Needed</b>: texture.bb / blitztexture.bmp
  9. </font>
  10. <p>&nbsp;</td>
  11. <td width="5%">&nbsp;</td>
  12. <td width="34%">
  13. <p align="right"><font face="verdana">
  14. <img src="7c.jpg" alt="Texturing" width="166" height="127">
  15. </font>
  16. </p>
  17. </td>
  18. </tr>
  19. </table>
  20. <p>
  21. For our objects to look more realistic we really need to texture them, but what is texture mapping ?<br>
  22. Think if it as a way of adding extra details to an object. For example... You design an ordinary white cube, doesn't look much does it ?</p>
  23. <p>
  24. But add a texturemap to it, and suddenly you have a BORG cube !.<br>
  25. Textures are bitmap pictures that have been designed with a paint program (that can save BMP format files.)</p>
  26. <p>
  27. Another example... If you designed a basic model of a creature, using a texturemap you could add all the external features - such as clothes and facial expressions.</p>
  28. <p>
  29. Although B3D has alot of commands to manage multiple textures and special effects, for now we shall just be using the very basic EntityTexture command.<br>
  30. Of course we could save ourselves alot of time by designing our objects and applying the textures to them directly from a 3d modelling program, but that would make this tutorial a waste of time !.<br><br>
  31. So why would we want to apply a texture in realtime ?, well for starters a new texture may be put onto the object at any time. Take a wall, shoot it ! - now for things to look realistic in our 3d world, we would like to have somekind of indication that it was shot. We could do this by loading a texture of a bullet hole directly onto the wall. Every 3d game currently on the market uses texture trickery in some form or another, as your experience grows - so will your imagination !. Why have a flat river, when you could use texturemaps to give the impression of ripples or waves.</p>
  32. <p>B3D has so many lovely features for us to use including the new ANIMATED textures command, we will be using this later on !. (Quake I/II/III used this trick to give us the impression of moving water)</p>
  33. <p>Let's look at this in practice:</p>
  34. <table border="1" width="86%" bordercolor="#FFFFFF">
  35. <tr>
  36. <td width="14%">&nbsp;</td>
  37. <td width="72%" bordercolor="#000000" bgcolor="#C0C0C0">&nbsp;<br>
  38. &nbsp; <font face="arial">Graphics3D 800,600<br>
  39. <br>
  40. &nbsp; SetBuffer BackBuffer()<br>
  41. <br>
  42. &nbsp; camera=CreateCamera()<br>
  43. &nbsp; CameraViewport camera,0,0,800,600<br>
  44. <br>
  45. &nbsp; light=CreateLight()<br>
  46. <br>
  47. &nbsp; cube=CreateCube()<br>
  48. &nbsp; PositionEntity cube,0,0,5<br>
  49. <br>
  50. &nbsp; texture=LoadTexture("blitztexture.bmp")<br>
  51. &nbsp; EntityTexture cube,texture<br>
  52. <br>
  53. &nbsp; While Not KeyHit(1)<br>
  54. <br>
  55. &nbsp; TurnEntity cube,0.1,0.2,0.3<br>
  56. <br>
  57. &nbsp; UpdateWorld<br>
  58. &nbsp; RenderWorld<br>
  59. <br>
  60. &nbsp; Text 340,500,&quot;Texturing Demo&quot;<br>
  61. <br>
  62. &nbsp; Flip<br>
  63. <br>
  64. &nbsp; Wend<br>
  65. &nbsp; End<br><br>
  66. </font></td>
  67. <td width="14%">&nbsp;</td>
  68. </tr>
  69. </table>
  70. <p>
  71. As you can see, a texture can make all the difference to a very basic object.</p>
  72. <p>
  73. The only 2 lines of code we don't already know are:
  74. </p>
  75. </font>
  76. <table border="0" width="100%" bgcolor="#6097C9">
  77. <tr>
  78. <td width="100%">
  79. <b>
  80. <font face="Arial">texture=LoadTexture(&quot;blitztexture.bmp&quot;)<br>
  81. EntityTexture cube,texture</font></b>
  82. </td>
  83. </tr>
  84. </table>
  85. <font face="verdana">
  86. <p>
  87. Two nice and friendly commands, the first loads a texturemap into memory - with the pointer variable 'texture' pointing to it.<br><br>
  88. Once we have successfully loaded the texture, we assign it to the object using the <b>EntityTexture</b> command. (here we are assigning the variable pointer TEXTURE to the cube we defined earlier)<br><br>
  89. You could if you wanted load the picture file <b>BLITZTEXTURE.BMP</b> into MS Paint and make some changes.. if you wanted to !<br><br>
  90. And that's all there is to it, but a quick word of advice: If your object isn't textured as it should, always check that the texturemaps are in the right directory. It's all to easy to spend half the day trying to work out a texturing problem, only to find that you moved the program to another directory without dragging the associated texture files with it.
  91. </p>
  92. <center><font color="#808080">Tutorial 5 - <a href="page6.html">Lighting</a></font></center></font>