Example #1
0
        public void updatearMiPropiaLuz(Escenario escenario, Personaje personaje)
        {
            Microsoft.DirectX.Direct3D.Effect currentShader;
            currentShader = TGCShaders.Instance.TgcMeshPointLightShader;

            TGCVector3 radioDeLuz = new TGCVector3(50, 0, 50);

            radioDeLuz += unEscondite.BoundingBox.PMin;

            var listMeshesCercanos = escenario.tgcScene.Meshes.FindAll(unMesh => unMesh.BoundingBox.PMin.X < radioDeLuz.X && unMesh.BoundingBox.PMin.Z < radioDeLuz.Z);

            foreach (TgcMesh mesh in listMeshesCercanos)
            {
                mesh.Effect    = currentShader;
                mesh.Technique = TGCShaders.Instance.GetTGCMeshTechnique(mesh.RenderType);

                // Estos son paramentros del current shader, si cambias el shader chequear los parametros o rompe
                mesh.Effect.SetValue("materialEmissiveColor", ColorValue.FromColor(Color.Black));
                mesh.Effect.SetValue("materialAmbientColor", ColorValue.FromColor(Color.White));
                mesh.Effect.SetValue("materialDiffuseColor", ColorValue.FromColor(Color.White));
                mesh.Effect.SetValue("materialSpecularColor", ColorValue.FromColor(Color.White));
                mesh.Effect.SetValue("materialSpecularExp", 9f);
                mesh.Effect.SetValue("eyePosition", TGCVector3.Vector3ToFloat4Array(personaje.eye));
                mesh.Effect.SetValue("lightAttenuation", 0.3f);
                mesh.Effect.SetValue("lightColor", ColorValue.FromColor(Color.Blue));
                mesh.Effect.SetValue("lightIntensity", 50f);
                mesh.Effect.SetValue("lightPosition", TGCVector3.Vector3ToFloat4Array(radioDeLuz));
            }
        }
Example #2
0
        public static Escenario GenerarEscenarioDefault(string MediaDir, int numeroDeEscenario)
        {
            Escenario e = new Escenario(MediaDir, "XWing/death+star-TgcScene.xml", numeroDeEscenario)
            {
                ScaleFactor    = TGCMatrix.Scaling(Escenario.defaultScale),
                RotationVector = new TGCVector3(0, FastMath.PI_HALF, 0)
            };

            e.MovementVector = e.GetOffsetVectorMoved();
            e.UpdateBoundingBox();
            e.GenerarTorres(MediaDir, 2);

            e.ApplyLightEffect();
            SetUpTerrainLight();

            return(e);
        }