Time for action — preparing our quad

We are going to use the quad from the previous example with the leaf texture material:

  1. Change the texture coordinates of the quad from range 0 to 1 to 0 to 2. The quad code should then look like this:
    manual->position(5.0, 0.0, 0.0);
    manual->textureCoord(0,2);
    manual->position(-5.0, 10.0, 0.0);
    manual->textureCoord(2,0);
    manual->position(-5.0, 0.0, 0.0);
    manual->textureCoord(2,2);
    manual->position(5.0, 10.0, 0.0);
    manual->textureCoord(0,0);
    
  2. Now compile and run the application. Just as before, we will see a quad with a leaf texture, but this time we will see the texture four times.
    Time for action — preparing our quad

What just happened?

We simply changed our quad to have texture coordinates that range from zero to two. This means that Ogre 3D needs to use one of its strategies to render texture coordinates that are larger than 1. The default mode is wrap. This means each value over 1 is wrapped to be between zero and one. The following is a diagram showing this effect and how the texture coordinates are wrapped. Outside the corners, we see the original texture coordinates and inside the corners, we see the value after the wrapping. Also for better understanding, we see the four texture repetitions with their implicit texture coordinates.

What just happened?

We have seen how our texture gets wrapped using the default texture wrapping mode. Our plant texture shows the effect pretty well, but it doesn't show the usefulness of this technique. Let's use another texture to see the benefits of the wrapping mode.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.153.67