Пример #1
0
 public void Update(Vehicle car)
 {
     Target        = (car.GetPosition()) + car.GetVectorAdelante() * 30;
     OffsetForward = -33;
     UpdateCamera(GlobalConcepts.GetInstance().GetElapsedTime());
     CalculateAABB();
     Scene.GetInstance().HandleCollisions(this);
 }
Пример #2
0
        private TGCPlane SelectPlane(List <TGCPlane> planes, TGCVector3 testPoint)
        {
            GlobalConcepts g = GlobalConcepts.GetInstance();

            planes.Sort((x, y) => g.IsInFrontOf(testPoint, x).CompareTo(g.IsInFrontOf(testPoint, y)));
            planes.Reverse();
            return(planes[0]);
        }
Пример #3
0
        public override TGCVector3 GetShootRotation()
        {
            float      angle  = GlobalConcepts.GetInstance().AngleBetweenVectors(new TGCVector3(0, 0, 1), direction);
            TGCVector3 result = TGCVector3.Cross(direction, new TGCVector3(0, 0, 1));

            angle = (result.Y > 0) ? -angle : angle;
            return(new TGCVector3(FastMath.PI_HALF, angle, 0));
        }
Пример #4
0
 public void CreateMesh(TgcMesh mesh)
 {
     this.mesh = mesh;
     this.mesh.AutoTransform = false;
     this.Transform();
     this.mesh.Effect    = TgcShaders.loadEffect(GlobalConcepts.GetInstance().GetShadersDir() + "Portal.fx");
     this.mesh.Technique = "Portal";
 }
Пример #5
0
        public void Render()
        {
            SetTime(time += GlobalConcepts.GetInstance().GetElapsedTime());
            mesh.Effect.SetValue("time", time);

            //this.Rotate(TGCMatrix.RotationZ(0.05f));
            this.Transform();
            this.mesh.Render();
        }
        public float SetDirection(TGCVector3 output, TGCVector3 normal)
        {
            float      angle  = GlobalConcepts.GetInstance().AngleBetweenVectors(normal, output);
            TGCVector3 result = TGCVector3.Cross(output, normal);

            //por la regla de la mano derecha
            angle = (result.Y < 0) ? angle + FastMath.PI : angle;
            this.Girar(angle);
            return(angle);
        }
        public static CustomSprite CreateImage(string path, TGCVector2 scalation, float rotation, TGCVector2 translation)
        {
            CustomSprite sprite = new CustomSprite();

            sprite.Bitmap   = new CustomBitmap(GlobalConcepts.GetInstance().GetMediaDir() + "GUI\\HUB\\Velocimetro\\VelocimetroSinFlecha.png", GlobalConcepts.GetInstance().GetScreen());
            sprite.position = translation;
            sprite.rotation = rotation;
            sprite.scaling  = new TGCVector2(0, 0);
            return(sprite);
        }
 private void CreateSmoke()
 {
     this.smoke                    = new ParticleEmitter(GlobalConcepts.GetInstance().GetMediaDir() + "Texturas\\Humo\\humo.png", 10);
     this.smoke.Position           = this.GetPosition();
     this.smoke.MinSizeParticle    = 0.3f;
     this.smoke.MaxSizeParticle    = 0.5f;
     this.smoke.ParticleTimeToLive = 0.5f;
     this.smoke.CreationFrecuency  = 0.001f;
     this.smoke.Dispersion         = 20;
     this.smoke.Speed              = new TGCVector3(1, 1, 1);
 }
Пример #9
0
 public bool IsColliding(Vehicle car)
 {
     foreach (TGCVector3 point in car.mesh.BoundingBox.computeCorners())
     {
         if (!GlobalConcepts.GetInstance().IsInFrontOf(point, this.realPlane))
         {
             return(true);
         }
     }
     return((int)TgcCollisionUtils.classifyPlaneAABB(this.realPlane, car.mesh.BoundingBox) != 1);
 }
Пример #10
0
 private bool AnyIsInside(TGCVector3[] points, TGCVector3 minPoint, TGCVector3 maxPoint)
 {
     foreach (TGCVector3 point in points)
     {
         if (GlobalConcepts.GetInstance().IsBetweenXZ(point, minPoint, maxPoint))
         {
             return(true);
         }
     }
     return(false);
 }
Пример #11
0
 public void SetElapsedTime()
 {
     this.elapsedTime = GlobalConcepts.GetInstance().GetElapsedTime();
     if (this.deltaTiempoAvance.tiempoTranscurrido() != 0)
     {
         this.deltaTiempoAvance.acumularTiempo(this.elapsedTime);
     }
     if (this.deltaTiempoSalto.tiempoTranscurrido() != 0)
     {
         this.deltaTiempoSalto.acumularTiempo(this.elapsedTime);
     }
 }
Пример #12
0
 private void CheckTime()
 {
     if (!visible)
     {
         timer.acumularTiempo(GlobalConcepts.GetInstance().GetElapsedTime());
     }
     if (timer.tiempoTranscurrido() > 60f)
     {
         visible = true;
         timer.resetear();
     }
 }
Пример #13
0
        private void CreateSpark()
        {
            ParticleEmitter particle = new ParticleEmitter(GlobalConcepts.GetInstance().GetMediaDir() + "Texturas\\Chispas\\Chispas.png", 10);

            particle.Position           = this.GetPosition();
            particle.MinSizeParticle    = 1f;
            particle.MaxSizeParticle    = 2f;
            particle.ParticleTimeToLive = 0.5f;
            particle.CreationFrecuency  = 0.1f;
            particle.Dispersion         = 30;
            particle.Playing            = false;
            particle.Speed = new TGCVector3(1, 1, 1);
            this.spark     = new ParticleTimer(particle, 1f);
        }
        override protected void CreateParticle()
        {
            ParticleEmitter particle = new ParticleEmitter(GlobalConcepts.GetInstance().GetMediaDir() + "Texturas\\Explosion\\BolaHielo.png", 10);

            particle.Position           = this.GetPosition();
            particle.MinSizeParticle    = 1f;
            particle.MaxSizeParticle    = 2f;
            particle.ParticleTimeToLive = 0.5f;
            particle.CreationFrecuency  = 0.1f;
            particle.Dispersion         = 30;
            particle.Playing            = false;
            particle.Speed = new TGCVector3(1, 1, 1);
            this.particle  = new ParticleTimer(particle, 2f);
        }
Пример #15
0
 public void Render()
 {
     time += GlobalConcepts.GetInstance().GetElapsedTime();
     mesh.Effect.SetValue("time", time);
     if (time > 100f)
     {
         time = 0f;
     }
     this.particle.Render(GlobalConcepts.GetInstance().GetElapsedTime());
     this.weaponState.Update();
     if (this.IsInView(this.mesh))
     {
         this.weaponState.Render();
     }
 }
        public override void Init()
        {
            GlobalConcepts.GetInstance().SetMediaDir(this.MediaDir);
            GlobalConcepts.GetInstance().SetShaderDir(this.ShadersDir);
            //GlobalConcepts.GetInstance().SetInput(Input);
            GlobalConcepts.GetInstance().SetDispositivoDeAudio(this.DirectSound.DsDevice);
            GlobalConcepts.GetInstance().SetScreen(D3DDevice.Instance.Device);
            GlobalConcepts.GetInstance().SetFrustum(this.Frustum);
            gameModelState = new InitialMenu(this);
            gameModelState.Init();

            //this.Camara = camaraManagement;

            //manager = new ObjectManagement(MediaDir + "meshCreator\\meshes\\Habitacion\\Billetes\\Billete2\\Billete2-TgcScene.xml", camaraManagement);
        }
Пример #17
0
        private void Collide(Vehicle car)
        {
            //direccion a la que estoy yendo antes de chocar
            TGCVector3 directionOfCollision = car.GetDirectionOfCollision();
            TGCVector3 normal = GlobalConcepts.GetInstance().GetNormalPlane(this.realPlane);
            TGCVector3 output = normal + directionOfCollision * 2;
            float      angle  = car.SetDirection(output, normal);

            car.Crash(angle);

            while (IsColliding(car))
            {
                car.Translate(TGCMatrix.Translation(normal * 0.1f));
                car.Transform();
            }
        }
Пример #18
0
        public Life(TGCMatrix matrix)
        {
            TgcSceneLoader loader = new TgcSceneLoader();
            TgcScene       scene  = loader.loadSceneFromFile(GlobalConcepts.GetInstance().GetMediaDir() + "MeshCreator\\Meshes\\Otros\\Vida\\Vida-TgcScene.xml");

            mesh = scene.Meshes[0];
            mesh.AutoTransform = false;
            Transform();
            timer          = new Timer();
            mesh.Effect    = TgcShaders.loadEffect(GlobalConcepts.GetInstance().GetShadersDir() + "Vida.fx");
            mesh.Technique = "Normal";
            sound          = new SoundsManager();
            sound.AddSound(GetPosition(), 50, 0, "Duke\\DameIAmGood.wav", "Vida", false);
            mesh.AutoTransform = false;
            transformation     = matrix;
        }
Пример #19
0
 public void Render()
 {
     time += GlobalConcepts.GetInstance().GetElapsedTime();
     if (time > 100f)
     {
         time = 0f;
     }
     sound.GetSound("Vida").Position = GetPosition();
     CheckTime();
     transformation = TGCMatrix.RotationYawPitchRoll(GlobalConcepts.GetInstance().GetElapsedTime(), 0, 0) * transformation;
     Transform();
     mesh.Effect.SetValue("time", time);
     if (this.IsInView(this.mesh) && visible)
     {
         this.mesh.Render();
     }
 }
Пример #20
0
        protected void CreateMesh(string rutaAMesh, TGCVector3 posicionInicial)
        {
            TgcSceneLoader loader = new TgcSceneLoader();
            TgcScene       scene  = loader.loadSceneFromFile(rutaAMesh);

            this.mesh = scene.Meshes[0];
            this.mesh.AutoTransform = false;
            this.matrixs.SetScalation(TGCMatrix.Scaling(escaladoInicial));
            this.matrixs.Translate(TGCMatrix.Translation(posicionInicial));
            this.trasladoInicial = this.matrixs.GetTranslation();
            this.mesh.BoundingBox.transform(this.matrixs.GetTransformation());
            this.obb                      = new BoundingOrientedBox(this.mesh.BoundingBox);
            this.mesh.Effect              = TgcShaders.loadEffect(GlobalConcepts.GetInstance().GetShadersDir() + "EfectosVehiculo.fx");
            mesh.Technique                = "Iluminate";
            this.pointsOfCollision        = new PointsOfCollision(mesh.getVertexPositions());
            this.pointsOfCollision.medium = (mesh.BoundingBox.PMax + mesh.BoundingBox.PMin) * 0.5f;
        }
Пример #21
0
        public Weapon(TransformationMatrix matrix, TgcMesh mesh)
        {
            this.initialTransformation = matrix;
            this.matrix             = matrix;
            this.mesh               = mesh;
            this.mesh.AutoTransform = false;
            TGCMatrix m = this.matrix.GetTransformation();

            this.mesh.Transform = m;
            this.mesh.BoundingBox.transform(m);
            this.sphere = TgcBoundingSphere.computeFromPoints(this.mesh.BoundingBox.computeCorners()).toClass();
            this.sphere.setValues(this.sphere.Center, 0.3f);
            this.weaponState  = new InExhibition(this);
            this.soundManager = new SoundsManager();
            this.CreateParticle();
            mesh.Effect = TgcShaders.loadEffect(GlobalConcepts.GetInstance().GetShadersDir() + "Arma.fx");
            ExhibitionEffect();
        }
Пример #22
0
 private void UpdateSmoke()
 {
     if (this.life >= 50)
     {
         this.smoke.Playing = false;
         ChangeLights(new ColorValue(255, 255, 255));
     }
     else if (this.life < 50 && this.life >= 20)
     {
         this.smoke.Playing = true;
         ChangeLights(new ColorValue(255, 164, 32));
     }
     else
     {
         this.smoke.changeTexture(GlobalConcepts.GetInstance().GetMediaDir() + "Texturas\\Humo\\fuego.png");
         ChangeLights(new ColorValue(255, 0, 0));
     }
     this.smoke.Position = this.GetPosition();
 }
Пример #23
0
        private void Collide(TgcMesh elemento, Vehicle car)
        {
            //direccion a la que estoy yendo antes de chocar
            TGCVector3 directionOfCollision = car.GetDirectionOfCollision();
            TgcRay     ray = new TgcRay();

            ray.Origin    = car.GetLastPosition();
            ray.Direction = directionOfCollision;
            //interseco el rayo con el aabb, para conocer un punto del plano con el que colisione
            TgcBoundingAxisAlignBox.Face[] faces;
            faces = elemento.BoundingBox.computeFaces();
            TGCPlane   plane  = this.CreatePlane(ray, faces, car.GetLastPosition());
            TGCVector3 normal = GlobalConcepts.GetInstance().GetNormalPlane(plane);
            TGCVector3 output = normal + directionOfCollision * 2;
            float      angle  = car.SetDirection(output, normal);

            car.Crash(angle);

            while (TgcCollisionUtils.testObbAABB(car.GetTGCBoundingOrientedBox(), elemento.BoundingBox))
            {
                car.Translate(TGCMatrix.Translation(normal));
                car.Transform();
            }
        }
Пример #24
0
 public bool IsInto(TGCVector3 minPoint, TGCVector3 maxPoint)
 {
     return(GlobalConcepts.GetInstance().IsBetweenXZ(this.GetPosition(), minPoint, maxPoint));
 }
 public override bool GoTo(Section section)
 {
     return(GlobalConcepts.GetInstance().IsBetweenXZ(targetPortal.GetPosition(), section.GetPuntoMinimo(), section.GetPuntoMaximo()));
 }
Пример #26
0
 public bool IsInView(TgcMesh mesh)
 {
     this.Transform();
     return(TgcCollisionUtils.classifyFrustumAABB(GlobalConcepts.GetInstance().GetFrustum(), mesh.BoundingBox) != 0);
 }
 public bool Contains(TGCVector3 position)
 {
     return(GlobalConcepts.GetInstance().IsBetweenXZ(position, minPoint, maxPoint));
 }
Пример #28
0
 public bool IsColliding(Weapon weapon)
 {
     //return TgcCollisionUtils.classifyPointPlane(weapon.GetPosition(), this.realPlane) == 0;
     return(!GlobalConcepts.GetInstance().IsInFrontOf(weapon.GetPosition(), realPlane));
 }
Пример #29
0
 public Plane(TGCVector3 minPoint, TGCVector3 maxPoint, TGCVector3 orientation, string fileName, float UCoordinate, float VCoordinate)
 {
     orientation.Normalize();
     this.plane = new TgcPlane(new TGCVector3(0, 0, 0), new TGCVector3(0, 0, 0), this.GetPlaneOrientation(orientation), TgcTexture.createTexture(GlobalConcepts.GetInstance().GetMediaDir() + "MeshCreator\\Meshes\\" + fileName), UCoordinate, VCoordinate);
     this.plane.setExtremes(minPoint, maxPoint);
     this.plane.updateValues();
     this.mesh          = this.plane.toMesh("plane");
     mesh.AutoTransform = false;
     //negrada atomica
     InvertNormals(orientation);
     this.realPlane = TGCPlane.FromPointNormal(minPoint, orientation);
     mesh.Effect    = TgcShaders.Instance.TgcMeshPointLightShader;
     mesh.Technique = "DIFFUSE_MAP";
 }
Пример #30
0
 private bool IsInView()
 {
     return(TgcCollisionUtils.classifyFrustumAABB(GlobalConcepts.GetInstance().GetFrustum(), this.plane.toMesh("plane").BoundingBox) != 0);
 }