Ejemplo n.º 1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="w"></param>
 /// <param name="h"></param>
 public void redimensionar(int w, int h)
 {
     Gl.glMatrixMode(Gl.GL_PROJECTION);
     Gl.glLoadIdentity();
     Glu.gluPerspective(Camera.getCurrentActiveCamera().FOV, Convert.ToDouble(AppState.Instance.Width) / Convert.ToDouble(AppState.Instance.Height), 1.0, 9999.0);
     Gl.glMatrixMode(Gl.GL_MODELVIEW);
 }
Ejemplo n.º 2
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();
            }
        }
Ejemplo n.º 3
0
        public override void draw()
        {
            if (this.Visible && Assets.Instance.Models.ContainsKey(this.ModelName))
            {
                ModelData modelo = Assets.Instance.Models[this.ModelName];

                if (this.ColisionArea.Visible)
                {
                    this.ColisionArea.drawArea(this.Position);
                }

                if (this.ToVisit && !this.Visited)
                {
                    Camera cam = Camera.getCurrentActiveCamera();

                    Gl.glEnable(Gl.GL_TEXTURE_2D);

                    Gl.glBindTexture(Gl.GL_TEXTURE_2D, Assets.Instance.Textures["Seta"]);

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

                    Gl.glBegin(Gl.GL_TRIANGLES);

                    Gl.glTexCoord2d(1, 1);
                    Gl.glVertex3d(0.5, 10.0, 0.0);

                    Gl.glTexCoord2d(0, 0);
                    Gl.glVertex3d(0.0, 9.0, 0.0);

                    Gl.glTexCoord2d(1, 0);
                    Gl.glVertex3d(-0.5, 10.0, 0.0);
                    Gl.glEnd();
                    Gl.glPopMatrix();

                    Gl.glBindTexture(Gl.GL_TEXTURE_2D, 0);
                }

                Gl.glDisable(Gl.GL_TEXTURE_2D);
                Gl.glPushMatrix();
                Gl.glTranslated(modelo.Translacao.Px, modelo.Translacao.Py, modelo.Translacao.Pz);
                Gl.glTranslated(this.Position.Px, this.Position.Py, this.Position.Pz);

                Gl.glRotated(modelo.Graus, modelo.Rotacao.Px, modelo.Rotacao.Py, modelo.Rotacao.Pz);
                Gl.glScaled(modelo.Escala.Px, modelo.Escala.Py, modelo.Escala.Pz);

                modelo.Model.Render();
                Gl.glPopMatrix();
                Gl.glEnable(Gl.GL_TEXTURE_2D);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        public void render()
        {
            this.clear();

            Camera.getCurrentActiveCamera().set();

            this.renderLighting();
            this.renderAtmosphere();
            this.renderMap();
            this.renderSceneObjects();

            this.displayMessageQueue();

            Glut.glutSwapBuffers();
        }
Ejemplo n.º 5
0
        public override void draw()
        {
            Camera cam = Camera.getCurrentActiveCamera();

            Gl.glPushMatrix();

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

            Gl.glEnable(Gl.GL_TEXTURE_2D);
            Gl.glEnable(Gl.GL_BLEND);
            Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA);
            Gl.glEnable(Gl.GL_ALPHA_TEST);
            Gl.glAlphaFunc(Gl.GL_GREATER, 0);

            Gl.glBindTexture(Gl.GL_TEXTURE_2D, Assets.Instance.Textures["Arvore1"]);

            Gl.glBegin(Gl.GL_QUADS);

            Gl.glNormal3d(0.0, 0.0, -1.0);

            Gl.glTexCoord2f(0, 0);
            Gl.glVertex3f(-3.0f, 0.0f, 0.0f);

            Gl.glTexCoord2f(1, 0);
            Gl.glVertex3f(3.0f, 0.0f, 0.0f);

            Gl.glTexCoord2f(1, 1);
            Gl.glVertex3f(3.0f, 6.0f, 0.0f);

            Gl.glTexCoord2f(0, 1);
            Gl.glVertex3f(-3.0f, 6.0f, 0.0f);
            Gl.glEnd();

            Gl.glDisable(Gl.GL_BLEND);
            Gl.glDisable(Gl.GL_ALPHA_TEST);

            Gl.glBindTexture(Gl.GL_TEXTURE_2D, 0);
            Gl.glDisable(Gl.GL_TEXTURE_2D);
            Gl.glPopMatrix();
        }
Ejemplo n.º 6
0
        //private void saveTour()
        //{
        //    if (this.CurrentTour.toVisit.Count > 0)
        //    {
        //        EasyTourismServices webService = new EasyTourismServices();

        //        List<WebService.ToVisit> tv = new List<WebService.ToVisit>();
        //        WebService.ToVisit[] tvArray;

        //        WebService.ToVisit t;

        //        /// TODO: Chuta logo para o Array[]!
        //        foreach (PointOfInterest p in this.CurrentTour.toVisit)
        //        {
        //            if (p.ToVisit && p.Visited)
        //            {
        //                t = new WebService.ToVisit();

        //                t.id = p.ID;
        //                t.visited = p.Visited;

        //                tv.Add(t);
        //            }
        //        }

        //        tvArray = new ToVisit[tv.Count];
        //        tv.CopyTo(tvArray);

        //        //webService.SaveTour("12345678-9012-3456-7890-123456789013", this.CurrentTour.tourID, tvArray);
        //    }
        //}

        private void timer(int valor)
        {
            if (this.Input.ExitingApplication)
            {
                if (AppState.Instance.SaveTour)
                {
                    this.Ws.save(ref this.tour, ref this.cartography);
                }

                Environment.Exit(0);
            }

            if (this.Input.SimulationSpeedChanged)
            {
                Messaging.Instance.Information.Enqueue(AppState.Instance.ResourceManager.GetString("SimulationSpeedChanged") + ": " + AppState.Instance.ResourceManager.GetString("SimulationSpeed" + AppState.Instance.CurrentSimulationSpeed.ToString()));
                this.Input.SimulationSpeedChanged = false;
            }

            #region Lidar com Input do Utilizador
            if (this.Input.keyPressed())
            {
                Camera cam = Camera.getCurrentActiveCamera();

                if (this.Input.isMoving())
                {
                    if (this.Input.TeclaW)
                    {
                        if (!this.ActiveTourist.collidesWithObjects(this.ActiveTourist.calculateNextPosition(Tourist.CharacterDirection.Front), this.collidible))
                        {
                            this.ActiveTourist.moveForward();
                            cam.moveForward();
                        }
                    }
                    else if (this.Input.TeclaS)
                    {
                        if (!this.ActiveTourist.collidesWithObjects(this.ActiveTourist.calculateNextPosition(Tourist.CharacterDirection.Back), this.collidible))
                        {
                            this.ActiveTourist.moveBackward();
                            cam.moveBackward();
                        }
                    }

                    if (this.Input.TeclaW || this.Input.TeclaS)
                    {
                        /**
                         *
                         */
                        String streetName = this.ActiveTourist.getCurrentRoad(this.Cartography.segments);

                        if (streetName.Length > 0)
                        {
                            Messaging.Instance.Information.Enqueue(streetName);
                        }

                        /**
                         *
                         */
                        this.ActiveTourist.visitedPointOfInterest(this.Cartography.pointsOfInterest);
                    }

                    if (this.Input.TeclaA)
                    {
                        this.ActiveTourist.moveLeft();
                        cam.moveLeft();
                    }

                    if (this.Input.TeclaD)
                    {
                        this.ActiveTourist.moveRight();
                        cam.moveRight();
                    }
                }

                if (this.Input.TeclaT)
                {
                    cam.lookUp();
                }

                if (this.Input.TeclaG)
                {
                    cam.lookDown();
                }

                if (this.Input.Tab)
                {
                    cam.mudarCamera();
                    this.Input.Tab = false;
                }

                if (this.Input.Plus)
                {
                    this.SoundManager.increaseVolume();
                    this.Input.Plus = false;
                }

                if (this.Input.Minus)
                {
                    this.SoundManager.decreaseVolume();
                    this.Input.Minus = false;
                }
            }
            #endregion

            if (!this.tourOver && this.ActiveTourist.checkVisitComplete(this.Cartography.pointsOfInterest))
            {
                Messaging.Instance.Information.Enqueue(AppState.Instance.ResourceManager.GetString("TourOver"));
                Messaging.Instance.Permanent.Add("");
                Messaging.Instance.Permanent.Add(AppState.Instance.ResourceManager.GetString("TourOverPressESC"));
                this.tourOver = true;
            }

            Messaging.Instance.stateCheck();
            AppState.Instance.clockForward();
            this.AtmosphericConditions.weatherStateCheck();

            Glut.glutPostRedisplay();
            Glut.glutTimerFunc(30, this.timer, valor);
        }