void lower_arm(float h) { // draw the lower arm setDiffuseColor( 0.85, 0.75, 0.25 ); setAmbientColor( 0.95, 0.75, 0.25 ); y_box(h); }
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(); }
// We are going to override (is that the right word?) the draw() // method of ModelerView to draw out SampleModel void SampleModel::draw() { // This call takes care of a lot of the nasty projection // matrix stuff. Unless you want to fudge directly with the // projection matrix, don't bother with this ... ModelerView::draw(); /************************************************* ** ** NOW SAVE THE CURRENT MODELVIEW MATRIX ** ** At this point in execution, the MODELVIEW matrix contains ** ONLY the camera transformation. We need to save this camera ** transformation so that we can use it later (for reasons ** explained below). ** *****************************************************/ cameraMatrix = getModelViewMatrix(); // draw the sample model setAmbientColor(.1f, .1f, .1f); //glPushMatrix(); //glPopMatrix(); glPushMatrix(); // push identity glTranslated(VAL(XPOS), VAL(YPOS), VAL(ZPOS)); // values set by the sliders if (VAL(NINJATURTLE)) setDiffuseColor(COLOR_GREEN); else setDiffuseColor(.940f, .816f, .811f); if (animate) glRotated(animHeadAngle, 0.0, 1.0, 0.0); if (VAL(EYEBANDANA)) drawEyeBandana(); if (!VAL(NINJATURTLE)) setDiffuseColor(.940f, .816f, .811f); drawHead(); if (!VAL(NINJATURTLE)) { setDiffuseColor(0, 0, 0); drawFace(); setDiffuseColor(.940f, .816f, .811f); drawNeck(); } drawUpperTorso(); drawLowerTorso(); if (!VAL(NINJATURTLE)) setDiffuseColor(.940f, .816f, .811f); drawRightHandJoint(); glPushMatrix(); if (animate) glRotated(animUpperArmAngle, 1.0, 0, 0); drawUpperRightHand(); drawLowerRightHand(); drawRightHand(); glPopMatrix(); drawLeftHandJoint(); glPushMatrix(); if (animate) glRotated(-animUpperArmAngle, 1.0, 0, 0); drawUpperLeftHand(); drawLowerLeftHand(); drawLeftHand(); glPopMatrix(); drawRightLegJoint(); drawLeftLegJoint(); drawUpperRightLeg(); drawLowerRightLeg(); drawRightFoot(); drawUpperLeftLeg(); drawLowerLeftLeg(); drawLeftFoot(); if (VAL(NINJATURTLE)) drawShell(); else drawTail(); // handle the positioning and hierachical modeling of the tail if (VAL(METABALLSKIN)) { MetaBalls mb; mb.setUpGrid(); mb.setUpMetaballs(); mb.evalScalarField(); mb.draw(); } glPopMatrix(); /*********************************************** ** ** NOW WE WILL ACTUALLY BEGIN DRAWING THE MODEL ** ** Draw your model up to the node where you would like ** particles to spawn from. ** ** FYI: As you call glRotate, glScale, or glTranslate, ** OpenGL is multiplying new transformations into the ** MODELVIEW matrix. ** ********************************************/ // If particle system exists, draw it ParticleSystem *ps = ModelerApplication::Instance()->GetParticleSystem(); if (ps != NULL) { ps->computeForcesAndUpdateParticles(t); ps->drawParticles(t, m_camera); } /************************************************* ** ** NOW DO ANY CLOSING CODE ** ** Don't forget that animator requires you to call ** endDraw(). ** **************************************************/ endDraw(); }
void SampleModel::drawShell() { // draw the front setDiffuseColor(251.0 / 255, 193.0 / 255, 86.0 / 255); drawTriangle(0, 0.4 + 0.8, 1.0, 0, 0.4, 1.3, 1.1, 0.4 + 0.8 - 0.3, 0.7); // T1: top, bottom, right drawTriangle(0, 0.4 + 0.8, 1.0, 0, 0.4, 1.3, -1.1, 0.4 + 0.8 - 0.3, 0.7); // T2: top, bottom, left drawTriangle(0, 0.4, 1.3, 1.1, 0.4 + 0.8 - 0.3, 0.7, 1.1, 0.4 + 0.8 - 0.3 - 0.8, 0.7); // T3: left, top, bottom drawTriangle(0, 0.4, 1.3, -1.1, 0.4 + 0.8 - 0.3, 0.7, -1.1, 0.4 + 0.8 - 0.3 - 0.8, 0.7); // T4: right, top, bottom drawTriangle(0, 0.4, 1.3, 1.1, 0.4 + 0.8 - 0.3 - 0.8, 0.7, 0, -1.0, 1.3); // T5: top, right, bottom drawTriangle(0, 0.4, 1.3, -1.1, 0.4 + 0.8 - 0.3 - 0.8, 0.7, 0, -1.0, 1.3); // T6: top, left, bottom drawTriangle(1.1, 0.4 + 0.8 - 0.3 - 0.8, 0.7, 0, -1.0, 1.3, 1.1, -1.5, 0.7); // T7: top, left, right drawTriangle(-1.1, 0.4 + 0.8 - 0.3 - 0.8, 0.7, 0, -1.0, 1.3, -1.1, -1.5, 0.7); // T8: top, right, left drawTriangle(0, -1.0, 1.3, 0, -1.9, 1.0, 1.1, -1.5, 0.7); // T9: top, bottom, right drawTriangle(0, -1.0, 1.3, 0, -1.9, 1.0, -1.1, -1.5, 0.7); // T10: top, bottom, left // draw the back squares setDiffuseColor(14.0 / 255, 130.0 / 255, 74.0 / 255); drawTriangle(0.3, 0.7, -1.5, -0.3, 0.7, -1.5, 0.3, 0.1, -1.5); // T11: left, right, bottom drawTriangle(0.3, 0.1, -1.5, -0.3, 0.1, -1.5, -0.3, 0.7, -1.5); // T12: left, right, top drawTriangle(0.3, 0.1, -1.5, -0.3, 0.1, -1.5, 0.3, -0.5, -1.5); // T13: left, right, bottom drawTriangle(0.3, -0.5, -1.5, -0.3, -0.5, -1.5, -0.3, 0.1, -1.5); // T14: left, right, top drawTriangle(0.3, -0.5, -1.5, -0.3, -0.5, -1.5, 0.3, -1.1, -1.5); // T15: left, right, bottom drawTriangle(0.3, -1.1, -1.5, -0.3, -1.1, -1.5, -0.3, -0.5, -1.5); // T16: left, right, top // draw the back top plates drawTriangle(0.3, 0.7, -1.5, -0.3, 0.7, -1.5, 0.0, 1.2, -0.7); // T17: left, right, top drawTriangle(-0.3, 0.7, -1.5, -1.3, 1.0, -0.7, 0.0, 1.2, -0.7); // T18: left, right, top drawTriangle(1.3, 1.0, -0.7, 0.3, 0.7, -1.5, 0.0, 1.2, -0.7); // T19: left, right, top // draw the back bottom plates drawTriangle(0.3, -1.1, -1.5, -0.3, -1.1, -1.5, 0.0, -1.6, -0.7); // T20: left, right, bottom drawTriangle(-0.3, -1.1, -1.5, -1.3, -1.3, -0.7, 0.0, -1.6, -0.7); // T21: left, right, bottom drawTriangle(1.3, -1.5, -0.7, 0.3, -1.1, -1.5, 0.0, -1.6, -0.7); // T22: left, right, bottom // draw the back side plates drawTriangle(1.3, 1.0, -0.7, 0.3, 0.7, -1.5, 1.3, -1.5, -0.7); // T23: left, right, bottom drawTriangle(1.3, -1.5, -0.7, 0.3, -1.1, -1.5, 0.3, 0.7, -1.5); // T24: left, right, top drawTriangle(-0.3, 0.7, -1.5, -1.3, 1.0, -0.7, -1.3, -1.3, -0.7); // T25: left, right, bottom drawTriangle(-0.3, -1.1, -1.5, -1.3, -1.3, -0.7, -0.3, 0.7, -1.5); // T26: left, right, top // draw the sides setDiffuseColor(140 / 255, 200.0 / 255, 65.0 / 255); drawTriangle(0, 0.4 + 0.8, 1.0, 1.1, 0.4 + 0.8 - 0.3, 0.7, 1.3, 1.0, -0.7); // T27 drawTriangle(1.3, 1.0, -0.7, 0.0, 1.2, -0.7, 0, 0.4 + 0.8, 1.0); // T28 drawTriangle(0, 0.4 + 0.8, 1.0, -1.1, 0.4 + 0.8 - 0.3, 0.7, 0.0, 1.2, -0.7); // T29 drawTriangle(-1.3, 1.0, -0.7, 0.0, 1.2, -0.7, -1.1, 0.4 + 0.8 - 0.3, 0.7); // T30 drawTriangle(-1.3, 1.0, -0.7, -1.1, 0.4 + 0.8 - 0.3, 0.7, - 1.3, -1.3, -0.7); // T31 drawTriangle(-1.1, 0.4 + 0.8 - 0.3, 0.7, -1.1, -1.5, 0.7, -1.3, -1.3, -0.7); // T32 drawTriangle(1.3, -1.5, -0.7, 0, -1.9, 1.0, 1.1, -1.5, 0.7); // T33 drawTriangle(1.3, -1.5, -0.7, 0.0, -1.6, -0.7, 0, -1.9, 1.0); // T34 drawTriangle(-1.3, -1.3, -0.7, 0.0, -1.6, -0.7, 0, -1.9, 1.0); // T35 drawTriangle(0, -1.9, 1.0, -1.1, -1.5, 0.7, -1.3, -1.3, -0.7); // T36 drawTriangle(1.1, 0.4 + 0.8 - 0.3, 0.7, 1.1, -1.5, 0.7, 1.3, -1.5, -0.7); // T37 drawTriangle(1.3, 1.0, -0.7, 1.1, 0.4 + 0.8 - 0.3, 0.7, 1.3, -1.5, -0.7); // T38 }
void ofMaterial::setColors(ofFloatColor oDiffuse, ofFloatColor oAmbient, ofFloatColor oSpecular, ofFloatColor oEmissive) { setDiffuseColor(oDiffuse); setAmbientColor(oAmbient); setSpecularColor(oSpecular); setEmissiveColor(oEmissive); }