Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I setup vertices for a rectangle?
    primarykey
    data
    text
    <p>I need to setup vertices for a rectangle - I have a square example, how would I modify it to get a rectangle 5 times the width and half the height?</p> <pre><code> /** 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, }; </code></pre> <p>Okay so I think I setup the vertices correctly but now I need to setup the normals textures and indices:</p> <pre><code>/** 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, }; </code></pre> <p>Any suggestions how to set these up:</p> <pre><code>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, }; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload