public void CreateRobotList() { GL.glPushMatrix(); // // hierarchical list // GL.glNewList(ROBOT_LIST, GL.GL_COMPILE); // BASE : no rotations!!! Angle will be implemented in the CALL routine // before call to CreateRobotList() GL.glColor3f(0, 0, 0.5f); GLU.gluCylinder(obj, 3 * r, 3 * r, r * 1.2, 40, 20); GL.glTranslated(0, 0, r * 1.2); GLU.gluDisk(obj, 0, 3 * r, 40, 20); GL.glColor3f(0, 0, 1); GLU.gluSphere(obj, r * 1.2, 20, 20); // end base // transformations GL.glRotatef(SHOULDER_angle, 1, 0, 0); // call SHOULDER GL.glCallList(SHOULDER_LIST); // transformations //no need in glTranslated 0, 0, SHOULDER_length //it is located properly now !!! GL.glRotatef(ARM_angle, 1, 0, 0); // call ARM GL.glCallList(ARM_LIST); GL.glEndList(); GL.glPopMatrix(); }
public void draw_sun() { GL.glPushMatrix(); GL.glColor3d(1, 1, 1); GL.glEnable(GL.GL_TEXTURE_2D); GL.glBindTexture(GL.GL_TEXTURE_2D, Textures[6]); quad = GLU.gluNewQuadric(); GLU.gluQuadricTexture(quad, 40); GL.glTranslatef(pos[0], pos[1], pos[2]); // rotating sun as well as all planets to Y axis GL.glTranslatef(0.0f, 0.0f + (float)-speed * 0.03f, 0.0f); //y - up down GL.glTranslatef(0.0f, 0.0f, 0.0f + (float)-speed * 0.01f); //z - back forward GL.glRotatef((float)moon, 0.0f, 1.0f, 0.0f); GLU.gluSphere(quad, 45, 1000, 1000); GL.glPopMatrix(); moon += 0.04f; }
protected void DrawThumbFinger(int fingerPart) { switch (fingerPart) { case 1: GL.glRotated(-45, 0, 0, 1); GL.glColor3d(1, 1, 1); GLU.gluSphere(objShpere, 0.6, 50, 50); GL.glTranslated(0, 0.2, 0); GL.glRotated(-90, 1, 0, 0); GL.glColor3d(1, 0.8, 0.6); GLU.gluCylinder(objFinger, 0.5, 0.5, 1, 50, 50); GL.glRotated(90, 1, 0, 0); GL.glTranslated(0, 0.8, 0); GL.glRotated(45, 0, 0, 1); break; case 2: GL.glRotated(-45, 0, 0, 1); GL.glColor3d(1, 1, 1); GLU.gluSphere(objShpere, 0.6, 50, 50); GL.glTranslated(0, 0.2, 0); GL.glRotated(-90, 1, 0, 0); GL.glColor3d(1, 0.8, 0.6); GLU.gluCylinder(objFinger, 0.5, 0.5, 0.7, 50, 50); GL.glRotated(90, 1, 0, 0); GL.glTranslated(0, 0.6, 0); GL.glColor3d(1, 1, 1); GLU.gluSphere(objShpere, 0.5, 50, 50); GL.glRotated(45, 0, 0, 1); GL.glTranslated(-4.6, -1.8, 0); break; } }
public void draw_moon() { GL.glPushMatrix(); GL.glColor3d(1, 1, 1); GL.glEnable(GL.GL_TEXTURE_2D); GL.glBindTexture(GL.GL_TEXTURE_2D, Textures[1]); quad = GLU.gluNewQuadric(); GLU.gluQuadricTexture(quad, 40); GL.glTranslatef(-200, 200, -300); // rotating moon as well as all planets to Y axis GL.glTranslatef(0.0f + (float)speed * 0.01f, 0.0f, 0.0f); GL.glTranslatef(0.0f, 0.0f + (float)speed * 0.01f, 0.0f); GL.glRotatef((float)moon++ *0.5f, 1.0f, 1.0f, 0.0f); GLU.gluSphere(quad, 18, 200, 200); GL.glPopMatrix(); }
private void DrawIsland() { float moveSphere = GlobalProperties.islandRadius - GlobalProperties.islandHeight; float rotate = 45.0f; GL.glEnable(GL.GL_CLIP_PLANE0); double[] clipPalane0 = { 0.0, 0.0, 1.0, 0.0 }; GL.glClipPlane(GL.GL_CLIP_PLANE0, clipPalane0); GL.glTranslatef(0.0f, 0.0f, -moveSphere); GL.glEnable(GL.GL_TEXTURE_2D); GL.glColor3f(1.0f, 1.0f, 1.0f); GL.glBindTexture(GL.GL_TEXTURE_2D, Textures[1]); GL.glRotatef(rotate, 1.0f, 1.0f, 0.0f); GLUquadric obj = GLU.gluNewQuadric(); GLU.gluQuadricTexture(obj, 1); GLU.gluSphere(obj, GlobalProperties.islandRadius, 32, 32); GLU.gluDeleteQuadric(obj); GL.glRotatef(-rotate, 1.0f, 1.0f, 0.0f); GL.glDisable(GL.GL_TEXTURE_2D); GL.glTranslatef(0.0f, 0.0f, moveSphere); GL.glDisable(GL.GL_CLIP_PLANE0); }
public static void glutSolidSphere(double radius, int slices, int stacks) { QUAD_OBJ_INIT(); GLU.gluQuadricDrawStyle(quadObj, GLU.GLU_FILL); GLU.gluQuadricNormals(quadObj, GLU.GLU_SMOOTH); // If we ever changed/used the texture or orientation state // of quadObj, we'd need to change it to the defaults here // with gluQuadricTexture and/or gluQuadricOrientation. GLU.gluSphere(quadObj, radius, slices, stacks); }
void DrawBounds() { if (isBounds) { GL.glScalef(0.99f, 0.99f, 0.99f); GL.glLineWidth(2); GL.glColor3f(1.0f, 0.0f, 0.0f); GL.glDisable(GL.GL_LIGHTING); GL.glBegin(GL.GL_LINE_LOOP); GL.glVertex3f(-1, -1, -1); GL.glVertex3f(1, -1, -1); GL.glVertex3f(1, -1, 1); GL.glVertex3f(-1, -1, 1); GL.glEnd(); GL.glBegin(GL.GL_LINE_LOOP); GL.glVertex3f(-1, 1, -1); GL.glVertex3f(1, 1, -1); GL.glVertex3f(1, 1, 1); GL.glVertex3f(-1, 1, 1); GL.glEnd(); GL.glBegin(GL.GL_LINES); GL.glVertex3f(-1, -1, -1); GL.glVertex3f(-1, 1, -1); GL.glVertex3f(1, -1, -1); GL.glVertex3f(1, 1, -1); GL.glVertex3f(1, -1, 1); GL.glVertex3f(1, 1, 1); GL.glVertex3f(-1, -1, 1); GL.glVertex3f(-1, 1, 1); GL.glEnd(); GL.glScalef(1.0f / 0.99f, 1.0f / 0.99f, 1.0f / 0.99f); } GL.glEnable(GL.GL_COLOR_MATERIAL); GL.glEnable(GL.GL_LIGHTING); GL.glEnable(GL.GL_LIGHT0); GL.glTranslatef(0.1f, 0.2f, -0.7f); GL.glColor3f(0, 1, 0); GLU.gluSphere(obj, 0.05, 16, 16); GL.glTranslatef(-0.1f, -0.2f, 0.7f); GL.glDisable(GL.GL_LIGHTING); }
void PrepareLists() { float ARM_length, SHOULDER_length; ARM_length = 2; ARM_angle = -45; SHOULDER_length = 2.5f; SHOULDER_angle = 10; ROBOT_angle = 45; r = 0.3f; ROBOT_LIST = GL.glGenLists(3); ARM_LIST = ROBOT_LIST + 1; SHOULDER_LIST = ROBOT_LIST + 2; GL.glPushMatrix(); GL.glNewList(ARM_LIST, GL.GL_COMPILE); //cone GL.glColor3f(0.5f, 0, 0); GLU.gluCylinder(obj, r, 0, ARM_length, 20, 20); GL.glTranslated(0, 0, ARM_length); //internal disk GL.glColor3f(1, 1, 0); GLU.gluDisk(obj, 0, r * 0.5, 20, 20); //external disk GL.glColor3f(1, 0, 0); GLU.gluDisk(obj, r * 0.5, r * 1.5, 20, 20); GL.glEndList(); GL.glPopMatrix(); GL.glPushMatrix(); GL.glNewList(SHOULDER_LIST, GL.GL_COMPILE); GL.glColor3f(0, 0.5f, 0); GLU.gluCylinder(obj, r, r, SHOULDER_length, 20, 20); GL.glTranslated(0, 0, SHOULDER_length); GL.glColor3f(0, 1, 0); GLU.gluSphere(obj, r * 1.2, 20, 20); GL.glEndList(); GL.glPopMatrix(); CreateRobotList(); }
protected void DrawSingleFinger(int fingerPart, double returnToZero) { switch (fingerPart) { case 1: GL.glColor3d(1, 1, 1); GLU.gluSphere(objShpere, 0.6, 50, 50); GL.glTranslated(0, 0.2, 0); GL.glRotated(-90, 1, 0, 0); GL.glColor3d(1, 0.8, 0.6); GLU.gluCylinder(objFinger, 0.5, 0.5, 1, 50, 50); GL.glRotated(90, 1, 0, 0); GL.glTranslated(0, 0.8, 0); break; case 2: GL.glColor3d(1, 1, 1); GLU.gluSphere(objShpere, 0.6, 50, 50); GL.glTranslated(0, 0.2, 0); GL.glRotated(-90, 1, 0, 0); GL.glColor3d(1, 0.8, 0.6); GLU.gluCylinder(objFinger, 0.5, 0.5, 0.7, 50, 50); GL.glRotated(90, 1, 0, 0); GL.glTranslated(0, 0.8, 0); break; case 3: GL.glColor3d(1, 1, 1); GLU.gluSphere(objShpere, 0.6, 50, 50); GL.glTranslated(0, 0.2, 0); GL.glRotated(-90, 1, 0, 0); GL.glColor3d(1, 0.8, 0.6); GLU.gluCylinder(objFinger, 0.5, 0.5, 0.7, 50, 50); GL.glRotated(90, 1, 0, 0); GL.glTranslated(0, 0.6, 0); GL.glColor3d(1, 1, 1); GLU.gluSphere(objShpere, 0.5, 50, 50); GL.glTranslated(-returnToZero, -5.1, 0); break; } }
void DrawSky(float skysize) { float mid = skysize; GL.glEnable(GL.GL_TEXTURE_2D); GL.glBindTexture(GL.GL_TEXTURE_2D, Textures[6]); GL.glDisable(GL.GL_LIGHTING); GL.glTranslatef(0, 0, -mid); GL.glRotatef(90, 0, 0, 1); GL.glRotatef(zavit, 1, 0, 0); GLU.gluQuadricTexture(obj, 1); GLU.gluSphere(obj, skysize * 1.5f, 50, 50); GL.glRotatef(-zavit, 1, 0, 0); GL.glRotatef(-90, 0, 0, 1); GL.glTranslatef(0, 0, mid); GL.glEnable(GL.GL_LIGHTING); GL.glDisable(GL.GL_TEXTURE_2D); zavit += 0.02f; }
public void DrawShadowLeg(bool side) { GL.glPushMatrix(); if (side == false) { GL.glRotatef(LegLeftUpAngle, 0, 1, 0); } else { GL.glRotatef(LegRightUpAngle, 0, 1, 0); } GLU.gluSphere(obj, radius * 1.7, 20, 20); GL.glCallList(LEG_UP_SHADOW_LIST); if (side == false) { if (WeaponIndex == 1 || WeaponIndex == 2) { GL.glRotatef(LegLeftDownAngle, 0, 1, 0); } else { GL.glScalef(-1, 1, 1); GL.glRotatef(LegLeftDownAngle, 0, 1, 0); GL.glScalef(1, 1, 1); } } else if (WeaponIndex == 1 || WeaponIndex == 2) { GL.glRotatef(LegRightDownAngle, 0, 1, 0); } else { GL.glScalef(-1, 1, 1); GL.glRotatef(LegRightDownAngle, 0, 1, 0); GL.glScalef(1, 1, 1); } GL.glCallList(LEG_DOWN_SHADOW_LIST); GL.glPopMatrix(); }
public void DrawFrame() { //draw the Frame of mirror radius = 0.18f; GL.glPushMatrix(); GL.glColor3f(0.3f, 0.1f, 0.0f); GL.glTranslatef(0, -1, 3); GLU.gluSphere(obj, radius, 20, 20); GL.glTranslatef(0, 1, -3); GL.glTranslatef(0, -1, -3f); GLU.gluCylinder(obj, radius, radius, radius * 33, 20, 20); GLU.gluSphere(obj, radius, 20, 20); GL.glTranslatef(0, -5.9f, 0); GLU.gluCylinder(obj, radius, radius, radius * 33, 20, 20); GLU.gluSphere(obj, radius, 20, 20); GL.glRotatef(-90, 1, 0, 0); GLU.gluCylinder(obj, radius, radius, radius * 33, 20, 20); GLU.gluSphere(obj, radius, 20, 20); GL.glScalef(-1, 1, 1); GL.glTranslatef(0, -6, 0); GLU.gluCylinder(obj, radius, radius, radius * 33, 20, 20); GLU.gluSphere(obj, radius, 20, 20); GL.glPopMatrix(); }
public void DrawShadowHand(bool side) { GL.glPushMatrix(); GL.glTranslated(0, 0, 0.23f); GL.glPushMatrix(); if (side == false) { GL.glTranslatef(0, 0.6f, 0); if (WeaponIndex == 1 || WeaponIndex == 2) { GL.glRotatef(ShoulderLeftAngle / 10, 0, 0, 1); GL.glRotatef(WeaponPlace, 0, 0, 1);//hand Move from fire } else { GL.glRotatef(-ShoulderLeftAngle, 0, 0, 1); } GL.glTranslatef(0, -0.6f, 0); } else { GL.glTranslatef(0, 0.6f, 0); if (WeaponIndex == 1 || WeaponIndex == 2) { GL.glRotatef(-ShoulderRightAngle / 10, 0, 0, 1); GL.glRotatef(WeaponPlace, 0, 0, 1);//hand Move from fire } else { GL.glRotatef(-ShoulderRightAngle, 0, 0, 1); } GL.glTranslatef(0, -0.6f, 0); } GL.glTranslatef(0, 0.6f, 0.55f); GLU.gluCylinder(obj, radius, radius, radius * 1.2, 40, 20); GL.glTranslated(0, 0, radius * 1.2); GLU.gluDisk(obj, 0, radius, 40, 20); GLU.gluSphere(obj, radius * 1.2, 20, 20); GL.glTranslatef(0, -0.6f, -0.55f); // build Robot shoulder GL.glCallList(SHOULDER_SHADOW_LIST); GL.glRotatef(ArmLeftAngle, 1, 0, 0); //Move down hand with WeaponIndex if (WeaponIndex == 2) { GL.glRotatef(-WeaponPlace, 0, 1, 0); GL.glRotatef(WeaponPlace, 0, 0, 1); } // build Robot arm GL.glCallList(ARM_SHADOW_LIST); GL.glPopMatrix(); if (IsMoving == false) //do not see bullets when walking { GL.glPushMatrix(); if (WeaponIndex == 2) { GL.glTranslatef(0.2f, 0.2f, 1.4f); GL.glRotatef(-8, 0, 1, 0); } else//WeaponIndex 1 { GL.glTranslatef(2.2f, 1.4f, 1.3f); GL.glRotatef(-8, 0, 1, 0); } GL.glRotatef(90, 0, 1, 0); GL.glTranslatef(0, 0, ShootDist); if (WeaponIndex == 1) { //draw bullet radius = radius * 2.2f; GL.glColor3f(0.0f, 0.0f, 0); GLU.gluCylinder(obj, radius / 4.5f, radius / 4.5f, radius / 2, 40, 20); GLU.gluDisk(obj, 0, radius / 4.5f, 20, 20); GL.glTranslatef(0, 0, radius / 2); GLU.gluCylinder(obj, radius / 4.5f, 0, radius / 4, 40, 20); radius = radius / 2.2f; } else if (WeaponIndex == 2) { //draw bullet GL.glColor3f(0.0f, 0.0f, 0); GLU.gluCylinder(obj, radius / 1.3f, radius / 1.3f, radius * 7, 40, 20); GLU.gluDisk(obj, 0, radius / 1.3f, 20, 20); GL.glTranslatef(0, 0, radius * 7); GLU.gluCylinder(obj, radius / 1.3f, 0, radius * 5, 40, 20); } GL.glPopMatrix(); } GL.glPopMatrix(); }
void DrawDynamicShadowHand() { switch (WeaponIndex) { case 0: GL.glPushMatrix(); GL.glNewList(SHOULDER_SHADOW_LIST, GL.GL_COMPILE); //shoulder GL.glTranslatef(0, 0.6f, 0); GL.glTranslated(0, 0, shoulderLength - 0.55); GL.glRotatef(55, 1, 0, 0); GLU.gluCylinder(obj, radius, radius, shoulderLength, 20, 20); GL.glTranslated(0, 0, shoulderLength); GLU.gluSphere(obj, 1.3 * radius, 20, 20); GL.glEndList(); GL.glPopMatrix(); GL.glPushMatrix(); GL.glNewList(ARM_SHADOW_LIST, GL.GL_COMPILE); //arm GL.glRotatef(-30, 1, 0, 0); GLU.gluCylinder(obj, radius, radius, armLength, 20, 20); GL.glTranslated(0, 0, armLength); GLU.gluSphere(obj, radius * 2.2, 20, 20); GL.glEndList(); GL.glPopMatrix(); break; case 1: GL.glPushMatrix(); GL.glNewList(SHOULDER_SHADOW_LIST, GL.GL_COMPILE); //shoulder GL.glTranslatef(0, 0.6f, 0); GL.glTranslated(0, 0, shoulderLength - 0.55); GL.glRotatef(65, 0, 1, 0); GLU.gluCylinder(obj, radius, radius, shoulderLength, 20, 20); GL.glTranslated(0, 0, shoulderLength); GLU.gluSphere(obj, 1.3 * radius, 20, 20); GL.glEndList(); GL.glPopMatrix(); GL.glPushMatrix(); GL.glNewList(ARM_SHADOW_LIST, GL.GL_COMPILE); //arm GL.glRotatef(-80, 1, 0, 0); GL.glRotatef(20, 0, 1, 0); GLU.gluCylinder(obj, radius, radius, armLength, 20, 20); GL.glTranslated(0, 0, armLength); GLU.gluSphere(obj, radius * 2.2, 20, 20); //gun1 GL.glTranslatef(0, 0.6f, 0); GL.glScalef(1.5f, 1.5f, 1.5f); gun1.DrawModel(false, 1); break; case 2: GL.glPushMatrix(); GL.glNewList(SHOULDER_SHADOW_LIST, GL.GL_COMPILE); //shoulder GL.glTranslatef(0, 0.6f, 0); GL.glTranslated(0, 0, shoulderLength - 0.55); GL.glRotatef(65, 1, 0, 0); GLU.gluCylinder(obj, radius, radius, shoulderLength, 20, 20); GL.glTranslated(0, 0, shoulderLength); GLU.gluSphere(obj, 1.3 * radius, 20, 20); GL.glEndList(); GL.glPopMatrix(); GL.glPushMatrix(); GL.glNewList(ARM_SHADOW_LIST, GL.GL_COMPILE); //arm GL.glRotatef(-80, 1, 0, 0); GL.glRotatef(90, 0, 1, 0); GLU.gluCylinder(obj, radius, radius, armLength, 20, 20); GL.glTranslated(0, 0, armLength); GLU.gluSphere(obj, radius * 2.2, 20, 20); //gun2 GL.glRotatef(-30, 0, 0, 1); GL.glTranslatef(0, 0.6f, 0); GL.glScalef(1.3f, 1.3f, 1.3f); gun2.DrawModel(false, 1); break; case 3: GL.glPushMatrix(); GL.glNewList(SHOULDER_SHADOW_LIST, GL.GL_COMPILE); //shoulder GL.glTranslatef(0, 0.6f, 0); GL.glTranslated(0, 0, shoulderLength - 0.55); GL.glRotatef(55, 1, 0, 0); GLU.gluCylinder(obj, radius, radius, shoulderLength, 20, 20); GL.glTranslated(0, 0, shoulderLength); GLU.gluSphere(obj, 1.3 * radius, 20, 20); GL.glEndList(); GL.glPopMatrix(); GL.glPushMatrix(); GL.glNewList(ARM_SHADOW_LIST, GL.GL_COMPILE); //arm GL.glRotatef(-30, 1, 0, 0); GLU.gluCylinder(obj, radius, radius, armLength, 20, 20); GL.glTranslated(0, 0, armLength); GLU.gluSphere(obj, radius * 2.2, 20, 20); //sword GL.glScalef(0.3f, 0.3f, 0.3f); sword.DrawModel(false, 1); GL.glScalef(-0.3f, -0.3f, -0.3f); break; } GL.glEndList(); GL.glPopMatrix(); }
public void PrepareShadow() { radius = 0.18f; Robot_SHADOW_LIST = GL.glGenLists(7); ARM_SHADOW_LIST = Robot_SHADOW_LIST + 1; SHOULDER_SHADOW_LIST = Robot_SHADOW_LIST + 2; HAND_SHADOW_LIST = Robot_SHADOW_LIST + 3; BODY_SHADOW_LIST = Robot_SHADOW_LIST + 4; HEAD_SHADOW_LIST = Robot_SHADOW_LIST + 5; LEG_UP_SHADOW_LIST = Robot_SHADOW_LIST + 6; LEG_DOWN_SHADOW_LIST = Robot_SHADOW_LIST + 7; GL.glPushMatrix(); GL.glNewList(HEAD_SHADOW_LIST, GL.GL_COMPILE); GL.glTranslatef(0, 1, 0); //head GL.glPushMatrix(); GL.glTranslatef(0, 1, 0); GL.glRotatef(-90, 1, 0, 0); GLU.gluSphere(obj, radius * 3.5, 20, 20); GL.glRotatef(180, 1, 0, 0); GLU.gluCylinder(obj, 3.5 * radius, 3.5 * radius, radius * 2, 20, 20); GL.glTranslatef(0, 0, radius * 2); GLU.gluCylinder(obj, 3.5 * radius, 0.5, radius * 2, 20, 20); GL.glTranslatef(0, 0, radius * 2); GLU.gluCylinder(obj, 0.5, 0, radius * 2, 20, 20); GL.glPopMatrix(); GL.glEndList(); GL.glPopMatrix(); GL.glPushMatrix(); GL.glNewList(BODY_SHADOW_LIST, GL.GL_COMPILE); //ALL body //neck GL.glPushMatrix(); GL.glRotatef(90, 1, 0, 0); GL.glTranslatef(0, 0, -2.0f); GLU.gluCylinder(obj, 1.5 * radius, 1.5 * radius, bodyLength, 20, 20); GL.glPopMatrix(); ////body up GL.glRotatef(90, 1, 0, 0); GL.glTranslatef(0, 0, -1.2f); GLU.gluCylinder(obj, radius, 6 * radius, bodyLength / 4, 20, 20); GL.glTranslatef(0, 0, 1.2f); //body midle GL.glScalef(1.0f, -1.0f, 1.0f); GL.glTranslatef(0, 0, -(bodyLength / 4 + 0.2f)); GLU.gluCylinder(obj, 6 * radius, 3 * radius, bodyLength / 1.5f, 20, 20); GL.glTranslatef(0, 0, (bodyLength / 4 + 0.2f)); GL.glScalef(1.0f, 1.0f, 1.0f); //Tusik GLU.gluCylinder(obj, 3 * radius, 3 * radius, bodyLength / 1.5f, 20, 20); //body down GL.glTranslatef(0, 0, (bodyLength / 1.5f)); GLU.gluCylinder(obj, 3 * radius, radius, bodyLength / 3.5f, 10, 10); GL.glTranslatef(0, 0, -(bodyLength / 1.5f)); GL.glRotatef(-90, 1, 0, 0); GL.glEndList(); GL.glPopMatrix(); DrawDynamicShadowHand(); GL.glPushMatrix(); GL.glNewList(LEG_UP_SHADOW_LIST, GL.GL_COMPILE); //leg_up GLU.gluCylinder(obj, 1.5f * radius, 1.5f * radius, legUpLength, 20, 20); GL.glTranslated(0, 0, legUpLength); GLU.gluSphere(obj, radius * 1.7f, 20, 20); GL.glEndList(); GL.glPopMatrix(); GL.glPushMatrix(); GL.glNewList(LEG_DOWN_SHADOW_LIST, GL.GL_COMPILE); //leg_down GLU.gluCylinder(obj, 1.5f * radius, 1.5f * radius, legDownLength, 20, 20); GL.glTranslated(0, 0, legDownLength); GLU.gluSphere(obj, 1.7f * radius, 20, 20); GL.glEndList(); GL.glPopMatrix(); }
public void DrawRobot(bool isForShades) { GL.glPushMatrix(); if (!isForShades) { GL.glColor4f(0f, 0f, 0.4f, 1f); GL.glEnable(GL.GL_COLOR_MATERIAL); GL.glMaterialf(GL.GL_FRONT_AND_BACK, GL.GL_SHININESS, 51.2f); GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT, chrome_ambient); GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_DIFFUSE, chrome_diffuse); GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_SPECULAR, chrome_specular); } GL.glTranslated(0, 0, 7.5); GL.glRotatef(180, 0, 1, 0); GL.glRotatef(-alfa, 0, 0, 1); GL.glTranslated(0, 0, updn); GL.glRotatef(bodyAngle, 0, 1, 0); GL.glPushMatrix(); //torso if (isForShades) { GL.glColor3f(0.2f, 0.2f, 0.2f); } GLU.gluCylinder(obj, 1.0, 1.0, 4.0, 50, 3); GLU.gluDisk(obj, 0, 1, 40, 20); GL.glTranslated(0, 0, 4); GLU.gluDisk(obj, 0, 1, 40, 20); GL.glTranslated(0, 0, -4); //head GL.glTranslated(0, 0, -r * 3); GLU.gluSphere(obj, r * 3, 20, 20); GL.glPopMatrix(); GL.glPushMatrix(); //right_upper_ARM GL.glTranslated(0, 1.3, 0.3); GL.glRotatef(right_upper_ARM_yangle, 0, 1, 0); GL.glRotatef(right_upper_ARM_xangle, 1, 0, 0); if (!isForShades) { GL.glColor3f(0.4f, 0.6f, 0f); } else { GL.glColor3f(0.2f, 0.2f, 0.2f); } GLU.gluSphere(obj, r * 1.4, 20, 20); if (!isForShades) { GL.glColor3f(0, 0, 1f); } else { GL.glColor3f(0.2f, 0.2f, 0.2f); } GLU.gluCylinder(obj, 0.3, 0.3, 1.7, 50, 3); //right_lower_ARM GL.glTranslated(0, 0, 1.7); GL.glRotatef(right_lower_ARM_angle, 0, 1, 0); if (!isForShades) { GL.glColor3f(0.4f, 0.6f, 0f); } else { GL.glColor3f(0.2f, 0.2f, 0.2f); } GLU.gluSphere(obj, r * 1.1, 20, 20); if (!isForShades) { GL.glColor3f(0, 0, 1f); } else { GL.glColor3f(0.2f, 0.2f, 0.2f); } GLU.gluCylinder(obj, 0.3, 0.3, 1.7, 50, 3); GL.glPopMatrix(); GL.glPushMatrix(); //left_upper_ARM GL.glTranslated(0, -1.3, 0.3); GL.glRotatef(left_upper_ARM_yangle, 0, 1, 0); GL.glRotatef(left_upper_ARM_xangle, 1, 0, 0); if (!isForShades) { GL.glColor3f(0.4f, 0.6f, 0f); } else { GL.glColor3f(0.2f, 0.2f, 0.2f); } GLU.gluSphere(obj, r * 1.4, 20, 20); if (!isForShades) { GL.glColor3f(0, 0, 1f); } else { GL.glColor3f(0.2f, 0.2f, 0.2f); } GLU.gluCylinder(obj, 0.3, 0.3, 1.7, 50, 3); //left_lower_ARM ///// GL.glTranslated(0, 0, 1.7); GL.glRotatef(left_lower_ARM_angle, 0, 1, 0); if (!isForShades) { GL.glColor3f(0.4f, 0.6f, 0f); } else { GL.glColor3f(0.2f, 0.2f, 0.2f); } GLU.gluSphere(obj, r * 1.1, 20, 20); if (!isForShades) { GL.glColor3f(0, 0, 1f); } else { GL.glColor3f(0.2f, 0.2f, 0.2f); } GLU.gluCylinder(obj, 0.3, 0.3, 1.7, 50, 3); GL.glPopMatrix(); GL.glPushMatrix(); //left_LEG GL.glTranslated(0, -0.7, 4.2); GL.glRotatef(right_upper_LEG_angle, 0, 1, 0); if (!isForShades) { GL.glColor3f(0.4f, 0.6f, 0f); } else { GL.glColor3f(0.2f, 0.2f, 0.2f); } GLU.gluSphere(obj, r * 1.5, 20, 20); if (!isForShades) { GL.glColor3f(0, 0, 1f); } else { GL.glColor3f(0.2f, 0.2f, 0.2f); } GLU.gluCylinder(obj, 0.3, 0.3, 1.7, 50, 3); GL.glTranslated(0, 0, 1.7); // right_lower_LEG GL.glRotatef(right_lower_LEG_angle, 0, 1, 0); if (!isForShades) { GL.glColor3f(0.4f, 0.6f, 0f); } else { GL.glColor3f(0.2f, 0.2f, 0.2f); } GLU.gluSphere(obj, r * 1.1, 20, 20); if (!isForShades) { GL.glColor3f(0, 0, 1f); } else { GL.glColor3f(0.2f, 0.2f, 0.2f); } GLU.gluCylinder(obj, 0.3, 0.3, 1.7, 50, 3); GL.glPopMatrix(); GL.glPushMatrix(); //right_LEG GL.glTranslated(0, 0.7, 4.2); GL.glRotatef(left_upper_LEG_angle, 0, 1, 0); if (!isForShades) { GL.glColor3f(0.4f, 0.6f, 0f); } else { GL.glColor3f(0.2f, 0.2f, 0.2f); } GLU.gluSphere(obj, r * 1.5, 20, 20); if (!isForShades) { GL.glColor3f(0, 0, 1f); } else { GL.glColor3f(0.2f, 0.2f, 0.2f); } GLU.gluCylinder(obj, 0.3, 0.3, 1.7, 50, 3); GL.glTranslated(0, 0, 1.7); //left_lower_LEG GL.glRotatef(left_lower_LEG_angle, 0, 1, 0); if (!isForShades) { GL.glColor3f(0.4f, 0.6f, 0f); } else { GL.glColor3f(0.2f, 0.2f, 0.2f); } GLU.gluSphere(obj, r * 1.1, 20, 20); if (!isForShades) { GL.glColor3f(0, 0, 1f); } else { GL.glColor3f(0.2f, 0.2f, 0.2f); } GLU.gluCylinder(obj, 0.3, 0.3, 1.7, 50, 3); GL.glPopMatrix(); GL.glPopMatrix(); }
void DrawFigures() { //!!!!!!!!!!!!! GL.glPushMatrix(); //!!!!!!!!!!!!! GL.glEnable(GL.GL_TEXTURE_2D); //plane grids if (!rotate) { GL.glPushMatrix(); drawground(); GL.glDisable(GL.GL_TEXTURE_2D); GL.glDisable(GL.GL_LIGHTING); GL.glEnable(GL.GL_COLOR); GL.glTranslatef(pos[0], pos[1], 10); GL.glColor3f(1, 1, 0); GLU.gluSphere(obj, 1, 16, 16); GL.glTranslatef(-pos[0], -pos[1], -10); GL.glEnd(); GL.glEnable(GL.GL_TEXTURE_2D); GL.glPopMatrix(); } else { GL.glPushMatrix(); angleG -= 0.2f; GL.glRotatef(angleG, 0, 0, 0.1f); drawground(); GL.glDisable(GL.GL_TEXTURE_2D); GL.glDisable(GL.GL_LIGHTING); GL.glEnable(GL.GL_COLOR); GL.glTranslatef(pos[0], pos[1], 10); GL.glColor3f(1, 1, 0); GL.glRotatef(angleG, 0, 2, 0); GLU.gluSphere(obj, 1, 16, 16); GL.glTranslatef(-pos[0], -pos[1], -10); GL.glEnd(); GL.glEnable(GL.GL_TEXTURE_2D); GL.glPopMatrix(); } DrawObjects(false, 1); //end of regular showFfron //!!!!!!!!!!!!! GL.glPopMatrix(); //!!!!!!!!!!!!! //SHADING begin //we'll define cubeXform matrix in MakeShadowMatrix Sub // Disable lighting, we'll just draw the shadow //else instead of shadow we'll see stange projection of the same objects GL.glDisable(GL.GL_LIGHTING); // floor shadow //!!!!!!!!!!!!! GL.glPushMatrix(); //!!!!!!!!!!!! MakeShadowMatrix(ground); GL.glMultMatrixf(cubeXform); DrawObjects(true, 1); //!!!!!!!!!!!!! GL.glPopMatrix(); }
public void Draw() { GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_STENCIL_BUFFER_BIT); GL.glMatrixMode(GL.GL_MODELVIEW); GL.glLoadIdentity(); GL.glTranslatef(0.0f, -1.5f, -6.0f); GL.glRotatef(10, 1.0f, 0.0f, 0.0f); GL.glRotatef(-tank.rotation, 0.0f, 1.0f, 0.0f); GL.glRotatef(-tank.turretRotation, 0.0f, 1.0f, 0.0f); GL.glTranslatef(-tank.posX, 0.0f, -tank.posZ); //DrawAxes(); DrawAll(); //target target.Drawself(); //LIGHT - before transforms // hence it is in const position GL.glPushMatrix(); GL.glEnable(GL.GL_LIGHTING); GL.glEnable(GL.GL_LIGHT0); GL.glTranslatef(0, 11, -35); float[] ambient = { 0, 0, 0.3f, 1 }; if (tank.TankType == 2) { ambient[2] = 0.2f; } else { ambient[0] = 0.2f; } float[] diffuse = { 1, 1, 1, 1 }; float[] specular = { 0.5f, 0.5f, 0.5f, 1f }; float[] pos = { 0, 1f, -0.5f, 0 }; GL.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, ambient); GL.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, diffuse); GL.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, specular); GL.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, pos); GL.glColor3f(1, 1, 0); GL.glDisable(GL.GL_LIGHTING); GLU.gluSphere(obj, 1, 12, 12); //SUN GL.glEnable(GL.GL_LIGHTING); GL.glPopMatrix(); if (!stelthmode) { GL.glEnable(GL.GL_BLEND); GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); GL.glEnable(GL.GL_STENCIL_TEST); GL.glStencilOp(GL.GL_REPLACE, GL.GL_REPLACE, GL.GL_REPLACE); GL.glStencilFunc(GL.GL_ALWAYS, 1, 0xFFFFFFFF); // draw floor always GL.glColorMask((byte)GL.GL_FALSE, (byte)GL.GL_FALSE, (byte)GL.GL_FALSE, (byte)GL.GL_FALSE); GL.glDisable(GL.GL_DEPTH_TEST); DrawMirror(false); // restore regular settings GL.glColorMask((byte)GL.GL_TRUE, (byte)GL.GL_TRUE, (byte)GL.GL_TRUE, (byte)GL.GL_TRUE); GL.glEnable(GL.GL_DEPTH_TEST); // reflection is drawn only where STENCIL buffer value equal to 1 GL.glStencilFunc(GL.GL_EQUAL, 1, 0xFFFFFFFF); GL.glStencilOp(GL.GL_KEEP, GL.GL_KEEP, GL.GL_KEEP); GL.glEnable(GL.GL_STENCIL_TEST); // draw reflected scene GL.glPushMatrix(); GL.glScalef(-1, 1, 1); //swap on Z axis GL.glEnable(GL.GL_CULL_FACE); GL.glCullFace(GL.GL_BACK); tank.drawSelf(); DrawBullets(); GL.glCullFace(GL.GL_FRONT); tank.drawSelf(); DrawBullets(); GL.glDisable(GL.GL_CULL_FACE); GL.glPopMatrix(); GL.glDepthMask((byte)GL.GL_FALSE); DrawMirror(false); GL.glDepthMask((byte)GL.GL_TRUE); // Disable GL.GL_STENCIL_TEST to show All, else it will be cut on GL.GL_STENCIL GL.glDisable(GL.GL_STENCIL_TEST); } else { GL.glEnable(GL.GL_BLEND); GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); GL.glEnable(GL.GL_STENCIL_TEST); GL.glStencilOp(GL.GL_REPLACE, GL.GL_REPLACE, GL.GL_REPLACE); GL.glStencilFunc(GL.GL_ALWAYS, 1, 0xFFFFFFFF); // draw floor always GL.glColorMask((byte)GL.GL_FALSE, (byte)GL.GL_FALSE, (byte)GL.GL_FALSE, (byte)GL.GL_FALSE); GL.glDisable(GL.GL_DEPTH_TEST); DrawMirror(false); // restore regular settings GL.glColorMask((byte)GL.GL_TRUE, (byte)GL.GL_TRUE, (byte)GL.GL_TRUE, (byte)GL.GL_TRUE); GL.glEnable(GL.GL_DEPTH_TEST); // reflection is drawn only where STENCIL buffer value equal to 1 GL.glStencilFunc(GL.GL_EQUAL, 1, 0xFFFFFFFF); GL.glStencilOp(GL.GL_KEEP, GL.GL_KEEP, GL.GL_KEEP); GL.glEnable(GL.GL_STENCIL_TEST); // draw reflected scene GL.glPushMatrix(); GL.glScalef(-1, 1, 1); //swap on Z axis GL.glEnable(GL.GL_CULL_FACE); GL.glCullFace(GL.GL_BACK); DrawBullets(); GL.glCullFace(GL.GL_FRONT); DrawBullets(); GL.glDisable(GL.GL_CULL_FACE); GL.glPopMatrix(); GL.glDepthMask((byte)GL.GL_FALSE); DrawMirror(false); GL.glDepthMask((byte)GL.GL_TRUE); // Disable GL.GL_STENCIL_TEST to show All, else it will be cut on GL.GL_STENCIL GL.glDisable(GL.GL_STENCIL_TEST); } if (!stelthmode) { tank.drawSelf(); } else { tank.drawstelth(); } DrawMirror(true); DrawBullets(); //REFLECTION e update(); WGL.wglSwapBuffers(m_uint_DC); }