/* Create our toolbar */ void init_call_info(void) { pghandle bArrowMask,bArrow; /* Set up a bitmap/bitmask for the keypad button up arrow. * We have the mask stored in PNM format, and we paint * the arrow bitmap itself solid black. If we wanted another * color for the arrow, we could paint it that other color, * then apply the bitmask to it with the PG_LGOP_INVERT_AND * logical operation to mask out only the arrow part. */ bArrowMask = pgNewBitmap(pgFromMemory(arrow_bits,arrow_len)); bArrow = pgCreateBitmap(11,6); pgRender(bArrow,PG_GROP_SETCOLOR,0x000000); pgRender(bArrow,PG_GROP_RECT,0,0,15,8); /* Create a toolbar that starts out hidden */ wInfoBar = pgRegisterApp(PG_APP_TOOLBAR,"pgtuxphone/call_info", PG_APPSPEC_SIDE, PG_S_BOTTOM, 0); pgSetWidget(PGDEFAULT, PG_WP_SIZE,0, 0); /* Create widgets within the toolbar */ wKeypadBtn = pgNewWidget(PG_WIDGET_BUTTON,0,0); pgSetWidget(PGDEFAULT, PG_WP_SIDE,PG_S_LEFT, PG_WP_BITMAP, bArrow, PG_WP_BITMASK, bArrowMask, PG_WP_EXTDEVENTS, PG_EXEV_TOGGLE, PG_WP_TEXT,pgNewString("Keypad"), 0); pgBind(PGDEFAULT,PG_WE_ACTIVATE,&btnKeypad,NULL); pgNewWidget(PG_WIDGET_BUTTON,0,0); pgSetWidget(PGDEFAULT, PG_WP_SIDE,PG_S_LEFT, PG_WP_TEXT,pgNewString("Redial"), 0); pgBind(PGDEFAULT,PG_WE_ACTIVATE,&btnRedial,NULL); /* Make the connect time opaque and fixed-width to minimize the * amount of redrawing necessary to update it */ wConnectTime = pgNewWidget(PG_WIDGET_LABEL,0,0); pgSetWidget(PGDEFAULT, PG_WP_TRANSPARENT,0, PG_WP_SIDE,PG_S_RIGHT, PG_WP_FONT,pgNewFont(NULL,0,PG_FSTYLE_FIXED), 0); wCallStatus = pgNewWidget(PG_WIDGET_LABEL,0,0); pgSetWidget(PGDEFAULT, PG_WP_SIDE,PG_S_RIGHT, 0); wName = pgNewWidget(PG_WIDGET_LABEL,0,0); pgSetWidget(PGDEFAULT, PG_WP_SIDE,PG_S_LEFT, PG_WP_FONT,pgNewFont(NULL,12,0), 0); wPhoneNumber = pgNewWidget(PG_WIDGET_CANVAS,0,0); pgSetWidget(PGDEFAULT, PG_WP_SIDE,PG_S_ALL, 0); new_vfd_label(wPhoneNumber); }
// display callback // // README: This gets called by the event handler // to draw the scene, so this is where you need // to build your scene -- make your changes and // additions here. All rendering happens in this // function. For Assignment 2, updates to the // joint DOFs (joint_ui_data) happen in the // animate() function. void display(void) { // Clear the screen with the background colour glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Setup the model-view transformation matrix glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // Specify camera transformation glTranslatef(camXPos, camYPos, camZPos); // Get the time for the current animation step, if necessary if( animate_mode ) { float curTime = animationTimer->elapsed(); if( curTime >= keyframes[maxValidKeyframe].getTime() ) { // Restart the animation animationTimer->reset(); curTime = animationTimer->elapsed(); } /////////////////////////////////////////////////////////// // README: // This statement loads the interpolated joint DOF vector // into the global 'joint_ui_data' variable. Use the // 'joint_ui_data' variable below in your model code to // drive the model for animation. /////////////////////////////////////////////////////////// // Get the interpolated joint DOFs joint_ui_data->setDOFVector( getInterpolatedJointDOFS(curTime) ); // Update user interface joint_ui_data->setTime(curTime); glui_keyframe->sync_live(); } /////////////////////////////////////////////////////////// // TODO: // Modify this function to draw the scene. // This should include function calls that apply // the appropriate transformation matrices and render // the individual body parts. // Use the 'joint_ui_data' data structure to obtain // the joint DOFs to specify your transformations. // Sample code is provided below and demonstrates how // to access the joint DOF values. This sample code // should be replaced with your own. // Use the 'renderStyle' variable and the associated // enumeration to determine how the geometry should be // rendered. /////////////////////////////////////////////////////////// // SAMPLE CODE ********** // GLfloat light_position[] = {1000 * cos(joint_ui_data->getDOF(Keyframe::LIGHT_THETA) * PI), 1000 * sin(joint_ui_data->getDOF(Keyframe::LIGHT_THETA) * PI), 1000, 1.0 }; if (renderStyle == METALLIC || renderStyle == MATTE) { glLightfv(GL_LIGHT0, GL_POSITION, light_position); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); } else { glDisable(GL_LIGHT0); glDisable(GL_LIGHTING); } glPushMatrix(); glScalef(0.5,0.5,0.5); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); // setup transformation for body part glTranslatef(joint_ui_data->getDOF(Keyframe::ROOT_TRANSLATE_X), joint_ui_data->getDOF(Keyframe::ROOT_TRANSLATE_Y), joint_ui_data->getDOF(Keyframe::ROOT_TRANSLATE_Z)); glRotatef(joint_ui_data->getDOF(Keyframe::ROOT_ROTATE_X), 1.0, 0.0, 0.0); glRotatef(joint_ui_data->getDOF(Keyframe::ROOT_ROTATE_Y), 0.0, 1.0, 0.0); glRotatef(joint_ui_data->getDOF(Keyframe::ROOT_ROTATE_Z), 0.0, 0.0, 1.0); // Body glColor3f(0, 1, 1); pgRender(&pgDrawBody); // Head glPushMatrix(); glTranslatef(0,3.0,0); glRotatef(joint_ui_data->getDOF(Keyframe::HEAD), 0.0, 1.0, 0.0); glColor3f(0.5, 1, 1); pgRender(&pgDrawHead); //Upper Beak glPushMatrix(); glTranslatef(-1.75,0,0); glRotatef(-90.0, 0.0, 0.0, 1.0); glColor3f(0.5, 0.5, 0); pgRender(&pgDrawBeak); glPopMatrix(); //Lower Beak glPushMatrix(); glTranslatef(-1.75,-0.2 - (joint_ui_data->getDOF(Keyframe::BEAK) / 2),0); glRotatef(-90.0, 0.0, 0.0, 1.0); glColor3f(0.5,0.5, 0); pgRender(&pgDrawBeak); glPopMatrix(); glPopMatrix(); //left Arm glPushMatrix(); glTranslatef(0,0.75,1.25); glRotatef(-90.0, 1.0, 0.0, 0.0); glRotatef(-joint_ui_data->getDOF(Keyframe::L_SHOULDER_YAW), 1.0, 0.0, 0.0); glRotatef(-joint_ui_data->getDOF(Keyframe::L_SHOULDER_ROLL), 0.0, 1.0, 0.0); glRotatef(-joint_ui_data->getDOF(Keyframe::L_SHOULDER_PITCH), 0.0, 0.0, 1.0); glTranslatef(0, 0.5, 0); glColor3f(1, 0.5, 0); pgRender(&pgDrawSoulder); //Left Hand glPushMatrix(); glTranslatef(0, -2, 0); glRotatef(-joint_ui_data->getDOF(Keyframe::L_ELBOW), 1.0, 0.0, 0.0); glColor3f(1, 1, 0); pgRender(&pgDrawHand); glPopMatrix(); glPopMatrix(); //Right Arm glPushMatrix(); glTranslatef(0,0.75,-1.25); glRotatef(90.0, 1.0, 0.0, 0.0); glRotatef(joint_ui_data->getDOF(Keyframe::R_SHOULDER_YAW), 1.0, 0.0, 0.0); glRotatef(joint_ui_data->getDOF(Keyframe::R_SHOULDER_ROLL), 0.0, 1.0, 0.0); glRotatef(-joint_ui_data->getDOF(Keyframe::R_SHOULDER_PITCH), 0.0, 0.0, 1.0); glTranslatef(0, 0.5, 0); glColor3f(1, 0.5, 0); pgRender(&pgDrawSoulder); //Right Hand glPushMatrix(); glTranslatef(0, -2, 0); glRotatef(joint_ui_data->getDOF(Keyframe::R_ELBOW), 1.0, 0.0, 0.0); glColor3f(1, 1, 0); pgRender(&pgDrawHand); glPopMatrix(); glPopMatrix(); //Left Leg glPushMatrix(); glTranslatef(0,-2.0,0.75); glRotatef(-joint_ui_data->getDOF(Keyframe::L_HIP_PITCH), 1.0, 0.0, 0.0); glRotatef(-joint_ui_data->getDOF(Keyframe::L_HIP_ROLL), 0.0, 1.0, 0.0); glRotatef(-joint_ui_data->getDOF(Keyframe::L_HIP_YAW), 0.0, 0.0, 1.0); glTranslatef(0, -0.75, 0); glColor3f(1, 0.5, 0); pgRender(&pgDrawLeg); //Left Foot glPushMatrix(); glTranslatef(0.1,-0.75,0); glRotatef(joint_ui_data->getDOF(Keyframe::L_KNEE), 0.0, 0.0, 1.0); glTranslatef(0.15, 0, 0); glColor3f(1, 1, 0); pgRender(&pgDrawFoot); glPopMatrix(); glPopMatrix(); //Right Leg glPushMatrix(); glTranslatef(0,-2.0,-0.75); glRotatef(joint_ui_data->getDOF(Keyframe::R_HIP_PITCH), 1.0, 0.0, 0.0); glRotatef(joint_ui_data->getDOF(Keyframe::R_HIP_ROLL), 0.0, 1.0, 0.0); glRotatef(-joint_ui_data->getDOF(Keyframe::R_HIP_YAW), 0.0, 0.0, 1.0); glTranslatef(0, -0.75, 0); glColor3f(1, 0.5, 0); pgRender(&pgDrawLeg); //Right Foot glPushMatrix(); glTranslatef(0.1,-0.75,0); glRotatef(joint_ui_data->getDOF(Keyframe::R_KNEE), 0.0, 0.0, 1.0); glTranslatef(0.15,0, 0); glColor3f(1,1, 0); pgRender(&pgDrawFoot); glPopMatrix(); glPopMatrix(); glPopMatrix(); // Execute any GL functions that are in the queue just to be safe glFlush(); // Dump frame to file, if requested if( frameToFile ) { sprintf(filenameF, "frame%03d.ppm", frameNumber); writeFrame(filenameF, false, false); } // Now, show the frame buffer that we just drew into. // (this prevents flickering). glutSwapBuffers(); }