diff --git a/include/glumodel.h b/include/glumodel.h index e145743..359835b 100644 --- a/include/glumodel.h +++ b/include/glumodel.h @@ -18,6 +18,7 @@ GenericModel(Vec _pos, Material _mat); void init(Vec _pos, Material _mat); + void setColor(Color* c); void setMaterial(Color _amb); void setMaterial(Color _amb, Color _spec); diff --git a/sources/glumodel.cpp b/sources/glumodel.cpp index 3ecaceb..85db1ee 100644 --- a/sources/glumodel.cpp +++ b/sources/glumodel.cpp @@ -21,6 +21,12 @@ enabled = true; } +void GenericModel::setColor(Color* c) { + Color sp = *(mat->specular->clone()); + delete mat; + mat = new Material(*(c->clone()), sp); +} + void GenericModel::translate ( Vec d ) { pos->add((Vec)d); } @@ -106,11 +112,7 @@ glTranslatef(0.5, 1, 0.5); construct(n); glPopMatrix(); - } else { - //TODO: make this parametrable - float c[] = {1.0, 0, 0}; - glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, c); - + } else { /* if available, use OpenGL lists to accelerate drawing */ if ( list == 0 ) { drawPyramid(); @@ -174,6 +176,9 @@ /* scale it to the desired length, width and height */ glScalef(len, len, len); + /* set material */ + mat->draw(); + /* draw it */ construct(iters); diff --git a/sources/main.cpp b/sources/main.cpp index 3ded33c..c9c7402 100755 --- a/sources/main.cpp +++ b/sources/main.cpp @@ -553,7 +553,7 @@ //draw sphere //mysphere.draw(); - //myfrac->draw(); + myfrac->draw(); //kochfrac->draw(); //draw cube