DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • How Does Video Annotation Augment Computer Vision?
  • Vulnerable Code [Comic]
  • How To Protect RDP From Ransomware Attacks
  • Advancements in Computer Vision: Deep Learning for Image Recognition

Trending

  • Apple and Anthropic Partner on AI-Powered Vibe-Coding Tool – Public Release TBD
  • Code Reviews: Building an AI-Powered GitHub Integration
  • Using Java Stream Gatherers To Improve Stateful Operations
  • Advancing Your Software Engineering Career in 2025

computer graphic

By 
Daewoo Han user avatar
Daewoo Han
·
Jun. 30, 15 · Code Snippet
Likes (0)
Comment
Save
Tweet
Share
922 Views

Join the DZone community and get the full member experience.

Join For Free
//	Name : Hoang Xuan Nhat Huy
//	ID : 51101332
#include 
#include 
#include 
#include 
#include 
using namespace std;

class Point3
{
public:
	float x, y, z;
	void set(float dx, float dy, float dz)
						{ x = dx; y = dy; z = dz;}
	void set(Point3& p)
						{ x = p.x; y = p.y; z = p.z;}
	Point3() { x = y = z = 0;}
	Point3(float dx, float dy, float dz)
						{ x = dx; y = dy; z = dz;}

};

class Color3
{
public:
	float r, g, b;
	void set(float red, float green, float blue)
						{ r = red; g = green; b = blue;}
	void set(Color3& c)
						{ r = c.r; g = c.g; b = c.b;}
	Color3() { r = g = b = 0;}
	Color3(float red, float green, float blue)
						{ r = red; g = green; b = blue;}

};

class Point2
{
	public:
		Point2() { x = y = 0.0f; } // constructor 1
		Point2(float xx, float yy) { x = xx; y = yy; } // constructor 2
		void set(float xx, float yy) { x = xx; y = yy; }
		float getX() { return x;}
		float getY() { return y;}
		void draw()		{	glBegin(GL_POINTS);
								glVertex2f((GLfloat)x, (GLfloat)y);
							glEnd();
						}
	private:
		float 	x, y;
};

class IntRect
{
	 public:
		IntRect() { l = 0; r = 100; b = 0; t = 100; } // constructor
		IntRect( int left, int right, int bottom, int top)
			{ l = left; r = right; b = bottom; t = top; }
		void set( int left, int right, int bottom, int top)
			{ l = left; r = right; b = bottom; t = top; }
		void draw(){
						glRecti(l, b, r, t);
						glFlush();
					} // draw this rectangle using OpenGL
		int  getWidth(){return (r-l);}
		int  getHeight() { return (t-b);}
	 private:
		int	l, r, b, t;
};


class RealRect
{
	 public:
		RealRect() { l = 0; r = 100; b = 0; t = 100; } // constructor
		RealRect( float left, float right, float bottom, float top)
			{ l = left; r = right; b = bottom; t = top; }
		void set( float left, float right, float bottom, float top)
			{ l = left; r = right; b = bottom; t = top; }
		float  getWidth(){return (r-l);}
		float  getHeight() { return (t-b);}
		void RealRect::draw(){
							glRectf(l, b, r, t);
							glFlush();
						};// draw this rectangle using OpenGL
	 private:
		float	l, r, b, t;
};

class Vector3
{
public:
	float	x, y, z;
	void set(float dx, float dy, float dz)
						{ x = dx; y = dy; z = dz;}
	void set(Vector3& v)
						{ x = v.x; y = v.y; z = v.z;}
	void flip()
						{ x = -x; y = -y; z = -z;}
	//void setDiff(Point3& a, Point3&
	void normalize();
	Vector3() { x = y = z = 0;}
	Vector3(float dx, float dy, float dz)
						{ x = dx; y = dy; z = dz;}
	Vector3(Vector3& v)
						{ x = v.x; y = v.y; z = v.z;}
	Vector3 cross(Vector3 b);
	float dot(Vector3 b);
};

class VertexID
{
public:
	int		vertIndex;
	int		colorIndex;
};

class Face
{
public:
	int			nVerts;
	VertexID*	vert;
	Face()
	{
		nVerts	= 0;
		vert	= NULL;
	}
	~Face()
	{
		if(vert !=NULL)
		{
			delete[] vert;
			vert = NULL;
		}
		nVerts = 0;
	}
};

class Mesh
{
public:
	int			numVerts;
	Point3*		pt;
	int			numFaces;
	Face*		face;
	float		slideX, slideY, slideZ;
	float		rotateX, rotateY, rotateZ;

public:
	Mesh()
	{
		slideX		= 0;
		slideY		= 0;
		slideZ		= 0;
		rotateX		= 0;
		rotateY		= 0;
		rotateZ		= 0;
		numVerts	= 0;
		pt			= NULL;
		numFaces	= 0;
		face		= NULL;
	}
	~Mesh()
	{
		if (pt != NULL)
		{
			delete[] pt;
		}
		if(face != NULL)
		{
			delete[] face;
		}
		numVerts = 0;
		numFaces = 0;
	}

	void DrawWireframe();
	void DrawColor();

	void CreateTetrahedron();
	void CreateCube(float	fSize);
	void CreateSphere(int nSlice, int nStack, float radius);
	void CreateYPlane(int nXSegment, int nZSegment, float fXWidth, float fZWidth);
	void CreateCuboid(float	fSizeX, float fSizeY, float	fSizeZ);
	void CreateCylinder(int nSegment, float fHeight, float fRadius);
	void CreateCylinderWithHole(int nSegment, float fHeight, float fORadius, float fIRadius);
	void CreatehaftSphere(int nSlice, int nStack, float radius);
	void SetColor(int colorIdx);

};
#define		DEG2RAD(x) (x*PI)/180.0f

void myDisplay();

int		screenWidth = 600;
int		screenHeight= 600;
float	fRoomSize = 15;

bool	bWireFrame = false;

float	YPlanePos = 0;

float	ballRadius = 0.4;
float	ball1SizeZ = 2;

float	cuboidBaseSizeXZ = 0.8;
float	cuboidBaseSizeY = 0.1;

float	cylBase1Radius = cuboidBaseSizeXZ/2 - 0.1;
float	cylBase1Height	= 0.2; 

float	cylBase2Radius = cylBase1Radius - 0.1;
float	cylBase2Height	= 2.5; 

///////////////////////////////////////////////////

float	upperArm1ORadius = cylBase1Radius;
float	upperArm1IRadius = cylBase2Radius;
float	upperArm1Height = cylBase1Height*1.5;
float	upperArm1Offset = 0.5;

float	upperArm2SizeX = upperArm1IRadius;
float	upperArm2SizeZ = 1.4/2;
float	upperArm2SizeY = upperArm1Height/2;

float	upperArm3Radius = upperArm2SizeX;
float	upperArm3Height = upperArm2SizeY*2;

float	upperArm4Radius = upperArm3Radius - 0.08;
float	upperArm4Height = upperArm3Height*2;

float	upperArmRotateY = 0;

///////////////////////////////////////////////
float	foreArm1ORadius = 0.2;
float	foreArm1IRadius = cylBase2Radius;
float	foreArm1Height = 0.5;
float	foreArm1Offset = 0.5;

//float	foreArm2SizeX = upperArm1IRadius;
//float	foreArm2SizeZ = 0.7;
//float	foreArm2SizeY = upperArm1Height;

float	foreArm2SizeX = 0.15;
float	foreArm2SizeZ = 1.4;
float	foreArm2SizeY = 0.5/2;

float	foreArm3Radius = 0.12;
float	foreArm3Height = 0.5;

float	foreArm4Radius = 0.1;
float	foreArm4Height = 1.6;

float	foreArmRotateY = 0;

float	handMove = 0;
float	handMove1 = 0;
float	move = 0;

bool	hold1 = false; 
bool	hold2 = false;
bool	hold3 = false;
bool	hold4 = false;

float	ball1upper = 0;
float	ball1hand = 0;
float	ball2upper = 0;
float	ball2hand = 0;
float	ball3upper = 0;
float	ball3hand = 0;
float	ball4upper = 0;
float	ball4hand = 0;

//Mesh for the foor
Mesh	planeY;
Mesh	planeY2;

//Mesh for the ball
Mesh	ball1;
Mesh	ball2;
Mesh	ball3;
Mesh	ball4;

//Mesh for the body
Mesh	cuboidBase;
Mesh	cylBase1;
Mesh	cylBase2;

//Mesh for upper arm
Mesh	upperArm1;
Mesh	upperArm2;
Mesh	upperArm3;
Mesh	upperArm4;

//Mesh for fore arm
Mesh	foreArm1;
Mesh	foreArm2;
Mesh	foreArm3;
Mesh	foreArm4;

Mesh	Hand;
Mesh	Hand1;

//Camera parameters
float camera_angle;
float camera_height;
float camera_dis;
float camera_X, camera_Y, camera_Z;
float lookAt_X, lookAt_Y, lookAt_Z;
float camera_lookAt;

bool	b4View = false;

#define PI				3.1415926
#define	COLORNUM		14


float	ColorArr[COLORNUM][3] = {{1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, { 0.0,  0.0, 1.0}, 
								{1.0, 1.0,  0.0}, { 1.0, 0.0, 1.0},{ 0.0, 1.0, 1.0}, 
								 {0.3, 0.3, 0.3}, {0.5, 0.5, 0.5}, { 0.9,  0.9, 0.9},
								{1.0, 0.5,  0.5}, { 0.5, 1.0, 0.5},{ 0.5, 0.5, 1.0},
									{0.0, 0.0, 0.0}, {1.0, 1.0, 1.0}};


void Mesh::SetColor(int colorIdx){
	for (int f = 0; f < numFaces; f++)
	{
		for (int v = 0; v < face[f].nVerts; v++)
		{
			face[f].vert[v].colorIndex = colorIdx;
		}
	}
}

void Mesh::CreateCylinderWithHole(int nSegment, float fHeight, float fORadius, float fIRadius)
{
	numVerts = nSegment * 4;
	pt = new Point3[numVerts];
	int count = 0;
	for (int i = 0; i < 4; i++)
	{
		if (i == 2)
			fHeight *= -1;
		float r = (i == 0 || i == 3) ? fIRadius : fORadius;
		for (int j = 0; j < nSegment; j++)
		{
			float x = r * cos(2 * PI*j / nSegment);
			float z = r * sin(2 * PI*j / nSegment);
			pt[count].set(x, fHeight, z);
			count++;
		}
	}
	// ve face
	numFaces = nSegment * 4;
	face = new Face[numFaces];
	count = 0;
	for (int i = 1; i < 5; i++)
	{
		for (int j = 0; j < nSegment; j++)
		{
			face[count].nVerts = 4;
			face[count].vert = new VertexID[face[count].nVerts];
			face[count].vert[0].vertIndex = nSegment * (i%4) + j;
			face[count].vert[1].vertIndex = nSegment * (i%4) + ((j + 1) % nSegment);
			face[count].vert[2].vertIndex = nSegment * (i - 1) + ((j + 1) % nSegment);
			face[count].vert[3].vertIndex = nSegment * (i - 1) + j;
			count++;
		}
	}
}

void Mesh::CreateCylinder(int nSegment, float fHeight, float fRadius)
{
	numVerts = 2*nSegment + 4;
	pt = new Point3[numVerts];
	pt[0].set(0,fHeight/2,0);
	pt[1].set(0,-fHeight/2,0);
	float y=fHeight/2;
	for (int i = 0; i <= nSegment; i++)
	{
		float deg = 360*i/nSegment * PI / 180;
		float x=fRadius*sin(deg);
		float z=fRadius*cos(deg);
		pt[2+i].set(x,y,z);
		pt[2+i+nSegment+1].set(x,-y,z);
	}

	numFaces = 3*nSegment;
	face = new Face[numFaces];

	for (int i = 0; i < nSegment; i++)
	{
		face[i].nVerts = 3;
		face[i].vert = new VertexID[face[i].nVerts];
		face[i].vert[0].vertIndex = 0;
		face[i].vert[1].vertIndex = 2+i;
		face[i].vert[2].vertIndex = 2+i+1;

		for(int j = 0; j= 2.35)
	{
		if(2.9*(sin(handMove1*PI/180)) + 1.6*(sin(upperArmRotateY*PI/180)) <= -2.35 && 2.9*(sin(handMove1*PI/180)) + 1.6*(sin(upperArmRotateY*PI/180)) >= -3.65)
		{
			//4
			if(move >= -0.11 && move <= -0.09)
			{
				if(hold1 == false && hold3 == false && hold4 == false)
				{
					hold2 = true;
					return 2;
				}
			}
		}
	}

	if(2.9*(cos(handMove1*PI/180)) + 1.6*(cos(upperArmRotateY*PI/180)) <= -2.35 && 2.9*(cos(handMove1*PI/180)) + 1.6*(cos(upperArmRotateY*PI/180)) >= -3.65)
	{
		if(2.9*(sin(handMove1*PI/180)) + 1.6*(sin(upperArmRotateY*PI/180)) <= -2.35 && 2.9*(sin(handMove1*PI/180)) + 1.6*(sin(upperArmRotateY*PI/180)) >= -3.65)
		{
			//3
			if(move >= -0.11 && move <= -0.09)
			{
				if(hold1 == false && hold2 == false && hold4 == false)
				{
					hold3 = true;
					return 3;
				}
			}
		}
	}

	if(2.9*(cos(handMove1*PI/180)) + 1.6*(cos(upperArmRotateY*PI/180)) <= -2.35 && 2.9*(cos(handMove1*PI/180)) + 1.6*(cos(upperArmRotateY*PI/180)) >= -3.65)
	{
		if(2.9*(sin(handMove1*PI/180)) + 1.6*(sin(upperArmRotateY*PI/180)) <= 3.65 && 2.9*(sin(handMove1*PI/180)) + 1.6*(sin(upperArmRotateY*PI/180)) >= 2.35)
		{
			//2
			if(move >= -0.11 && move <= -0.09)
			{
				if(hold1 == false && hold3 == false && hold2 == false)
				{
					hold4 = true;
					return 4;
				}
			}
		}
	}

	if(2.9*(cos(handMove1*PI/180)) + 1.6*(cos(upperArmRotateY*PI/180)) <= 3.65 && 2.9*(cos(handMove1*PI/180)) + 1.6*(cos(upperArmRotateY*PI/180)) >= 2.35)
	{
		if(2.9*(sin(handMove1*PI/180)) + 1.6*(sin(upperArmRotateY*PI/180)) <= 3.65 && 2.9*(sin(handMove1*PI/180)) + 1.6*(sin(upperArmRotateY*PI/180)) >= 2.35)
		{
			//1
			if(move >= -0.11 && move <= -0.09)
			{
				if(hold2 == false && hold3 == false && hold4 == false)
				{
					hold1 = true;
					return 1;
				}
			}
		}
	}
	/*
	if(sin(upperArmRotateY*PI/180) >= -0.809017 && sin(upperArmRotateY*PI/180) <= 0.207912) 
	{
		if(sin(handMove1*PI/180) >= -0.927184 && sin(handMove1*PI/180) <= -0.809017 && move >= -0.11 && move <= -0.09) cout<<"blabla"< -0.08)
				//move -= 0.05;
		}
		else if(move > -0.875)
			move -= 0.05;
		break;
	case 'v':
	case 'V':
		b4View = !b4View;
		changeCameraPos();
		break;
	case '+':
		camera_dis += 0.1;
		changeCameraPos();
		break;
	case '-':
		camera_dis -= 0.1;
		changeCameraPos();
		break;

	//Code here
	
	////////////////////////////////////////////
	}
    glutPostRedisplay();
}

void drawFloor()
{
	int SPACE = -2;
	for (int i = 0; i < 5; i++)
	{
		for (int j = 0; j < 5; j++)
		{
			glPushMatrix();
			glTranslated(planeY.slideX + i*SPACE, planeY.slideY, planeY.slideZ + j*SPACE);
			if(bWireFrame){
				planeY.DrawWireframe();
			}
			else{
				planeY.DrawColor();
			}
			glPopMatrix();

			glPushMatrix();
			glTranslated(planeY2.slideX + i*SPACE, planeY2.slideY, planeY2.slideZ + j*SPACE);
			if(bWireFrame){
				planeY2.DrawWireframe();
			}
			else{
				planeY2.DrawColor();
			}
			glPopMatrix();
		}
	}
}

void drawBall1()
{

	glPushMatrix();

	glRotated(ball1upper, 0, 1, 0);

	glTranslated(ball1.slideX, ball1.slideY, ball1.slideZ);	



	glTranslated(-cos(45*PI/180)*2.9, 0, -cos(45*PI/180)*2.9);

	glRotated(ball1hand, 0, 1, 0);

	glTranslated(cos(45*PI/180)*2.9, 0, cos(45*PI/180)*2.9);

	//glTranslated(0, move, 0);

	//glTranslated(-ball1.slideX, -ball1.slideY, -ball1.slideZ);	

	//glRotated(ball1hand, 0, 1, 0);

	//glTranslated(ball1.slideX, ball1.slideY, ball1.slideZ);	

		if(bWireFrame)
			ball1.DrawWireframe();
		else
			ball1.DrawColor();
	glPopMatrix();
}

void drawBall2()
{
	glPushMatrix();

		glRotated(ball2upper, 0, 1, 0);

		glTranslated(ball2.slideX, ball2.slideY, ball2.slideZ);	



		glTranslated(cos(45*PI/180)*2.9, 0, -cos(45*PI/180)*2.9);

		glRotated(ball2hand, 0, 1, 0);

		glTranslated(-cos(45*PI/180)*2.9, 0, cos(45*PI/180)*2.9);

		if(bWireFrame)
			ball2.DrawWireframe();
		else
			ball2.DrawColor();
	glPopMatrix();
}

void drawBall3()
{
	glPushMatrix();

		glRotated(ball3upper, 0, 1, 0);

		glTranslated(ball3.slideX, ball3.slideY, ball3.slideZ);	



		glTranslated(cos(45*PI/180)*2.9, 0, cos(45*PI/180)*2.9);

		glRotated(ball3hand, 0, 1, 0);

		glTranslated(-cos(-45*PI/180)*2.9, 0, -cos(45*PI/180)*2.9);

		if(bWireFrame)
			ball3.DrawWireframe();
		else
			ball3.DrawColor();
	glPopMatrix();
}

void drawBall4()
{
	glPushMatrix();

	glRotated(ball4upper, 0, 1, 0);

	glTranslated(ball4.slideX, ball4.slideY, ball4.slideZ);	



	glTranslated(-cos(45*PI/180)*2.9, 0, cos(45*PI/180)*2.9);

	glRotated(ball4hand, 0, 1, 0);

	glTranslated(cos(45*PI/180)*2.9, 0, -cos(45*PI/180)*2.9);

		if(bWireFrame)
			ball4.DrawWireframe();
		else
			ball4.DrawColor();
	glPopMatrix();
}

void drawCuboidBase()
{
	glPushMatrix();		
		//////////////////////////////////
		glTranslated(0, cuboidBase.slideY, 0);
		if(bWireFrame)
			cuboidBase.DrawWireframe();
		else
			cuboidBase.DrawColor();
	glPopMatrix();
}
void drawCylBase1()
{
	glPushMatrix();
		//////////////////////////////////
		glTranslated(0, cylBase1.slideY, 0);
		if(bWireFrame)
			cylBase1.DrawWireframe();
		else
			cylBase1.DrawColor();
	glPopMatrix();
}

void drawCylBase2()
{
	glPushMatrix();		
		//////////////////////////////////
		glTranslated(0, cylBase2.slideY, 0);
		if(bWireFrame)
			cylBase2.DrawWireframe();
		else
			cylBase2.DrawColor();
	glPopMatrix();
}
///////////////////////////////////////////////////////////////////////
void drawUpperArm1()
{
	glPushMatrix();
		glRotated(upperArmRotateY, 0, 1, 0);
		//////////////////////////////////
		glTranslated(0, upperArm1.slideY, 0);
		if(bWireFrame)
			upperArm1.DrawWireframe();
		else
			upperArm1.DrawColor();
	glPopMatrix();
}

void drawUpperArm2()
{
	glPushMatrix();
		glRotated(upperArmRotateY, 0, 1, 0);
		//////////////////////////////////
		glTranslated(0, upperArm2.slideY, upperArm2.slideZ);
		if(bWireFrame)
			upperArm2.DrawWireframe();
		else
			upperArm2.DrawColor();
	glPopMatrix();
}

void drawUpperArm3()
{
	glPushMatrix();
		glRotated(upperArmRotateY, 0, 1, 0);
		//////////////////////////////////
		glTranslated(0, upperArm3.slideY, upperArm3.slideZ);
		if(bWireFrame)
			upperArm3.DrawWireframe();
		else
			upperArm3.DrawColor();
	glPopMatrix();
}

void drawUpperArm4()
{
	glPushMatrix();
		glRotated(upperArmRotateY, 0, 1, 0);
		//////////////////////////////////
		glTranslated(0, upperArm4.slideY, upperArm4.slideZ);
		if(bWireFrame)
			upperArm4.DrawWireframe();
		else
			upperArm4.DrawColor();
	glPopMatrix();
}

///////////////////////////////////////////////////////////////////
////////////////////////////////////////////////
/////////////// THE	FORE ARM ///////////////////
////////////////////////////////////////////////
void drawforeArm1()
{
	glPushMatrix();
		glRotated(upperArmRotateY, 0, 1, 0);
		//////////////////////////////////
		glTranslated(0, foreArm1.slideY, foreArm1.slideZ);

		if(bWireFrame)
			foreArm1.DrawWireframe();
		else
			foreArm1.DrawColor();
	glPopMatrix();
}

void drawforeArm2()
{
	glPushMatrix();
	//glTranslated(foreArm2.slideX, foreArm2.slideY - 2.5, foreArm2.slideZ);
		glRotated(upperArmRotateY, 0, 1, 0);
		//////////////////////////////////
		glTranslated(0, foreArm2.slideY, foreArm2.slideZ);

		glTranslated(0, -foreArm2.slideY, -(foreArm2.slideZ - 1.6));

		glRotated(foreArmRotateY, 0, 1, 0);

		glTranslated(0, foreArm2.slideY, (foreArm2.slideZ - 1.6));

		if(bWireFrame)
			foreArm2.DrawWireframe();
		else
			foreArm2.DrawColor();
	glPopMatrix();
}

void drawforeArm3()
{
	glPushMatrix();
		glRotated(upperArmRotateY, 0, 1, 0);
		//////////////////////////////////
		glTranslated(0, foreArm3.slideY, foreArm3.slideZ);

		glTranslated(0, -foreArm3.slideY, -(foreArm3.slideZ - 1.6));

		glRotated(foreArmRotateY, 0, 1, 0);

		glTranslated(0, foreArm3.slideY, (foreArm3.slideZ - 1.6));

		if(bWireFrame)
			foreArm3.DrawWireframe();
		else
			foreArm3.DrawColor();
	glPopMatrix();
}

void drawforeArm4()
{
	glPushMatrix();
		glRotated(upperArmRotateY, 0, 1, 0);
		//////////////////////////////////
		glTranslated(0, foreArm4.slideY, foreArm4.slideZ);

		glTranslated(0, -foreArm4.slideY, -(foreArm4.slideZ - 1.6));

		glRotated(foreArmRotateY, 0, 1, 0);

		glTranslated(0, foreArm4.slideY, (foreArm4.slideZ - 1.6));

		if(bWireFrame)
			foreArm4.DrawWireframe();
		else
			foreArm4.DrawColor();
	glPopMatrix();
}

void drawHand()
{
	glPushMatrix();
		glRotated(upperArmRotateY, 0, 1, 0);
		//////////////////////////////////
		glTranslated(0, Hand.slideY, Hand.slideZ);

		glTranslated(0, -Hand.slideY, -(Hand.slideZ - 1.6));

		glRotated(foreArmRotateY, 0, 1, 0);

		glTranslated(0, Hand.slideY, (Hand.slideZ - 1.6));

		glTranslated(0, move, 0);

		if(bWireFrame)
			Hand.DrawWireframe();
		else
			Hand.DrawColor();
	glPopMatrix();	
}	

void drawHand1()
{
	glPushMatrix();

	if(move >= -0.11 && move <= -0.09)
	{
		//cout<        : to rotate camera counterclockwise." << endl;

	glutInit(&argc, argv); //initialize the tool kit
	glutInitDisplayMode(GLUT_DOUBLE |GLUT_RGB);//set the display mode
	glutInitWindowSize(screenWidth, screenHeight); //set window size
	glutInitWindowPosition(100, 100); // set window position on screen
	glutCreateWindow("Lab4"); // open the screen window

	///////////////////////////////////////////////////////////////
	// The Floor
	planeY.CreateYPlane(10, 10, 1, 1);
	planeY.slideX = 4.5;
	planeY.slideY = YPlanePos;
	planeY.slideZ = 4.5;
	planeY.SetColor(15);

	planeY2.CreateYPlane(10, 10, 1, 1);
	planeY2.slideX = 3.5;
	planeY2.slideY = YPlanePos;
	planeY2.slideZ = 3.5;
	planeY2.SetColor(15);

	///////////////////////////////////////////////////////////////
	// 4 balls
	ball1.CreateSphere(50, 20, ballRadius);
	ball1.slideX = 3;
	ball1.slideY = YPlanePos + ballRadius;
	ball1.slideZ = 3;
	ball1.SetColor(1);

	ball2.CreateSphere(50, 20, ballRadius);
	ball2.slideX = -3;
	ball2.slideY = YPlanePos + ballRadius;
	ball2.slideZ = 3;
	ball2.SetColor(2);

	ball3.CreateSphere(50, 20, ballRadius);
	ball3.slideX = -3;
	ball3.slideY = YPlanePos + ballRadius;
	ball3.slideZ = -3;
	ball3.SetColor(3);

	ball4.CreateSphere(50, 20, ballRadius);
	ball4.slideX = 3;
	ball4.slideY = YPlanePos + ballRadius;
	ball4.slideZ = -3;
	ball4.SetColor(4);

	///////////////////////////////////////////////////////////////
	// The Body
	cuboidBase.CreateCuboid(cuboidBaseSizeXZ/2.0, cuboidBaseSizeY/2.0, cuboidBaseSizeXZ/2.0);
	cuboidBase.slideY = YPlanePos + cuboidBaseSizeY/2.0;
	cuboidBase.SetColor(0);

	cylBase1.CreateCylinder(20, cylBase1Height, cylBase1Radius);
	cylBase1.slideY = YPlanePos + cuboidBaseSizeY/2.0 + cylBase1Height/2;
	cylBase1.SetColor(1);

	cylBase2.CreateCylinder(20, cylBase2Height, cylBase2Radius);
	cylBase2.slideY = YPlanePos + cuboidBaseSizeY/2.0 + cylBase1Height/2 + cylBase2Height/2 ;
	cylBase2.SetColor(2);

	///////////////////////////////////////////////////
	// The Upper Arm
	upperArm1.CreateCylinder(20, upperArm1Height, upperArm1ORadius);
	upperArm1.slideY = YPlanePos + cuboidBaseSizeY/2.0 + cylBase1Height/2 + cylBase2Height - upperArm1Offset;
	upperArm1.SetColor(5);

	upperArm2.CreateCuboid(upperArm2SizeX, upperArm2SizeY, upperArm2SizeZ);
	upperArm2.slideY = YPlanePos + cuboidBaseSizeY/2.0 + cylBase1Height/2 + cylBase2Height - upperArm1Offset;
	upperArm2.slideZ = upperArm2SizeZ + upperArm1IRadius;
	upperArm2.SetColor(6);

	upperArm3.CreateCylinder(20, upperArm3Height, upperArm3Radius);
	upperArm3.slideY = YPlanePos + cuboidBaseSizeY/2.0 + cylBase1Height/2 + cylBase2Height - upperArm1Offset;
	upperArm3.slideZ = upperArm2.slideZ + upperArm2SizeZ ;
	upperArm3.SetColor(5);

	upperArm4.CreateCylinder(20, upperArm4Height, upperArm4Radius);
	upperArm4.slideY = YPlanePos + cuboidBaseSizeY/2.0 + cylBase1Height/2 + cylBase2Height - upperArm1Offset + 
						upperArm4Height/2 + upperArm3Height/2;
	upperArm4.slideZ = upperArm3.slideZ;
	upperArm4.SetColor(2);

	///////////////////////////////////////////////////
	// The Fore Arm
	foreArm1.CreateCylinder(20, foreArm1Height, foreArm1ORadius);
	foreArm1.slideY = upperArm3.slideY + upperArm4Height/2 + upperArm1Height/4;
	foreArm1.slideZ = upperArm4.slideZ;
	foreArm1.SetColor(3);

	foreArm2.CreateCuboid(foreArm2SizeX, foreArm2SizeY, foreArm2SizeZ);
	foreArm2.slideY = foreArm1.slideY;
	foreArm2.slideZ = foreArm1.slideZ + foreArm1IRadius/2 + foreArm2SizeZ;
	foreArm2.SetColor(4);

	foreArm3.CreateCylinder(20, foreArm3Height, foreArm3Radius);
	foreArm3.slideY = foreArm2.slideY;
	foreArm3.slideZ = foreArm2.slideZ + foreArm2SizeZ;
	foreArm3.SetColor(5);

	foreArm4.CreateCylinder(20, foreArm4Height, foreArm4Radius);
	foreArm4.slideY = foreArm3.slideY + 0.2;
	foreArm4.slideZ = foreArm3.slideZ;
	foreArm4.SetColor(0);
	
	///////////////////////////////////////////////////
	// The Hand
	Hand.CreateCylinder(20, 3.5, 0.08);
	Hand.slideY = foreArm4.slideY;
	Hand.slideZ = foreArm4.slideZ;
	Hand.SetColor(1);

	Hand1.CreateCylinder(20, 0.2, 0.4);
	Hand1.slideY = foreArm4.slideY - 3.5/2;
	Hand1.slideZ = foreArm4.slideZ;
	Hand1.SetColor(7);

	/////////////////////////////////////////////////////////

	myInit();
	
	glutKeyboardFunc(myKeyboard);
    glutDisplayFunc(myDisplay);
	glutSpecialFunc(mySpecialKeyboard);

	glutMainLoop();
	return 0;
}
Computer

Opinions expressed by DZone contributors are their own.

Related

  • How Does Video Annotation Augment Computer Vision?
  • Vulnerable Code [Comic]
  • How To Protect RDP From Ransomware Attacks
  • Advancements in Computer Vision: Deep Learning for Image Recognition

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!