void ofxIndustrialRobotVisualizer::drawGeneric(){
	
	//Base
	ofSetColor(0, 255, 255);	
	glTranslated(0, -25, 0);
	//ofxBox(ofxVec3f(0,25,0), ofxVec3f(200, 50, 200));	
	
	//model.draw();
	ofSetColor(255, 0, 0);
	glPushMatrix();
	glScaled(1.0, -1.0, 1.0);
	ofSetColor(255, 255, 255);

//	model.draw();
	glPopMatrix();
	//	ofxSphere(ofxVec3f(0,0,0), ofxVec3f(200, 200, 200));
	
	glRotated(180, 0.0, 0.0, -1.0); 
	glPushMatrix();
		glScaled(1.0, 1.0, -1.0);
	//	glScaled(0.1, 0.1, 0.1);
	drawArm0();
	drawArm1();
	drawArm2();
	drawArm3();
	drawArm4();
	//Draw tool
	ofSetColor(255, 0, 0);
	float l = helper->getTool()->l; //The length of the tool
	ofxVec3f rotation = helper->getTool()->getRotation();
	glRotated(rotation.z, 0.0, 0.0, 1.0);
	ofxBox(ofxVec3f(helper->getTool()->h/2.0,l/2,0), ofxVec3f(helper->getTool()->h, l, helper->getTool()->w), ofxVec3f(0.0, 0.0, 0.0));
	//	ofxVec3f axis = helper->getAxis(i); //The axis the arm rotates around
	//	ofxVec3f offset = helper->getOffset(i);
	//	glRotated(helper->getRotationAngle(i), axis.x, axis.y, axis.z); // Rotate it around the axis
	//	glTranslated(0, l, 0);
	//	ofxBox(ofxVec3f(0,-l/2.0,0), ofxVec3f(60, l, 60), ofxVec3f(0.0, 0.0, 0.0));
	//	glTranslated(-offset.y, offset.x, offset.z);	
	
	glPopMatrix();
	glScaled(1.0, 1.0, -1.0);

	//Target
	glRotated(180, 0.0, 1.0, 0.0); 
	ofSetColor(255, 0, 0);
	ofxSphere(controller->targetPosition, ofxVec3f(20, 20, 20));
	glBegin(GL_LINE_STRIP);
	glVertex3d(controller->targetPosition.x, controller->targetPosition.y, controller->targetPosition.z);
	ofxVec3f temp = controller->targetPosition+ controller->targetDir*500.0;
	glVertex3d(temp.x,temp.y, temp.z);
	glEnd();
	
	glPushMatrix();
	ofSetColor(0, 255, 0);
	for(int i=0;i<timeline->numberPositionCues(); i++){
		ofxVec3f vec = timeline->getPositionCue(i)->position;
		ofxSphere(vec, ofxVec3f(10, 10, 10));	
	}
	timeline->spline.drawRaw(10, 5);
	ofSetColor(255, 255, 0, 100);
	timeline->spline.drawSmooth(50, 0, 10);
	glLineWidth(1);
	ofSetColor(255, 255, 255, 255);
	ofFill();
	//	glDisable(GL_DEPTH_TEST);
	
/*	glBegin(GL_POLYGON);
	for(int i=0;i<3;i++){
		glVertex3f(plotter->spaceDefinition[i].x,plotter->spaceDefinition[i].y,plotter->spaceDefinition[i].z);
	}
	glVertex3f(plotter->fourthCorner().x,plotter->fourthCorner().y,plotter->fourthCorner().z);
	glEnd();
*/
	for(int i=0;i<plotter->lines.size();i++){
		glBegin(GL_LINE_STRIP);
		ofxVec3f x = (plotter->spaceDefinition[1]-plotter->spaceDefinition[0]).normalized();
		ofxVec3f y = (plotter->spaceDefinition[2]-plotter->spaceDefinition[1]).normalized();
		for(int u=0;u<plotter->lines[i].size();u++){
			ofxVec3f point = x * plotter->lines[i][u].x + y * plotter->lines[i][u].y + plotter->spaceDefinition[0];
			glVertex3f(point.x,point.y,point.z);
		}

		glEnd();
	}
	
	glPopMatrix();
	
	
}
Пример #2
0
void drawGuy2(void)
{
	mvstack.push(model_view);
	if (TIME >= 20 && TIME < 20.5)
	{
		model_view *= RotateX(-600+TIME*30);
	}
	else if (TIME >= 20.5 && TIME < 21.5)
	{
		model_view *= RotateX(15);
	}
	else if (TIME >= 21.5 && TIME < 22)
	{
		model_view *= RotateX(15);
		model_view *= RotateX((21.5*30) - TIME*30);
	}
	else if (TIME >= 22 && TIME < 22.5)
	{
		model_view *= RotateY((22*90)- TIME*90);
	}
	else if (TIME >= 22.5 && TIME < 23)
	{
		model_view *= RotateY(-45);
	}
	else if (TIME >= 23 && TIME < 23.5)
	{
		model_view *= RotateY(-45);
		model_view *= RotateY((-23*90) + TIME*90);
	}
	else if (TIME >= 23.5 && TIME < 24)
	{
		model_view *= RotateY((-23.5 * 90) + TIME*90);
	}
	else if (TIME >= 24 && TIME < 24.5)
	{
		model_view *= RotateY(45);
	}
	else if (TIME >= 24.5 && TIME < 25)
	{
		model_view *= RotateY(45);
		model_view *= RotateY((24.5*90) - TIME*90);
	}
	else if (TIME >= 25 && TIME < 25.5)
	{
		model_view *= RotateX ((-25*30) + TIME*30);
	}
	else if (TIME >= 25.5 && TIME < 28.5)
	{
		model_view *= RotateX(15);
	}
	else if (TIME >= 28.5 && TIME < 29.5)
	{
		model_view *= RotateX((28.5*15) - TIME*15);
	}
	drawHead2();
	model_view = mvstack.pop();

	mvstack.push(model_view);
		drawTorso2();
	model_view = mvstack.pop();
	
	// saber armi
	mvstack.push(model_view);
	if (TIME >=6 && TIME < 9.5)
	{
		model_view *= RotateX(-20*sin(3*TIME));
	}
	else if (TIME >= 9.5 && TIME < 10)
	{
		model_view *= RotateX(959 - TIME*102);
	}
	else if (TIME >= 10 && TIME < 16)
	{
		model_view *= RotateY(30*sin(5*TIME));
		model_view *= RotateX(-45);
	}
	else if (TIME >= 16 && TIME < 20)
	{
		model_view *= RotateX(-45);
	}
	else if (TIME >= 20 && TIME < 20.5)
	{
		model_view *= RotateX(-45);
		model_view *= RotateX(-1800 + TIME*20.5);
	}
	else if (TIME >= 29.5)
	{
		model_view *= RotateX(30*sin(20*TIME));
	}
	drawArm2();
	model_view = mvstack.pop();

	//static 
	mvstack.push(model_view);
	if (TIME >=6 && TIME < 10)
	{
		model_view *= RotateX(20*sin(3*TIME));
	}
	else if (TIME >= 10 &&  TIME < 20)
	{
		model_view *= RotateX(-45);
	}	
	else if (TIME >= 20 && TIME < 20.5)
	{
		model_view *= RotateX(-45);
		model_view *= RotateX(-1800 + TIME*20.5);
	}
	else if (TIME >= 29.5)
	{
		model_view *= RotateX(-30*sin(20*TIME));
	}
		drawTopArm2Right();
	model_view = mvstack.pop();

	//legs

	//LEG1
	mvstack.push(model_view);
	if (TIME >= 6 && TIME < 10)
	{
		model_view *= RotateX(5*sin(5*TIME));
	}
	else if (TIME >= 26.5 && TIME < 28.5)
	{
		model_view *= RotateX(5*sin(5*TIME));
	}
	else if (TIME >= 29.5)
	{
		model_view *= RotateX(5*sin(20*TIME));
	}
		mvstack.push(model_view);
			set_colour(.8, .8, .8);
			model_view *= Translate(-.25, -2.5, 0);
			model_view *= RotateX(180);
			//model_view *= RotateX(5+sin(2*TIME));
			drawLegPart3();
			model_view *= Translate(0, .9, 0);
			model_view *= Scale (.2, .2, .2);
			drawSphere();
		model_view = mvstack.pop();

		//LOWERLEG 1
		mvstack.push(model_view);
			set_colour(.8, .8, .8);
			model_view *= Translate(-.25, -4.32, 0);
			if (TIME >= 6 && TIME < 10)
			{
				model_view *= RotateX(5*sin(5*TIME));
			}
			else if (TIME >= 26.5 && TIME < 28.5)
			{
			model_view *= RotateX(5*sin(5*TIME));
			}
			else if (TIME >= 29.5)
			{
				model_view *= RotateX(5*sin(20*TIME));
			}
			drawLegPart4();
		model_view = mvstack.pop();
	model_view = mvstack.pop();

	//LEG2	
	mvstack.push(model_view);
		if (TIME >= 6 && TIME < 10)
		{
			model_view *= RotateX(-5*sin(5*TIME));
		}
		else if (TIME >= 26.5 && TIME < 28.5)
		{
			model_view *= RotateX(-5*sin(5*TIME));
		}
		else if (TIME >= 29.5)
		{
			model_view *= RotateX(-5*sin(20*TIME));
		}
		mvstack.push(model_view);
			set_colour(.8, .8, .8);
			model_view *= Translate(.25, -2.5, 0);
			model_view *= RotateX(180);
			drawLegPart3();
			model_view *= Translate(0, .9, 0);
			model_view *= Scale (.2, .2, .2);
			drawSphere();
		model_view = mvstack.pop();
		//LOWER LEG  2
		mvstack.push(model_view);
				set_colour(.8, .8, .8);
				model_view *= Translate(.25, -4.32, 0);
				if (TIME >= 6 && TIME < 10)
				{
					model_view *= RotateX(-5*sin(5*TIME));
				}
				else if (TIME >= 26.5 && TIME < 28.5)
				{
					model_view *= RotateX(-5*sin(5*TIME));
				}
					else if (TIME >= 29.5)
				{
					model_view *= RotateX(-5*sin(20*TIME));
				}
				drawLegPart4();
		model_view = mvstack.pop();

	model_view = mvstack.pop();
}