diff --git a/sources/main.cpp b/sources/main.cpp index 067b567..d7ae529 100755 --- a/sources/main.cpp +++ b/sources/main.cpp @@ -242,10 +242,10 @@ Material(Color(1,1,0)), 50); - KochFractal* kochfrac = new KochFractal(Vec(0,0,0), 3, 30); + KochFractal* kochfrac = new KochFractal(Vec(0,0,-15), 3, 30); userAnim->addThing((Thing*)kochfrac); - SierpinskiPyramid* myfrac = new SierpinskiPyramid(Vec(-7,10,-7), 4, 15); + SierpinskiPyramid* myfrac = new SierpinskiPyramid(Vec(-7,5,0), 4, 15); userAnim->addThing((Thing*)myfrac); @@ -316,38 +316,42 @@ userAnim->addThing((Thing*)cube); cube->setDelta(PI/2.0); - + cube->hide(); + /* end cube */ /* begin import */ char* modelfile = "obj/chaiselongue.obj"; Model* myModel = importModel(modelfile); printf("imported %s : %d faces\n", modelfile, myModel->numFaces()); - Vec myCen = Vec(5,-10,5); - myModel->setCenter(myCen); + myModel->scale(4); + myModel->setPosition(Vec(10,0,40)); myModel->setMaterial(Color(0,0,1), Color(0,0,1)); - myModel->setPosition(myCen); //myModel->showNormals(); myModel->setDelta(PI/2.0); + myModel->hide(); userAnim->addThing((Thing*)myModel); Model* shuttle = importModel("obj/shuttle.obj"); shuttle->setDelta(PI/2.0); - myModel->setMaterial(Color(1,1,1), Color(1,0,1)); + shuttle->setMaterial(Color(0.9,0.9,0.9), Color(1,1,1)); userAnim->addThing((Thing*)shuttle); - Vec shuttleCenter = Vec(0,0,0); + Vec shuttleCenter = Vec(90,0,0); + + shuttle->rotate(Vec(-90,0,0)); shuttle->setCenter(shuttleCenter); - shuttle->setPosition(Vec(30,0,0)); + shuttle->setPosition(Vec(90,0,0)); StaticAnimation* shuttleAnim = new StaticAnimation(); shuttleAnim->init(); + shuttleAnim->setSpeed(2); shuttleAnim->addThing((Thing*)shuttle); - shuttleAnim->setRot(Vec(0.5, 0.3, 0.4)); + shuttleAnim->setRot(Vec(0.2, 1, 0.7)); anims.push_back((Animation*)shuttleAnim); @@ -411,14 +415,22 @@ Color(1,1,1)), 90); - Light light1(GL_LIGHT1, +// SpotLight light1(GL_LIGHT1, +// Vec (0, 50, 0), +// Material(Color(0.0,0.0,0.7), //Color(0.5,0.5,0.5), +// Color(0,0,1)), +// 90); + + Light light2(GL_LIGHT2, Vec (20, 20, 20), - Material(Color(0.5,0.5,0.5), + Material(Color(0.5,0.5,0.0), Color(0,0,0))); userAnim->addThing((Thing*)(&light0)); - userAnim->addThing((Thing*)(&light1)); +// userAnim->addThing((Thing*)(&light1)); + userAnim->addThing((Thing*)(&light2)); + //spot 0 animation StaticAnimation* l0Anim = new StaticAnimation(); l0Anim->init(); anims.push_back((Animation*)l0Anim); @@ -426,9 +438,13 @@ l0Anim->addThing((Thing*)(&light0)); l0Anim->setRot(Vec(1,0,0)); - //Vec l1_pos(-10.0f, -10.0f, -10.0f); - //Color l1_col(0.0f, 0.5f, 1.0f); - //DiffuseLight light1(l1_pos, l1_col, GL_LIGHT1); +// //blue spot 1 animation +// StaticAnimation* l1Anim = new StaticAnimation(); +// l1Anim->init(); +// anims.push_back((Animation*)l1Anim); + +// l1Anim->addThing((Thing*)(&light1)); +// l1Anim->setRot(Vec(0,0,1.3)); //glEnable(GL_COLOR_MATERIAL); @@ -467,16 +483,16 @@ userAnim->addThing((Thing*)rotatingCubes); - StaticAnimation* l1Anim = new StaticAnimation(); - l1Anim->init(); - anims.push_back((Animation*)l1Anim); + StaticAnimation* cAnim = new StaticAnimation(); + cAnim->init(); + anims.push_back((Animation*)cAnim); - l1Anim->addThing((Thing*)rotatingCubes); - l1Anim->setRot(Vec(1.5f,0,0)); + cAnim->addThing((Thing*)rotatingCubes); + cAnim->setRot(Vec(1.5f,0,0)); + rotatingCubes->hide(); - userAnim->addThing((Thing*)mysphere); + userAnim->addThing((Thing*)(&mysphere)); - cube->showNormals(); float delta = 0; while (!done) { delta += 1; @@ -524,47 +540,23 @@ //draw lights light0.draw(); - light1.draw(); - - //glTranslatef(0,0,-50); - + //light1.draw(); + light2.draw(); + /* do animations */ for ( std::vector::size_type anim_ct = 0; anim_ct < anims.size(); anim_ct++ ) { ((Animation*)anims.at(anim_ct))->tick(); } rotatingCubes->draw(); - -// //xy plane -// glBegin(GL_TRIANGLES); -// glNormal3f(0,0,1); -// glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue.v()); -// glVertex3f(0,0,0); -// //glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue.v()); -// glVertex3f(10,0,0); -// //glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red.v()); -// glVertex3f(0,10,0); -// glEnd(); - -// //xz plane -// glBegin(GL_TRIANGLES); -// glNormal3f(0,1,0); -// glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue.v()); -// glVertex3f(0,0,0); -// //glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue.v()); -// glVertex3f(30,0,0); -// //glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green.v()); -// glVertex3f(0,0,30); -// glEnd(); - //draw sphere - //mysphere.draw(); + mysphere.draw(); myfrac->draw(); kochfrac->draw(); //draw cube - //cube->draw(); + cube->draw(); //draw imported model myModel->draw();