merged
1 parent c75ac03 commit 6d7fe453ff370e5162ddaef92791dbccb56cad83
@glproj03 glproj03 authored on 9 Feb 2006
Showing 1 changed file
View
122
sources/main.cpp
GluSphere mysphere (Vec(0,-50,0),
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);
 
/* begin cube */
//cube->setCenter(cubeCen);
 
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);
 
/* end import */
Material(Color(0.5,0.5,0.5), //Color(0.5,0.5,0.5),
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);
 
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);
 
///////////////////////////////////////////////////////////////////////////
}
 
userAnim->addThing((Thing*)rotatingCubes);
StaticAnimation* l1Anim = new StaticAnimation();
l1Anim->init();
anims.push_back((Animation*)l1Anim);
 
l1Anim->addThing((Thing*)rotatingCubes);
l1Anim->setRot(Vec(1.5f,0,0));
 
userAnim->addThing((Thing*)mysphere);
 
cube->showNormals();
StaticAnimation* cAnim = new StaticAnimation();
cAnim->init();
anims.push_back((Animation*)cAnim);
 
cAnim->addThing((Thing*)rotatingCubes);
cAnim->setRot(Vec(1.5f,0,0));
rotatingCubes->hide();
 
userAnim->addThing((Thing*)(&mysphere));
 
float delta = 0;
while (!done) {
delta += 1;
/////////////////////
glLoadIdentity();
 
//draw lights
light0.draw();
light1.draw();
//glTranslatef(0,0,-50);
//light1.draw();
light2.draw();
/* do animations */
for ( std::vector<Animation*>::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();