sp<Retval> GdMonCpustat::draw(int num, sp<info>& info, sp<MonBase>& dest
                        , const char* path)
  {
      sp<Retval> retval;
      if( DFW_RET(retval, MonCpustat::draw(num, info, dest, path)) )
          return DFW_RETVAL_D(retval);
      if( DFW_RET(retval, baseInit()) )
          return DFW_RETVAL_D(retval);

      struct max_st  max;
      struct data_st dt;
      getMax(&max, info, m_g.cs.w);
      setData(&dt);

      drawHead(dest->m_sec, info->m_sec);

      uint64_t first_sec;
      uint64_t last_sec = dest->m_sec;
      for(int k=info->m_aLists.size(), dx=m_g.cr.ex; ((k>0)&&(dx>m_g.cr.sx));)
      {
          sp<GdMonCpustat> p  = info->m_aLists.get(k-1);
          sp<GdMonCpustat> pp = info->m_aLists.get(k-2);
          procData(dx, &max, &dt, p, pp);
          drawData(dx, &dt);
          k--;
          dx--;
          first_sec = p->m_sec;
      }

      drawBottom(dest, &max, &dt);
      drawLast(first_sec, last_sec);
      if( DFW_RET(retval, savePng(path, savename(), 0)) )
          return DFW_RETVAL_D(retval);
      return NULL;
  }
Beispiel #2
0
void Snake::draw(QPainter *painter)
{
    drawHead(painter);
    for(int i=0; i<body.size(); i++){
        body[i]->drawBody(painter);
    }
}
void LineShape::draw(wxDC& dc)
{
	if (isSelected()) {
		dc.SetPen(wxPen(WXSTRING("RED"), lineWidth, wxSOLID));
	} else {
		dc.SetPen(wxPen(WXSTRING("BLACK"), lineWidth, wxSOLID));
	}

	dc.DrawLine(node1->getCentre().x, node1->getCentre().y, node2->getCentre().x,
	            node2->getCentre().y);

	if (arrowHeadSize > 0) {
		drawHead(dc);
	}

	if (title == "" && node1->getTitle() != "" && node2->getTitle() != "") {
		title = node1->getTitle() + " to " + node2->getTitle();
	}
	Size textSize = dc.GetTextExtent(WXSTRING(title));

	Point textPoint = getBegin();
	// double angle = getAngle();
	double angle = Shape2DUtils::getAngle(node1->getCentre(), node2->getCentre());
	double dX = (getLength() / 2 - textSize.x / 2) * sin(angle);
	double dY = (getLength() / 2 - textSize.x / 2) * cos(angle);

	textPoint.x += dX;
	textPoint.y -= dY;

	double degreeAngle = angle * (180.0 / PI);
	double rotationAngle = 90 - degreeAngle;

	dc.DrawRotatedText(WXSTRING(title), textPoint, rotationAngle);
}
Beispiel #4
0
void drawRobot()
{
	glPushMatrix();
		glTranslatef (0, 0, -BodyH/2);
		drawBody();
	glPopMatrix();

	//Head
	glPushMatrix();
		glTranslatef (0, 0, BodyH/2);
		glRotatef (HeadAngle, 0.0, 0.0, 1.0);
		drawHead();
	glPopMatrix();

	//Arms
	glPushMatrix();
		glRotatef (ArmVertAngle, 1.0, 0.0, 0.0);
		glRotatef (ArmLatAngle, 0.0, 1.0, 0.0);
		drawArm();
	glPopMatrix();

	glPushMatrix();
		glRotatef (-ArmVertAngle, 1.0, 0.0, 0.0);
		glRotatef (ArmLatAngle, 0.0, 1.0, 0.0);
		drawArm();
	glPopMatrix();

	//Legs
	glPushMatrix();
		glTranslatef (0, 0, -BodyH/2);
		glRotatef (LegRotAngle, 0.0, 0.0, 1.0);
		glRotatef (-LegVertAngle, 1.0, 0.0, 0.0);
		drawLeg();
	glPopMatrix();

	glPushMatrix();
		glTranslatef (0, 0, -BodyH/2);
		glRotatef (LegRotAngle+90, 0.0, 0.0, 1.0);
		glRotatef (-LegVertAngle, 1.0, 0.0, 0.0);
		drawLeg();
	glPopMatrix();

	glPushMatrix();
		glTranslatef (0, 0, -BodyH/2);
		glRotatef (LegRotAngle+180, 0.0, 0.0, 1.0);
		glRotatef (-LegVertAngle, 1.0, 0.0, 0.0);
		drawLeg();
	glPopMatrix();

	glPushMatrix();
		glTranslatef (0, 0, -BodyH/2);
		glRotatef (LegRotAngle+270, 0.0, 0.0, 1.0);
		glRotatef (-LegVertAngle, 1.0, 0.0, 0.0);
		drawLeg();
	glPopMatrix();
}
void Person::drawPerson()
{
	/*
	Draw torso
    Draw head
    Draw right arm
    Draw left arm
    Draw right leg
    Draw left leg*/
	//////////////////////////////////////////////////////

	glPushMatrix();//(0,0)
		glPushMatrix();
			glTranslatef(-75,0,0);//Move to center of torso bottom: -3", 0"
			drawTorso();
		glPopMatrix();

		glPushMatrix();
			glTranslatef(0, 300, 0);//Move to top of torso, 0", 30"
			glPushMatrix();
				glTranslatef(0, 60, 0);//move to center of head: 0", 36"
				drawHead();
			glPopMatrix();
		glPopMatrix();

		glPushMatrix();
			//Right arm
			glTranslatef(150,10,0);
			glRotatef(20,0,0,1);
			drawArm();
		glPopMatrix();
		glPushMatrix();
			//left arm
			glScalef(-1,1,0);
			glTranslatef(150,10,0);
			glRotatef(20,0,0,1);
			drawArm();
		glPopMatrix();
		glPushMatrix();
			//Draw Right leg
			glTranslatef(15, 0, 0);
			glTranslatef(0, -300, 0);
			drawLeg();
		glPopMatrix();
		glPushMatrix();
			//Draw left leg
			glScalef(-1,1,0);
			glTranslatef(15, 0, 0);
			glTranslatef(0, -300, 0);
			drawLeg();
		glPopMatrix();
	glPopMatrix();

}//end drawPerson
void drawBee() {
    mvstack.push(model_view);
    //rotate bee
    model_view *= RotateY(-10*TIME);
    model_view *= Translate(0, 5, 0);
    model_view *= Translate(5, .5*sin(100+TIME), 0);
    model_view *= RotateY(90);

    //draw bee parts
    drawBody();    
    drawHead();
    drawTail();
    drawWings();
    drawLegz();

    model_view = mvstack.pop();
}
Beispiel #7
0
static void startContinuous(void){
	// Method for continuing the Continuous mode
	resetContinuous();
	drawGallow();
	int i;
	for (i=0; i<try; i++){
		if (i==0){
			drawHead();
		}
		else if (i==1){
			drawBody();
		}
		else if (i==2){
			drawRightArm();
		}
		else if (i==3){
			drawLeftArm();
		}
		else if (i==4){
			drawRightLeg();
		}
	}
	static char puc_score[10];
	usprintf(puc_score, "Score: %d", score);
    RIT128x96x4StringDraw(puc_score, 69, 0, 15);
	displayAlphabet();
	drawUnderscore(0, 83);
	drawHiddenWord();
}

static void startClassic(void){
	// Method for starting the Classic mode
	resetClassic();
	drawGallow();
	static char puc_score[10];
	usprintf(puc_score, "Score: %d", score);
    RIT128x96x4StringDraw(puc_score, 69, 0, 15);
	displayAlphabet();
    drawUnderscore(0, 83);
	drawHiddenWord();
}
void drawSkeliton() {
    glClearColor(1.f, 1.f, 1.f, 1.f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glColor3f(0, 0, 0);
    glTranslatef(0, 10, -100);
    
    glutSolidSphere(1.5, 50, 40);
    glPushMatrix();
    
    drawDownwardsLineOfHeight(20);      // Torso
    
    glPushMatrix();
    
    drawLeftLimb();
    
    glPopMatrix();
    
    drawRightLimb();
    
    glPopMatrix();
    
    glPushMatrix();                     // bottom of stack so push the center point so we can come back to it
    
    drawLeftLimb();
    
    glPopMatrix();
    
    glPushMatrix();                     // bottom of stack so push the center point so we can come back to it
    
    drawRightLimb();
    
    glPopMatrix();
    
    glPushMatrix();                     // bottom of stack so push the center point so we can come back to it
    
    drawHead();
    
    glPopMatrix();                      // return to center pos
    
    glutSwapBuffers();
}
Beispiel #9
0
void drawEntireBody(){
	// Draw our hinged object
	// Push the current transformation matrix on the stack
	glPushMatrix();
		glPushMatrix();
		{
			glTranslatef(bodyPositionX, 0.0, 0.0);
			// Scale to size of body
			glScalef(BODY_WIDTH, BODY_LENGTH, 1.0);
			// Set the colour to green
			glColor3f(0.0, 1.0, 0.0);

			// Draw the body
			Point bodyPoints[] = {
					// top left, right points
					{-NECK_WIDTH/2, 0.5f}, {NECK_WIDTH/2, 0.5f},
					// middle right point
					{BELLY_WIDTH/2, -0.4f},
					// bottom right point
					{BOTTOM_WIDTH/2, -0.7f},
					// bottom left point
					{-BOTTOM_WIDTH/2, -0.7f},
					// middle left point
					{-BELLY_WIDTH/2, -0.4f}};
			drawPolygon(6, bodyPoints);

			drawArm();
			drawLeg(1.0, leg1Rotation, foot1Rotation);
			drawLeg(-1.0, leg2Rotation, foot2Rotation);
			drawHead();
		}
		glPopMatrix();


	// Retrieve the previous state of the transformation stack
	glPopMatrix();
}
/**
 *  DrawNeutral function.
 *
 *  This function draws the stick figure depending on the
 *  transforming stage of the player or draws a diamond if the
 *  player is not tracked.
 *
 *  @param player is the ID of the player.
 *
 */
void NeutralModel :: drawNeutral (XnUserID player)
{
    // UserGenerator.
    UserGenerator userGen;

    // Color of the stick figure.
    XnFloat color[3];

    // Material properties.
    GLfloat mat_specular[] = { 0.3, 0.3, 0.3, 0.3 };
    GLfloat mat_shininess[] = { 10.0 };

    // Center of mass.
    XnPoint3D com;

    // Player's stage.
    int stage;

    float ax;
    Vector3D a;
    Vector3D b;
    Vector3D c;
    Vector3D u;
    Vector3D v;
    Vector3D w;

    GLuint mode;

    // Select the players color according his ID.
    color[0] = Colors[player % nColors][0];
    color[1] = Colors[player % nColors][1];
    color[2] = Colors[player % nColors][2];

    // Set the material for the stick figure.
    GLfloat materialColor[] = {color[0], color[1], color[2], 1.0f};
    
    glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, materialColor);
    glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
    glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);

    userGen = nm_UserDetector -> retUserGenerator();
    SkeletonCapability skelCap = userGen.GetSkeletonCap();

    mode =  GLM_SMOOTH | GLM_MATERIAL;


    a = Vector3D(joint[LSHOULDER]);
    b = Vector3D(joint[RSHOULDER]);
    c = Vector3D(joint[RHIP]);

    u = b - a;
    v = c - a;

    w = u.cross(v);
    w.y = 0.0;
    w.normalize();

    ax = 57.2957795 * acos(w.z);

    if (w.x <= 0.0) {
        ax = -ax;
    }

    // Init the drawing process.
    // Draws a stick figure if player is been tracked.
    if (skelCap.IsTracking(player)) {
       
        // Get player's stage.
        stage = nm_UserDetector -> retStage(player);

        loadJoints(player, skelCap);

        // Drawing legs.
        if ((stage >= 0) && (stage < 4)) { 

            // Left leg.
            glPushMatrix();
                orientMatrix(joint[RHIP],joint[RKNEE]);
                glTranslatef( 0.0, 0.0, 50.0);
                glScalef(250.0, 250.0, 250.0);
                glRotatef(90, -1.0, 0.0, 0.0);
                glRotatef(ax, 0.0,-1.0, 0.0);
                glmDraw(zamusModelParts.thigh, mode); 

            glPopMatrix();
            
            glPushMatrix();
                orientMatrix(joint[RKNEE],joint[RFOOT]);
                glTranslatef( 0.0, 0.0, 50.0);
                glScalef(100.0, 100.0, 100.0);
                glRotatef(90, -1.0, 0.0, 0.0);
                glRotatef(ax, 0.0,-1.0, 0.0);
                glmDraw(zamusModelParts.leg, mode); 
            glPopMatrix();

            // Right leg.
            glPushMatrix();
                orientMatrix(joint[LHIP], joint[LKNEE]);
                glTranslatef( 0.0, 0.0, 50.0);
                glScalef(-250.0, 250.0, 250.0);
                glRotatef(90, -1.0, 0.0, 0.0);
                glRotatef(-ax, 0.0,-1.0, 0.0);
                glmDraw(zamusModelParts.thigh, mode); 

            glPopMatrix();
            
            glPushMatrix();
                orientMatrix(joint[LKNEE], joint[LFOOT]);
                glTranslatef( 0.0, 0.0, 50.0);
                glScalef(-100.0, 100.0, 100.0);
                glRotatef(90, -1.0, 0.0, 0.0);
                glRotatef(-ax, 0.0,-1.0, 0.0);
                glmDraw(zamusModelParts.leg, mode); 

            glPopMatrix();
                  
            // Foots.
            glPushMatrix();
                glTranslatef( joint[LFOOT].X, joint[LFOOT].Y, joint[LFOOT].Z);
                glScalef(40.0,-40.0,-40.0);
                glRotatef(ax, 0.0,-1.0, 0.0);
                glTranslatef(0.0,-0.25, 0.5);
                glmDraw(zamusModelParts.foot, mode); 

            glPopMatrix();
            
            glPushMatrix();
                glTranslatef( joint[RFOOT].X, joint[RFOOT].Y, joint[RFOOT].Z);
                glScalef(-40.0,-40.0,-40.0);
                glRotatef(-ax, 0.0,-1.0, 0.0);
                glTranslatef(0.0,-0.25, 0.5);
                glmDraw(zamusModelParts.foot, mode); 

            glPopMatrix();
            


        } 
        else {
            drawLimp(joint[LKNEE],joint[LFOOT]);
            drawLimp(joint[RKNEE],joint[RFOOT]);
            drawLimp(joint[LHIP],joint[LKNEE]);
            drawLimp(joint[RHIP],joint[RKNEE]);
        }

        // Draw torso.
        if ((stage > 0) && (stage < 4)) {

            glPushMatrix();
                orientMatrix(joint[NECK],joint[TORSO]);
                glScalef(400.0, 400.0, 400.0);
                glRotatef(90, -1.0, 0.0, 0.0);
                glRotatef(ax, 0.0,-1.0, 0.0);
                glTranslatef(0.0, -0.1, 0.0);
                glmDraw(zamusModelParts.chest, mode); 
            glPopMatrix();

        }
        else {
            drawTorso();
        }

        // Drawing arms.
        if (stage == 2) {
    
            // Shoulders
            glPushMatrix();
                glTranslatef(joint[LSHOULDER].X, 
                             joint[LSHOULDER].Y,
                             joint[LSHOULDER].Z);
                glRotatef(-ax, 0.0,-2.0, 0.0);
                glTranslatef(-30.0,-40.0, 0.0);
                glScalef(500.0,-500.0, 500.0);
                glmDraw(zamusModelParts.shoulder, mode); 
            glPopMatrix();
            glPushMatrix();
                glTranslatef(joint[RSHOULDER].X, 
                             joint[RSHOULDER].Y,
                             joint[RSHOULDER].Z);
                glRotatef(-ax, 0.0,-1.0, 0.0);
                glTranslatef( 30.0,-40.0, 0.0);
                glScalef(500.0,-500.0, 500.0);
                glmDraw(zamusModelParts.shoulder, mode); 
            glPopMatrix();

            // LeftArm
            glPushMatrix();
                orientMatrix(joint[RSHOULDER], joint[RELBOW]);
                glTranslatef( 0.0, 0.0, 50.0);
                glScalef(500.0, 500.0, 500.0);
                glRotatef(90, -1.0, 0.0, 0.0);
                glRotatef(ax, 0.0,-1.0, 0.0);
                glmDraw(zamusModelParts.arm, mode); 
            glPopMatrix();
            glPushMatrix();
                orientMatrix(joint[RELBOW], joint[RHAND]);
                glTranslatef( 0.0, 0.0, 60.0);
                glScalef(250.0, 250.0, 250.0);
                glRotatef(90, -1.0, 0.0, 0.0);
                glRotatef(-ax, 0.0,-1.0, 0.0);
                glmDraw(zamusModelParts.forearm, mode); 
            glPopMatrix();
            
            glPushMatrix();
                orientMatrix(joint[LSHOULDER], joint[LELBOW]);
                glTranslatef( 0.0, 0.0, 50.0);
                glScalef(500.0, 500.0, 500.0);
                glRotatef(90, -1.0, 0.0, 0.0);
                glRotatef(ax, 0.0,-1.0, 0.0);
                glmDraw(zamusModelParts.arm, mode); 
            glPopMatrix();
            
            glPushMatrix();
                orientMatrix(joint[LELBOW],joint[LHAND]);
                glTranslatef( 0.0, 0.0, 80.0);
                glScalef(300.0, 300.0, 300.0);
                glRotatef(90, -1.0, 0.0, 0.0);
                glRotatef(-ax, 0.0,-1.0, 0.0);
                glmDraw(zamusModelParts.cannon, mode); 
            glPopMatrix();
           
        }
        else if ((stage == 4) || (stage == 5)) {

            glPushMatrix();
                glTranslatef(joint[LSHOULDER].X, 
                             joint[LSHOULDER].Y,
                             joint[LSHOULDER].Z);
                glRotatef(-ax, 0.0,-2.0, 0.0);
                glScalef(500.0,-500.0, 500.0);
                glmDraw(linqModelParts.shoulder, mode); 
            glPopMatrix();

            glPushMatrix();
                orientMatrix(joint[LSHOULDER],joint[LELBOW]);
                glTranslatef( 0.0, 0.0, 50.0);
                glScalef(-180.0, 180.0, 180.0);
                glRotatef(90, -1.0, 0.0, 0.0);
                glRotatef(-ax, 0.0,-1.0, 0.0);
                glmDraw(linqModelParts.thigh, mode); 
            glPopMatrix();
            
            glPushMatrix();
                orientMatrix(joint[LELBOW],joint[LHAND]);
                glTranslatef( 0.0, 0.0, 50.0);
                glScalef(-80.0, 80.0, 80.0);
                glRotatef(90, -1.0, 0.0, 0.0);
                glRotatef(-ax, 0.0,-1.0, 0.0);
                glmDraw(linqModelParts.leg, mode); 
            glPopMatrix();
            
        }
        else {
            drawLimp(joint[LSHOULDER],joint[LELBOW]);
            drawLimp(joint[LELBOW],joint[LHAND]);
        }
        
        if (stage == 5) {
        
            
            glPushMatrix();
                glTranslatef(joint[RSHOULDER].X, 
                             joint[RSHOULDER].Y, 
                             joint[RSHOULDER].Z);
                glRotatef(-ax, 0.0,-1.0, 0.0);
                glScalef(500.0,-500.0, 500.0);
                glmDraw(linqModelParts.shoulder, mode); 
            glPopMatrix();


            glPushMatrix();
                orientMatrix(joint[RSHOULDER],joint[RELBOW]);
                glTranslatef( 0.0, 0.0, 50.0);
                glScalef(350.0, 350.0, 350.0);
                glRotatef(90, -1.0, 0.0, 0.0);
                glRotatef(ax, 0.0,-1.0, 0.0);
                glmDraw(linqModelParts.arm, mode); 
            glPopMatrix();
            
            glPushMatrix();
                orientMatrix(joint[RELBOW],joint[RHAND]);
                glTranslatef( 0.0, 0.0, 60.0);
                glScalef(250.0, 250.0, 250.0);
                glRotatef(90, -1.0, 0.0, 0.0);
                glRotatef(-ax, 0.0,-1.0, 0.0);
                glmDraw(linqModelParts.forearm, mode); 
            glPopMatrix();
        
        } 
        else {
            drawLimp(joint[RSHOULDER],joint[RELBOW]);
            drawLimp(joint[RELBOW],joint[RHAND]);
        }


        // Draw head.
        drawHead();
    }
    // Draws a diamond in the player's center of mass.
    else {
        userGen.GetCoM(player, com);
        nm_DepthGenerator.ConvertRealWorldToProjective(1, &com, &com);

        glPushMatrix();

            glTranslatef(com.X, com.Y, com.Z);
            glutSolidSphere(60.0, 4, 2);

        glPopMatrix();
    }

}
Beispiel #11
0
void
GPIOFIntHandler(void){
	// Method for handling multiple functions for a select button press

	// Clear the GPIO interrupt
	GPIOPinIntClear(GPIO_PORTF_BASE, GPIO_PIN_1);

	// Disable Interrupts
	GPIOPinIntDisable(GPIO_PORTF_BASE, GPIO_PIN_1);
	GPIOPinIntDisable(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);

	// Check which state we are in
	if (state==0){
		// This state handles the main menu

		if (pointer==0){
			// Begin Classic Mode
			state = 1;
			startClassic();
		}
		else if (pointer==1){
			// Begin Continuous Mode
			state = 3;
			startClassic();
		}
		else if (pointer==2){
			// Show the instructions
			state = 2;
			RIT128x96x4Clear();
			displayInstructions();
			done = 1;
		}
		else if (pointer==3){
			// Show the high scores
			state = 2;
			RIT128x96x4Clear();
			displayScores();
			done = 1;
		}
		else if (pointer==4){
			state = 0;
			initMain();
		}
	}
	else if (state==1){
		// This state handles classic mode

		// Black out the letter that was selected
		int idx = position + position2;
		int pos = 0;
		char *puc_letter = alpha[idx];
		if (idx>12){
			pos = position2 * 10;
			RIT128x96x4StringDraw(puc_letter, pos, 87, 2);
		}
		else {
			pos = position * 10;
			RIT128x96x4StringDraw(puc_letter, pos, 75, 2);
		}

		// Add the letter to the list of selected letters
		int i;
		int wrong = 1;
		int used = 0;
		// Loop through the list until we find an empty spot to place the letter
		for (i=0; i<26; i++){
			if (strcmp(selected[i],"!")==0){
				selected[i] = puc_letter;
				break;
			}
			if (strcmp(selected[i],puc_letter)==0){
				wrong = 0;
				used = 1;
				break;
			}
		}

		// Check to see if the letter was already used
		if (!used){
			// Check the word to see if a letter matches the one selected. If it
			// does, we need to display the letters instead of an underscore
			for (i=0; i<strlen(words[wotd]); i++){
				char w_let = words[wotd][i];
				static char g[3];
				usprintf(g, "%d", w_let);
				char p_let = *puc_letter;
				if (w_let==p_let){
					wrong = 0;
					// Display the letter selected
					RIT128x96x4StringDraw(puc_letter, 10+i*10, 53, 15);
					correct++;
				}
			}
		}

		// Check to see if it was a wrong selection
		if (wrong==1){
			// Increment the number of wrong attempts
			try++;
			// If the selection was wrong, we need to draw a piece of the hangman
			if (try==1){
				drawHead();
			}
			else if (try==2){
				drawBody();
			}
			else if (try==3){
				drawRightArm();
			}
			else if (try==4){
Beispiel #12
0
void PatBike::draw()
{
    setMaterial();
    if (isJousting)
    {
        joust();
    }
    else
    {
        move();
    }
     glPushMatrix();//BIKE

        glTranslated(bikePosX, 0.28, bikePosZ);
        glRotatef(heading, 0, 1, 0);
        
        glScalef(0.5,0.5,0.5);
        tm->BindTextureByIndex(2);   
        drawEngine(0.55, 0.45, 0.50, 0.4, 0.75);
        glDisable(GL_TEXTURE_2D);

        glPushMatrix();// Connect Front2Back
            glColor3f(0.6, 0.6, 0.65);
            glTranslatef(0.55, 0, 0);
            glRotatef(90, 0, 1, 0);
            glRotatef(-70, 1, 0, 0);
            drawCylinder(0.075, 0.075, 1.25, 75, 75);
        glPopMatrix();

        glPushMatrix();// Gas Tank

            glColor3f(0.4, 0.2, 0.2);
            glTranslatef(-0.6, 0.35, 0.0);
            glScalef(0.62,0.42, 0.42);
         //glEnable(GL_TEXTURE_2D); 
         //   glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); 
         //   glBindTexture(GL_TEXTURE_2D, texture[5]); 
            
            tm->BindTextureByIndex(5);   
                glutSolidCube(1.0);
            glDisable(GL_TEXTURE_2D);
        glPopMatrix();
                
        drawSeat();

        glPushMatrix();
            drawTrailerHitch();
        glPopMatrix();
        
        //Draw the lower back frame
        drawBottomBackFrame();

        glPushMatrix();
            glTranslatef(-1.4, 0, 0.0);
            drawTire(11);
        glPopMatrix();				

            //Start front frame
        glPushMatrix();
            glTranslatef(1.7, 0, 0.0);
            glRotatef(15, 0, 0, 1);
            //if (heading < -225.0f)
            //{
            //    glRotatef(-45.0f,0,1,0);
            //}
            //else if (heading < -179.0f)
            //{
            //    glRotatef(heading + 180.0f,0,1,0);
            //}
            //else if (heading < -45.0f)
            //{
            //    glRotatef(-45.0f,0,1,0);
            //}
            //else
            //{
            //    glRotatef(heading,0,1,0);
            //}

            glPushMatrix();	
                drawTire(11);
            glPopMatrix();
            drawFrontFrame();
            glTranslatef(-0.01, 1.2, 0.0);
            glPushMatrix();
                drawHead();					
            glPopMatrix();
        glPopMatrix();	
    

        glPushMatrix();
            glTranslatef(1.0f, 1.6f, 0.0f);
            glRotatef(45, 0.0f, 1.0f, 0.0f);
            if (okToDrawSpear)
                drawSpear(0.4, 0, 5.00, 75, 75);
        glPopMatrix();
    glPopMatrix();
    glDisable(GL_COLOR_MATERIAL);
    
}
/********************************************************
 *
 *
 * Draw Robot
 *
 *
 ********************************************************/
void Virtual3dCharacterViewer::glDrawBody(Character3DBody& body)
{
    glPushMatrix();


    // getHipPos() ; // get Hip's Position from the IK calculator .
    LocateHip (body);
    body.HipPosInCamera = getCurTranslation () ;
    body.HipPosInScreen = getScreenPos(body.HipPosInCamera) ;
    RotateHip(body) ;
    glPushMatrix();     // save the Hip Matrix
    drawHip (body) ;

    glTranslatef( 0.0, body.Model.LenHipToChest, 0.0 ) ;
    RotateChest (body);
    drawChest (body) ;


    glTranslatef(0.0, body.Model.LenChestToNeck, 0.0);

    body.NeckPosInCamera = getCurTranslation () ;
    body.NeckPos = TransformVector( WorldMatInv, body.NeckPosInCamera ) ;
    body.NeckPosInScreen = getScreenPos(body.NeckPosInCamera) ;


    glPushMatrix();     // save the Neck Matrix

    RotateLeftShoulder(body);
    drawLeftShoulder(body);

    glTranslatef(body.Model.LenNeckToShoulder, 0.0, 0.0);
    RotateLeftUpperArm(body);
    drawLeftUpperArm(body);


    glTranslatef(body.Model.LenShoulderToElbow, 0.0, 0.0);
    RotateLeftLowerArm(body);
    drawLeftLowerArm(body);



    glTranslatef(body.Model.LenElbowToWrist, 0.0, 0.0);

    body.LeftWristPosInCamera = getCurTranslation () ;
    Vector3D bias(-1,0,0) ;
    body.LeftWristPos = TransformVector( WorldMatInv, body.LeftWristPosInCamera );
    body.LeftWristPosInScreen = getScreenPos(body.LeftWristPosInCamera) ;

    RotateLeftHand(body);
    drawLeftHand(body);


    glPopMatrix();      // reload the Neck Matrix
    glPushMatrix();     // restore the Neck Matrix again .


    RotateRightShoulder(body);
    drawRightShoulder(body);

    glTranslatef(-body.Model.LenNeckToShoulder, 0.0, 0.0);
    RotateRightUpperArm(body);
    drawRightUpperArm(body);


    glTranslatef(-body.Model.LenShoulderToElbow, 0.0, 0.0);
    RotateRightLowerArm(body);
    drawRightLowerArm(body);

    glTranslatef(-body.Model.LenElbowToWrist, 0.0, 0.0);

    body.RightWristPosInCamera = getCurTranslation () ;
    body.RightWristPos = TransformVector( WorldMatInv, body.RightWristPosInCamera ) ;
    body.RightWristPosInScreen = getScreenPos(body.RightWristPosInCamera) ;

    RotateRightHand(body);
    drawRightHand(body);


    glPopMatrix();      // reload the Neck Matrix again .

    RotateHead(body);
    drawHead (body);
    glTranslatef(0.0, body.Model.LenNeckToHead, 0.0);
    body.HeadPosInCamera = getCurTranslation () ;
    body.HeadPos = TransformVector( WorldMatInv, body.HeadPosInCamera ) ;
    body.HeadPosInScreen = getScreenPos(body.HeadPosInCamera) ;

    glPopMatrix();      // reload the Hip Matrix .
    glPushMatrix();     // restore the Hip Matrix again.

    RotateLeftThighRoot (body);
    drawLeftThighRoot(body);

    glTranslatef(body.Model.LenHipToThigh, 0.0, 0.0);

    RotateLeftThigh (body) ;
    drawLeftThigh(body);

    glTranslatef(0.0, -body.Model.LenThighToKnee, 0.0);

    RotateLeftShank(body);
    drawLeftShank(body);

    glTranslatef(0.0, -body.Model.LenKneeToAnkle, 0.0);
    body.LeftAnklePosInCamera = getCurTranslation();
    body.LeftAnklePos = TransformVector( WorldMatInv, body.LeftAnklePosInCamera ) ;
    body.LeftAnklePosInScreen = getScreenPos(body.LeftAnklePosInCamera) ;

    RotateLeftFoot (body);
    drawLeftFoot(body);


    glPopMatrix();      // reload the Hip Matrix again.


    RotateRightThighRoot (body);
    drawRightThighRoot(body);

    glTranslatef(-body.Model.LenHipToThigh, 0.0, 0.0);

    RotateRightThigh (body) ;
    drawRightThigh(body);

    glTranslatef(0.0, -body.Model.LenThighToKnee, 0.0);

    RotateRightShank(body);
    drawRightShank(body);

    glTranslatef(0.0, -body.Model.LenKneeToAnkle, 0.0);
    body.RightAnklePosInCamera = getCurTranslation();
    body.RightAnklePos = TransformVector( WorldMatInv, body.RightAnklePosInCamera ) ;
    body.RightAnklePosInScreen = getScreenPos(body.RightAnklePosInCamera) ;



    RotateRightFoot (body);
    drawRightFoot(body);


    glPopMatrix();
}
Beispiel #14
0
/* draws a penguin centered (roughly) at the origin
   Also moves him around in a circle
   It now takes a parameter that indicates whether or
   no the penguin is a shadow (just for coloring purposes) */
void drawPenguin( int is_shadow )
{
	/* the colors we apply to the bird */
	/* Black does not really show lighting very well,
	   (or at all!) so the bird is now a blusih colour */
	GLfloat bluish[3];
	GLfloat orange[3];

	if( is_shadow )
	{
		/* bluish and orange are both grey for a shadow */
		bluish[0] = bluish[1] = bluish[2] = 0.2;
		orange[0] = orange[1] = orange[2] = 0.2;
	}
	else
	{
		/* for normal penguin, normal colors */
		bluish[0] = 0.08;
		bluish[1] = 0.2;
		bluish[2] = 0.35;

		orange[0] = 1.0;
		orange[1] = 0.5;
		orange[2] = 0.0;
	}

	/* draw main body and head bluish */
	glColor3fv( bluish );

	glPushMatrix( );
		/* Wobble the body a little bit */
		glRotatef( wobble_amount, 0.0, 0.0, 1.0 );
		drawHead( );
		drawBody( );

		/* draw the beak orange */
		glColor3fv( orange );
		drawBeak( );
	glPopMatrix( );

	/* draw penguin's left wing bluish */
	glColor3fv( bluish );
	drawLeftWing( );

	/* draw the left foot orange */
	glColor3fv( orange );
	drawLeftFoot( );

	/* to draw the penguins' right appendages, we just invert the world
	   along the X axis, and draw the left ones over again... */
	glScalef( -1.0, 1.0, 1.0 );

	glColor3fv( bluish );		/* bluish wing */
	drawLeftWing( );
	
	/* orange */
	glColor3fv( orange );
	/* to make the left and right rotate on an opposite way, we invert the right one... */
	GLfloat temp = foot_move_amount;
	foot_move_amount = abs( 90.0 - foot_move_amount );
	drawLeftFoot( );
	foot_move_amount = temp;	/* reset the value for the left foot */
}
Beispiel #15
0
// 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();
}
Beispiel #16
0
void glutDisplay() {
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  loadGlobalCoord();

  glShadeModel(GL_SMOOTH);
  glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
  glEnable(GL_DEPTH_TEST);
  glEnable(GL_LIGHTING);
                      
  glEnable(GL_LIGHT0);
  glLightfv(GL_LIGHT0, GL_AMBIENT, AMBIENT_LIGHT);
  glLightfv(GL_LIGHT0, GL_DIFFUSE, DIFFUSE_LIGHT);
  glLightfv(GL_LIGHT0, GL_SPECULAR, SPECULAR_LIGHT);
  glLightfv(GL_LIGHT0, GL_POSITION, LIGHT_POSITION);
                                    
  glEnable(GL_LIGHT1);
  glLightfv(GL_LIGHT1, GL_AMBIENT, AMBIENT_SUB_LIGHT);
  glLightfv(GL_LIGHT1, GL_DIFFUSE, DIFFUSE_SUB_LIGHT);
  glLightfv(GL_LIGHT1, GL_SPECULAR, SPECULAR_LIGHT);
  glLightfv(GL_LIGHT1, GL_POSITION, SUB_LIGHT_POSITION);

  glEnable(GL_COLOR_MATERIAL); 
  glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, MATERIAL_AMBIENT); 
  glMaterialfv(GL_FRONT, GL_SPECULAR, MATERIAL_SPECULAR);
  glMateriali(GL_FRONT, GL_SHININESS, 48);

  glTranslatef(0, 0, baseTrans);
  glRotatef(bodyRot, 0, 0, 1);
  glRotatef(90.0f, 1, 0, 0);
  glColor3f(1.0, 1.0, 0); // Yellow color
  
  GLUquadricObj* body = gluNewQuadric();
  gluCylinder(body, 5.5, 7.0, 17, 100, 10);
  gluDeleteQuadric(body);

  glPushMatrix();
    drawLeftArm();
  glPopMatrix();

  glPushMatrix();
    drawRightArm();
  glPopMatrix();

  glPushMatrix();
    drawLeftLeg();
  glPopMatrix();

  glPushMatrix();
    drawRightLeg();
  glPopMatrix();
  
  glPushMatrix();
    drawTail();      
    
    glPushMatrix();
      drawBall();
    glPopMatrix();
  glPopMatrix();

  glPushMatrix();
    drawHead();  
 
    glPushMatrix();
      drawLeftEye();
    glPopMatrix();

    glPushMatrix();
      drawRightEye();
    glPopMatrix();

    glPushMatrix();
      drawLeftCheek();
    glPopMatrix();

    glPushMatrix();
      drawRightCheek();
    glPopMatrix();

    glPushMatrix();
      drawMouse();  
    glPopMatrix();

    glPushMatrix();
      drawLeftEar();
    glPopMatrix();

    glPushMatrix();
      drawRightEar();
    glPopMatrix();
  glPopMatrix();
  
  glutSwapBuffers();
}