Results 1 to 2 of 2

Thread: Clarify someones work please

  1. #1

    Thread Starter
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 2004
    Location
    Saskatoon, SK
    Posts
    2,339

    Clarify someones work please

    PHP Code:
    //$Author:        DigiBen            [email][email protected][/email]         //
        // We want to calculate the texture coordinate for the current vertex.
        // To do this, we just take the current x and y and divide them by the
        // MAP_SIZE of our terrain.  This is of course assuming the height map
        // has the same width and height.  Notice that we negate the v value (IE, (u, v)).
        // This is because we need to flip the texture upside down so it lines up correctly.
        // This simple math we use to find the texture coordinate can be explained easily.
        // We know that our terrain is made up of a grid, and that if we want to stretch
        // the entire texture over top of that grid, we just divide the current section
        // of the grid by the total section of the grid, which gives us a ratio from 0
        // to 1.  This works great because the (u, v) coordinates for a texture map go
        // from (0, 0) in the top left corner to (1, 1) in the bottom right corner.

        // Give OpenGL the current texture coordinate for our height map
        
    glTexCoord2f(   (float)/ (float)MAP_SIZE,    
                      - (float)
    / (float)MAP_SIZE    ); 

    That is correct, even I figured that out myself..

    I do not get why the v has to be negetive....What is he talking about???
    What does a -v do?
    "From what was there, and was meant to be, but not of that was faded away." - - Steve Damm

    "The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm

    "When you do things right, people won't be sure if you did anything at all." - - God from Futurama

  2. #2
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    It is for flipping it up side down. If not the textures will not line up corectly. That is the right way to do it if you are rendering a terrain, from left to right, and then the next line of traingles/quads goes from right to left. If you draw it down on a paper then you see why. It's pretty logical when you can see it in front of you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width