示例#1
0
        /// <summary>
        /// Inizializza l'effetto avanzato Glass (da utilizzare all'esterno del GameLoop)
        /// </summary>
        /// <param name="cubeMap"></param>
        public void GlassEffect(CubeMap cubeMap)
        {
            try
            {
                EffectPool pool = new EffectPool();
                Effect = Microsoft.DirectX.Direct3D.Effect.FromFile(LogiX_Engine.Device, "MEDIA//Glass.fx", null, ShaderFlags.None, pool);
                EffectHandles = new EffectHandle[10];
                EffectTechniques = new EffectHandle[1];
                EffectTechniques[0] = Effect.GetTechnique("Glass");
                EffectHandles[0] = Effect.GetParameter(null, "matViewProjection");
                EffectHandles[1] = Effect.GetParameter(null, "PointOfView");
                EffectHandles[2] = Effect.GetParameter(null, "refractionScale");
                EffectHandles[3] = Effect.GetParameter(null, "baseColor");
                EffectHandles[4] = Effect.GetParameter(null, "ambient");
                EffectHandles[5] = Effect.GetParameter(null, "indexOfRefractionRatio");
                EffectHandles[6] = Effect.GetParameter(null, "reflectionScale");
                EffectHandles[7] = Effect.GetParameter(null, "texCube");
                EffectHandles[8] = Effect.GetParameter(null, "alpha");
                EffectHandles[9] = Effect.GetParameter(null, "matWorld");

                CubeTextures = new CubeTexture[1];
                CubeTextures[0] = cubeMap.DXCubeTexture;

                correct = true;
            }
            catch
            {
                Error("OnCreateObject");
            }
        }
示例#2
0
 /// <summary>
 /// Inizializza un effetto base tra quelli possibili (definiti da LogiX_Technologies.XEffects). Da utilizzare all'esterno del GameLoop
 /// </summary>
 /// <param name="baseTexturePath"></param>
 /// <param name="normalTexturePath"></param>
 /// <param name="cubeMap"></param>
 /// <param name="DefaultEffects"></param>
 public void DefaultEffect(string baseTexturePath, string normalTexturePath, CubeMap cubeMap, XEffects DefaultEffects)
 {
     switch (DefaultEffects)
     {
         case XEffects.PerPixelDirectionalLight:
             try
             {
                 EffectPool pool = new EffectPool();
                 Effect = Microsoft.DirectX.Direct3D.Effect.FromFile(LogiX_Engine.Device, "PerPixelDirectionalLight.fx", null, ShaderFlags.None, pool);
                 EffectHandles = new EffectHandle[8];
                 EffectTechniques = new EffectHandle[1];
                 EffectTechniques[0] = Effect.GetTechnique("t0");
                 EffectHandles[0] = Effect.GetParameter(null, "transform");
                 EffectHandles[1] = Effect.GetParameter(null, "world");
                 EffectHandles[2] = Effect.GetParameter(null, "LightDirection");
                 EffectHandles[3] = Effect.GetParameter(null, "ViewDirection");
                 EffectHandles[4] = Effect.GetParameter(null, "base_Tex");
                 EffectHandles[5] = Effect.GetParameter(null, "Specular");
                 EffectHandles[6] = Effect.GetParameter(null, "Diffuse");
                 EffectHandles[7] = Effect.GetParameter(null, "SpecularPower");
                 BaseTextures = new BaseTexture[1];
                 BaseTextures[0] = TextureLoader.FromFile(LogiX_Engine.Device, baseTexturePath);
                 correct = true;
             }
             catch
             {
                 Error("OnCreateObject");
             }
             break;
         case XEffects.PerPixelPointLight:
             try
             {
                 EffectPool pool = new EffectPool();
                 Effect = Microsoft.DirectX.Direct3D.Effect.FromFile(LogiX_Engine.Device, Application.StartupPath + "/PerPixelPointLight.fx", null, ShaderFlags.None, pool);
                 EffectHandles = new EffectHandle[11];
                 EffectTechniques = new EffectHandle[1];
                 EffectTechniques[0] = Effect.GetTechnique("PerPixelLightning");
                 EffectHandles[0] = Effect.GetParameter(null, "World");
                 EffectHandles[1] = Effect.GetParameter(null, "View");
                 EffectHandles[2] = Effect.GetParameter(null, "Projection");
                 EffectHandles[3] = Effect.GetParameter(null, "LightPosition");
                 EffectHandles[4] = Effect.GetParameter(null, "ReflectionRatio");
                 EffectHandles[5] = Effect.GetParameter(null, "SpecularRatio");
                 EffectHandles[6] = Effect.GetParameter(null, "SpecularStyleLerp");
                 EffectHandles[7] = Effect.GetParameter(null, "SpecularPower");
                 EffectHandles[8] = Effect.GetParameter(null, "LightColor");
                 EffectHandles[9] = Effect.GetParameter(null, "MyTex_Tex");
                 EffectHandles[10] = Effect.GetParameter(null, "myCubemap_Tex");
                 BaseTextures = new BaseTexture[1];
                 CubeTextures = new CubeTexture[1];
                 BaseTextures[0] = TextureLoader.FromFile(LogiX_Engine.Device, baseTexturePath);
                 CubeTextures[0] = cubeMap.DXCubeTexture;
             }
             catch
             {
                 Error("OnCreateObject");
             }
             break;
         case XEffects.BumpPerPixelPointLight:
             try
             {
                 EffectPool pool = new EffectPool();
                 Effect = Microsoft.DirectX.Direct3D.Effect.FromFile(LogiX_Engine.Device, Application.StartupPath + "PerPixelPointLight.fx", null, ShaderFlags.None, pool);
                 EffectHandles = new EffectHandle[12];
                 EffectTechniques = new EffectHandle[1];
                 EffectTechniques[0] = Effect.GetTechnique("PerPixelLightning");
                 EffectHandles[0] = Effect.GetParameter(null, "World");
                 EffectHandles[1] = Effect.GetParameter(null, "View");
                 EffectHandles[2] = Effect.GetParameter(null, "Projection");
                 EffectHandles[3] = Effect.GetParameter(null, "LightPosition");
                 EffectHandles[4] = Effect.GetParameter(null, "ReflectionRatio");
                 EffectHandles[5] = Effect.GetParameter(null, "SpecularRatio");
                 EffectHandles[6] = Effect.GetParameter(null, "SpecularStyleLerp");
                 EffectHandles[7] = Effect.GetParameter(null, "SpecularPower");
                 EffectHandles[8] = Effect.GetParameter(null, "LightColor");
                 EffectHandles[9] = Effect.GetParameter(null, "MyTex_Tex");
                 EffectHandles[10] = Effect.GetParameter(null, "MyNTex_Tex");
                 EffectHandles[11] = Effect.GetParameter(null, "myCubemap_Tex");
                 BaseTextures = new BaseTexture[2];
                 CubeTextures = new CubeTexture[1];
                 BaseTextures[0] = TextureLoader.FromFile(LogiX_Engine.Device, baseTexturePath);
                 BaseTextures[1] = TextureLoader.FromFile(LogiX_Engine.Device, normalTexturePath);
                 CubeTextures[0] = cubeMap.DXCubeTexture;
                 correct = true;
             }
             catch
             {
                 Error("OnCreateObject");
             }
             break;
         case XEffects.Reflect:
             try
             {
                 EffectPool pool = new EffectPool();
                 Effect = Microsoft.DirectX.Direct3D.Effect.FromFile(LogiX_Engine.Device, "Reflect.fx", null, ShaderFlags.None, pool);
                 EffectHandles = new EffectHandle[7];
                 EffectTechniques = new EffectHandle[1];
                 EffectTechniques[0] = Effect.GetTechnique("Textured_Bump");
                 EffectHandles[0] = Effect.GetParameter(null, "fvEyePosition");
                 EffectHandles[1] = Effect.GetParameter(null, "matView");
                 EffectHandles[2] = Effect.GetParameter(null, "matViewProjection");
                 EffectHandles[3] = Effect.GetParameter(null, "ReflectionRatio");
                 EffectHandles[4] = Effect.GetParameter(null, "bump_Tex");
                 EffectHandles[5] = Effect.GetParameter(null, "cube_Tex");
                 EffectHandles[6] = Effect.GetParameter(null, "Bump");
                 BaseTextures = new BaseTexture[1];
                 CubeTextures = new CubeTexture[1];
                 BaseTextures[0] = TextureLoader.FromFile(LogiX_Engine.Device, normalTexturePath);
                 CubeTextures[0] = cubeMap.DXCubeTexture;
                 correct = true;
             }
             catch
             {
                 Error("OnCreateObject");
             }
             break;
     }
 }