Beispiel #1
0
void DrawCylinder(Cylinder c) {
	float colorv[4] = {c.r, c.g, c.b, 0};
	glMaterialfv(GL_FRONT, GL_DIFFUSE, colorv);
	renderCylinder_convenient(c.p1.x, c.p1.y, c.p1.z,
			                  c.p2.x, c.p2.y, c.p2.z,
							  c.radius, c.radius*10+4);
}
/* The main drawing function. */
GLvoid DrawGLScene(GLvoid)
{
	GLfloat xtrans, ztrans, ytrans;
	GLfloat sceneroty,scenerotx;

	// calculate translations and rotations.
	xtrans = -xpos;
	ztrans = -zpos;
	ytrans = -walkbias-0.25f;
	sceneroty = 360.0f - yrot;
	scenerotx = 360.0f - xrot;

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);		// Clear The Screen And The Depth Buffer
	glLoadIdentity();

	glRotatef(lookupdown, 1.0f, 0, 0);
	glRotatef(sceneroty, 0, 1.0f, 0);
	glRotatef(scenerotx,1.0f,0,0);

	glTranslatef(xtrans, ytrans, ztrans);    

	glBindTexture(GL_TEXTURE_2D, texture[filter]);    // pick the texture.


	model();  // create the external model of the house

	make_Railing(); // create the railing on the first floor of the house
	
	float i;

	/**Code for making pillars in lower floor**/
	for(i = -2.9533333;i <= 2.95 ; i += 0.85){
		renderCylinder_convenient(i,0,3,i,1,3,0.04,16);
	}
	/**Code ends for pillars on low floor**/

	/**Code for making pillars in first floor**/
	for(i = -2.9533333;i <= 2.95 ; i += 0.85){
		renderCylinder_convenient(i,1,2,i,2,2,0.04,16);
	}
	/**Code ends for pillars on first floor**/

	// since this is double buffered, swap the buffers to display what just got drawn.
	
	glutSwapBuffers();
}
Beispiel #3
0
void DrawSub(Object o) {
	const int length = 30;
	const int radius = 4.5;
	float colorv[4] = {0, 0, .75, 0};
	glMaterialfv(GL_FRONT, GL_DIFFUSE, colorv);
	renderCylinder_convenient(o.Pos.x+sin(o.Rot.z)*length*.5, o.Pos.y+cos(o.Rot.z)*length*.5, o.Pos.z,
	                          o.Pos.x-sin(o.Rot.z)*length*.5, o.Pos.y-cos(o.Rot.z)*length*.5, o.Pos.z,
							  radius, 20);
}
Beispiel #4
0
Datei: as4.cpp Projekt: cgtz/ik
void renderIK() {
    //Eigen::Vector3d goal = interpolateGoal();
    for (int i = 0; i < appendages.size(); i++) {
        test.solveIK(appendages[i], goals[i]);
        if (octopus) {
            glPushMatrix();
            glTranslatef(cos((2*PI/goals.size())*i), sin((2*PI/goals.size())*i), 0);
        }

        glColor3f(0, 1, 1);
        renderCylinder_convenient(0, 0, 0, appendages[i][0].currPos[0], appendages[i][0].currPos[1], appendages[i][0].currPos[2], 0.04, 10);

        glPushMatrix();
        glTranslatef(appendages[i][0].currPos[0], appendages[i][0].currPos[1], appendages[i][0].currPos[2]);
        glutSolidSphere(0.1, 10, 10);
        glPopMatrix();

        for (int j=1; j<appendages[i].size(); j++) {
            if (j%2==0) {
                glColor3f(0, 1, 1);
            } else {
                glColor3f(1, 0, 1);
            }
            renderCylinder_convenient(appendages[i][j-1].currPos[0], appendages[i][j-1].currPos[1], appendages[i][j-1].currPos[2], appendages[i][j].currPos[0], appendages[i][j].currPos[1], appendages[i][j].currPos[2], 0.04, 5);
            
            glPushMatrix();
            glTranslatef(appendages[i][j].currPos[0], appendages[i][j].currPos[1], appendages[i][j].currPos[2]);
            glutSolidSphere(0.1, 10, 10);
            glPopMatrix();
        }
        glBegin(GL_LINES);
        glColor3f(1, 1, 0);
        glVertex3f(0,0,0);
        glVertex3f(goals[i][0],goals[i][1],goals[i][2]);
        glEnd();

        if (octopus) glPopMatrix();
    }
}
Beispiel #5
0
/*
 *  Draw the hand
 *     at (x,y,z)
 *     fingers facing (dx,dy,dz)
 *     up towards (ux,uy,uz)
 */
void hand::drawHand( note n, note prev_n, double t )
{

	vector<double> pt, j, next_pt, prev_pt;
	vector< vector<double> >::iterator j_it;
	finger f = fingers[0]; //dummy assignment to avoid using a constructor
	vector< vector<double> > prev_verts, next_verts, verts;
	vector< vector<double> >::iterator v_it;
	vector< vector< vector<double> > > fingVerts;
	vector< vector< vector<double> > >::iterator f_it;

	// Get current position of all fingers at this time
	if (t<0.1)
		t = t/0.1;
	else
		t =1;
	pt.assign(3,0);
	prev_verts.clear();
	verts.clear();
	fingVerts.clear();
	for (int i=0; i<fingers.size(); i++){
		next_verts  = fingers[i].fVerts;
		prev_verts = this->prevFingers[i].fVerts;
		for (int j=0; j<next_verts.size(); j++){
			prev_pt = prev_verts[j];
			next_pt = next_verts[j];
			pt[0] = next_pt[0]*t + (1-t)*prev_pt[0];
			pt[1] = next_pt[1]*t + (1-t)*prev_pt[1];
			pt[2] = next_pt[2]*t + (1-t)*prev_pt[2];
			verts.push_back(pt);
			pt.assign(3,0);
		}
		fingVerts.push_back(verts);
		verts.clear();
	}

	// Begin drawing  =================================

	// DRAW WRIST (aka base)
	glPushMatrix();
		vector<double> wrist_pt; wrist_pt.assign(3, 0);
		wrist_pt[0]=0; wrist_pt[1]=0; wrist_pt[2]=-(neck_r+buffHelp+baseH);
		glTranslated(this->wrist[0]*t+prevWrist[0]*(1-t),0,0);
		glRotated(-90, 0,0,1);
		glRotated(theta, 0,1,0);
		draw_axes(1,1,1);
		glColor3ub(hRGB[0],hRGB[1],hRGB[2]);

		glTranslated(0,0,baseH);
		glBegin( GL_POLYGON );
			glVertex3d(wrist_pt[0],wrist_pt[1],wrist_pt[2]);
			Vertex(  fingerTh[4]-thHelp, 0, baseLen[4],
						0,0,-(neck_r+buffHelp+baseH) );
			for (int i=0; i<4; i++){
				Vertex(  fingerTh[i], 0, baseLen[i],
							0,0,-(neck_r+buffHelp+baseH) );
			}
		glEnd();
		glTranslated(0,0,-2*baseH);
		glBegin( GL_POLYGON );
			glVertex3d(wrist_pt[0],wrist_pt[1],wrist_pt[2]);
			Vertex(  fingerTh[4]-thHelp, 0, baseLen[4],
						0,0,-(neck_r+buffHelp+baseH) );
			for (int i=0; i<4; i++){
				Vertex(  fingerTh[i], 0, baseLen[i],
							0,0,-(neck_r+buffHelp+baseH) );
			}
		glEnd();

		glBegin( GL_QUAD_STRIP );
			for (int i=0; i<baseVerts.size(); i++){
				pt = baseVerts[i];
				glVertex3d( pt[0],pt[1],pt[2]);
				glVertex3d( pt[0],pt[1],pt[2]+2*baseH);
			}
			pt = baseVerts[0];
			glVertex3d( pt[0],pt[1],pt[2]);
			glVertex3d( pt[0],pt[1],pt[2]+2*baseH);
		glEnd();
	glPopMatrix();

	// DRAW FINGERS
	glColor3ub( hRGB[0], hRGB[1], hRGB[2] );
	for (f_it = fingVerts.begin(); f_it!=fingVerts.end(); f_it++){
		verts = *f_it;
		for (v_it = verts.begin(); v_it!=verts.end()-1; v_it++){
			pt      = *v_it;
			next_pt = *(v_it+1);
			renderCylinder_convenient( pt[0],pt[1],pt[2],
												next_pt[0],next_pt[1],next_pt[2],
												fingRadius, fingSubDiv);
		}
	}



	// DRAW JOINTS
	for (f_it = fingVerts.begin(); f_it!=fingVerts.end(); f_it++){
		verts = *f_it;
		for (v_it = verts.begin(); v_it!=verts.end(); v_it++){
			pt      = *v_it;
			ball( pt[0],pt[1],pt[2],
					jRGB[0],jRGB[1],jRGB[2],
					jointRadius);
		}
	}

	// for (int ii=0; ii<fingers.size(); ii++){
	// 	fingers[ii];
	// 	for (int jj=0; jj<f.joints.size(); jj++){
	// 		j = f.joints[jj];
	// 		ball(j[0],j[1],j[2],
	// 				jRGB[0],jRGB[1],jRGB[2],
	// 				jointRadius);
	// 	}
	// 	ball(f.tip[0],f.tip[1],f.tip[2],
	// 			hRGB[0],hRGB[1],hRGB[2],
	// 			jointRadius);
	// }

	// currentFingers.clear();
	ErrCheck("drawHand");
}