glRotatef() private method

private glRotatef ( float angle, float x, float y, float z ) : void
angle float
x float
y float
z float
return void
Beispiel #1
0
 public void Rotate(float angle, float x, float y, float z)
 {
     if (!isMatrixPushed)
     {
         GL.glPushMatrix();
         isMatrixPushed = true;
     }
     GL.glRotatef(angle, x, y, z);
 }
Beispiel #2
0
 /// <summary>
 /// Rotate camera in local(camera) space
 /// </summary>
 public void rotateLocal(float deg, float x, float y, float z)
 {
     GL.glMatrixMode(GL.GL_MODELVIEW);
     GL.glPushMatrix();
     GL.glLoadMatrixf(maf_matrix);
     GL.glRotatef(deg, x, y, z);
     GL.glGetFloatv(GL.GL_MODELVIEW_MATRIX, maf_matrix);
     GL.glPopMatrix();
 }
Beispiel #3
0
 public void createStemList()
 {
     GL.glNewList(STEM_LIST + currentTree, GL.GL_COMPILE);
     GL.glPushMatrix();
     GL.glRotatef(-90, 1, 0, 0);
     GLU.gluCylinder(obj, 0.1 * widhtScale, 0.08 * widhtScale, 1, 10, 10);
     GL.glPopMatrix();
     GL.glEndList();
 }
Beispiel #4
0
 void CreateApple()
 {
     GL.glColor3d(1, 0, 0);
     GL.glNewList(APPLE_LIST, GL.GL_COMPILE);
     GL.glPushMatrix();
     GL.glRotatef(-90, 1, 0, 0);
     GLUT.glutSolidTorus(0.2, 0.1, 10, 10);
     GL.glPopMatrix();
     GL.glEndList();
 }
Beispiel #5
0
        private void drawHandle(float i_Height)
        {
            GLUquadric obj = GLU.gluNewQuadric();

            GL.glTranslatef(0.5f, 0.0f + i_Height, 0.5f);
            GL.glRotatef(-90, 1, 0, 0);
            GLU.gluCylinder(obj, 0.1, 0.1, 0.5, 16, 16);
            GL.glTranslatef(-0.5f, -1 * i_Height, -0.5f);

            GLU.gluDeleteQuadric(obj);
        }
Beispiel #6
0
        /// <summary>
        /// Rotate camera in world space
        /// </summary>
        public void rotateGlobal(float deg, float x, float y, float z)
        {
            float dx = x * maf_matrix[0] + y * maf_matrix[1] + z * maf_matrix[2];
            float dy = x * maf_matrix[4] + y * maf_matrix[5] + z * maf_matrix[6];
            float dz = x * maf_matrix[8] + y * maf_matrix[9] + z * maf_matrix[10];

            GL.glMatrixMode(GL.GL_MODELVIEW);
            GL.glPushMatrix();
            GL.glLoadMatrixf(maf_matrix);
            GL.glRotatef(deg, dx, dy, dz);
            GL.glGetFloatv(GL.GL_MODELVIEW_MATRIX, maf_matrix);
            GL.glPopMatrix();
        }
Beispiel #7
0
        void drawStar(Star star, bool isForShade)
        {
            if (star.toDraw == true)
            {
                GL.glPushMatrix();



                GL.glTranslatef(0f, 0f, 1f);
                GL.glTranslatef(star.X + (float)xExisOrigin, star.Y + (float)yExisOrigin, 3 - Math.Abs(2f * (float)Math.Cos(ballZMovement)));
                GL.glRotatef(ballZtranslate, 0, 0, 1f);


                if (!isForShade)
                {
                    GL.glEnable(GL.GL_TEXTURE_2D);
                    GL.glColor3f(1.0f, 1.0f, 1.0f);
                    GL.glBindTexture(GL.GL_TEXTURE_2D, Textures[6]);
                    GL.glEnable(GL.GL_TEXTURE_GEN_S);

                    GL.glEnable(GL.GL_TEXTURE_GEN_T);
                    GL.glTexGeni(GL.GL_S, GL.GL_TEXTURE_GEN_MODE, (int)GL.GL_SPHERE_MAP);
                    GL.glTexGeni(GL.GL_T, GL.GL_TEXTURE_GEN_MODE, (int)GL.GL_SPHERE_MAP);
                }
                else
                {
                    GL.glColor3d(0.2, 0.2, 0.2);
                }
                for (int i = 0; i < 5; i++)
                {
                    GL.glRotatef(72, 1, 0, 0);
                    GL.glBegin(GL.GL_QUADS);

                    GL.glVertex3f(0f, 0f, 0);
                    GL.glVertex3f(0f, (float)Math.Sin(36), 1);
                    GL.glVertex3f(0f, 0, 3f);
                    GL.glVertex3f(0f, -(float)Math.Sin(36), 1);

                    GL.glEnd();
                }
                if (!isForShade)
                {
                    GL.glDisable(GL.GL_TEXTURE_GEN_S);
                    GL.glDisable(GL.GL_TEXTURE_GEN_T);
                    GL.glDisable(GL.GL_TEXTURE_2D);
                }
                GL.glPopMatrix();
            }
        }
Beispiel #8
0
        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();

            //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 };

            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.glPopMatrix();

            tank.drawSelf();

            DrawBullets();
            //REFLECTION e

            if (networkconnected)
            {
                enemytank.drawSelf();
            }

            update();
            WGL.wglSwapBuffers(m_uint_DC);
        }
        public void Drawlake()
        {
            float[] lake_ambuse = { 0.0117f, 0.4296f, 0.6562f, 0.3f };
            GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE, lake_ambuse);

            for (int ll = 0; ll < 6; ll++)
            {
                GL.glPushMatrix();

                GL.glTranslated(160 - (ll * 70), 0, 0);
                GL.glColor4f(0.0117f, 0.4296f, 0.6562f, 0.5f);
                GL.glRotatef(90, 1, 0, 0);
                GLU.gluDisk(obj, 0, lake_size, 30, 30);// size of lake

                GL.glPopMatrix();
            }
        }
Beispiel #10
0
        void RotateRobotByDirection()
        {
            switch (button)
            {
            case cOGL.arrow.backward:
                GL.glRotatef(180, 0, 1, 0);
                break;

            case cOGL.arrow.right:
                GL.glRotatef(-90, 0, 1, 0);
                break;

            case cOGL.arrow.left:
                GL.glRotatef(90, 0, 1, 0);
                break;
            }
        }
Beispiel #11
0
 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();
 }
Beispiel #12
0
        public void update_cube_map_rotations()
        {
            GL.glTranslatef(0.0f, 0.0f, -1.4f);

            GL.glRotatef(cubemapXYZAngles[0], 1.0f, 0.0f, 0.0f);
            GL.glRotatef(cubemapXYZAngles[1], 0.0f, 1.0f, 0.0f);
            GL.glRotatef(cubemapXYZAngles[2], 0.0f, 0.0f, 1.0f);

            GL.glDisable(GL.GL_LIGHTING);
            GL.glDisable(GL.GL_TEXTURE_2D);

            DrawBounds();

            GL.glColor4f(1.0f, 1.0f, 1.0f, 0.5f);
            GL.glEnable(GL.GL_TEXTURE_2D);
            DrawTexturedCube();
            GL.glColor4f(1.0f, 1.0f, 1.0f, 1);
            GL.glDisable(GL.GL_TEXTURE_2D);
        }
Beispiel #13
0
        private void gyroRotatingTransform()
        {
            // make the gyro turn around itself
            m_rotatingAngle += m_rotatingSpeed;
            GL.glTranslatef(CubeWidth / 2.0f, 0.0f, CubeDepth / 2.0f);
            GL.glRotatef(m_rotatingAngle, 0.0f, -1.0f, 0.0f);
            GL.glTranslatef(-CubeWidth / 2.0f, 0.0f, -CubeDepth / 2.0f);

            // the gyro loose power
            GL.glRotatef(m_fallingAngle, 1.0f, 0.0f, 0.0f);
            m_rotatingSpeed -= m_rotatingSlowFactor;
            m_fallingAngle  += m_fallingFactor;

            if (m_fallingAngle >= 45)
            {
                m_yAxisFellAngle = m_rotatingAngle % 360.0f;
                m_xAxisFellAngle = m_fallingAngle % 360.0f;
                m_gyroState      = eGyroState.Slowing;
            }
        }
Beispiel #14
0
        private void gyroSlowingTransform()
        {
            // calc slowing angle
            m_slowingAngle += m_slowingSpeed;

            // set the gyro last position with swinging angle
            GL.glTranslatef(CubeWidth / 2.0f, 0.0f, CubeDepth / 2.0f);
            GL.glRotatef(m_yAxisFellAngle + m_slowingAngle, 0.0f, -1.0f, 0.0f);
            GL.glTranslatef(-CubeWidth / 2.0f, 0.0f, -CubeDepth / 2.0f);
            GL.glRotatef(m_xAxisFellAngle, 1.0f, 0.0f, 0.0f);

            m_slowingSpeed -= m_slowingSlowFactor; // slow down is linear

            if (m_slowingSpeed < m_startStopingSpeed)
            {
                m_startedStopingAngle = m_slowingAngle;
                m_stopingAngle        = m_slowingAngle;
                m_stopingSpeed        = m_slowingSpeed;
                m_gyroState           = eGyroState.Stoping;
            }
        }
Beispiel #15
0
        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;
        }
Beispiel #16
0
 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();
 }
Beispiel #17
0
        private void drawGyroCylinder()
        {
            GL.glPushMatrix();

            // translate the position to draw the cylinder on the top of the cube
            float xCylinderOrigin = CubeWidth / 2;
            float yCylinderOrigin = CubeHeight;
            float zCylinderOrigin = CubeDepth / 2;

            GL.glTranslatef(xCylinderOrigin, yCylinderOrigin, zCylinderOrigin);

            // draw the cylinder
            int        cylinderSegements = 16;
            GLUquadric GluQuadric;

            GluQuadric = GLU.gluNewQuadric();

            GL.glRotatef(90, -1, 0, 0);             // the cylinder height is relative to z axis
            GLU.gluCylinder(GluQuadric, CylinderRadius, CylinderRadius, CylinderHeight, cylinderSegements, cylinderSegements);
            GL.glRotatef(90, 1, 0, 0);

            GLU.gluDeleteQuadric(GluQuadric);

            // draw cylinder cover
            GL.glBegin(GL.GL_POLYGON);

            for (int i = 0; i < cylinderSegements; i++)
            {
                float theta = 2.0f * 3.1415926f * i / cylinderSegements;           //get the current angle

                float x = CylinderRadius * (float)Math.Cos(theta);                 //calculate the x component
                float y = CylinderRadius * (float)Math.Sin(theta);                 //calculate the y component

                GL.glVertex3f(x, CylinderHeight, y);
            }

            GL.glEnd();

            GL.glPopMatrix();
        }
Beispiel #18
0
        public void Draw()
        {
            // MAIN FUNCTION
            if (m_uint_DC == 0 || m_uint_RC == 0)
            {
                MessageBox.Show("No screen dimension. Drawing canceled");
                return;
            }

            // GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
            GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_STENCIL_BUFFER_BIT);

            GL.glLoadIdentity();

            GL.glTranslatef(0.0f, 0.0f, -6.0f);

            GL.glRotatef(90.0f - GlobalProperties.CurrentVerticalViewAngle, -1.0f, 0.0f, 0.0f);
            GL.glRotatef(GlobalProperties.CurrentHorizontalViewAngle, 0.0f, 0.0f, 1.0f);

            GL.glEnable(GL.GL_LIGHTING);
            if (GlobalProperties.LightBeamOn)
            {
                GL.glEnable(GL.GL_LIGHT0);
            }
            else
            {
                GL.glDisable(GL.GL_LIGHT0);
            }

            // DrawAxes();
            DrawAll();
            GL.glDisable(GL.GL_LIGHTING);

            GL.glFlush();

            WGL.wglSwapBuffers(m_uint_DC);
        }
Beispiel #19
0
        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();
        }
Beispiel #20
0
 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();
 }
// ############################################################################
// ############################################################################
// ############################################################################
// ############################################################################


// ============================================================================
// The following is an example of OpenGL rendering code, complete with
// buffer swapping.  This function can be called by a Form's "OnPaint()"
// method if a previous WGL.DemoInitOpenGL() call (for example) has
// already successfully established a valid Render Context (RC).
// ============================================================================

        public static void DemoOpenGLDraw
        (
            int int_WindowWidth,
            int int_WindowHeight,
            uint uint_DC
        )
        {
            int   int_Phase   = (int)(System.Environment.TickCount % 120000);
            float float_Phase = (float)(0.3f * (int_Phase));

            if (int_WindowWidth <= 0)
            {
                int_WindowWidth = 1;
            }
            if (int_WindowHeight <= 0)
            {
                int_WindowHeight = 1;
            }

            GL.glViewport(0, 0, int_WindowWidth, int_WindowHeight);

            GL.glEnable(GL.GL_DEPTH_TEST);
            GL.glDepthFunc(GL.GL_LEQUAL);
            GL.glEnable(GL.GL_CULL_FACE);
            GL.glCullFace(GL.GL_BACK);
            GL.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
            GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
            GL.glMatrixMode(GL.GL_PROJECTION);
            GL.glLoadIdentity();

            //GL.glOrtho( 0.0f, (float)(int_WindowWidth), 0.0f, (float)(int_WindowHeight), -1.0f, 1.0f );
            GLU.gluPerspective
            (
                60.0,  // Field of view angle (Y angle; degrees)
                ((double)(int_WindowWidth) / (double)(int_WindowHeight)),
                1.0,   // Near plane
                1000.0 // Far  plane
            );

            GL.glMatrixMode(GL.GL_MODELVIEW);
            GL.glLoadIdentity();

            // Translating the camera to +600.0f Z is essentially
            // adding -600.0f to all drawing commands.
            GL.glTranslatef(0.0f, 0.0f, -600.0f);

            GL.glRotatef((0.11f * float_Phase), 1.0f, 0.0f, 0.0f);
            GL.glRotatef((0.31f * float_Phase), 0.0f, 1.0f, 0.0f);
            GL.glRotatef((0.19f * float_Phase), 0.0f, 0.0f, 1.0f);

            float[][] vert_xyz = new float[8][]
            {
                new float[] { -100.0f, -100.0f, -100.0f }, // 0
                new float[] { -100.0f, -100.0f, 100.0f },  // 1
                new float[] { -100.0f, 100.0f, -100.0f },  // 2
                new float[] { -100.0f, 100.0f, 100.0f },   // 3
                new float[] { 100.0f, -100.0f, -100.0f },  // 4
                new float[] { 100.0f, -100.0f, 100.0f },   // 5
                new float[] { 100.0f, 100.0f, -100.0f },   // 6
                new float[] { 100.0f, 100.0f, 100.0f } // 7
            };
            int [][] tri_abc = new int [12][]
            {
                new int[] { 0, 2, 4 }, new int[] { 4, 2, 6 }, // Back
                new int[] { 0, 4, 1 }, new int[] { 1, 4, 5 }, // Bottom
                new int[] { 0, 1, 2 }, new int[] { 2, 1, 3 }, // Left
                new int[] { 4, 6, 5 }, new int[] { 5, 6, 7 }, // Right
                new int[] { 2, 3, 6 }, new int[] { 6, 3, 7 }, // Top
                new int[] { 1, 5, 3 }, new int[] { 3, 5, 7 } // Front
            };
            float[][] colors_rgb = new float[12][]
            {
                new float[] { 0.5f, 0.1f, 0.1f }, new float[] { 1.0f, 0.1f, 0.1f }, // Red
                new float[] { 0.5f, 0.5f, 0.1f }, new float[] { 1.0f, 1.0f, 0.1f }, // Yellow
                new float[] { 0.1f, 0.5f, 0.1f }, new float[] { 0.1f, 1.0f, 0.1f }, // Green
                new float[] { 0.1f, 0.5f, 0.5f }, new float[] { 0.1f, 1.0f, 1.0f }, // Cyan
                new float[] { 0.1f, 0.1f, 0.5f }, new float[] { 0.1f, 0.1f, 1.0f }, // Blue
                new float[] { 0.5f, 0.1f, 0.5f }, new float[] { 1.0f, 0.1f, 1.0f } // Magenta
            };

            int iTriTotal = 12;
            int iTriIndex = 0;

            GL.glBegin(GL.GL_TRIANGLES);
            for (iTriIndex = 0; iTriIndex < iTriTotal; iTriIndex++)
            {
                GL.glColor3fv(colors_rgb[iTriIndex]);
                GL.glVertex3fv(vert_xyz[tri_abc[iTriIndex][0]]);

                GL.glColor3fv(colors_rgb[iTriIndex]);
                GL.glVertex3fv(vert_xyz[tri_abc[iTriIndex][1]]);

                GL.glColor3fv(colors_rgb[iTriIndex]);
                GL.glVertex3fv(vert_xyz[tri_abc[iTriIndex][2]]);
            }
            GL.glEnd();

            WGL.wglSwapBuffers(uint_DC);
        }
Beispiel #22
0
        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();
        }
Beispiel #23
0
        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);
        }
Beispiel #24
0
        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;
            }
        }
Beispiel #25
0
        /**********************************************************************************************************
        *
        *
        *
        * 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);
        }
Beispiel #26
0
        public void Draw()
        {
            pos[0] = -4 + (float)xExisOrigin + (float)ScrollValue[11];
            pos[1] = 15 + (float)yExisOrigin + (float)ScrollValue[12];
            pos[2] = 15 + (float)ScrollValue[13];


            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();


            // not trivial
            double [] ModelVievMatrixBeforeSpecificTransforms = new double[16];
            double [] CurrentRotationTraslation = new double[16];

            GLU.gluLookAt(ScrollValue[0], ScrollValue[1], ScrollValue[2],
                          ScrollValue[3], ScrollValue[4], ScrollValue[5],
                          ScrollValue[6], ScrollValue[7], ScrollValue[8]);
            GL.glTranslatef(0.0f, 0.0f, -30.0f);

            GL.glRotatef(105, 0, 0, 1);
            GL.glRotatef(70, 0, 1, 0);
            GL.glRotatef(15, 1, 0, 0);
            //save current ModelView Matrix values
            //in ModelVievMatrixBeforeSpecificTransforms array
            //ModelView Matrix ========>>>>>> ModelVievMatrixBeforeSpecificTransforms
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, ModelVievMatrixBeforeSpecificTransforms);
            //ModelView Matrix was saved, so
            GL.glLoadIdentity(); // make it identity matrix

            //make transformation in accordance to KeyCode
            float delta;

            if (intOptionC != 0)
            {
                delta = 5.0f * Math.Abs(intOptionC) / intOptionC; // signed 5

                switch (Math.Abs(intOptionC))
                {
                case 1:
                    GL.glRotatef(delta, 1, 0, 0);
                    break;

                case 2:
                    GL.glRotatef(delta, 0, 1, 0);
                    break;

                case 3:
                    GL.glRotatef(delta, 0, 0, 1);
                    break;

                case 4:
                    GL.glTranslatef(delta / 20, 0, 0);
                    break;

                case 5:
                    GL.glTranslatef(0, delta / 20, 0);
                    break;

                case 6:
                    GL.glTranslatef(0, 0, delta / 20);
                    break;
                }
            }
            //as result - the ModelView Matrix now is pure representation
            //of KeyCode transform and only it !!!

            //save current ModelView Matrix values
            //in CurrentRotationTraslation array
            //ModelView Matrix =======>>>>>>> CurrentRotationTraslation
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, CurrentRotationTraslation);

            //The GL.glLoadMatrix function replaces the current matrix with
            //the one specified in its argument.
            //The current matrix is the
            //projection matrix, modelview matrix, or texture matrix,
            //determined by the current matrix mode (now is ModelView mode)
            GL.glLoadMatrixd(AccumulatedRotationsTraslations); //Global Matrix

            //The GL.glMultMatrix function multiplies the current matrix by
            //the one specified in its argument.
            //That is, if M is the current matrix and T is the matrix passed to
            //GL.glMultMatrix, then M is replaced with M • T
            GL.glMultMatrixd(CurrentRotationTraslation);

            //save the matrix product in AccumulatedRotationsTraslations
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, AccumulatedRotationsTraslations);

            //replace ModelViev Matrix with stored ModelVievMatrixBeforeSpecificTransforms
            GL.glLoadMatrixd(ModelVievMatrixBeforeSpecificTransforms);
            //multiply it by KeyCode defined AccumulatedRotationsTraslations matrix
            GL.glMultMatrixd(AccumulatedRotationsTraslations);


            //REFLECTION//DrawAxes();

            //REFLECTION b
            intOptionB += 1;  //for rotation
            intOptionC += 10; //for rotation
            // without REFLECTION was only DrawAll();
            // now
            //!!!!------sky box
            GL.glPushMatrix();
            GL.glPushAttrib(GL.GL_CURRENT_BIT);
            GL.glColor4f(1.0f, 1.0f, 1.0f, 0.5f);


            GL.glEnable(GL.GL_TEXTURE_2D);
            GL.glDisable(GL.GL_BLEND);
            GL.glRotatef(90, 1, 0, 0);
            DrawTexturedCube();
            GL.glPopAttrib();
            GL.glPopMatrix();
            /////
            GL.glEnable(GL.GL_BLEND);
            GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);


            //only floor, 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); // 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);

            DrawFloor3();

            // 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);
            DrawFigures();

            GL.glCullFace(GL.GL_FRONT);
            DrawFigures();

            GL.glDisable(GL.GL_CULL_FACE);
            GL.glPopMatrix();

            // really draw floor
            //( half-transparent ( see its color's alpha byte)))
            // in order to see reflected objects
            GL.glDepthMask((byte)GL.GL_FALSE);

            DrawFloor3();

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



            DrawFigures();



            GL.glDisable(GL.GL_TEXTURE_2D);

            GL.glFlush();
            WGL.wglSwapBuffers(m_uint_DC);
        }
Beispiel #27
0
        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();
        }
Beispiel #28
0
        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();
        }
Beispiel #29
0
        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();
        }
Beispiel #30
0
        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();
        }