Advertisement
Guest User

r3n

a guest
Apr 6th, 2009
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.43 KB | None | 0 0
  1.     // Plus symbols added to increase readability.
  2.     // This defines the position of each vertex.
  3.   float  vertexPosDat[8][3]=
  4.   {
  5.     {-3.5, +3.5, +3.5}, //left,top,front
  6.     {+3.5, +3.5, +3.5}, //right,top,front
  7.     {+3.5, +3.5, -3.5}, //right,top,back
  8.     {-3.5, +3.5, -3.5}, //left, top,back
  9.     {-3.5, -3.5, +3.5}, //left,bottom,front
  10.     {+3.5, -3.5, +3.5}, //right,bottom,front
  11.     {+3.5, -3.5, -3.5}, //right,bottom,back
  12.     {-3.5, -3.5, -3.5}  //left,bottom,back
  13.   };
  14.  
  15.   // This defines the colour of each vertex.
  16.   float   vertexColDat[8][4]=
  17.   {
  18.     {0.5, 0.0, 0.0, 1.0}, //dark red
  19.     {0.3, 0.3, 0.6, 1.0}, //dark blue
  20.     {1.0, 0.0, 0.0, 1.0}, //red
  21.     {0.3, 0.3, 0.6, 1.0}, //dark blue
  22.     {0.3, 0.3, 0.6, 1.0}, //dark blue
  23.     {0.5, 0.0, 0.0, 1.0}, //dark red
  24.     {0.3, 0.3, 0.6, 1.0}, //dark blue
  25.     {1.0, 0.0, 0.0, 1.0}, //red
  26.   };
  27.  
  28.   // This defines the vertexes of each quad in anti-clockwise order.
  29.     unsigned int quadVerDat[6][4]=
  30.     {
  31.       {0,1,2,3}, //top
  32.       {0,3,7,4}, //left
  33.       {3,2,6,7}, //back
  34.       {2,1,5,6}, //right
  35.       {0,4,5,1}, //front
  36.       {4,7,6,5}, //bottom
  37.     };
  38.  
  39.     int a,b;
  40.  
  41.      // Put the vertex data into the cube.ver[] struct.
  42.      for (a=0;a<8;++a)
  43.      {
  44.        for (b=0;b<3;++b)
  45.        {
  46.          cube.ver[a].pos[b]=vertexPosDat[a][b];
  47.          cube.ver[a].col[b]=vertexColDat[a][b];
  48.        }
  49.      }
  50.  
  51.      // Put the quad data into the cube.quad[] struct.
  52.      for (a=0;a<6;++a)
  53.      {
  54.        for (b=0;b<4;++b)
  55.        {
  56.          cube.quad[a].ver[b]=quadVerDat[a][b];
  57.        }
  58.      }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement