glTranslatef() 개인적인 메소드

private glTranslatef ( float x, float y, float z ) : void
x float
y float
z float
리턴 void
예제 #1
0
        private void gyroStopingTransform()
        {
            // calc stoping angle
            m_stopingAngle += m_stopingSpeed * m_swingingDirection;

            // set the gyro last position with swinging angle
            GL.glTranslatef(CubeWidth / 2.0f, 0.0f, CubeDepth / 2.0f);
            GL.glRotatef(m_yAxisFellAngle + m_stopingAngle, 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_stopingSpeed -= m_stopingSlowFactor;

            float swingedAngle = (m_stopingAngle - m_startedStopingAngle);

            if (swingedAngle * m_swingingDirection > m_swingingAmplitude)
            {
                m_swingingDirection *= -1;                          // swing to the other side
                m_swingingAmplitude -= m_swingingAmplitudeDecrease; // swinging amlitude is decrease every swinging direction change
            }

            if (m_stopingSpeed <= 0)
            {
                m_stopingSpeed = 0; // continue drawing, but the gyro will not move
            }
        }
예제 #2
0
        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;
        }
예제 #3
0
        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();
        }
예제 #4
0
        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();
        }
예제 #5
0
        void StartReflaction(int x, int y, int z)
        {
            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);
            GL.glPushMatrix();
            GL.glRotated(90, 0, 1, 0);
            GL.glTranslatef(0, -4, 0);
            mirror.Draw();
            GL.glPopMatrix();
            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(x, y, z); //swap on Z axis
        }
예제 #6
0
 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();
 }
예제 #7
0
        double[] WillPlace(float x, float y, float z)
        {
            double[] Robot_place_temp = new double[2];
            Robot_place_temp[0] = RobotPlace[0];
            Robot_place_temp[1] = RobotPlace[1];
            GL.glRotatef(-Robot.WalkAngle, 0, 1, 0);
            GL.glTranslatef(x, y, z);
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, AccumulatedRotationsTraslations);
            WillRobotPlace[0] = AccumulatedRotationsTraslations[12];
            WillRobotPlace[1] = AccumulatedRotationsTraslations[14];


            if (Math.Abs(WillRobotPlace[0]) < Math.Abs(Robot_place_temp[0]) && Math.Abs(Robot_place_temp[0]) > 1.5)
            {
                Robot_place_temp[0] = 18.49f;
            }
            else if (Math.Abs(WillRobotPlace[0]) > Math.Abs(Robot_place_temp[0]) && Math.Abs(Robot_place_temp[0]) < 1.5 && Math.Abs(Robot_place_temp[1]) < 4)
            {
                Robot_place_temp[0] = 1.6f;
            }
            if (Math.Abs(WillRobotPlace[1]) < Math.Abs(Robot_place_temp[1]) && Math.Abs(Robot_place_temp[1]) > 4.5)
            {
                Robot_place_temp[1] = 18.49f;
            }
            else if (Math.Abs(WillRobotPlace[1]) > Math.Abs(Robot_place_temp[1]) && Math.Abs(Robot_place_temp[1]) < 4.5 && Math.Abs(Robot_place_temp[1]) > 4)
            {
                Robot_place_temp[1] = 4.6f;
            }

            //return to orginal position matrix
            GL.glTranslatef(-x, -y, -z);
            GL.glRotatef(Robot.WalkAngle, 0, 1, 0);
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, AccumulatedRotationsTraslations);
            return(Robot_place_temp);
        }
예제 #8
0
파일: cOGL.cs 프로젝트: matanmaron/Tanks
        void DrawMirror(bool screen)
        {
            GL.glTranslatef(0f, 0f, -30f);

            GL.glBegin(GL.GL_QUADS);
            //!!! for blended REFLECTION
            float mirrorhight = 3;
            float mirrorwidth = 15;

            if (screen)
            {
                GL.glColor4d(0.0, 0.0, 0.6, 0.4);
            }
            else
            {
                GL.glColor4d(1, 1, 1, 0);
            }
            GL.glVertex3f(0, 0, 0);
            GL.glVertex3f(0, 0, mirrorwidth);
            GL.glVertex3f(0, mirrorhight, mirrorwidth);
            GL.glVertex3f(0, mirrorhight, 0);
            GL.glEnd();

            GL.glTranslatef(0f, 0f, 30f);
        }
예제 #9
0
        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);
        }
예제 #10
0
        private void DrawTower()
        {
            const double baseRadius = 0.25, topRadius = 0.16, height = 2.3, diskHeight = 0.06;
            const double diskRadius      = topRadius + 0.2;
            float        lightBeamLength = GlobalProperties.LightBeamLength;

            GL.glPushMatrix();

            DrawPillar(baseRadius, topRadius, height);

            GL.glTranslatef(0.0f, 0.0f, (float)height);

            DrawDisk(diskHeight, diskRadius);

            GL.glTranslatef(0.0f, 0.0f, (float)diskHeight);

            DrawWindow();

            GL.glTranslatef(0.0f, 0.0f, -(float)diskHeight / 2);
            GL.glRotatef(GlobalProperties.LightBeamHorizontalAngle, 0.0f, 0.0f, 1.0f);
            GL.glRotatef(GlobalProperties.LightBeamVerticalAngle, 0.0f, 1.0f, 0.0f);
            if (GlobalProperties.LightBeamOn)
            {
                DrawLightBeam();
                DrawLightSource();
            }

            GL.glPopMatrix();
        }
예제 #11
0
        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.glLoadIdentity();
            GL.glTranslatef(-1.0f, -1.0f, -6.0f);

            drawAxises();
            updateTimer();

            GL.glTranslated(0.5f, 0.0f, 0.5f);

            GL.glRotatef(m_RotateAngle, 0, 1.0f, 0); // y axis rotate
            GL.glRotatef(m_FallAngle, 1, 0, 0);      // x axis rotate

            GL.glTranslated(-0.5f, 0.0f, -0.5f);
            GL.glEnable(GL.GL_TEXTURE_2D);
            GL.glBindTexture(GL.GL_TEXTURE_2D, m_Texture[0]);

            drawDreidel();
            GL.glDisable(GL.GL_TEXTURE_2D);
            GL.glFlush();
            WGL.wglSwapBuffers(m_uint_DC);
        }
예제 #12
0
 public void Translate(float x, float y, float z)
 {
     if (!isMatrixPushed)
     {
         GL.glPushMatrix();
         isMatrixPushed = true;
     }
     GL.glTranslatef(x, y, z);
 }
예제 #13
0
 void DrawLight()
 {
     GL.glTranslatef(pos[0], pos[1], pos[2]);
     GL.glColor3f(1, 1, 0);
     GLUT.glutSolidSphere(0.8, 10, 10);
     GL.glTranslatef(-pos[0], -pos[1], -pos[2]);
     GL.glEnd();
     GL.glDisable(GL.GL_LIGHTING);
 }
예제 #14
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);
        }
예제 #15
0
 public void PrepareAndDrawShadow()
 {
     CAR_SHADOW_LIST = GL.glGenLists(1);
     CAR_SHADOW      = CAR_SHADOW_LIST + 1;
     GL.glPushMatrix();
     GL.glNewList(CAR_SHADOW, GL.GL_COMPILE);
     GL.glTranslatef(0, -5.5f, 0);
     GL.glScalef(0.1f, 0.1f, 0.1f);
     carModel.DrawModel(false, 1);
     GL.glPopMatrix();
     GL.glEndList();
     GL.glPopMatrix();
 }
예제 #16
0
 public void Drawfloor()
 {
     GL.glPushMatrix();
     GL.glColor3f(0.0f, 1.0f, 0.0f);
     GL.glTranslatef(0, -0.001f, 0);
     GL.glBegin(GL.GL_QUADS);
     GL.glNormal3f(0, 1, 0);
     GL.glVertex3f(-100, 0, -100);
     GL.glVertex3f(-100, 0, 100);
     GL.glVertex3f(100, 0, 100);
     GL.glVertex3f(100, 0, -100);
     GL.glEnd();
     GL.glPopMatrix();
 }
예제 #17
0
        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();
            }
        }
예제 #18
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();
            }
        }
예제 #19
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);
        }
예제 #20
0
        void DrawLights()
        {
            //GL.glPushMatrix();
            GL.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, lightPos);

            //Draw Light Source
            GL.glDisable(GL.GL_LIGHTING);
            GL.glTranslatef(lightPos[0], lightPos[1], lightPos[2]);
            //Yellow Light source
            GL.glColor3f(1, 1, 0);
            GLUT.glutSolidSphere(0.05, 8, 8);
            GL.glTranslatef(-lightPos[0], -lightPos[1], -lightPos[2]);

            //main System draw
            GL.glEnable(GL.GL_LIGHTING);
            //GL.glPopMatrix();
        }
예제 #21
0
        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);
        }
예제 #22
0
        void DrawFiguresRef()
        {
            GL.glPushMatrix();

            // must be in scene to be reflected too
            GL.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, pos);

            //Draw Light Source
            GL.glDisable(GL.GL_LIGHTING);
            GL.glTranslatef(pos[0], pos[1], pos[2]);
            //Yellow Light source
            GL.glColor3f(1, 1, 0);
            GL.glTranslatef(-pos[0], -pos[1], -pos[2]);
            //projection line from source to plane
            GL.glBegin(GL.GL_LINES);
            GL.glColor3d(0.5, 0.5, 0);
            GL.glVertex3d(pos[0], pos[1], 0);
            GL.glVertex3d(pos[0], pos[1], pos[2]);
            GL.glEnd();

            GL.glEnable(GL.GL_LIGHTING);

            GL.glRotated(intOptionB, 0, 0, 1);

            GL.glColor3f(1, 0, 0);
            GL.glTranslated(0, -0.5, 1);
            GL.glRotated(intOptionC, 1, 1, 1);

            GL.glRotated(-intOptionC, 1, 1, 1);
            GL.glTranslated(0, -0.5, -1);

            GL.glTranslated(1, 2, 1.5);
            GL.glRotated(90, 1, 0, 0);
            GL.glColor3d(0, 1, 1);
            GL.glRotated(intOptionB, 1, 0, 0);

            GL.glRotated(-intOptionB, 1, 0, 0);
            GL.glRotated(-90, 1, 0, 0);
            GL.glTranslated(-1, -2, -1.5);

            GL.glRotated(intOptionB, 0, 0, 1);

            GL.glPopMatrix();
        }
예제 #23
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();
 }
예제 #24
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);
        }
예제 #25
0
        public void DrawFigures()
        {
            GL.glPushMatrix();



            GL.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, pos);

            //Draw Light Source
            GL.glDisable(GL.GL_LIGHTING);
            GL.glTranslatef(pos[0], pos[1], pos[2]);
            //Yellow Light source
            GL.glColor3f(1, 1, 0);
            GLUT.glutSolidSphere(0.05, 8, 8);
            GL.glTranslatef(-pos[0], -pos[1], -pos[2]);

            //main System draw
            GL.glEnable(GL.GL_LIGHTING);

            DrawRobot(false);
            drawStars(false);
            //end of regular show
            //!!!!!!!!!!!!!
            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);
            // wall shadow
            //!!!!!!!!!!!!!
            GL.glPushMatrix();
            //!!!!!!!!!!!!
            MakeShadowMatrix(ground);
            GL.glMultMatrixf(cubeXform);
            DrawRobot(true);
            drawStars(true);
            //!!!!!!!!!!!!!
            GL.glPopMatrix();
            //!!!!!!!!!!!!!
        }
예제 #26
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;
            }
        }
예제 #27
0
        private void DrawWindow()
        {
            float windowRadius = GlobalProperties.windowRadius,
                  wondowHeight = GlobalProperties.windowHeight;

            GL.glEnable(GL.GL_TEXTURE_2D);
            GL.glColor3f(1.0f, 1.0f, 1.0f);
            GL.glBindTexture(GL.GL_TEXTURE_2D, Textures[5]);

            GLUquadric obj = GLU.gluNewQuadric();

            GLU.gluQuadricTexture(obj, 5);
            GLU.gluCylinder(obj, windowRadius, windowRadius, wondowHeight, 32, 32);
            GL.glTranslatef(0.0f, 0.0f, wondowHeight);
            GLU.gluCylinder(obj, windowRadius, 0, wondowHeight * 2 / 3, 32, 32);
            GL.glTranslatef(0.0f, 0.0f, -wondowHeight / 2);

            GLU.gluDeleteQuadric(obj);

            GL.glDisable(GL.GL_TEXTURE_2D);
        }
예제 #28
0
파일: cOGL.cs 프로젝트: matanmaron/Tanks
        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;
        }
예제 #29
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;
            }
        }
예제 #30
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();
        }