Ejemplo n.º 1
0
        /// /////////////////////////////////////////////////////////////////////
        /// ////////////////////////////INIT/////////////////////////////////////
        /// /////////////////////////////////////////////////////////////////////

        public void init(string MediaDir, string shaderDir, TgcCamera camara)
        {
            var d3dDevice = D3DDevice.Instance.Device;

            resolucionX = d3dDevice.PresentationParameters.BackBufferWidth;
            resolucionY = d3dDevice.PresentationParameters.BackBufferHeight;

            var loader = new TgcSceneLoader();

            scene           = loader.loadSceneFromFile(MediaDir + "ParadigmasEscena\\nivelParadigmas-TgcScene.xml");
            pathDeLaCancion = MediaDir + "Musica\\FeverTime.mp3";


            var skeletalLoader = new TgcSkeletalLoader();

            personajePrincipal = skeletalLoader.loadMeshAndAnimationsFromFile(
                MediaDir + "Robot\\Robot-TgcSkeletalMesh.xml",
                MediaDir + "Robot\\",
                new[] {
                MediaDir + "Robot\\Caminando-TgcSkeletalAnim.xml",
                MediaDir + "Robot\\Parado-TgcSkeletalAnim.xml",
            });

            personajePrincipal.playAnimation("Parado", true);

            personajePrincipal.Position = new TGCVector3(210, 1, 310);
            personajePrincipal.RotateY(Geometry.DegreeToRadian(180));

            camaraInterna = new TgcThirdPersonCamera(personajePrincipal.Position, 250, 500);
            camaraInterna.rotateY(Geometry.DegreeToRadian(180));

            HUD    = new Sprite(D3DDevice.Instance.Device);
            vida   = TgcTexture.createTexture(MediaDir + "Textures\\vida.png");
            mumuki = TgcTexture.createTexture(MediaDir + "Textures\\iconoMumuki.png");

            coleccionablesAdquiridos = new Boton(cantidadColeccionablesAgarrados.ToString(), 0.9f, 0.88f, null);

            SetearListas();
            AplicarShaders(shaderDir);


            scene.Meshes.Add(charcoEstatic1);
            scene.Meshes.Add(charcoEstatic2);
            scene.Meshes.Add(charcoEstatic3);

            reproductorMp3.FileName = pathDeLaCancion;
            reproductorMp3.play(true);
            AdministradorDeEscenarios.getSingleton().SetCamara(camaraInterna);
        }
Ejemplo n.º 2
0
        /////////////////////////////////////////////////////////////////////////
        ////////////////////////////////INIT/////////////////////////////////////
        /////////////////////////////////////////////////////////////////////////


        public void init(string MediaDir, string shaderDir, TgcCamera camara)
        {
            var d3dDevice = D3DDevice.Instance.Device;

            resolucionX = d3dDevice.PresentationParameters.BackBufferWidth;
            resolucionY = d3dDevice.PresentationParameters.BackBufferHeight;

            D3DDevice.Instance.ParticlesEnabled = true;
            D3DDevice.Instance.EnableParticles();

            var loader = new TgcSceneLoader();

            scene = loader.loadSceneFromFile(MediaDir + "NivelFisica1\\EscenaSceneEditorFisica1-TgcScene.xml");

            SetearAguas();

            pathDeLaCancion = MediaDir + "Musica\\FeverTime.mp3";


            meshesDeLaEscena = new List <TgcMesh>();

            HUD       = new Sprite(D3DDevice.Instance.Device);
            vida      = TgcTexture.createTexture(MediaDir + "Textures\\vida.png");
            fisicaLib = TgcTexture.createTexture(MediaDir + "NivelFisica1\\Textures\\TexturaTapaLibro.jpg");

            var skeletalLoader = new TgcSkeletalLoader();

            personajePrincipal =
                skeletalLoader.loadMeshAndAnimationsFromFile(
                    MediaDir + "Robot\\Robot-TgcSkeletalMesh.xml",
                    MediaDir + "Robot\\",
                    new[]
            {
                MediaDir + "Robot\\Caminando-TgcSkeletalAnim.xml",
                MediaDir + "Robot\\Parado-TgcSkeletalAnim.xml",
                MediaDir + "Robot\\Empujar-TgcSkeletalAnim.xml",
            });
            //Configurar animacion inicial
            personajePrincipal.playAnimation("Parado", true);

            personajePrincipal.Position = puntoCheckpointActual;
            personajePrincipal.RotateY(Geometry.DegreeToRadian(180));


            camaraInterna = new TgcThirdPersonCamera(personajePrincipal.Position, 250, 500);
            // camara = camaraInterna;
            camaraInterna.rotateY(Geometry.DegreeToRadian(180));

            librosAdquiridos = new Boton(cantidadLibrosAdquiridos.ToString(), resolucionX - (resolucionX / 9), resolucionY - (resolucionY / 7), null);

            plataforma1 = scene.Meshes[164];
            plataforma2 = scene.Meshes[165];

            plataformasMovibles.Add(plataforma1);
            plataformasMovibles.Add(plataforma2);

            bolaDeCanion1 = scene.Meshes[172];
            bolaDeCanion2 = scene.Meshes[173];
            bolaDeCanion3 = scene.Meshes[174];

            posicionInicialBolaDeCanion1 = scene.Meshes[172].Position;
            posicionInicialBolaDeCanion2 = scene.Meshes[173].Position;
            posicionInicialBolaDeCanion3 = scene.Meshes[174].Position;

            bolasDeCanion.Add(bolaDeCanion1);
            bolasDeCanion.Add(bolaDeCanion2);
            bolasDeCanion.Add(bolaDeCanion3);

            pathTexturaEmisorDeParticulas = MediaDir + "Textures\\fuego.png";
            cantidadDeParticulas          = 10;

            emisorDeParticulas1 = new ParticleEmitter(pathTexturaEmisorDeParticulas, cantidadDeParticulas);
            emisorDeParticulas1.MinSizeParticle    = 30f;
            emisorDeParticulas1.MaxSizeParticle    = 30f;
            emisorDeParticulas1.ParticleTimeToLive = 1f;
            emisorDeParticulas1.CreationFrecuency  = 1f; //0.25
            emisorDeParticulas1.Dispersion         = 500;
            emisorDeParticulas1.Speed          = new TGCVector3(-25, 40, 50);
            posicionInicialEmisorDeParticulas1 = new TGCVector3(1935, 200, 4345);
            emisorDeParticulas1.Position       = posicionInicialEmisorDeParticulas1;

            emisorDeParticulas2 = new ParticleEmitter(pathTexturaEmisorDeParticulas, cantidadDeParticulas);
            emisorDeParticulas2 = new ParticleEmitter(pathTexturaEmisorDeParticulas, cantidadDeParticulas);
            emisorDeParticulas2.MinSizeParticle    = 30f;
            emisorDeParticulas2.MaxSizeParticle    = 30f;
            emisorDeParticulas2.ParticleTimeToLive = 1f;
            emisorDeParticulas2.CreationFrecuency  = 1f;
            emisorDeParticulas2.Dispersion         = 500;
            emisorDeParticulas2.Speed          = new TGCVector3(-25, 40, 50);
            posicionInicialEmisorDeParticulas2 = new TGCVector3(2205, 200, 4345);
            emisorDeParticulas2.Position       = posicionInicialEmisorDeParticulas2;

            emisorDeParticulas3 = new ParticleEmitter(pathTexturaEmisorDeParticulas, cantidadDeParticulas);
            emisorDeParticulas3 = new ParticleEmitter(pathTexturaEmisorDeParticulas, cantidadDeParticulas);
            emisorDeParticulas3.MinSizeParticle    = 30f;
            emisorDeParticulas3.MaxSizeParticle    = 30f;
            emisorDeParticulas3.ParticleTimeToLive = 1f;
            emisorDeParticulas3.CreationFrecuency  = 1f;
            emisorDeParticulas3.Dispersion         = 500;
            emisorDeParticulas3.Speed          = new TGCVector3(-25, 40, 50);
            posicionInicialEmisorDeParticulas3 = new TGCVector3(2495, 200, 4345);
            emisorDeParticulas3.Position       = posicionInicialEmisorDeParticulas3;

            reproductorMp3.FileName = pathDeLaCancion;
            reproductorMp3.play(true);

            AdministradorDeEscenarios.getSingleton().SetCamara(camaraInterna);

            cantVidas = 3;
            effect    = TgcShaders.loadEffect(shaderDir + "MultiDiffuseLights.fx");
            for (var i = 224; i < 250; ++i)
            {
                lights.Add(scene.Meshes[i]);
            }

            scene.Meshes[4].D3dMesh.ComputeNormals();
            scene.Meshes[48].D3dMesh.ComputeNormals();
            var lightColors           = new ColorValue[lights.Count];
            var pointLightPositions   = new Vector4[lights.Count];
            var pointLightIntensity   = new float[lights.Count];
            var pointLightAttenuation = new float[lights.Count];

            for (var i = 0; i < lights.Count; i++)
            {
                var lightMesh = lights[i];

                lightColors[i]           = ColorValue.FromColor(Color.White);
                pointLightPositions[i]   = TGCVector3.Vector3ToVector4(lightMesh.BoundingBox.Position);
                pointLightIntensity[i]   = 20;
                pointLightAttenuation[i] = 0.07f;
            }
            tecnicaNormal = scene.Meshes[0].Technique;
            sinEfectos    = scene.Meshes[0].Effect;
            foreach (var mesh in scene.Meshes)
            {
                //if (mesh.Name.Contains("Box") || mesh.Name.Contains("Madera") || mesh.Name.Contains("East") || mesh.Name.Contains("South") || mesh.Name.Contains("North") || mesh.Name.Contains("West"))
                if (!mesh.Name.Contains("Floor"))
                {
                    continue;
                }
                mesh.Effect = effect;

                mesh.Effect.SetValue("lightColor", lightColors);
                mesh.Effect.SetValue("lightPosition", pointLightPositions);
                mesh.Effect.SetValue("lightIntensity", pointLightIntensity);
                mesh.Effect.SetValue("lightAttenuation", pointLightAttenuation);
                mesh.Effect.SetValue("materialEmissiveColor", ColorValue.FromColor(Color.Black));
                mesh.Effect.SetValue("materialDiffuseColor", ColorValue.FromColor(Color.White));
                mesh.Technique = "MultiDiffuseLightsTechnique";
                if (mesh.Name.Contains("Box") || mesh.Name.Contains("Madera"))
                {
                    mesh.Effect.SetValue("lightAttenuation", pointLightAttenuation);
                    mesh.D3dMesh.ComputeNormals();
                }
            }

            AplicarShaders(shaderDir);
        }