Esempio n. 1
0
        static void Afficher_Ma_Scene()
        {
            //.... DEBUT DE NE PAS TOUCHER
            Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT | Gl.GL_STENCIL_BUFFER_BIT); // Effacer les buffer d'affichage, de profondeur et de masque
            Gl.glMatrixMode(Gl.GL_MODELVIEW);                                                       // choisir la matrice de vue
            Gl.glLoadIdentity();                                                                    // initialiser la matrice vue en matrice identité Le repere est donc en 0,0,0
            Glu.gluLookAt(0.0, 0.0, 20.0,                                                           // La caméra est à  0,0,20 (x y z)
                          0.0, 0.0, 0.0,                                                            // regarde 0,0,0 (le centre)
                          0.0, 1.0, 0.0);                                                           // vecteur orientation  (vers le haut)

            //..... FIN DE NE PAS TOUCHER

            foreach (var item in Liste_objet)
            {
                item.affiche_toi();
            }

            Gl.glPushMatrix();
            Gl.glTranslatef(Position_curseur_X, Position_curseur_Y, 0);
            Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_DIFFUSE, Bleu);
            Glut.glutSolidSphere(1, 20, 20);
            Gl.glPopMatrix();


            Gl.glColor3f(0.9f, 0.5f, 0.9f);             // choix de la couleur 90% de rouge 50% de vert 90% bleu

            OPENGL_Affiche_Chaine(-15, 10, Le_Message); // on affiche un texte en -10,-100

            Glut.glutSwapBuffers();
        }
Esempio n. 2
0
        private void Clock()
        {
            Gl.glColor3ub(255, 180, 180);

            Gl.glPushMatrix();
            Gl.glScaled(1.0f, 1.0f, 0.7f);
            Glut.glutSolidTorus(1, 9, 32, 32);
            Gl.glPopMatrix();

            Glut.glutSolidCylinder(0.5f, 0.3f, 32, 32);
            Gl.glColor3ub(255, 255, 255);

            Gl.glPushMatrix();
            Gl.glScaled(9.0f, 9.0f, 0.1f);
            Glut.glutSolidSphere(1.0f, 100, 100);
            Gl.glPopMatrix();
            //Glut.glutSolidCylinder(9f, 0.1f, 32, 32);
            for (int i = 0; i < 12; i++)
            {
                Gl.glPushMatrix();

                Gl.glColor3ub(150, 175, 255);
                Gl.glRotated(i * 30.0f, 0, 0, 1);
                Gl.glTranslated(7.5f, 0.0f, 0.1f);
                Gl.glScaled(1.0f, 0.2f, 0.2f);
                Glut.glutSolidCube(1.0f);

                Gl.glPopMatrix();
            }
        }
Esempio n. 3
0
        // --- Callbacks ---
        #region Display()
        private static void Display()
        {
            Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);

            Gl.glPushMatrix();
            Gl.glRotatef(20.0f, 1.0f, 0.0f, 0.0f);

            Gl.glPushMatrix();
            Gl.glTranslatef(-0.75f, 0.5f, 0.0f);
            Gl.glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
            Glut.glutSolidTorus(0.275, 0.85, 15, 15);
            Gl.glPopMatrix();

            Gl.glPushMatrix();
            Gl.glTranslatef(-0.75f, -0.5f, 0.0f);
            Gl.glRotatef(270.0f, 1.0f, 0.0f, 0.0f);
            Glut.glutSolidCone(1.0, 2.0, 15, 15);
            Gl.glPopMatrix();

            Gl.glPushMatrix();
            Gl.glTranslatef(0.75f, 0.0f, -1.0f);
            Glut.glutSolidSphere(1.0, 15, 15);
            Gl.glPopMatrix();
            Gl.glPopMatrix();
            Gl.glFlush();
        }
Esempio n. 4
0
        static void Redraw()
        {
            Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
            Gl.glPushMatrix();

            Axis3D.DrawAxis();

            FigureMotion();

            // Установка материала шара
            Gl.glLightfv(Gl.GL_LIGHT0, Gl.GL_POSITION, light1);
            Gl.glLightfv(Gl.GL_LIGHT1, Gl.GL_POSITION, light2);
            Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_AMBIENT, ambient);
            Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_DIFFUSE, diffuse);
            Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_SPECULAR, specular);
            Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_EMISSION, emission);
            Gl.glMaterialf(Gl.GL_FRONT, Gl.GL_SHININESS, shininess);

            // Отрисовка шара
            Glut.glutSolidSphere(3.0, 50, 50); // шар с радиусом 3

            Gl.glPopMatrix();
            Glut.glutSwapBuffers(); // Переключение буфферов отрисовки

            CalculateNewFigureSize();
        }
Esempio n. 5
0
        /// <summary>
        ///     Draws the scene.
        /// </summary>
        private static void Render()
        {
            Gl.glColor3f(0.4f, 1.0f, 0.4f);
            Glut.glutSolidSphere(0.6, 12, 12);

            Gl.glPushMatrix();
            Gl.glTranslatef(0.6f, 0.35f, 0.6f);
            Gl.glColor3f(1.0f, 0.7f, 0.7f);
            Glut.glutSolidCube(0.2);
            Gl.glPopMatrix();

            Gl.glPushMatrix();
            Gl.glTranslatef(0.7f, 0.85f, 0.7f);
            Gl.glRotatef(angle2 += 1, 0.0f, 1.0f, 0.0f);
            Gl.glTranslatef(0.0f, -0.2f, 0.0f);
            Gl.glRotatef(-90, 1.0f, 0.0f, 0.0f);
            Gl.glColor3f(1.0f, 1.0f, 0.4f);
            Glut.glutWireCone(0.2, 0.4, 8, 8);
            Gl.glPopMatrix();

            Gl.glPushMatrix();
            Gl.glTranslatef(-0.9f, -0.9f, -0.1f);
            Gl.glRotatef(90, -0.5f, 0.5f, 0.15f);
            Gl.glRotatef(angle2, 0.0f, 0.0f, 1.0f);
            Gl.glColor3f(1.0f, 0.4f, 1.0f);
            Glut.glutWireTorus(0.2, 0.5, 8, 8);
            Gl.glPopMatrix();
        }
Esempio n. 6
0
 protected override void Particular()
 {
     Gl.glColor3d(1, 1, 1);
     Gl.glBindTexture(Gl.GL_TEXTURE_2D, GlUtils.Texture("WOOD1"));
     Gl.glPushMatrix();
     Gl.glTranslated(0.8f * 30, 0, 0);
     GlUtils.GambarBangun(0.8f * 30, 0.6f * 30, 0.4f * 30);
     Gl.glTranslated(0, 0, 0.45f * 30);
     GlUtils.GambarBangun(0.8f * 30, 0.6f * 30, 0.05f * 30);
     Gl.glTranslated(-0.7f * 30, 0, 0.06f * 30);
     Gl.glColor3d(.5, .5, .5);
     Glut.glutSolidSphere(0.05f * 30, 10, 10);
     Gl.glColor3d(1, 1, 1);
     Gl.glPopMatrix();
     Gl.glPushMatrix();
     Gl.glTranslated(-0.8f * 30, 0, 0);
     GlUtils.GambarBangun(0.8f * 30, 0.6f * 30, 0.4f * 30);
     Gl.glTranslated(0, 0, 0.45f * 30);
     GlUtils.GambarBangun(0.8f * 30, 0.6f * 30, 0.05f * 30);
     Gl.glTranslated(0.7f * 30, 0, 0.06f * 30);
     Gl.glColor3d(.5, .5, .5);
     Glut.glutSolidSphere(0.05f * 30, 10, 10);
     Gl.glPopMatrix();
     height = 36;
     Gl.glColor3d(1, 1, 1);
     Gl.glBindTexture(Gl.GL_TEXTURE_2D, 0);
 }
Esempio n. 7
0
 private static void RenderSphere(float x, float y, float z)
 {
     Gl.glPushMatrix();
     Gl.glTranslatef(x, y, z);
     Glut.glutSolidSphere(0.4, 16, 16);
     Gl.glPopMatrix();
 }
Esempio n. 8
0
        private void DrawLever()
        {
            int leverHeight = 70;

            textureLoader.LoadTextureForModel("metal.jpg");
            uint metalTexture = textureLoader.GetTextureObj();

            Gl.glEnable(Gl.GL_TEXTURE_2D);
            Gl.glEnable(Gl.GL_TEXTURE_GEN_S);
            Gl.glEnable(Gl.GL_TEXTURE_GEN_T);
            Gl.glTexGeni(Gl.GL_S, Gl.GL_TEXTURE_GEN_MODE, Gl.GL_SPHERE_MAP);
            Gl.glTexGeni(Gl.GL_T, Gl.GL_TEXTURE_GEN_MODE, Gl.GL_SPHERE_MAP);
            Gl.glBindTexture(Gl.GL_TEXTURE_2D, metalTexture);

            Gl.glPushMatrix();
            Gl.glRotated(90, 1, 0, 0);
            Gl.glTranslated(0, 0, -leverHeight);
            Glut.glutSolidCylinder(1, leverHeight, 16, 16);

            // отключаем режим текстурирования
            Gl.glDisable(Gl.GL_TEXTURE_2D);
            Gl.glDisable(Gl.GL_TEXTURE_GEN_S);
            Gl.glDisable(Gl.GL_TEXTURE_GEN_T);
            Gl.glDisable(Gl.GL_TEXTURE_2D);

            Gl.glColor3d(1, 0.01, 0.01);
            Glut.glutSolidSphere(2, 16, 16);
            Gl.glPopMatrix();
        }
Esempio n. 9
0
        static void OnDisplay()
        {
            Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
            Gl.glLoadIdentity();
            Glu.gluLookAt(eye_x, eye_y, eye_z, 0, -10, 0, 1, 0, 0);
            Gl.glRotated(aX, 1, 0, 0);
            Gl.glRotated(aY, 0, 1, 0);
            Gl.glRotated(aZ, 0, 0, 1);
            Gl.glTranslated(1.5, 0, 0);

            Gl.glEnable(Gl.GL_TEXTURE_2D);

            //Glu.gluQuadricTexture();

            //основание
            Gl.glTranslated(-1.5, 0, 0);
            Glut.glutSolidSphere(1.1, 50, 50);

            //тело
            Gl.glTranslated(1.6, 0, 0);
            Glut.glutSolidSphere(0.75, 50, 50);

            //голова
            Gl.glTranslated(1.1, 0, 0);
            Glut.glutSolidSphere(0.55, 50, 50);

            //правая рука
            Gl.glTranslated(-1, 0, 0);
            Gl.glRotated(20, 0, 1, 0);
            Glut.glutSolidCylinder(0.05, 2.5, 50, 50);

            //левая рука
            Gl.glRotated(-140, 0, -1, 0);
            Glut.glutSolidCylinder(0.05, 2.5, 50, 50);

            //шляпа
            Gl.glTranslated(-1.3, 0, 0.47);
            Gl.glRotated(290, 0, 1, 0);
            Glut.glutSolidCone(0.5, 0.75, 50, 50);

            //нос
            Gl.glTranslated(0, 0.3, -0.4);
            Gl.glRotated(275, 1, 0, 0);
            Glut.glutSolidCone(0.07, 0.75, 50, 50);

            //правый глаз
            Gl.glTranslated(-0.2, -0.25, 0.15);
            Glut.glutSolidSphere(0.05, 50, 50);

            //левый глаз
            Gl.glTranslated(0.4, 0, 0);
            Glut.glutSolidSphere(0.05, 50, 50);

            //рот
            Gl.glTranslated(-0.47, 0.4, 0.0175);
            Gl.glRotated(90, 0, 1, 0);
            Glut.glutSolidCylinder(0.05, 0.5, 50, 50);

            Glut.glutSwapBuffers();
        }
Esempio n. 10
0
        protected override void Particular()
        {
            Gl.glColor3d(0.2, 0.3, 0);
            Gl.glRotated(90, 1, 0, 0);
            Gl.glRotated(45, 0, 0, 1);
            Gl.glScaled(1, 1, 0.4);
            Glut.glutSolidTorus(0.22f * 30, 0.22f * 30, 40, 4);
            Gl.glColor3d(0.3, 1, 0.2);
            Gl.glScaled(1, 1, 1.5);
            Glut.glutSolidTorus(0.15f * 30, 0.15f * 30, 40, 40);

//			}
//			else if(objStruct.angle==2)
//			{
//				Glut.glutSolidTorus(0.18,0.18,40,40);
//				Gl.glColor3d(1-temp[0],1-temp[1],1-temp[2]);
//				Glut.glutSolidTorus(0.18,0.18,40,3);
//			}

            Gl.glColor3d(0.2, 0.5, 0.3);
            Gl.glScaled(1, 1, 1);
            Glut.glutSolidSphere(0.1f * 30, 20, 20);
            height = 6.6;
            Gl.glColor3d(1, 1, 1);
        }
Esempio n. 11
0
        /// <summary>
        ///     Draws the scene.
        /// </summary>
        private static void Render()
        {
            Gl.glLightfv(Gl.GL_LIGHT0, Gl.GL_POSITION, light0Position);

            Gl.glPushMatrix();
            Gl.glColor3f(0.4f, 1.0f, 0.4f);
            Gl.glTranslatef(0.0f, 0.0f, 2.5f);
            Glut.glutSolidSphere(0.5, 12, 12);

            Gl.glTranslatef(0.5f, 0.0f, -0.7f);
            Gl.glColor3f(1.0f, 0.4f, 0.4f);
            Glut.glutSolidCube(0.3);

            Gl.glTranslatef(-0.5f, 0.0f, -0.2f);
            Gl.glRotatef(-90, 1.0f, 0.0f, 0.0f);
            Gl.glColor3f(1.0f, 1.0f, 0.4f);
            Glut.glutSolidCone(0.3, 0.6, 8, 8);
            Gl.glPopMatrix();

            Gl.glPushMatrix();
            Gl.glTranslatef(0.2f, 0.3f, -2.0f);
            Gl.glColor3f(0.9f, 0.4f, 0.9f);
            Glut.glutWireTorus(0.3f, 0.8f, 8, 8);
            Gl.glPopMatrix();
        }
Esempio n. 12
0
        private void Carousel()
        {
            Gl.glPushMatrix();

            Gl.glRotated(-90, 1f, 0f, 0f);
            Gl.glTranslated(0f, 0.0f, -1.0f);

            Gl.glColor4d(0.5f, 0.5f, 0.5f, 0.2f);
            //center

            Glut.glutSolidCylinder(0.4f, 1.2f, 20, 1);

            //top
            Gl.glColor3ub(255, 200, 220);
            Gl.glPushMatrix();
            Gl.glTranslated(0f, 0f, 1.2f);
            Glut.glutSolidTorus(0.1f, 1.0f, 20, 9);
            Glut.glutSolidCylinder(1f, 0.05f, 20, 1);
            Gl.glColor3ub(200, 250, 255);
            Glut.glutSolidCone(0.8f, 1.1f, 20, 20);
            Gl.glTranslated(0f, 0f, 1.1f);
            Gl.glColor3ub(255, 200, 220);
            Glut.glutSolidSphere(0.1f, 10, 10);
            Gl.glPopMatrix();

            Gl.glPopMatrix();
        }
Esempio n. 13
0
        public override void Draw()
        {
            Gl.glPushMatrix();
            Gl.glTranslated(this.Position.X, this.Position.Y, this.Position.Z);
            Gl.glRotated(this.Angle.X, 1, 0, 0);
            Gl.glRotated(this.Angle.Y, 0, 1, 0);
            Gl.glRotated(this.Angle.Z, 0, 0, 1);

            DrawingService.PickTexture(TextureNames.Metal);
            DrawingService.GenerateTexture();
            Glut.glutSolidSphere(0.25 * this.Size, 48, 48);
            Gl.glPopMatrix();
            DrawingService.DeactivateGeneration();

            foreach (var obj in this.FixtureObjects)
            {
                //obj.Position += this.Position;
                //Point3d n = new Point3d(0, 0, 0);
                //bool flag = obj.Position.Equals(n);
                //if (flag)
                //    obj.Position += this.Position;

                obj.Draw();

                //if (flag)
                //    obj.Position -= this.Position;
                //obj.Position -= this.Position;
            }
        }
Esempio n. 14
0
        //Рисование снеговика, вокруг которого вращается камера
        static void drawSnowMan()
        {
            Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
            // установить камеру
            Gl.glLoadIdentity();
            vec3 cameraLook = cameraPos + cameraFront;

            Glu.gluLookAt(cameraPos.x, cameraPos.y, cameraPos.z, cameraLook.x, cameraLook.y, cameraLook.z,
                          cameraUp.x, cameraUp.y, cameraUp.z);

            Glu.gluLookAt(camX, camY, camZ, 0.0, 0.0, 0.0, 0.0, camUpY, 0.0);

            Gl.glColor3f(1.0f, 1.0f, 1.0f);
            // тело снеговика
            Gl.glTranslatef(0.0f, 0.75f, 0.0f);
            Glut.glutSolidSphere(0.75f, 20, 20);
            // голова снеговика
            Gl.glTranslatef(0.0f, 1.0f, 0.0f);
            Glut.glutSolidSphere(0.25f, 20, 20);
            // глаза снеговика
            Gl.glPushMatrix();
            Gl.glColor3f(0.0f, 0.0f, 0.0f);
            Gl.glTranslatef(0.05f, 0.10f, 0.18f);
            Glut.glutSolidSphere(0.05f, 10, 10);
            Gl.glTranslatef(-0.1f, 0.0f, 0.0f);
            Glut.glutSolidSphere(0.05f, 10, 10);
            Gl.glPopMatrix();
            // нос снеговика
            Gl.glColor3f(1.0f, 0.5f, 0.5f);
            Gl.glRotatef(0.0f, 1.0f, 0.0f, 0.0f);
            Glut.glutSolidCone(0.08f, 0.5f, 10, 2);
            //Gl.glPopMatrix();
            Gl.glFlush();
            Glut.glutSwapBuffers();
        }
Esempio n. 15
0
        public override void Draw(bool select = false)
        {
            Gl.glPushMatrix();
            if (select)
            {
                Gl.glColor3fv(MathUtils.GetVector3Array(Color));
            }
            else if (isSelected)
            {
                Gl.glColor3fv(MathUtils.GetVector3Array(new Vector(1, 1, 1)));
            }
            else
            {
                Gl.glColor3fv(MathUtils.GetVector3Array(new Vector(1, 0, 1)));
            }
            Gl.glTranslatef(Traslation.x, Traslation.y, Traslation.z);
            if (Wireframe)
            {
                Glut.glutWireSphere(Radius, 16, 16);
            }
            else
            {
                Glut.glutSolidSphere(Radius, 16, 16);
            }

            Gl.glPopMatrix();
        }
Esempio n. 16
0
 protected override void dessine_toi()
 {
     Gl.glPushMatrix();
     Gl.glTranslatef((float)Position_objet_X, (float)Position_objet_Y, 0);
     Glut.glutSolidSphere(1, 20, 20);
     Gl.glPopMatrix();
 }
Esempio n. 17
0
        /// <summary>
        ///
        /// </summary>
        public void drawParticles()
        {
            Camera cam = Camera.getCurrentActiveCamera();

            this.ActiveParticles = 0;
            bool maxParticlesReached = false;

            foreach (Particle p in this.particleList)
            {
                if (p.Alive)
                {
                    this.ActiveParticles++;

                    Gl.glPushMatrix();

                    Gl.glTranslated(cam.Following.Position.Px + p.Position.Px, p.Position.Py, cam.Following.Position.Pz + p.Position.Pz);
                    Gl.glRotated(Utilities.toDegrees(cam.Following.Angle) + 90.0, 0.0, 1.0, 0.0);

                    Gl.glColor3d(1.0, 1.0, 1.0);

                    /// TODO: Deveria estar no draw da classe Particle já que ela herda de ThreeDObject
                    if (this.TypeOfParticle == ParticleType.Rain)
                    {
                        Gl.glBegin(Gl.GL_QUADS);
                        Gl.glTexCoord2d(1.0, 1.0);
                        Gl.glVertex3d(0.001, -0.1, 0.0);

                        Gl.glTexCoord2d(1.0, 0.0);
                        Gl.glVertex3d(-0.001, -0.1, 0.0);

                        Gl.glTexCoord2d(0.0, 0.0);
                        Gl.glVertex3d(-0.001, 0.1, 0.0);

                        Gl.glTexCoord2d(0.0, 1.0);
                        Gl.glVertex3d(0.001, 0.1, 0.0);
                        Gl.glEnd();
                    }
                    else
                    {
                        Glut.glutSolidSphere(0.02, 10, 10);
                    }

                    p.Position.Py -= p.Velocity;

                    Gl.glPopMatrix();
                }

                if (this.ActiveParticles >= this.CurrentMaxActiveParticles || this.ActiveParticles >= this.MaxParticles)
                {
                    maxParticlesReached = true;
                    break;
                }
            }

            if (!maxParticlesReached)
            {
                this.reviveParticles();
            }
        }
Esempio n. 18
0
 static void Bola()
 {
     Gl.glPushMatrix();
     Gl.glColor3f(0.803922f, 0.521569f, 0.247059f);
     Gl.glTranslatef(tx, ty, tz);
     Glut.glutSolidSphere(1.0f, 200, 200);
     Gl.glPopMatrix();
 }
Esempio n. 19
0
 private void DrawSphere(Point point)
 {
     Gl.glColor3d(100, 0, 100);
     //Gl.glColor3d(point.X, point.Y, point.Z);
     Gl.glTranslated(point.X, point.Y, point.Z);
     Glut.glutSolidSphere(0.15f, 5, 5);
     Gl.glTranslated(-point.X, -point.Y, -point.Z);
 }
Esempio n. 20
0
        static void Display()
        {
            Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
            Gl.glMatrixMode(Gl.GL_MODELVIEW);
            Gl.glPushMatrix();

            Gl.glBegin(Gl.GL_LINES);
            Gl.glColor3f(0.0f, 1.0f, 0.0f);     // ось x
            Gl.glVertex3f(0f, 0f, 0f);
            Gl.glVertex3f(14f, 0f, 0f);

            Gl.glColor3f(1.0f, 0.0f, 0.0f);     // ось y
            Gl.glVertex3f(0f, 0f, 0f);
            Gl.glVertex3f(0f, 14f, 0f);

            Gl.glColor3f(0.0f, 0.0f, 1.0f);     // ось z
            Gl.glVertex3f(0f, 0f, 0f);
            Gl.glVertex3f(0f, 0f, 14f);
            Gl.glEnd();

            Gl.glPushMatrix();
            Gl.glRotatef(_angleLight1, 0f, 0f, 1f);
            Gl.glLightfv(Gl.GL_LIGHT0, Gl.GL_POSITION, lpt);
            Gl.glPopMatrix();

            Gl.glPushMatrix();
            Gl.glTranslatef(0f, 0f, 5f);
            Gl.glScalef(2f, 2f, 2f);
            Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_AMBIENT, no_mat);
            Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_DIFFUSE, mat_diffuse);
            Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_SPECULAR, no_mat);
            Gl.glMaterialf(Gl.GL_FRONT, Gl.GL_SHININESS, no_shininess);
            Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_EMISSION, no_mat);
            Glut.glutSolidCone(1, 2, 50, 50);
            Gl.glPopMatrix();

            Gl.glPushMatrix();
            Gl.glRotatef(_angleLight1, 0f, 1f, 0f);
            Gl.glLightfv(Gl.GL_LIGHT0, Gl.GL_POSITION, rpt);
            Gl.glPopMatrix();

            Gl.glPushMatrix();
            Gl.glTranslatef(6f, 0f, 0f);
            Gl.glScalef(2f, 2f, 2f);
            Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_AMBIENT, mat_ambient);
            Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_DIFFUSE, mat_diffuse);
            Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_SPECULAR, mat_specular);
            Gl.glMaterialf(Gl.GL_FRONT, Gl.GL_SHININESS, no_shininess);
            Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_EMISSION, mat_emission);
            Glut.glutSolidSphere(1.0, 50, 50);
            Gl.glPopMatrix();

            Glut.glutSwapBuffers();

            // вращение
            _angleLight1 += 1f;
            _angleLight2 += 1.5f;
        }
Esempio n. 21
0
        // --- Callbacks ---
        #region Display()
        /// <summary>
        ///     <para>
        ///         Draw a sphere in a diamond-shaped section in the middle of a window with 2
        ///         torii.
        ///     </para>
        /// </summary>
        private static void Display()
        {
            Gl.glClear(Gl.GL_STENCIL_BUFFER_BIT);

            // create a diamond shaped stencil area
            Gl.glMatrixMode(Gl.GL_PROJECTION);
            Gl.glPushMatrix();
            Gl.glLoadIdentity();
            Gl.glOrtho(-3.0, 3.0, -3.0, 3.0, -1.0, 1.0);
            Gl.glMatrixMode(Gl.GL_MODELVIEW);
            Gl.glPushMatrix();
            Gl.glLoadIdentity();

            // Disable color buffer update.
            Gl.glColorMask(0, 0, 0, 0);
            Gl.glDisable(Gl.GL_DEPTH_TEST);
            Gl.glStencilFunc(Gl.GL_ALWAYS, 0x1, 0x1);
            Gl.glStencilOp(Gl.GL_REPLACE, Gl.GL_REPLACE, Gl.GL_REPLACE);

            Gl.glBegin(Gl.GL_QUADS);
            Gl.glVertex3f(-1.0f, 0.0f, 0.0f);
            Gl.glVertex3f(0.0f, 1.0f, 0.0f);
            Gl.glVertex3f(1.0f, 0.0f, 0.0f);
            Gl.glVertex3f(0.0f, -1.0f, 0.0f);
            Gl.glEnd();
            Gl.glPopMatrix();
            Gl.glMatrixMode(Gl.GL_PROJECTION);
            Gl.glPopMatrix();
            Gl.glMatrixMode(Gl.GL_MODELVIEW);

            // Enable color buffer update.
            Gl.glColorMask(1, 1, 1, 1);
            Gl.glEnable(Gl.GL_DEPTH_TEST);
            Gl.glStencilOp(Gl.GL_KEEP, Gl.GL_KEEP, Gl.GL_KEEP);

            Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);

            // draw blue sphere where the stencil is 1
            Gl.glStencilFunc(Gl.GL_EQUAL, 0x1, 0x1);
            Gl.glCallList(BLUEMAT);
            Glut.glutSolidSphere(0.5, 15, 15);

            // draw the tori where the stencil is not 1
            Gl.glStencilFunc(Gl.GL_NOTEQUAL, 0x1, 0x1);
            Gl.glPushMatrix();
            Gl.glRotatef(45.0f, 0.0f, 0.0f, 1.0f);
            Gl.glRotatef(45.0f, 0.0f, 1.0f, 0.0f);
            Gl.glCallList(YELLOWMAT);
            Glut.glutSolidTorus(0.275, 0.85, 15, 15);
            Gl.glPushMatrix();
            Gl.glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
            Glut.glutSolidTorus(0.275, 0.85, 15, 15);
            Gl.glPopMatrix();
            Gl.glPopMatrix();

            Gl.glFlush();
        }
Esempio n. 22
0
 private static void DrawSphere()
 {
     Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_AMBIENT, mat3_amb);
     Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_DIFFUSE, mat3_dif);
     Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_SPECULAR, mat3_spec);
     Gl.glMaterialf(Gl.GL_FRONT, Gl.GL_SHININESS, mat3_shiness);
     Gl.glPushMatrix();
     Gl.glTranslatef(0.75f, 0.0f, -11.0f);
     Gl.glRotated(20.0, 1.0, 0.0, 0.0);
     Glut.glutSolidSphere(1.0, 15, 15);
     Gl.glPopMatrix();
 }
Esempio n. 23
0
        private void simpleOpenGlControl1_Paint(object sender, PaintEventArgs e)
        {
            Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);

            Gl.glMatrixMode(Gl.GL_MODELVIEW);
            Gl.glLoadIdentity();

            Glu.gluLookAt(0.0, 0.0, 50.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);



            float[] mat_ambient   = new float[] { 0.0f, 0.1f, 0.0f, 1.0f }; //偏綠色材質
            float[] mat_diffuse   = new float[] { 0.0f, 0.7f, 0.0f, 1.0f }; //偏綠色材質
            float[] mat_specular  = new float[] { 0.9f, 0.9f, 0.9f, 1.0f };
            float   mat_shininess = 32.0f;                                  //閃亮係數的數值

            Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_AMBIENT, mat_ambient);       //設定材質的環境光反射係數
            Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_DIFFUSE, mat_diffuse);       //設定材質的散射光反射係數
            Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_SPECULAR, mat_specular);     //設定材質的鏡射光反射係數
            Gl.glMaterialf(Gl.GL_FRONT, Gl.GL_SHININESS, mat_shininess);    //設定材質的閃亮係數



            Gl.glColor3d(0.0, 1.0, 0.0);
            Glut.glutSolidSphere(2.0, 20, 20);

            // Draw the first electron
            Gl.glColor3d(0.0, 0.0, 1.0);
            Gl.glPushMatrix();
            Gl.glRotated(angle1, 1.0, 1.0, 0.0);
            Gl.glTranslated(0.0, 0.0, 10.0);
            Glut.glutSolidSphere(1.0, 20, 20);
            Gl.glPopMatrix();

            // Draw the second electron
            Gl.glColor3d(1.0, 1.0, 0.0);
            Gl.glPushMatrix();
            Gl.glRotated(angle2, -1.0, 1.0, 0.0);
            Gl.glTranslated(0.0, 0.0, 10.0);
            Glut.glutSolidSphere(1.0, 20, 20);
            Gl.glPopMatrix();


            // Draw the third electron
            Gl.glEnable(Gl.GL_COLOR_MATERIAL); //打開色彩材質的功能 讓glColor3d的功能出現
            Gl.glColor3d(1.0, 0.0, 1.0);
            Gl.glPushMatrix();
            Gl.glRotated(angle3, 0.0, 1.0, 0.0);
            Gl.glTranslated(0.0, 0.0, 10.0);
            Glut.glutSolidSphere(1.0, 20, 20);
            Gl.glPopMatrix();
            Gl.glDisable(Gl.GL_COLOR_MATERIAL); //關掉色彩材質的功能
        }
Esempio n. 24
0
 private static void Sphere(int texture)
 {
     if (texturing)
     {
         Gl.glBindTexture(Gl.GL_TEXTURE_2D, texture);
         Glut.glutSolidSphere(RI, lod, lod);
     }
     else
     {
         Glut.glutSolidSphere(RI, lod, lod);
     }
 }
Esempio n. 25
0
        static void Desenha()
        {
            Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);

            //-------------------------Pedra Direita--------------------------------------

            Gl.glPushMatrix();//salva para mover so estes objetos

            Gl.glTranslated(_pedraDireitaX, _pedraDireitaY, 0f);

            Gl.glColor3f(0.5f, 0.35f, 0.05f);

            Glut.glutSolidSphere(0.7, 5, 10);


            Gl.glPopMatrix(); //apaga da pilha

            //---------------------------------------------------------------------

            if (_duasPedras)
            {
                //-------------------------Pedra Esquerda--------------------------------------

                Gl.glPushMatrix();//salva para mover so estes objetos

                Gl.glTranslated(_pedraEsquerdaX, _pedraEsquerdaY, 0f);

                Gl.glColor3f(0.5f, 0.35f, 0.05f);

                Glut.glutSolidSphere(0.7, 5, 10);


                Gl.glPopMatrix(); //apaga da pilha

                //---------------------------------------------------------------------
            }

            //---------------------Bola Rolando--------------------------------------

            Gl.glPushMatrix();//salva para mover so estes objetos
            Gl.glTranslatef(_bolaX, -7.0f, 0.0f);
            Gl.glRotatef(90, 0.0f, 0.2f, 0.0f);
            Gl.glColor3f(1.0f, 0.666667f, 0.666667f);
            Gl.glRotatef(_rot, 0.0f, 0.0f, 0.2f);
            Glut.glutSolidSphere(0.5, 10, 10);

            //-----------------------------------------------------------------------

            Gl.glPopMatrix(); //apaga da pilha

            Glut.glutSwapBuffers();
        }
Esempio n. 26
0
        protected void renderLamp()
        {
            Gl.glGetBooleanv(Gl.GL_CULL_FACE, out cullFace);
            Gl.glDisable(Gl.GL_CULL_FACE);

            Glu.GLUquadric quadric;
            quadric = Glu.gluNewQuadric();

            Gl.glPushMatrix();
            Gl.glTranslated(0, 0, 0);
            #region cuerpo
//			Gl.glColor3d(1, 0, 0);
            //Gl.glColor3d(1, 0, 0);

            Gl.glPushMatrix();
            Gl.glTranslated(0, 25, 0);
            Gl.glRotated(-90, 1, 0, 0);
            Glu.gluCylinder(quadric, 5, 10, 10, 8, 10);
            Gl.glPopMatrix();
            #endregion cuerpo
            #region bombillo
            Gl.glPushMatrix();
            Gl.glTranslated(0, 25, 0);
            Gl.glRotated(90, 1, 0, 0);
            //Gl.glColor3d(.5,.5,.5);

            Glu.gluCylinder(quadric, 5, 5, 12, 8, 8);
            Gl.glPopMatrix();
            Gl.glBindTexture(Gl.GL_TEXTURE_2D, GlUtils.Texture("bulb"));
            Gl.glPushMatrix();

            Gl.glColor3d(1, 1, 1);
            Gl.glTranslated(0, 8, 0);
            Glut.glutSolidSphere(10, 8, 8);
            Gl.glPopMatrix();
            #endregion bombillo;
            Gl.glPushMatrix();
            Gl.glEnable(Gl.GL_BLEND);
            Gl.glColor3d(.98, .58, .35);
            Gl.glClipPlane(Gl.GL_CLIP_PLANE0, plano);
            Gl.glEnable(Gl.GL_CLIP_PLANE0);
            Gl.glLightModeli(Gl.GL_LIGHT_MODEL_TWO_SIDE, 1);
            Glu.gluSphere(quadric, 30, 15, 10);
            Gl.glLightModeli(Gl.GL_LIGHT_MODEL_TWO_SIDE, 0);
            Gl.glPopMatrix();
            Gl.glDisable(Gl.GL_CLIP_PLANE0);
            Gl.glPopMatrix();
            if (cullFace != Gl.GL_FALSE)
            {
                Gl.glEnable(Gl.GL_CULL_FACE);
            }
        }
Esempio n. 27
0
 private void CreateDisplayList()
 {
     // генерация дисплейног осписка
     DisplayListNom = Gl.glGenLists(1);
     float[] Color = { 1f, 0.7f, 0.7f, .5f };
     // начало создания списка
     Gl.glNewList(DisplayListNom, Gl.GL_COMPILE);
     // Gl.glColor3b(0, 0, 255);
     // Gl.glColor3d(0, 0, 255);
     Gl.glMaterialfv(Gl.GL_FRONT_AND_BACK, Gl.GL_AMBIENT_AND_DIFFUSE, Color);
     Glut.glutSolidSphere(0.01f, 10, 10);
     Gl.glEndList();
     // флаг - дисплейный список создан
     isDisplayList = true;
 }
Esempio n. 28
0
        protected override void Particular()
        {
            Gl.glBindTexture(Gl.GL_TEXTURE_2D, GlUtils.Texture("rose"));
            Gl.glRotated(90, 1, 0, 0);
            Gl.glRotated(45, 0, 0, 1);
            Gl.glScaled(1, 1, 0.4);
            Glut.glutSolidTorus(0.5f * 30, 0.5 * 30, 40, 4);

            Gl.glScaled(1, 1, 1.5);
            Glut.glutSolidTorus(0.3f * 30, 0.3f * 30, 40, 40);

            Gl.glScaled(1, 1, 1);
            Glut.glutSolidSphere(0.2f * 30, 20, 20);
            height = 6.6;
            Gl.glColor3d(1, 1, 1);
        }
Esempio n. 29
0
        private void jackPart()
        {
            Gl.glPushMatrix();
            Gl.glScaled(0.2, 0.2, 1.0);
            Glut.glutSolidSphere(1.0, 16, 16);
            Gl.glPopMatrix();

            Gl.glPushMatrix();
            Gl.glTranslated(0.0, 0.0, 1.0);
            Glut.glutSolidSphere(0.2, 16, 16);
            Gl.glPopMatrix();

            Gl.glPushMatrix();
            Gl.glTranslated(0.0, 0.0, -1.0);
            Glut.glutSolidSphere(0.2, 16, 16);
            Gl.glPopMatrix();
        }
Esempio n. 30
0
        protected override void DoRender()
        {
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            var camera = Matrix4.LookAt(0.0f, 3.5f, 8.0f, 0.0f, 3.5f, 0.0f, 0.0f, 1.0f, 0.0f);

            GL.LoadMatrix(ref camera);

            GL.Color4(Color4.Black);

            foreach (var particle in World.Particles)
            {
                GL.PushMatrix();
                GL.Translate(particle.Position);
                Glut.glutSolidSphere(0.1f, 20, 10);
                GL.PopMatrix();
            }
        }