pmc/cube.cc
changeset 43 cf8c1b5127b2
parent 42 83b8151b966d
child 45 7197576fedcf
equal deleted inserted replaced
42:83b8151b966d 43:cf8c1b5127b2
    20 
    20 
    21     surface = s;
    21     surface = s;
    22     height = 25;
    22     height = 25;
    23 }
    23 }
    24 
    24 
    25 Cube::Cube (Surface * s, Vector p1, Vector p2, Vector p3, Vector p4, int h)
    25 Cube::Cube (Surface * s, Vector& p1, Vector& p2, Vector& p3, Vector& p4, int h)
    26 {
    26 {
    27     height = h;
    27     height = h;
    28     surface = s;
    28     surface = s;
       
    29     Vector location(h/2, h/2);
    29 
    30 
    30     P[0] = new Vector (p1);
    31     P[0] = new Vector (p1);
    31     P[1] = new Vector (p2);
    32     P[1] = new Vector (p2);
    32     P[2] = new Vector (p3);
    33     P[2] = new Vector (p3);
    33     P[3] = new Vector (p4);
    34     P[3] = new Vector (p4);
    34 
    35 
    35     for (int i = 0; i < 4; i++) {
    36     for (int i = 0; i < 4; i++) {
    36         P[4 + i] = new Vector (*P[i]);
    37         P[4 + i] = new Vector (*P[i]);
    37         *P[4 + i] = *P[i] + Vector (h / 2, h / 2);
    38         *P[4 + i] = *P[i] + location;
    38     }
    39     }
    39 }
    40 }
    40 
    41 
    41 Cube::~Cube ()
    42 Cube::~Cube ()
    42 {
    43 {
    43     for (int i = 0; i < 6; i++) {
    44     for (int i = 0; i < 8; i++) {
    44 #ifdef DEBUG
    45 #ifdef DEBUG
    45         fprintf (stderr, "Removing P[%d]: ", i);
    46         fprintf (stderr, "Removing P[%d]: ", i);
    46 #endif
    47 #endif
    47         delete P[i];
    48         delete P[i];
    48     }
    49     }