User Tools

Site Tools


public:t-vien-09-1:lab_3_materials

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

public:t-vien-09-1:lab_3_materials [2010/09/29 21:28]
hannes
public:t-vien-09-1:lab_3_materials [2010/09/29 21:31] (current)
hannes
Line 52: Line 52:
     - Load the //colormap// texture and apply it to your terrain node.  But first you must generate texture coordinates for your terrain geometry.  You can generate texture coordinates for any geometry in a node by making the following call ''<nodepath>.setTexGen(TextureStage.getDefault(),TexGenAttrib.MWorldPosition)''.  You will also have to scale the texture and center it by using the ''<nodepath>.setTexScale(<texture stage>, <u scale>, <v scale>)'' and ''<nodepath>.setTexOffset(<texture stage>, <u offset>, <v offset>)'' methods.  Good uniform scale would be **1/128** (this value is 1/(<horizontal scale of terrain>*<terrain size>), i.e. 1/(0.25*512)), and centering just involves an offset of -0.5 for both ''u'' and ''v''.     - Load the //colormap// texture and apply it to your terrain node.  But first you must generate texture coordinates for your terrain geometry.  You can generate texture coordinates for any geometry in a node by making the following call ''<nodepath>.setTexGen(TextureStage.getDefault(),TexGenAttrib.MWorldPosition)''.  You will also have to scale the texture and center it by using the ''<nodepath>.setTexScale(<texture stage>, <u scale>, <v scale>)'' and ''<nodepath>.setTexOffset(<texture stage>, <u offset>, <v offset>)'' methods.  Good uniform scale would be **1/128** (this value is 1/(<horizontal scale of terrain>*<terrain size>), i.e. 1/(0.25*512)), and centering just involves an offset of -0.5 for both ''u'' and ''v''.
   - **Skybox:**\\  The sky and the world beyond the terrain is still gray and gloomy.  Surround your entire scene with a box that has textures facing the inside to replace the gray color with something interesting.  A box like that, with textures depicting a sky already applied, can be found with the name **"Models/skybox.egg"**.  As you can see, this sort of an object is called a //skybox//.  Create a new **''create_skybox''** method in your **''World''** class.  Use it to load the skybox model as the member variable **self.skybox** in your **World** class, attach it to **render** and scale it up 200 times.  A //skybox// represents a horizon that the user should never be able to reach and pass through, and therefore it needs to move with the user, always keeping the user at its center.  This is easy to do since **World** already has a **move** method that updates the camera position.  Once the camera position has been updated in that method, give **self.skybox** the same position as the camera.  Try moving outside of the room and notice how the clouds seems to stay put.\\ NOTE: The clouds textures of the //skybox// were rendered using the [[http://www.planetside.co.uk/|Terragen Tool]] with a handy [[http://www.terathon.com/wiki/index.php?title=Making_a_Skybox_Using_Terragen|skybox rendering script]].  You can create your own skies with this tool.  You can replace the textures of ''Models/skybox.egg'' simply by opening the file in a text editor and changing the texture filenames to your files.   - **Skybox:**\\  The sky and the world beyond the terrain is still gray and gloomy.  Surround your entire scene with a box that has textures facing the inside to replace the gray color with something interesting.  A box like that, with textures depicting a sky already applied, can be found with the name **"Models/skybox.egg"**.  As you can see, this sort of an object is called a //skybox//.  Create a new **''create_skybox''** method in your **''World''** class.  Use it to load the skybox model as the member variable **self.skybox** in your **World** class, attach it to **render** and scale it up 200 times.  A //skybox// represents a horizon that the user should never be able to reach and pass through, and therefore it needs to move with the user, always keeping the user at its center.  This is easy to do since **World** already has a **move** method that updates the camera position.  Once the camera position has been updated in that method, give **self.skybox** the same position as the camera.  Try moving outside of the room and notice how the clouds seems to stay put.\\ NOTE: The clouds textures of the //skybox// were rendered using the [[http://www.planetside.co.uk/|Terragen Tool]] with a handy [[http://www.terathon.com/wiki/index.php?title=Making_a_Skybox_Using_Terragen|skybox rendering script]].  You can create your own skies with this tool.  You can replace the textures of ''Models/skybox.egg'' simply by opening the file in a text editor and changing the texture filenames to your files.
-  - **Fog:**\\ To add a little bit of an atmosphere, add some fog to your whole scene and play with the values.  Don't make the fog too dense or you won't see much through the windows of your house.<code python>+  - **Fog:**\\ To add a little bit of an atmosphere (and to save the rendering engine from rendering objects that are very far away), add some fog to your whole scene and play with the values.  Don't make the fog too dense or you won't see much through the windows of your house.<code python>
 # HINT - Adding fog to a sub-tree starting at '<nodepath>'  # HINT - Adding fog to a sub-tree starting at '<nodepath>' 
 fog = Fog("Fog") fog = Fog("Fog")
/var/www/ailab/WWW/wiki/data/pages/public/t-vien-09-1/lab_3_materials.txt ยท Last modified: 2010/09/29 21:31 by hannes