2010-09-16 5 views
0

J'ai besoin de configurer les sommets pour un rectangle - J'ai un exemple carré, comment pourrais-je le modifier pour obtenir un rectangle 5 fois la largeur et la moitié de la hauteur?Comment configurer les sommets pour un rectangle?

/** The initial vertex definition */  
private float vertices[] = { 
        //Vertices according to faces 
        -1.0f, -1.0f, 1.0f, //v0 
        1.0f, -1.0f, 1.0f,  //v1 
        -1.0f, 1.0f, 1.0f,  //v2 
        1.0f, 1.0f, 1.0f,  //v3 

        1.0f, -1.0f, 1.0f,  // ... 
        1.0f, -1.0f, -1.0f, 
        1.0f, 1.0f, 1.0f, 
        1.0f, 1.0f, -1.0f, 

        1.0f, -1.0f, -1.0f, 
        -1.0f, -1.0f, -1.0f, 
        1.0f, 1.0f, -1.0f, 
        -1.0f, 1.0f, -1.0f, 

        -1.0f, -1.0f, -1.0f, 
        -1.0f, -1.0f, 1.0f, 
        -1.0f, 1.0f, -1.0f, 
        -1.0f, 1.0f, 1.0f, 

        -1.0f, -1.0f, -1.0f, 
        1.0f, -1.0f, -1.0f, 
        -1.0f, -1.0f, 1.0f, 
        1.0f, -1.0f, 1.0f, 

        -1.0f, 1.0f, 1.0f, 
        1.0f, 1.0f, 1.0f, 
        -1.0f, 1.0f, -1.0f, 
        1.0f, 1.0f, -1.0f, 
             }; 

Ok donc je pense que je configurer les sommets correctement, mais maintenant je dois installer les textures normals et indices:

/** The initial vertex definition */  
private float vertices[] = { 
        //Vertices according to faces 
        -1.0f, -.5f, 1.0f, //v0 
        4.0f, -.5f, 1.0f,  //v1 
        -1.0f, .5f, 1.0f,  //v2 
        4.0f, .5f, 1.0f,  //v3 

        4.0f, -.5f, 1.0f,  // 2... 
        4.0f, -.5f, -1.0f, 
        4.0f, .5f, 1.0f, 
        4.0f, .5f, -1.0f, 

        4.0f, -.5f, -1.0f, //3 
        -1.0f, -.5f, -1.0f, 
        4.0f, .5f, -1.0f, 
        -1.0f, .5f, -1.0f, 

        -1.0f, -.5f, -1.0f, //4 
        -1.0f, -.5f, 1.0f, 
        -1.0f, .5f, -1.0f, 
        -1.0f, .5f, 1.0f, 

        -1.0f, -.5f, -1.0f, //5 
        4.0f, -.5f, -1.0f, 
        -1.0f, -.5f, 1.0f, 
        4.0f, -.5f, 1.0f, 

        -1.0f, .5f, 1.0f, //6 
        4.0f, .5f, 1.0f, 
        -1.0f, .5f, -1.0f, 
        4.0f, .5f, -1.0f, 
             }; 

Toute suggestion comment configurer ces:

private float normals[] = { 
         // Normals 
         0.0f, 0.0f, 1.0f, 


        0.0f, 0.0f, -1.0f, 
        0.0f, 1.0f, 0.0f, 
        0.0f, -1.0f, 0.0f, 

        0.0f, 0.0f, 1.0f, 
        0.0f, 0.0f, -1.0f, 
        0.0f, 1.0f, 0.0f, 
        0.0f, -1.0f, 0.0f, 

        0.0f, 0.0f, 1.0f, 
        0.0f, 0.0f, -1.0f, 
        0.0f, 1.0f, 0.0f, 
        0.0f, -1.0f, 0.0f, 

        0.0f, 0.0f, 1.0f, 
        0.0f, 0.0f, -1.0f, 
        0.0f, 1.0f, 0.0f, 
        0.0f, -1.0f, 0.0f, 

        0.0f, 0.0f, 1.0f, 
        0.0f, 0.0f, -1.0f, 
        0.0f, 1.0f, 0.0f, 
        0.0f, -1.0f, 0.0f, 

        0.0f, 0.0f, 1.0f, 
        0.0f, 0.0f, -1.0f, 
        0.0f, 1.0f, 0.0f, 
        0.0f, -1.0f, 0.0f, 
             }; 

/** The initial texture coordinates (u, v) */ 
private float texture[] = { 
        //Mapping coordinates for the vertices 
        0.0f, 0.0f, 
        0.0f, 1.0f, 
        1.0f, 0.0f, 
        1.0f, 1.0f, 

        0.0f, 0.0f, 
        0.0f, 1.0f, 
        1.0f, 0.0f, 
        1.0f, 1.0f, 

        0.0f, 0.0f, 
        0.0f, 1.0f, 
        1.0f, 0.0f, 
        1.0f, 1.0f, 

        0.0f, 0.0f, 
        0.0f, 1.0f, 
        1.0f, 0.0f, 
        1.0f, 1.0f, 

        0.0f, 0.0f, 
        0.0f, 1.0f, 
        1.0f, 0.0f, 
        1.0f, 1.0f, 

        0.0f, 0.0f, 
        0.0f, 1.0f, 
        1.0f, 0.0f, 
        1.0f, 1.0f, 
           }; 

/** The initial indices definition */ 
private byte indices[] = { 
        // Faces definition 
        0, 1, 3, 0, 3, 2,  // Face front 
        4, 5, 7, 4, 7, 6,  // Face right 
        8, 9, 11, 8, 11, 10, // ... 
        12, 13, 15, 12, 15, 14, 
        16, 17, 19, 16, 19, 18, 
        20, 21, 23, 20, 23, 22, 
              }; 

Répondre

Questions connexes