Colorful-house.cpp

From Immersive Visualization Lab Wiki
Jump to: navigation, search
  // This data structure defines a simple house, with crazy colors
  
  int nVerts = 42;    // your vertex array needs to have this many entries
  
  // These are the x,y,z coordinates of the vertices of the triangles
  float vertices[] = {  
            -4,-4,4, 4,-4,4, 4,4,4, -4,4,4,     // front face
            -4,-4,-4, -4,-4,4, -4,4,4, -4,4,-4, // left face
            4,-4,-4,-4,-4,-4, -4,4,-4, 4,4,-4,  // back face
            4,-4,4, 4,-4,-4, 4,4,-4, 4,4,4,     // right face
            4,4,4, 4,4,-4, -4,4,-4, -4,4,4,     // top face
            -4,-4,4, -4,-4,-4, 4,-4,-4, 4,-4,4, // bottom face

            -20,-4,20, 20,-4,20, 20,-4,-20, -20,-4,-20, // grass
            -4,4,4, 4,4,4, 0,8,4,                       // front attic wall
            4,4,4, 4,4,-4, 0,8,-4, 0,8,4,               // left slope
            -4,4,4, 0,8,4, 0,8,-4, -4,4,-4,             // right slope
            4,4,-4, -4,4,-4, 0,8,-4};                   // rear attic wall

  // These are the RGB colors corresponding to the vertices, in the same order
  float colors[] = { 
            1,0,0, 1,0,1, 1,0,0, 1,1,0,  // front
            0,1,0, 0,1,1, 0,1,0, 1,1,0,  // left
            1,0,0, 1,1,0, 1,0,0, 1,0,1,  // back
            0,1,0, 0,1,0, 0,1,0, 1,0,0,  // right
            0,0,1, 1,0,0, 0,0,1, 1,0,0,  // top
            0,0,1, 0,0,1, 0,0,1, 0,0,1,  // bottom
  
            0,0.5,0, 0,0.5,0, 0,0.5,0, 0,0.5,0, // grass is dark green
            0,0,1, 0,0,1, 1,0,0,                // front attic wall
            1,0,0, 1,0,0, 1,0,0, 0,0,1,         // left slope
            0,1,0, 0,1,0, 0,1,0, 0,0,1,         // right slope
            0,0,1, 0,0,1, 0,0,1,};              // rear attic wall

  // The index data stores the connectivity of the triangles; 
  // index 0 refers to the first triangle defined above
  int indices[] = {
            0,2,3,    0,1,2,      // front face
            4,6,7,    4,5,6,      // left face
            8,10,11,  8,9,10,     // back face
            12,14,15, 12,13,14,   // right face
            16,18,19, 16,17,18,   // top face
            20,22,23, 20,21,22,   // bottom face
                   
            24,26,27, 24,25,26,   // grass
            28,29,30,             // front attic wall
            31,33,34, 31,32,33,   // left slope
            35,37,38, 35,36,37,   // right slope
            39,40,41};            // rear attic wall