void RenderScene(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glEnable( GL_DEPTH_TEST ) ; glUseProgram(shader); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); float angle = timer.GetElapsedSeconds(); M3DVector3f eye = {cos(angle)*4.0f,sin(angle)*4.0,sin(angle)*4.0f}; M3DVector3f at = {0,0,0}; M3DVector3f up = {0.0f,0.0f,1.0f}; GLFrame cameraFrame; LookAt(cameraFrame, eye, at, up); cameraFrame.GetCameraMatrix(cameraMatrix); m3dMatrixMultiply44(matrix, viewFrustum.GetProjectionMatrix(), cameraMatrix); M3DMatrix44f tMatrix; m3dTranslationMatrix44(tMatrix, 0, 0, 0); m3dMatrixMultiply44(matrix, tMatrix, matrix); if((sin(angle) < 0 && sin(angle-0.003) > 0) || (sin(angle) > 0 && sin(angle-0.003) < 0)) { debugMatrix44(matrix); } glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,matrix); // drawGrid(0.1); drawPyramid(); glutSwapBuffers(); glutPostRedisplay(); }
void drawRoof(void) { mvstack.push(model_view); set_colour(.92, .5, .25); model_view *= Scale(20, 20, 20); drawPyramid(); model_view = mvstack.pop(); }
void RenderScene(void) { // Clear the window with current clearing color glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glUseProgram(shader); glEnable(GL_CULL_FACE); glFrontFace(GL_CW); CStopWatch timer; float angle = timer.GetElapsedSeconds()*3.14f; M3DVector3f mAt={0,0,0}; M3DVector3f mUp={0,0,1}; M3DVector3f mEye; mEye[0]=6.8f*cos(angle); mEye[1]=6.0f*sin(angle); mEye[2]=5.0f; LookAt(mFrame,mEye,mAt,mUp); mFrame.GetCameraMatrix(mCameraMatrix); matrixStack.LoadMatrix(mFrustrum.GetProjectionMatrix()); matrixStack.MultMatrix(mCameraMatrix); glUniformMatrix4fv(MVPMatrixLocation, 1, GL_FALSE, matrixStack.GetMatrix()); drawGrid(); matrixStack.Translate(1.0f,7.0f,0.0f); matrixStack.Rotate(30.0f,0.0,0.0,1.0); glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,matrixStack.GetMatrix()); drawPyramid(); matrixStack.PopMatrix(); matrixStack.Translate(-7.0f,0.0f,0.0f); matrixStack.Scale(2.0f, 2.0f, 2.0f); glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,matrixStack.GetMatrix()); drawPyramid(); matrixStack.PopMatrix(); // Perform the buffer swap to display back buffer glutSwapBuffers(); glutPostRedisplay(); }
void FeatureGenerator::createHouse(v2di_t cornerIndex, World &world) { // WARNING: this always corners at 0, 0 int worldX = cornerIndex.x * WORLD_CHUNK_SIDE; int worldZ = cornerIndex.y * WORLD_CHUNK_SIDE; height_info_t heightInfo = FeatureUtil::getHeightInfo(worldX, worldZ, WORLD_CHUNK_SIDE, WORLD_CHUNK_SIDE, world); // now build the house v3di_t a, b; int floorHeight = heightInfo.avg + 1; int roofHeight = 5; int sideLength = 7; int offset = 4; // make a roof a.x = worldX + (offset - 1); a.y = floorHeight + roofHeight; a.z = worldZ + (offset - 1); drawPyramid(a, sideLength + 2, BLOCK_TYPE_LIGHT_BLUE, world); WorldMap &worldMap = *world.getWorldMap(); // fill it a.x = worldX + offset; a.y = floorHeight; a.z = worldZ + 4; b.x = worldX + offset + sideLength; b.y = floorHeight + roofHeight; b.z = worldZ + offset + sideLength; worldMap.fillVolume(a, b, BLOCK_TYPE_LIGHT_STONE); // hollow it out a.x = worldX + offset + 1; a.y = floorHeight; a.z = worldZ + offset + 1; b.x = worldX + offset + (sideLength - 1); b.y = floorHeight + roofHeight - 1; b.z = worldZ + offset + (sideLength - 1); worldMap.fillVolume(a, b, BLOCK_TYPE_AIR); // make the door a.x = worldX + offset; a.y = floorHeight; a.z = worldZ + offset + 3; b.x = worldX + offset; b.y = floorHeight + 2; b.z = worldZ + offset + 4; worldMap.fillVolume(a, b, BLOCK_TYPE_AIR); }
void display(void) { glLoadIdentity(); glClearColor(0.0f,0.0f,0.0f,1.0f); //set the background colour // OK, now clear the screen with the background colour glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); /* Place the camera in various positions in the secene */ if(curTime >= 0 && curTime <= 3){ gluLookAt(-12,5,30,0,5,0,0,1,0); } else if(curTime > 3 && curTime <= 6){ gluLookAt(-12,5, 10, 0, 7, 0, 0, 1, 0); } else if(curTime > 6 && curTime <= 10.75){ gluLookAt(0, 5, 30, 0, 5, 0, 0, 1, 0); } else if(curTime > 10.75 && curTime <= 11.5){ gluLookAt(-12, 7, -8, 0, 4, -2, 0, 1, 0); } else if(curTime > 11.5 && curTime <= 12){ gluLookAt(11, 25, -30, -2,5, 0, 0, 1, 0); } else { gluLookAt(-12,5, 10, 0, 7, 0, 0, 1, 0); } drawWalls(); drawColumnSet(); drawStairs(); drawCube(); drawSphere(); drawPlatform(); drawPyramid(); glPushMatrix(); drawMan(); glPopMatrix(); drawHammer(); glFlush(); glutSwapBuffers(); if (recording) { int frame = (int)(curTime / tStep + 0.5); save_image(frame); } }
void FeatureGenerator::createPyramid(int side, v2di_t cornerIndex, World &world) { // WARNING: relative to 0, 0 int worldX = cornerIndex.x * WORLD_CHUNK_SIDE; int worldZ = cornerIndex.y * WORLD_CHUNK_SIDE; int width = side * WORLD_CHUNK_SIDE; int halfWidth = width >> 1; height_info_t heightInfo = FeatureUtil::getHeightInfo(worldX, worldZ, width, width, world); v3di_t baseNearPoint = { worldX, heightInfo.low, worldZ }; drawPyramid(baseNearPoint, side * WORLD_CHUNK_SIDE, BLOCK_TYPE_OBSIDIAN, world); }
void NICPQGLViewer::init() { // Init QGLViewer. QGLViewer::init(); // Set some default settings. glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); glEnable(GL_DEPTH_TEST); glEnable(GL_NORMALIZE); glShadeModel(GL_FLAT); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Don't save state. setStateFileName(QString::null); // Mouse bindings. setMouseBinding(Qt::RightButton, CAMERA, ZOOM); setMouseBinding(Qt::MidButton, CAMERA, TRANSLATE); // Replace camera. qglviewer::Camera *oldcam = camera(); qglviewer::Camera *cam = new StandardCamera(); setCamera(cam); cam->setPosition(qglviewer::Vec(-1.0f, 0.0f, 0.0f)); cam->setUpVector(qglviewer::Vec(0.0f, 0.0f, 1.0f)); cam->lookAt(qglviewer::Vec(0.0f, 0.0f, 0.0f)); delete oldcam; // Create draw lists. _ellipsoidDrawList = glGenLists(_numDrawLists); _pyramidDrawList = glGenLists(_numDrawLists); // Compile draw lists. // Ellipsoid. glNewList(_ellipsoidDrawList, GL_COMPILE); drawSphere(1.0f); glEndList(); // Pyramid. glNewList(_pyramidDrawList, GL_COMPILE); drawPyramid(0.5f, 0.5f); glEndList(); }
unsigned int drawHardcodedModelRaw(unsigned int modelType) { switch (modelType) { case OBJ_FOG : drawFog(); break; case OBJ_PLANE : drawObjPlane(0,0,0, 0.5); break; case OBJ_GRIDPLANE : drawGridPlane( 0.0 , 0.0 , 0.0, 1.0); break; case OBJ_AXIS : drawAxis(0,0,0,1.0); break; case OBJ_CUBE : drawCube(); break; case OBJ_PYRAMID : drawPyramid(); break; case OBJ_SPHERE : drawSphere( SPHERE_QUALITY ); break; case OBJ_INVISIBLE : /*DONT DRAW ANYTHING*/ break; case OBJ_QUESTION : drawQuestion(); break; case OBJ_BBOX : drawBoundingBox(0,0,0,-1.0,-1.0,-1.0,1.0,1.0,1.0); break; default : return 0; break; } return 1; }
void RenderLightProjection::render(const RenderInfo& info) const { // greebo: These four define the base area and are always needed to draw the light // Note the minus sign before intersectPlanes (the points have to be mirrored against the origin) Vector3 bottomUpRight = -Plane3::intersect(_frustum.left, _frustum.top, _frustum.back); Vector3 bottomDownRight = -Plane3::intersect(_frustum.left, _frustum.bottom, _frustum.back); Vector3 bottomUpLeft = -Plane3::intersect(_frustum.right, _frustum.top, _frustum.back); Vector3 bottomDownLeft = -Plane3::intersect(_frustum.right, _frustum.bottom, _frustum.back); // The planes of the frustum are measured at world 0,0,0 so we have to position the intersection points relative to the light origin bottomUpRight += _origin; bottomDownRight += _origin; bottomUpLeft += _origin; bottomDownLeft += _origin; if (_start != Vector3(0,0,0)) { // Calculate the vertices defining the top area // Again, note the minus sign Vector3 topUpRight = -Plane3::intersect(_frustum.left, _frustum.top, _frustum.front); Vector3 topDownRight = -Plane3::intersect(_frustum.left, _frustum.bottom, _frustum.front); Vector3 topUpLeft = -Plane3::intersect(_frustum.right, _frustum.top, _frustum.front); Vector3 topDownLeft = -Plane3::intersect(_frustum.right, _frustum.bottom, _frustum.front); topUpRight += _origin; topDownRight += _origin; topUpLeft += _origin; topDownLeft += _origin; Vector3 frustum[8] = { topUpRight, topDownRight, topDownLeft, topUpLeft, bottomUpRight, bottomDownRight, bottomDownLeft, bottomUpLeft }; drawFrustum(frustum); } else { // no light_start, just use the top vertex (doesn't need to be mirrored) Vector3 top = Plane3::intersect(_frustum.left, _frustum.right, _frustum.top); top += _origin; Vector3 pyramid[5] = { top, bottomUpRight, bottomDownRight, bottomDownLeft, bottomUpLeft }; drawPyramid(pyramid); } }
void myInitOGLFun() { //create and compile display list myLandscapeDisplayList = glGenLists(1); glNewList(myLandscapeDisplayList, GL_COMPILE); drawXZGrid(landscapeSize, -1.5f); //pick a seed for the random function (must be same on all nodes) srand(9745); for(int i=0; i<numberOfPyramids; i++) { float xPos = static_cast<float>(rand()%landscapeSize - landscapeSize/2); float zPos = static_cast<float>(rand()%landscapeSize - landscapeSize/2); glPushMatrix(); glTranslatef(xPos, -1.5f, zPos); drawPyramid(0.6f); glPopMatrix(); } glEndList(); }
void drawTile(float x, float y, float z, float scale, int tile, float mx, float my, float mz, Image *image) { UNREFERENCED_PARAMETER(image); UNREFERENCED_PARAMETER(mx); UNREFERENCED_PARAMETER(my); UNREFERENCED_PARAMETER(mx); UNREFERENCED_PARAMETER(mz); switch (tile) { case 1: drawCube(x,y,z,scale); //drawOcto(x,y,z,scale); //drawPoint(x,y,z,scale, mx, my, mz, image); break; case 2: drawPyramid(x,y,z); break; } }
void Ariou() { Mat4f temp = getModelViewMatrix(); ModelerApplication::Instance()->Swing(LEFT_UPPER_ARM_ROTATE_X, 3.1); //ModelerApplication::Instance()->Swing(LEFT_UPPER_ARM_ROTATE_Y, 2.5); ModelerApplication::Instance()->Swing(HEAD_ROTATE, 1); ModelerApplication::Instance()->Swing(RIGHT_UPPER_ARM_ROTATE_X, 1.1); ModelerApplication::Instance()->Swing(RIGHT_UPPER_ARM_ROTATE_Y, 4.5); ModelerApplication::Instance()->Swing(LEFT_LEG_ROTATE_X, 6.1); ModelerApplication::Instance()->Swing(RIGHT_LEG_ROTATE_X, 6.1); glPushMatrix(); glTranslated(VAL(XPOS), VAL(YPOS), VAL(ZPOS)); glScaled(VAL(XSCALE), VAL(YSCALE), VAL(ZSCALE)); glRotated(VAL(ROTATE), 0, 1, 0); setDiffuseColor(COLOR_YELLOW); // Torus if (VAL(DETAIL_LEVEL) > 1) { glPushMatrix(); glTranslated(.0f, 6, .0f); drawTorus(VAL(TORUS_R), VAL(TORUS_r)); glPopMatrix(); } //head glPushMatrix(); glTranslated(0, VAL(LEG_LENGTH) + 0.05 + VAL(HEIGHT) + 0.05 + VAL(HEAD_SIZE), 0); glRotated(VAL(HEAD_ROTATE), 0.0, 1.0, 0.0); drawSphere(VAL(HEAD_SIZE)); if (VAL(DETAIL_LEVEL) > 2) { // Nose drawRoundCylinder(VAL(HEAD_SIZE) * 1.1, 0.2, 0.2); // Ear glPushMatrix(); glTranslated(0.9 / sqrt(0.9*0.9 + 1.1*1.1) * VAL(HEAD_SIZE), 1.1 / sqrt(0.9*0.9 + 1.1*1.1) * VAL(HEAD_SIZE), 0); glRotated(-20, 0, 0, 1); SpawnParticles(temp); drawPyramid(VAL(EAR_SIZE)); glPopMatrix(); glPushMatrix(); glTranslated(-0.9 / sqrt(0.9*0.9 + 1.1*1.1) * VAL(HEAD_SIZE), 1.1 / sqrt(0.9*0.9 + 1.1*1.1) * VAL(HEAD_SIZE), 0); glRotated(20, 0, 0, 1); SpawnParticles(temp); drawPyramid(VAL(EAR_SIZE)); glPopMatrix(); // Eyes glPushMatrix(); setDiffuseColor(COLOR_RED); glTranslated(-0.5 / sqrt(0.5*0.5 * 2) * VAL(HEAD_SIZE) * 0.5, 0.5 / sqrt(0.5*0.5 * 2) * VAL(HEAD_SIZE) * 0.5, VAL(HEAD_SIZE) - 0.9); drawRoundCylinder( 0.9, 0.2, 0.2); glPopMatrix(); glPushMatrix(); setDiffuseColor(COLOR_RED); glTranslated( 0.5 / sqrt(0.5*0.5 * 2) * VAL(HEAD_SIZE) * 0.5, 0.5 / sqrt(0.5*0.5 * 2) * VAL(HEAD_SIZE) * 0.5, VAL(HEAD_SIZE) - 0.9); drawRoundCylinder( 0.9, 0.2, 0.2); glPopMatrix(); } glPopMatrix(); if (VAL(DETAIL_LEVEL) > 1) { //body // a.k.a. torso/trunk glPushMatrix(); setDiffuseColor(COLOR_YELLOW); glTranslated(0, 0.05 + VAL(LEG_LENGTH), 0); glRotated(-90, 1.0, 0.0, 0.0); drawRoundCylinder(VAL(HEIGHT), 0.7, 0.6); glPushMatrix(); glTranslated(-0.8, 0, VAL(HEIGHT) - 0.4); glRotated(90, 0, 1, 0); // the shoulder if (VAL(DETAIL_LEVEL) > 2) { drawRoundCylinder(1.6, 0.2, 0.2); } glPopMatrix(); // the waist if (VAL(DETAIL_LEVEL) > 3) { glPushMatrix(); glTranslated(0, 0, 0.5); glRotated(90, 1, 0, 0); drawTorus(0.7, 0.08); glPopMatrix(); } glPopMatrix(); if (VAL(DETAIL_LEVEL) > 2) { //right arm glPushMatrix(); glTranslated(-0.7 - 0.20, VAL(LEG_LENGTH) + 0.05 + VAL(HEIGHT) * 0.9f, 0); glTranslated(0.15, 0, 0); glRotated(VAL(RIGHT_UPPER_ARM_ROTATE_X), 1.0, 0.0, 0.0); glRotated(VAL(RIGHT_UPPER_ARM_ROTATE_Y), 0.0, 1.0, 0.0); glTranslated(-0.15, 0, 0); drawRoundCylinder(VAL(UPPER_ARM_LENGTH), 0.22, 0.15); // lower arm glTranslated(0, 0, VAL(UPPER_ARM_LENGTH) - 0.1); glRotated(VAL(RIGHT_LOWER_ARM_ROTATE) - 180, 1, 0, 0); drawRoundCylinder(VAL(LOWER_ARM_LENGTH), 0.15, 0.20); // hand glPushMatrix(); glTranslated(-0.03, -0.15, VAL(LOWER_ARM_LENGTH) - 0.1); glRotated(VAL(RIGHT_HAND_ANGLE), 0, 1, 0); drawCylinder(0.8, 0.15, 0.0001); glPopMatrix(); glPushMatrix(); glTranslated(0.03, -0.15, VAL(LOWER_ARM_LENGTH) - 0.1); glRotated(-VAL(RIGHT_HAND_ANGLE), 0, 1, 0); drawCylinder(0.8, 0.15, 0.0001); glPopMatrix(); glPopMatrix(); //left arm glPushMatrix(); glTranslated(0.7 + 0.20, VAL(LEG_LENGTH) + 0.05 + VAL(HEIGHT) * 0.9f, 0); glTranslated(-0.15, 0, 0); glRotated(VAL(LEFT_UPPER_ARM_ROTATE_X), 1.0, 0.0, 0.0); glRotated(VAL(LEFT_UPPER_ARM_ROTATE_Y), 0.0, 1.0, 0.0); glTranslated(0.15, 0, 0); drawRoundCylinder(VAL(UPPER_ARM_LENGTH), 0.22, 0.15); glTranslated(0, 0, VAL(UPPER_ARM_LENGTH) - 0.1); glRotated(VAL(LEFT_LOWER_ARM_ROTATE) - 180, 1, 0, 0); drawRoundCylinder(VAL(LOWER_ARM_LENGTH), 0.15, 0.20); // hand glPushMatrix(); glTranslated(-0.03, 0, VAL(LOWER_ARM_LENGTH) - 0.1); glRotated(VAL(LEFT_HAND_ANGLE), 0, 1, 0); drawBox(0.03, 0.25, 0.5); glPopMatrix(); glPushMatrix(); glTranslated(0.03, 0, VAL(LOWER_ARM_LENGTH) - 0.1); glRotated(-VAL(LEFT_HAND_ANGLE), 0, 1, 0); drawBox(0.03, 0.25, 0.5); if (VAL(DETAIL_LEVEL) > 3) { glRotated(90, 0, 0, 1); drawCylinder(5, 0.02, 0.02); if (VAL(DETAIL_LEVEL) > 4) { glTranslated(0, 0, 4); glPushMatrix(); setDiffuseColor(COLOR_GREEN); glTranslated(0, -0.5, 1); //SpawnParticles(temp); glPushMatrix(); glRotated(90, 1.0, 0.0, 0.0); glPopMatrix(); glPopMatrix(); } } glPopMatrix(); glPopMatrix(); } //right leg glPushMatrix(); setDiffuseColor(COLOR_YELLOW); glTranslated(-0.5, VAL(LEG_LENGTH), 0); glRotated(VAL(RIGHT_LEG_ROTATE_X), 1.0, 0.0, 0.0); glRotated(VAL(RIGHT_LEG_ROTATE_Y), 0.0, 1.0, 0.0); drawRoundCylinder(VAL(LEG_LENGTH) - 0.15, 0.3, 0.4); glTranslated(0, 0, VAL(LEG_LENGTH) * 0.85f); glRotated(70, 1, 0, 0); drawTorus(VAL(FEET_SIZE), VAL(FEET_SIZE) / 4); glPopMatrix(); //left leg glPushMatrix(); glTranslated(0.5, VAL(LEG_LENGTH), 0); glRotated(VAL(LEFT_LEG_ROTATE_X), 1.0, 0.0, 0.0); glRotated(VAL(LEFT_LEG_ROTATE_Y), 0.0, 1.0, 0.0); drawRoundCylinder(VAL(LEG_LENGTH) - 0.15, 0.3, 0.4); glTranslated(0, 0, VAL(LEG_LENGTH) * 0.85f); glRotated(70, 1, 0, 0); drawTorus(VAL(FEET_SIZE), VAL(FEET_SIZE) / 4); glPopMatrix(); } glPopMatrix(); }
void RenderScene(void) { // Clear the window with current clearing color glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glUseProgram(shader); M3DVector3f at={0,0,0}; M3DVector3f up={0,0,1}; M3DVector3f eye; float angle = timer.GetElapsedSeconds()*M_PI/3; eye[0]=6.8f*cos(angle); eye[1]=6.0f*sin(angle); eye[2]=5.0f; LookAt(cameraFrame,eye,at,up); geometryPipeline.SetMatrixStacks(modelView,projection); projection.LoadMatrix(viewFrustum.GetProjectionMatrix()); modelView.PushMatrix(); cameraFrame.GetCameraMatrix(mCamera); modelView.LoadMatrix(mCamera); modelView.PushMatrix(); glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); drawLines(); drawPyramid(); modelView.PopMatrix(); modelView.PushMatrix(); modelView.Translate(1.0f,6.0f,2.0f); modelView.Rotate(180.0f,0.0f,0.0f,1.0f); glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); drawPyramid(); modelView.PopMatrix(); modelView.PushMatrix(); modelView.Translate(6.0f,-4.0f,1.0f); modelView.Rotate(60.0f,1.0f,1.0f,1.5f); glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); drawPyramid(); modelView.PopMatrix(); modelView.PushMatrix(); modelView.Translate(-2.0f,0.0f,1.0f); modelView.Rotate(80.0f,1.0f,0.0f,1.0f); modelView.Scale(0.8f,0.4f,1.0f); glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix()); drawPyramid(); modelView.PopMatrix(); modelView.PopMatrix(); // Perform the buffer swap to display back buffer glutSwapBuffers(); glutPostRedisplay(); }
void Ariou::draw() { ModelerView::draw(); ModelerApplication::Instance()->Swing(LEFT_UPPER_ARM_ROTATE_X, 3.1); //ModelerApplication::Instance()->Swing(LEFT_UPPER_ARM_ROTATE_Y, 2.5); ModelerApplication::Instance()->Swing(HEAD_ROTATE, 1); ModelerApplication::Instance()->Swing(RIGHT_UPPER_ARM_ROTATE_X, 1.1); ModelerApplication::Instance()->Swing(RIGHT_UPPER_ARM_ROTATE_Y, 4.5); ModelerApplication::Instance()->Swing(LEFT_LEG_ROTATE_X, 6.1); ModelerApplication::Instance()->Swing(RIGHT_LEG_ROTATE_X, 6.1); ModelerApplication::Instance()->Swing(LS_DEPTH, 0.02); ModelerApplication::Instance()->Swing(LS_ANGLE, 0.15); setAmbientColor(.1f, .1f, .1f); setDiffuseColor(COLOR_RED); glPushMatrix(); glScaled(VAL(FLOOR_SIZE), VAL(FLOOR_SIZE), VAL(FLOOR_SIZE)); drawSierpinskiTriangle(0, 0, 1, 0.86602540378443864676372317075293618347140262690519, 0, -0.5, -0.86602540378443864676372317075293618347140262690519, 0, -0.5, VAL(FLOOR_DEPTH)); glTranslated(0, -0.05, 0); setDiffuseColor(COLOR_WHITE); drawPolygon(16, 2); glPopMatrix(); glPushMatrix(); /* GLfloat maambient[] = { 0.79225f, 0.79225f, 0.79225f, 1.0f }; GLfloat madiffuse[] = { 0.50754f, 0.50754f, 0.50754f, 1.0f }; GLfloat maspecular[] = { 0.508273f, 0.508273f, 0.508273f, 0.508273f }; GLfloat shininess = 51.2f; GLfloat maemi[] = { 0.0f, 0.0f, 0.0f, 1.0f }; glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, maambient); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, madiffuse); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, maspecular); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess); glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, maemi); */ glTranslated(VAL(XPOS), VAL(YPOS), VAL(ZPOS)); glScaled(VAL(XSCALE), VAL(YSCALE), VAL(ZSCALE)); glRotated(VAL(ROTATE), 0, 1, 0); setDiffuseColor(COLOR_YELLOW); // Torus if (VAL(DETAIL_LEVEL) > 1) { glPushMatrix(); glTranslated(.0f, 6, .0f); drawTorus(VAL(TORUS_R), VAL(TORUS_r)); glPopMatrix(); } //head glPushMatrix(); glTranslated(0, VAL(LEG_LENGTH) + 0.05 + VAL(HEIGHT) + 0.05 + VAL(HEAD_SIZE), 0); glRotated(VAL(HEAD_ROTATE), 0.0, 1.0, 0.0); drawSphere(VAL(HEAD_SIZE)); if (VAL(DETAIL_LEVEL) > 2) { // Nose drawRoundCylinder(VAL(HEAD_SIZE) * 1.1, 0.2, 0.2); // Ear glPushMatrix(); glTranslated(0.9 / sqrt(0.9*0.9 + 1.1*1.1) * VAL(HEAD_SIZE), 1.1 / sqrt(0.9*0.9 + 1.1*1.1) * VAL(HEAD_SIZE), 0); glRotated(-20, 0, 0, 1); drawPyramid(VAL(EAR_SIZE)); glPopMatrix(); glPushMatrix(); glTranslated(-0.9 / sqrt(0.9*0.9 + 1.1*1.1) * VAL(HEAD_SIZE), 1.1 / sqrt(0.9*0.9 + 1.1*1.1) * VAL(HEAD_SIZE), 0); glRotated(20, 0, 0, 1); drawPyramid(VAL(EAR_SIZE)); glPopMatrix(); // Eyes glPushMatrix(); setDiffuseColor(COLOR_RED); glTranslated(-0.5 / sqrt(0.5*0.5 * 2) * VAL(HEAD_SIZE) * 0.5, 0.5 / sqrt(0.5*0.5 * 2) * VAL(HEAD_SIZE) * 0.5, VAL(HEAD_SIZE) - 0.9); drawRoundCylinder( 0.9, 0.2, 0.2); glPopMatrix(); glPushMatrix(); setDiffuseColor(COLOR_RED); glTranslated( 0.5 / sqrt(0.5*0.5 * 2) * VAL(HEAD_SIZE) * 0.5, 0.5 / sqrt(0.5*0.5 * 2) * VAL(HEAD_SIZE) * 0.5, VAL(HEAD_SIZE) - 0.9); drawRoundCylinder( 0.9, 0.2, 0.2); glPopMatrix(); } glPopMatrix(); if (VAL(DETAIL_LEVEL) > 1) { //body // a.k.a. torso/trunk glPushMatrix(); setDiffuseColor(COLOR_YELLOW); glTranslated(0, 0.05 + VAL(LEG_LENGTH), 0); glRotated(-90, 1.0, 0.0, 0.0); drawRoundCylinder(VAL(HEIGHT), 0.7, 0.6); glPushMatrix(); glTranslated(-0.8, 0, VAL(HEIGHT) - 0.4); glRotated(90, 0, 1, 0); // the shoulder if (VAL(DETAIL_LEVEL) > 2) { drawRoundCylinder(1.6, 0.2, 0.2); } glPopMatrix(); // the waist if (VAL(DETAIL_LEVEL) > 3) { glPushMatrix(); glTranslated(0, 0, 0.5); glRotated(90, 1, 0, 0); drawTorus(0.7, 0.08); glPopMatrix(); } glPopMatrix(); if (VAL(DETAIL_LEVEL) > 2) { //right arm glPushMatrix(); glTranslated(-0.7 - 0.20, VAL(LEG_LENGTH) + 0.05 + VAL(HEIGHT) * 0.9f, 0); glTranslated(0.15, 0, 0); glRotated(VAL(RIGHT_UPPER_ARM_ROTATE_X), 1.0, 0.0, 0.0); glRotated(VAL(RIGHT_UPPER_ARM_ROTATE_Y), 0.0, 1.0, 0.0); glTranslated(-0.15, 0, 0); drawRoundCylinder(VAL(UPPER_ARM_LENGTH), 0.22, 0.15); // lower arm glTranslated(0, 0, VAL(UPPER_ARM_LENGTH) - 0.1); glRotated(VAL(RIGHT_LOWER_ARM_ROTATE) - 180, 1, 0, 0); drawRoundCylinder(VAL(LOWER_ARM_LENGTH), 0.15, 0.20); // hand glPushMatrix(); glTranslated(-0.03, -0.15, VAL(LOWER_ARM_LENGTH) - 0.1); glRotated(VAL(RIGHT_HAND_ANGLE), 0, 1, 0); drawCylinder(0.8, 0.15, 0.0001); glPopMatrix(); glPushMatrix(); glTranslated(0.03, -0.15, VAL(LOWER_ARM_LENGTH) - 0.1); glRotated(-VAL(RIGHT_HAND_ANGLE), 0, 1, 0); drawCylinder(0.8, 0.15, 0.0001); glPopMatrix(); glPopMatrix(); //left arm glPushMatrix(); glTranslated(0.7 + 0.20, VAL(LEG_LENGTH) + 0.05 + VAL(HEIGHT) * 0.9f, 0); glTranslated(-0.15, 0, 0); glRotated(VAL(LEFT_UPPER_ARM_ROTATE_X), 1.0, 0.0, 0.0); glRotated(VAL(LEFT_UPPER_ARM_ROTATE_Y), 0.0, 1.0, 0.0); glTranslated(0.15, 0, 0); drawRoundCylinder(VAL(UPPER_ARM_LENGTH), 0.22, 0.15); glTranslated(0, 0, VAL(UPPER_ARM_LENGTH) - 0.1); glRotated(VAL(LEFT_LOWER_ARM_ROTATE) - 180, 1, 0, 0); drawRoundCylinder(VAL(LOWER_ARM_LENGTH), 0.15, 0.20); // hand glPushMatrix(); glTranslated(-0.03, 0, VAL(LOWER_ARM_LENGTH) - 0.1); glRotated(VAL(LEFT_HAND_ANGLE), 0, 1, 0); drawBox(0.03, 0.25, 0.5); glPopMatrix(); glPushMatrix(); glTranslated(0.03, 0, VAL(LOWER_ARM_LENGTH) - 0.1); glRotated(-VAL(LEFT_HAND_ANGLE), 0, 1, 0); drawBox(0.03, 0.25, 0.5); if (VAL(DETAIL_LEVEL) > 3) { glRotated(90, 0, 0, 1); drawCylinder(5, 0.02, 0.02); if (VAL(DETAIL_LEVEL) > 4) { glTranslated(0, 0, 4); LS ls("X", VAL(LS_DEPTH), VAL(LS_ANGLE)); ls.expand(0); glPushMatrix(); setDiffuseColor(COLOR_GREEN); glTranslated(0, -0.5, 1); glPushMatrix(); glRotated(90, 1.0, 0.0, 0.0); ls.drawLS(); glPopMatrix(); glPopMatrix(); } } glPopMatrix(); glPopMatrix(); } //right leg glPushMatrix(); setDiffuseColor(COLOR_YELLOW); glTranslated(-0.5, VAL(LEG_LENGTH), 0); glRotated(VAL(RIGHT_LEG_ROTATE_X), 1.0, 0.0, 0.0); glRotated(VAL(RIGHT_LEG_ROTATE_Y), 0.0, 1.0, 0.0); drawRoundCylinder(VAL(LEG_LENGTH) - 0.15, 0.3, 0.4); glTranslated(0, 0, VAL(LEG_LENGTH) * 0.85f); glRotated(70, 1, 0, 0); drawTorus(VAL(FEET_SIZE), VAL(FEET_SIZE) / 4); glPopMatrix(); //left leg glPushMatrix(); glTranslated(0.5, VAL(LEG_LENGTH), 0); glRotated(VAL(LEFT_LEG_ROTATE_X), 1.0, 0.0, 0.0); glRotated(VAL(LEFT_LEG_ROTATE_Y), 0.0, 1.0, 0.0); drawRoundCylinder(VAL(LEG_LENGTH) - 0.15, 0.3, 0.4); glTranslated(0, 0, VAL(LEG_LENGTH) * 0.85f); glRotated(70, 1, 0, 0); drawTorus(VAL(FEET_SIZE), VAL(FEET_SIZE) / 4); glPopMatrix(); } glPopMatrix(); }