public void createStemAndLeafs() { GL.glNewList(STEM_AND_LEAVS_LIST + currentTree, GL.GL_COMPILE); GL.glPushMatrix(); GL.glPushAttrib(GL.GL_LIGHTING_BIT); GL.glCallList(STEM_LIST + currentTree); GL.glCallList(LEAF_MAT); for (int i = 0; i < 3; i++) { GL.glTranslatef(0, (float)1 / 3, 0); GL.glRotatef(90, 0, 1, 0); GL.glPushMatrix(); GL.glRotatef(50, 1, 0, 0); GL.glCallList(LEAF_LIST + currentTree); GL.glPopMatrix(); GL.glPushMatrix(); GL.glRotatef(180, 0, 1, 0); GL.glRotatef(60, 1, 0, 0); GL.glCallList(LEAF_LIST + currentTree); GL.glPopMatrix(); } GL.glPopAttrib(); GL.glPopMatrix(); GL.glEndList(); }
public void DrawShadow() { GL.glPushMatrix(); GL.glNewList(Robot_SHADOW_LIST, GL.GL_COMPILE); //build the Robot GL.glTranslatef(0, Jump, 0); GL.glTranslatef(0, 1.3f, 0); // build Robot head GL.glCallList(HEAD_SHADOW_LIST); GL.glTranslatef(0, -1.3f, 0); // build Robot body GL.glCallList(BODY_SHADOW_LIST); //build Robot hands DrawShadowHand(false); //left hand GL.glRotatef(180, 0, 1, 0); if (WeaponIndex == 1 || WeaponIndex == 2) { GL.glScalef(-1, 1, 1); } DrawShadowHand(true); //right hand //build Robot legs GL.glRotatef(90, 1, 0, 0); GL.glTranslatef(0, 0, 1.9f); GL.glTranslatef(0, 0.3f, 0); DrawShadowLeg(false); //left leg GL.glTranslatef(0, -0.6f, 0); DrawShadowLeg(true); //right leg GL.glEndList(); GL.glPopMatrix(); }
public override void DrawToy(double[] translateCoords, double[] rotateCoords, bool isShadow) { GL.glTranslated(translateCoords[0], translateCoords[1], translateCoords[2]); if (!isShadow) { GL.glColor3d(1, 1, 1); } else { GL.glDisable(GL.GL_TEXTURE_2D); } GL.glRotated(rotateCoords[0], rotateCoords[1], rotateCoords[2], rotateCoords[3]); if (isShadow) { GL.glCallList(SHADOW_LIST); } else { GL.glCallList(LIST); } GL.glRotated(-rotateCoords[0], rotateCoords[1], rotateCoords[2], rotateCoords[3]); GL.glTranslated(-translateCoords[0], -translateCoords[1], -translateCoords[2]); GL.glDisable(GL.GL_TEXTURE_2D); }
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(); }
void DrawFigures() { GL.glEnable(GL.GL_COLOR_MATERIAL); GL.glEnable(GL.GL_LIGHT0); GL.glEnable(GL.GL_LIGHTING); //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! GL.glRotatef(ROBOT_angle, 0, 0, 1); GL.glCallList(ROBOT_LIST); //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // saw GL.glLineStipple(1, 0x1243); GL.glLineWidth(3); GL.glEnable(GL.GL_LINE_STIPPLE); GL.glColor3f(1, 1, 0); //yellow GL.glBegin(GL.GL_LINES); float angle; for (int i = 0; i <= 9; i++) { angle = alpha + i * 6.283f / 10; GL.glVertex3d(0.5f * r * Math.Cos(angle), 0.5f * r * Math.Sin(angle), 0.01f); GL.glVertex3d(1.5f * r * Math.Cos(angle + 0.6), 1.5f * r * Math.Sin(angle + 0.6), 0.01f); } GL.glEnd(); GL.glLineWidth(1); GL.glDisable(GL.GL_LINE_STIPPLE); }
public void CreateFloorList() { GL.glPushMatrix(); GL.glNewList(floorMainList, GL.GL_COMPILE); GL.glCallList(floorStartPosition); GL.glCallList(floorList); GL.glEndList(); GL.glPopMatrix(); }
void CreateTree() { GL.glNewList(TREE_LIST + currentTree, GL.GL_COMPILE); GL.glPushMatrix(); GL.glPushAttrib(GL.GL_LIGHTING_BIT); GL.glCallList(TREE_MAT); GL.glScaled(amplitude, amplitude, amplitude); FractalTreeRec(0); GL.glPopAttrib(); GL.glPopMatrix(); GL.glEndList(); }
void FractalTreeRec(int level) { if (level == size) { GL.glPushMatrix(); GL.glRotated(rand.NextDouble() * 180, 0, 1, 0); GL.glCallList(STEM_AND_LEAVS_LIST + currentTree); for (int i = applesRate; i > 0; i--) { if (rand.Next(1, 3) == 1) { GL.glPushMatrix(); GL.glTranslatef(0, (float)1 / i, 0); GL.glCallList(APPLE_MAT); GL.glCallList(APPLE_LIST); GL.glCallList(TREE_MAT); GL.glPopMatrix(); } } GL.glPopMatrix(); } else { GL.glCallList(STEM_LIST + currentTree); GL.glPushMatrix(); GL.glRotated(rand.NextDouble() * 180, 0, 1, 0); GL.glTranslatef(0, 1 + size / 10, 0); GL.glScalef(0.7f, 0.7f, 0.7f); GL.glPushMatrix(); GL.glRotated(110 + rand.NextDouble() * 40, 0, 1, 0); GL.glRotated(30 + rand.NextDouble() * 20, 0, 0, 1); FractalTreeRec(level + 1); GL.glPopMatrix(); GL.glPushMatrix(); GL.glRotated(-130 + rand.NextDouble() * 40, 0, 1, 0); GL.glRotated(30 + rand.NextDouble() * 20, 0, 0, 1); FractalTreeRec(level + 1); GL.glPopMatrix(); GL.glPushMatrix(); GL.glRotated(-20 + rand.NextDouble() * 40, 0, 1, 0); GL.glRotated(30 + rand.NextDouble() * 20, 0, 0, 1); FractalTreeRec(level + 1); GL.glPopMatrix(); GL.glPopMatrix(); } }
public void Draw(bool isForShades) { GL.glPushMatrix(); GL.glScalef(-1, 1, 1); GL.glRotatef(-90, 0, 1, 0); GL.glTranslatef(7, 0, 0); GL.glTranslatef(0, 0, (Drive % 46) - 23); if (!isForShades) { GL.glEnable(GL.GL_LIGHTING); GL.glCallList(CAR); } else { GL.glDisable(GL.GL_LIGHTING); GL.glCallList(CAR_SHADOW); } GL.glPopMatrix(); }
void drawLake() { GL.glEnable(GL.GL_LIGHTING); GL.glCallList(WATER_MAT); GL.glPushMatrix(); if (ScrollValue[16] >= 0) { GL.glScaled(1, 1, 1 + ScrollValue[16]); } else { GL.glScaled(1 + ScrollValue[16], 1, 1); } GL.glTranslated(ScrollValue[12], 0, ScrollValue[13]); GL.glRotated(90, 1, 0, 0); GLU.gluDisk(obj, 0, ScrollValue[14], 30, 30); GL.glPopMatrix(); GL.glDisable(GL.GL_LIGHTING); }
void DrawFigures() { GL.glPushMatrix(); GL.glEnable(GL.GL_COLOR_MATERIAL); DrawLightSource(); GL.glCallList(handList); GL.glEnd(); GL.glPopMatrix(); GL.glPushMatrix(); if (enableLightSource) { MakeShadowMatrix(ground); } GL.glMultMatrixf(cubeXform); GL.glPopMatrix(); }
public override void DrawToy(double[] translateCoords, double[] rotateCoords, bool isShadow) { float[] material = new float[3]; material[0] = 0.0215f; material[1] = 0.1745f; material[2] = 0.0215f; GL.glMaterialfv(GL.GL_FRONT, GL.GL_AMBIENT, material); material[0] = 0.07568f; material[1] = 0.61424f; material[2] = 0.07568f; GL.glMaterialfv(GL.GL_FRONT, GL.GL_DIFFUSE, material); material[0] = 0.633f; material[1] = 0.727811f; material[2] = 0.633f; GL.glMaterialfv(GL.GL_FRONT, GL.GL_SPECULAR, material); GL.glMaterialf(GL.GL_FRONT, GL.GL_SHININESS, 5f); GL.glTranslated(translateCoords[0], translateCoords[1], translateCoords[2]); if (!isShadow) { GL.glColor3d(1, 1, 1); } else { GL.glDisable(GL.GL_TEXTURE_2D); } GL.glRotated(rotateCoords[0], rotateCoords[1], rotateCoords[2], rotateCoords[3]); GL.glScaled(10, 10, 10); if (isShadow) { GL.glCallList(SHADOW_LIST); } else { GL.glCallList(LIST); } GL.glScaled(0.1, 0.1, 0.1); GL.glRotated(-rotateCoords[0], rotateCoords[1], rotateCoords[2], rotateCoords[3]); GL.glTranslated(-translateCoords[0], -translateCoords[1], -translateCoords[2]); GL.glDisable(GL.GL_TEXTURE_2D); }
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 Draw(bool isForShades) { GL.glPushMatrix(); GL.glTranslatef(0, -7, 0); //adapt Robot size to models GL.glScalef(0.5f, 0.5f, 0.5f); GL.glTranslatef(0, Jump * 1.3f, 0); GL.glRotatef(Angle, 0, 0, 1); GL.glRotatef(AngleCrash / 4, 0, 0, 1); GL.glRotatef(AngleCrash, 1, 0, 0); GL.glRotatef(-AngleCrash * 2, 0, 1, 0); GL.glRotatef(AngleWeapon3, 0, 1, 0); GL.glTranslatef(0, -Jump * 1.3f, 0); //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! GL.glTranslatef(0, 3.7f, 0); if (!isForShades) { GL.glEnable(GL.GL_LIGHTING); GL.glColor3f(0.5f, 0.5f, 0.9f); GL.glCallList(Robot_LIST); } else { GL.glDisable(GL.GL_LIGHTING); GL.glColor3f(0, 0, 0); GL.glCallList(Robot_SHADOW_LIST); } GL.glPopMatrix(); }
void DrawFigures() { skyBox.DrawSkyBox(); MainLightSource.DrawLightSource(new float[] { 1, 1, 0 }); StaticRedLightSource.DrawLightSource(new float[] { 1, 0, 0 }); StaticBlueLightSource.DrawLightSource(new float[] { 0, 0, 1 }); //Banner Light source GL.glTranslatef(bannerLightPos[0], bannerLightPos[1], bannerLightPos[2]); Random r = new Random(); GL.glColor3d(r.NextDouble(), r.NextDouble(), r.NextDouble()); GLUT.glutSolidSphere(0.1, 8, 8); GL.glTranslatef(-bannerLightPos[0], -bannerLightPos[1], -bannerLightPos[2]); GL.glEnd(); GL.glDisable(GL.GL_DEPTH_TEST); GL.glDisable(GL.GL_LIGHTING); // Start Drawing Floor Shadow GL.glPushMatrix(); GL.glEnable(GL.GL_BLEND); GL.glColor4d(0, 0, 0, 0.25); mainShadowManager.MakeShadowMatrix(mainShadowManager.Ground, cubeXform); GL.glMultMatrixf(cubeXform); m_SideMachine.DrawSideMachines(new double[3] { 0, -0.4, 6 }, true); m_SideMachine.DrawSideMachines(new double[3] { 0, -0.4, -6 }, true); GL.glCallList(SHADOW_LIST); //GL.glColor4d(0.05, 0, 0, 0.25); //redShadowManager.MakeShadowMatrix(redShadowManager.Ground, cubeXform); //GL.glMultMatrixf(cubeXform); //m_SideMachine.DrawSideMachines(new double[3] { 0, -0.4, 6 }, true); //m_SideMachine.DrawSideMachines(new double[3] { 0, -0.4, -6 }, true); //GL.glCallList(SHADOW_LIST); //GL.glColor4d(0, 0, 0.05, 0.25); //blueShadowManager.MakeShadowMatrix(blueShadowManager.Ground, cubeXform); //GL.glMultMatrixf(cubeXform); //m_SideMachine.DrawSideMachines(new double[3] { 0, -0.4, 6 }, true); //m_SideMachine.DrawSideMachines(new double[3] { 0, -0.4, -6 }, true); //GL.glCallList(SHADOW_LIST); GL.glDisable(GL.GL_BLEND); GL.glPopMatrix(); //for (int i = 0; i < 4; i++) //{ // GL.glPushMatrix(); // shadowManager.MakeShadowMatrix(shadowManager.Walls[i], cubeXform); // GL.glMultMatrixf(cubeXform); // m_SideMachine.DrawSideMachines(new double[3] { 0, -0.4, 6 }, true); // m_SideMachine.DrawSideMachines(new double[3] { 0, -0.4, -6 }, true); // GL.glCallList(SHADOW_LIST); // GL.glPopMatrix(); //} //End Drawing Floor Shadow GL.glEnable(GL.GL_DEPTH_TEST); GL.glEnable(GL.GL_COLOR_MATERIAL); GL.glEnable(GL.GL_LIGHT0); GL.glEnable(GL.GL_LIGHT1); GL.glEnable(GL.GL_LIGHT2); GL.glEnable(GL.GL_LIGHT3); GL.glEnable(GL.GL_LIGHTING); GL.glPushMatrix(); m_SideMachine.DrawSideMachines(new double[3] { 0, -0.4, 6 }, false); m_SideMachine.DrawSideMachines(new double[3] { 0, -0.4, -6 }, false); //toyCar.DrawToy(new double[3] { 1.4, 0.3, 0 }, new double[4] { 40, 0, 1, 0 }, false); GL.glCallList(CLAW_MACHINE_LIST); GL.glPopMatrix(); GL.glDisable(GL.GL_COLOR_MATERIAL); GL.glDisable(GL.GL_LIGHTING); //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! }
/********************************************************************************************************** * * * * MAIN DRAW FUNCTION * * * **********************************************************************************************************/ public void Draw() { if (m_uint_DC == 0 || m_uint_RC == 0) { return; } GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_STENCIL_BUFFER_BIT); GL.glViewport(0, 0, Width, Height); GL.glLoadIdentity(); GLU.gluLookAt(ScrollValue[0], ScrollValue[1], ScrollValue[2], ScrollValue[3], ScrollValue[4], ScrollValue[5], ScrollValue[6], ScrollValue[7], ScrollValue[8]); GL.glRotatef(xAngle, 1.0f, 0.0f, 0.0f); GL.glRotatef(yAngle, 0.0f, 1.0f, 0.0f); GL.glRotatef(zAngle, 0.0f, 0.0f, 1.0f); GL.glTranslatef(xShift, yShift, zShift); pos[0] = light_position[0] = ScrollValue[9]; pos[1] = light_position[1] = ScrollValue[10]; pos[2] = light_position[2] = ScrollValue[11]; pos[3] = light_position[3] = 0; GL.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, light_ambient); GL.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, light_diffuse); GL.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, light_specular); GL.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, light_position); GL.glLightModelfv(GL.GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); GL.glEnable(GL.GL_LIGHT0); /* * * Reflection * */ GL.glEnable(GL.GL_BLEND); GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); if (reflectionOn) { //draw only to STENCIL buffer GL.glEnable(GL.GL_STENCIL_TEST); GL.glStencilOp(GL.GL_REPLACE, GL.GL_REPLACE, GL.GL_REPLACE); GL.glStencilFunc(GL.GL_ALWAYS, 1, 0xFFFFFFFF); GL.glColorMask((byte)GL.GL_FALSE, (byte)GL.GL_FALSE, (byte)GL.GL_FALSE, (byte)GL.GL_FALSE); GL.glDisable(GL.GL_DEPTH_TEST); drawLake(); // 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); /* * * draw reflected scene * */ GL.glEnable(GL.GL_LIGHTING); for (currentTree = 0; currentTree < numOfTrees; currentTree++) { GL.glPushMatrix(); //GL.glTranslated(randX[currentTree], 0,randZ[currentTree]); GL.glTranslated(locationX[currentTree], 0, locationZ[currentTree]); GL.glRotated(locationRotateY[currentTree], 0, 1, 0); GL.glScalef(1, -1, 1); //swap on Z axis if (scullFaceOn) { GL.glEnable(GL.GL_CULL_FACE); GL.glCullFace(GL.GL_BACK); GL.glCallList(TREE_LIST + currentTree); GL.glCullFace(GL.GL_FRONT); GL.glCallList(TREE_LIST + currentTree); GL.glDisable(GL.GL_CULL_FACE); } else { GL.glCallList(TREE_LIST + currentTree); } GL.glPopMatrix(); } drawLake(); GL.glStencilFunc(GL.GL_NOTEQUAL, 1, 0xFFFFFFFF); GL.glStencilOp(GL.GL_KEEP, GL.GL_KEEP, GL.GL_KEEP); // really draw floor //( half-transparent ( see its color's alpha byte))) // in order to see reflected objects //GL.glDepthMask((byte)GL.GL_FALSE); GL.glDepthMask((byte)GL.GL_TRUE); if (!textureOn) { drawFloor(); } else { drawFloorTextured(); DrawTexturedCube(); } GL.glDisable(GL.GL_LIGHTING); GL.glDisable(GL.GL_STENCIL_TEST); } else { GL.glEnable(GL.GL_LIGHTING); drawLake(); if (!textureOn) { drawFloor(); } else { drawFloorTextured(); DrawTexturedCube(); } GL.glDisable(GL.GL_LIGHTING); } DrawLight(); /* * Draw trees */ GL.glEnable(GL.GL_LIGHTING); GL.glPushMatrix(); for (currentTree = 0; currentTree < numOfTrees; currentTree++) { GL.glPushMatrix(); //GL.glTranslated(randX[currentTree], 0, randZ[currentTree]); GL.glTranslated(locationX[currentTree], 0, locationZ[currentTree]); GL.glRotated(locationRotateY[currentTree], 0, 1, 0); GL.glCallList(TREE_LIST + currentTree); GL.glPopMatrix(); } GL.glPopMatrix(); /* * Draw trees shadows */ GL.glDisable(GL.GL_LIGHTING); GL.glColor3d(0, 0, 0); if (shadowOn) { GL.glPushMatrix(); MakeShadowMatrix(ground); GL.glMultMatrixf(cubeXform); for (currentTree = 0; currentTree < numOfTrees; currentTree++) { GL.glPushMatrix(); //GL.glTranslated(randX[currentTree], 0, randZ[currentTree]); GL.glTranslated(locationX[currentTree], 0, locationZ[currentTree]); GL.glRotated(locationRotateY[currentTree], 0, 1, 0); GL.glCallList(TREE_LIST + currentTree); GL.glPopMatrix(); } GL.glPopMatrix(); } GL.glFlush(); WGL.wglSwapBuffers(m_uint_DC); }
public void CreateHandList() { GL.glPushMatrix(); GL.glNewList(handList, GL.GL_COMPILE); switch (movingPart) { case 0: GL.glCallList(handBaseList); CallFingerList(1); CallFingerList(2); CallFingerList(3); CallFingerList(4); CallFingerList(5); break; case 1: //Index finger move implementation GL.glCallList(handBaseList); CallFingerList(2); CallFingerList(3); CallFingerList(4); CallFingerList(5); GL.glCallList(indexFingerStart); GL.glRotatef(indexFingerAngle[0], 1, 0, 0); GL.glCallList(indexPhalanxList1); GL.glRotatef(indexFingerAngle[1], 1, 0, 0); GL.glCallList(indexPhalanxList2); GL.glRotatef(indexFingerAngle[2], 1, 0, 0); GL.glCallList(indexPhalanxList3); break; case 2: //Middle finger move implementation GL.glCallList(handBaseList); CallFingerList(1); CallFingerList(3); CallFingerList(4); CallFingerList(5); GL.glCallList(middleFingerStart); GL.glRotatef(middleFingerAngle[0], 1, 0, 0); GL.glCallList(middlePhalanxList1); GL.glRotatef(middleFingerAngle[1], 1, 0, 0); GL.glCallList(middlePhalanxList2); GL.glRotatef(middleFingerAngle[2], 1, 0, 0); GL.glCallList(middlePhalanxList3); break; case 3: //Ring finger move implementation GL.glCallList(handBaseList); CallFingerList(1); CallFingerList(2); CallFingerList(4); CallFingerList(5); GL.glCallList(ringFingerStart); GL.glRotatef(ringFingerAngle[0], 1, 0, 0); GL.glCallList(ringPhalanxList1); GL.glRotatef(ringFingerAngle[1], 1, 0, 0); GL.glCallList(ringPhalanxList2); GL.glRotatef(ringFingerAngle[2], 1, 0, 0); GL.glCallList(ringPhalanxList3); break; case 4: //Pinky finger move implementation GL.glCallList(handBaseList); CallFingerList(1); CallFingerList(2); CallFingerList(3); CallFingerList(5); GL.glCallList(pinkyFingerStart); GL.glRotatef(pinkyFingerAngle[0], 1, 0, 0); GL.glCallList(pinkyPhalanxList1); GL.glRotatef(pinkyFingerAngle[1], 1, 0, 0); GL.glCallList(pinkyPhalanxList2); GL.glRotatef(pinkyFingerAngle[2], 1, 0, 0); GL.glCallList(pinkyPhalanxList3); break; case 5: //Thumb finger move implementation GL.glCallList(handBaseList); CallFingerList(1); CallFingerList(2); CallFingerList(3); CallFingerList(4); GL.glCallList(thumbFingerStart); GL.glRotated(-45, 0, 0, 1); GL.glRotatef(thumbFingerAngle[0], 1, 0, 0); GL.glRotated(45, 0, 0, 1); GL.glCallList(thumbPhalanxList1); GL.glRotated(-45, 0, 0, 1); GL.glRotatef(thumbFingerAngle[1], 1, 0, 0); GL.glRotated(45, 0, 0, 1); GL.glCallList(thumbPhalanxList2); break; } GL.glEndList(); 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(); }
public void Draw() { float delta = 0; double[] ModelViewMatrixBeforeTransforms = new double[16]; double[] CurrentTraslation = new double[16]; if (m_uint_DC == 0 || m_uint_RC == 0) { return; } GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_STENCIL_BUFFER_BIT); GL.glLoadIdentity(); if (enableLookAtValue) { GLU.gluLookAt(LookAtNumberValue[0], LookAtNumberValue[1], LookAtNumberValue[2], LookAtNumberValue[3], LookAtNumberValue[4], LookAtNumberValue[5], LookAtNumberValue[6], LookAtNumberValue[7], LookAtNumberValue[8]); } GL.glTranslatef(0.0f, 0.0f, -20.0f); if (enableRotate) { GL.glRotatef(viewAngle, 0.0f, 1.0f, 0.0f); viewAngle -= 2f; } DrawRoom(); DrawOldAxes(); DrawLightSource(); GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, ModelViewMatrixBeforeTransforms); GL.glLoadIdentity(); if (coordSysMoveDirection != 0) { delta = 5.0f * Math.Abs(coordSysMoveDirection) / coordSysMoveDirection; switch (Math.Abs(coordSysMoveDirection)) { case 1: GL.glTranslatef(delta / 20, 0, 0); break; case 2: GL.glTranslatef(0, delta / 20, 0); break; case 3: GL.glTranslatef(0, 0, delta / 20); break; case 4: GL.glRotatef(delta, 1, 0, 0); break; case 5: GL.glRotatef(delta, 0, 1, 0); break; case 6: GL.glRotatef(delta, 0, 0, 1); break; } } GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, CurrentTraslation); GL.glLoadMatrixd(AccumulatedTraslations); GL.glMultMatrixd(CurrentTraslation); GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, AccumulatedTraslations); GL.glLoadMatrixd(ModelViewMatrixBeforeTransforms); GL.glMultMatrixd(AccumulatedTraslations); DrawAxes(); GL.glCallList(handList); if (enableReflection) { 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); GL.glColorMask((byte)GL.GL_FALSE, (byte)GL.GL_FALSE, (byte)GL.GL_FALSE, (byte)GL.GL_FALSE); GL.glDisable(GL.GL_DEPTH_TEST); //DrawFloor(); GL.glCallList(floorMainList); GL.glColorMask((byte)GL.GL_TRUE, (byte)GL.GL_TRUE, (byte)GL.GL_TRUE, (byte)GL.GL_TRUE); GL.glEnable(GL.GL_DEPTH_TEST); GL.glStencilFunc(GL.GL_EQUAL, 1, 0xFFFFFFFF); GL.glStencilOp(GL.GL_KEEP, GL.GL_KEEP, GL.GL_KEEP); GL.glEnable(GL.GL_STENCIL_TEST); GL.glPushMatrix(); GL.glScalef(1, -1, 1); GL.glEnable(GL.GL_CULL_FACE); GL.glCullFace(GL.GL_BACK); GL.glTranslated(0, 3, 0); DrawFigures(); GL.glCullFace(GL.GL_FRONT); DrawFigures(); GL.glDisable(GL.GL_CULL_FACE); GL.glPopMatrix(); GL.glDepthMask((byte)GL.GL_FALSE); //DrawFloor(); GL.glCallList(floorMainList); GL.glDepthMask((byte)GL.GL_TRUE); GL.glDisable(GL.GL_STENCIL_TEST); } GL.glFlush(); WGL.wglSwapBuffers(m_uint_DC); }
protected void CallFingerList(int fingerIndex) { switch (fingerIndex) { case 1: GL.glPushMatrix(); GL.glCallList(indexFingerStart); GL.glRotatef(indexFingerAngle[0], 1, 0, 0); GL.glCallList(indexPhalanxList1); GL.glRotatef(indexFingerAngle[1], 1, 0, 0); GL.glCallList(indexPhalanxList2); GL.glRotatef(indexFingerAngle[2], 1, 0, 0); GL.glCallList(indexPhalanxList3); GL.glPopMatrix(); break; case 2: GL.glPushMatrix(); GL.glCallList(middleFingerStart); GL.glRotatef(middleFingerAngle[0], 1, 0, 0); GL.glCallList(middlePhalanxList1); GL.glRotatef(middleFingerAngle[1], 1, 0, 0); GL.glCallList(middlePhalanxList2); GL.glRotatef(middleFingerAngle[2], 1, 0, 0); GL.glCallList(middlePhalanxList3); GL.glPopMatrix(); break; case 3: GL.glPushMatrix(); GL.glCallList(ringFingerStart); GL.glRotatef(ringFingerAngle[0], 1, 0, 0); GL.glCallList(ringPhalanxList1); GL.glRotatef(ringFingerAngle[1], 1, 0, 0); GL.glCallList(ringPhalanxList2); GL.glRotatef(ringFingerAngle[2], 1, 0, 0); GL.glCallList(ringPhalanxList3); GL.glPopMatrix(); break; case 4: GL.glPushMatrix(); GL.glCallList(pinkyFingerStart); GL.glRotatef(pinkyFingerAngle[0], 1, 0, 0); GL.glCallList(pinkyPhalanxList1); GL.glRotatef(pinkyFingerAngle[1], 1, 0, 0); GL.glCallList(pinkyPhalanxList2); GL.glRotatef(pinkyFingerAngle[2], 1, 0, 0); GL.glCallList(pinkyPhalanxList3); GL.glPopMatrix(); break; case 5: GL.glPushMatrix(); GL.glCallList(thumbFingerStart); GL.glRotated(-45, 0, 0, 1); GL.glRotatef(thumbFingerAngle[0], 1, 0, 0); GL.glRotated(45, 0, 0, 1); GL.glCallList(thumbPhalanxList1); GL.glRotated(-45, 0, 0, 1); GL.glRotatef(thumbFingerAngle[1], 1, 0, 0); GL.glRotated(45, 0, 0, 1); GL.glCallList(thumbPhalanxList2); GL.glPopMatrix(); break; } }