示例#1
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);
 }
示例#2
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();
 }
示例#3
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();
        }
示例#4
0
        protected void DrawLightSource()
        {
            if (enableLightSource)
            {
                GL.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, lightPosition);
                GL.glEnable(GL.GL_LIGHTING);
                GL.glEnable(GL.GL_COLOR_MATERIAL);

                GL.glTranslated(lightPosition[0], lightPosition[1], lightPosition[2]);
                GL.glColor3d(1, 1, 0);
                GLUT.glutSolidSphere(0.5, 50, 50);
                GL.glTranslated(-lightPosition[0], -lightPosition[1], -lightPosition[2]);
            }
            else
            {
                GL.glDisable(GL.GL_LIGHTING);
            }
        }
示例#5
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();
            //!!!!!!!!!!!!!
        }
 public void Draw()
 {
     GL.glColor3f(color.R, color.G, color.B);
     GLUT.glutSolidSphere(radius, 8, 8);
     ApplyTransformation();
 }
        public void drawPenguin()
        {
            GL.glPushMatrix();
            //  drawaxe();
            GL.glRotatef(90, 0.0f, 1.0f, 0.0f);

            GL.glRotatef(-90, 1.0f, 0.0f, 0.0f);


            //drawaxe();
            GL.glTranslated(0.0, -200, 0);
            GL.glTranslated(0.0, speed, 0);  // going forward
            GL.glRotated(spirala, 0, 0, 1);  //turn 180 deg

            // drawaxe();



            if (speedFlg)
            {
                if (!spiralaFlg)
                {
                    if (forward)
                    {
                        if (speed < 380)
                        {
                            speed += 5;
                            GL.glRotated(flap * 6, 0, 0, 1);  //Jump
                        }
                        if (speed >= 380)
                        {
                            speedFlg   = false;
                            spiralaFlg = true;
                            forward    = false;
                        }
                    }
                    if (!forward)
                    {
                        if (speed > 0)
                        {
                            speed -= 5;
                            GL.glRotated(flap * 6, 0, 0, 1);
                        }
                        if (speed <= 0)
                        {
                            speedFlg   = false;
                            spiralaFlg = true;
                            forward    = true;
                        }
                    }
                }
            }
            if (!speedFlg)
            {
                if (spiralaFlg)
                {
                    if (spirala < spindLim)
                    {
                        spirala += 18;
                        GL.glTranslated(0.0, 0, 0 + flap * 8);
                    }
                    else
                    {
                        spiralaFlg = false;
                        spindLim  += 180;
                    }
                }
                if (!spiralaFlg)
                {
                    speedFlg = true;
                }
            }

            if (!checkBox)
            {
                if (!flapFlg)
                {
                    flap += 0.5f;
                    if (flap >= 5)
                    {
                        flapFlg = true;
                    }
                }
                if (flapFlg)
                {
                    flap -= 0.5f;
                    if (flap <= 0)
                    {
                        flapFlg = false;
                    }
                }
            }
            if (checkBox)
            {
                flap = 0;
            }



            GL.glPushMatrix();

            GL.glScaled(scale_inc, scale_inc, scale_inc); //size of penguin
            //drawaxe();

            float[] front_ambuse = { 0.9f, 0.9f, 0.9f, 1.0f };

            GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE, front_ambuse);

            GL.glColor3f(1.0f, 1.0f, 1.0f);
            //Front body
            GL.glBegin(GL.GL_QUADS);
            GL.glNormal3d(0, 0, 1);
            GL.glVertex3d(-3, 3, 0);
            GL.glVertex3d(3, 3, 0);
            GL.glVertex3d(4, 4, 5);
            GL.glVertex3d(-4, 4, 5);
            GL.glEnd();

            GL.glBegin(GL.GL_QUADS);
            GL.glNormal3d(0, 0, 1);
            GL.glVertex3d(-4, 4, 5);
            GL.glVertex3d(4, 4, 5);
            GL.glVertex3d(2.5, 3, 12);
            GL.glVertex3d(-2.5, 3, 12);
            GL.glEnd();

            float[] backLow_ambuse = { 0.01f, 0.01f, 0.01f, 1.0f };
            GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE, backLow_ambuse);

            GL.glColor3f(0.01f, 0.01f, 0.01f);

            //Back body
            GL.glBegin(GL.GL_QUADS);
            GL.glNormal3d(0, 0, 1);
            GL.glVertex3d(-3, 0, 0);
            GL.glVertex3d(3, 0, 0);
            GL.glVertex3d(4, -1, 5);
            GL.glVertex3d(-4, -1, 5);
            GL.glEnd();

            float[] backHigh_ambuse = { 0.18f, 0.18f, 0.18f, 1.0f };
            GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE, backHigh_ambuse);

            GL.glColor3f(0.18f, 0.18f, 0.18f);

            GL.glBegin(GL.GL_QUADS);
            GL.glNormal3d(0, 0, 1);
            GL.glVertex3d(-4, -1, 5);
            GL.glVertex3d(4, -1, 5);
            GL.glVertex3d(2.5, 0, 12);
            GL.glVertex3d(-2.5, 0, 12);
            GL.glEnd();


            float[] SideFront_ambuse = { 0.91f, 0.91f, 0.91f, 1.0f };

            GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE, SideFront_ambuse);
            GL.glColor3f(0.91f, 0.91f, 0.91f);

            //leftSide-front body
            GL.glBegin(GL.GL_TRIANGLE_STRIP);
            GL.glNormal3d(0, 0, 1);
            GL.glVertex3d(-3, 3, 0);
            GL.glVertex3d(-3.5, 1, 0);
            GL.glVertex3d(-4, 4, 5);
            GL.glVertex3d(-4.2, 1, 5.5);
            GL.glVertex3d(-2.5, 3, 12);
            GL.glEnd();

            //rightSide-front body
            GL.glBegin(GL.GL_TRIANGLE_STRIP);
            GL.glNormal3d(0, 0, 1);
            GL.glVertex3d(3, 3, 0);
            GL.glVertex3d(3.5, 1, 0);
            GL.glVertex3d(4, 4, 5);
            GL.glVertex3d(4.2, 1, 5.5);
            GL.glVertex3d(2.5, 3, 12);
            GL.glEnd();


            float[] SideBack_ambuse = { 0.1f, 0.1f, 0.1f, 1.0f };

            GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE, SideBack_ambuse);
            GL.glColor3f(0.1f, 0.1f, 0.1f);

            //leftSide-front body
            GL.glBegin(GL.GL_TRIANGLE_STRIP);
            GL.glNormal3d(0, 0, 1);
            GL.glVertex3d(-3, 0, 0);
            GL.glVertex3d(-3.5, 1, 0);
            GL.glVertex3d(-4, -1, 5);
            GL.glVertex3d(-4.2, 1, 5.5);
            GL.glVertex3d(-2.5, 0, 12);
            GL.glVertex3d(-2.5, 3, 12);
            GL.glEnd();

            //rightSide-front body
            GL.glBegin(GL.GL_TRIANGLE_STRIP);
            GL.glNormal3d(0, 0, 1);
            GL.glVertex3d(3, 0, 0);
            GL.glVertex3d(3.5, 1, 0);
            GL.glVertex3d(4, -1, 5);
            GL.glVertex3d(4.2, 1, 5.5);
            GL.glVertex3d(2.5, 0, 12);
            GL.glVertex3d(2.5, 3, 12);
            GL.glEnd();


            ////// neck
            GL.glBegin(GL.GL_TRIANGLE_STRIP);
            GL.glNormal3d(0, 0, 1);

            GL.glVertex3d(2.5, 3, 12);
            GL.glVertex3d(-2.5, 3, 12);
            GL.glVertex3d(0, 1.0, 15);
            GL.glEnd();

            GL.glColor3f(0f, 0.0f, 0.0f);

            float[] beak_ambuse = { 0.6021f, 0.3001f, 0.0156f, 1.0f };

            GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE, beak_ambuse);
            GL.glColor3f(0.6021f, 0.3001f, 0.0156f);

            ////// beak -left
            GL.glBegin(GL.GL_TRIANGLE_STRIP);
            GL.glNormal3d(0, 0, 1);
            GL.glVertex3d(-2.5, 3, 12);
            GL.glVertex3d(0, 1.0, 15);
            GL.glVertex3d(0, 6.0, 10);
            GL.glEnd();
            ////// beak -right
            GL.glBegin(GL.GL_TRIANGLE_STRIP);
            GL.glNormal3d(0, 0, 1);
            GL.glVertex3d(2.5, 3, 12);
            GL.glVertex3d(0, 1.0, 15);
            GL.glVertex3d(0, 6.0, 10);
            GL.glEnd();


            float[] wing_ambuse = { 0.7421f, 0.4101f, 0.0156f, 1.0f };

            GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE, wing_ambuse);
            GL.glColor3f(0.7421f, 0.4101f, 0.0156f);

            ////// wing -left
            GL.glBegin(GL.GL_TRIANGLE_STRIP);
            GL.glNormal3d(0, 0, 1);
            GL.glVertex3d(-2.5, 3, 12);
            GL.glVertex3d(-4.2, +1.0, 5.5);
            GL.glVertex3d(-5 + (float)-flap * 0.4, -5.0 + (float)flap * 0.4, 4);

            GL.glEnd();
            ////// wing -right
            GL.glBegin(GL.GL_TRIANGLE_STRIP);
            GL.glNormal3d(0, 0, 1);
            GL.glVertex3d(2.5, 3, 12);
            GL.glVertex3d(4.2, +1.0, 5.5);
            GL.glVertex3d(5 + (float)flap * 0.4, -5.0 + (float)flap * 0.4, 4);
            GL.glEnd();


            //Head
            float[] head_ambuse = { 0.1117f, 0.1296f, 0.1562f, 1.0f };

            GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE, head_ambuse);
            GL.glColor3f(0.1117f, 0.1296f, 0.1562f);

            GL.glPushMatrix();
            GL.glTranslated(0, 1.5, 13);
            GLUT.glutSolidSphere(3.2, 64, 64);
            GL.glPopMatrix();



            //Legs
            float[] legs_ambuse = { 0.5021f, 0.2001f, 0.0156f, 1.0f };

            GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE, legs_ambuse);
            GL.glColor3f(0.1117f, 0.1296f, 0.1562f);

            GL.glPushMatrix();
            GL.glTranslated(-2.2, 3, 0);
            GLUT.glutSolidSphere(1.8, 32, 100);
            GL.glPopMatrix();
            GL.glPushMatrix();
            GL.glTranslated(2.2, 3, 0);
            GLUT.glutSolidSphere(1.8, 32, 100);
            GL.glPopMatrix();


            GL.glPushMatrix();



            //Eyes
            float[] eyesW_ambuse = { 1f, 1f, 1f, 1.0f };

            GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE, eyesW_ambuse);
            GL.glColor3f(1f, 1f, 1f);

            GL.glPushMatrix();
            GL.glTranslated(-1.2, 3.5, 13);
            GLUT.glutSolidSphere(1, 32, 32);
            GL.glPopMatrix();
            GL.glPushMatrix();
            GL.glTranslated(1.2, 3.5, 13);
            GLUT.glutSolidSphere(1, 32, 32);
            GL.glPopMatrix();

            float[] eyesB_ambuse = { 0f, 0f, 0f, 1.0f };

            GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE, eyesB_ambuse);
            GL.glColor3f(1f, 1f, 1f);

            GL.glPushMatrix();
            GL.glTranslated(-1.2, 3.9, 12.8);
            GLUT.glutSolidSphere(0.7, 32, 32);
            GL.glPopMatrix();
            GL.glPushMatrix();
            GL.glTranslated(1.2, 3.9, 12.8);
            GLUT.glutSolidSphere(0.7, 32, 32);
            GL.glPopMatrix();

            GL.glPopMatrix();
            GL.glPopMatrix();
            GL.glPopMatrix();
        }
示例#8
0
        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);
            //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        }