Ejemplo n.º 1
0
        unsafe private void NotifyMaterialSetup(uint pass_id, MaterialPtr mat)
        {
            // Prepare the fragment params offsets
            switch (pass_id)
            {
            //case 994: // rt_lum4
            case 993:     // rt_lum3
            case 992:     // rt_lum2
            case 991:     // rt_lum1
            case 990:     // rt_lum0
                break;

            case 800:     // rt_brightpass
                break;

            case 701:     // rt_bloom1
            {
                // horizontal bloom
                mat.Load();
                GpuProgramParametersSharedPtr fparams =
                    mat.GetBestTechnique().GetPass(0).GetFragmentProgramParameters();
                String progName = mat.GetBestTechnique().GetPass(0).FragmentProgramName;
                fixed(float *p_mBloomTexOffsetsHorz = &mBloomTexOffsetsHorz[0, 0])
                {
                    fparams.SetNamedConstant("sampleOffsets", p_mBloomTexOffsetsHorz, 15);
                }

                fixed(float *p_mBloomTexWeights = &mBloomTexWeights[0, 0])
                {
                    fparams.SetNamedConstant("sampleWeights", p_mBloomTexWeights, 15);
                }

                break;
            }

            case 700:     // rt_bloom0
            {
                // vertical bloom
                mat.Load();
                GpuProgramParametersSharedPtr fparams =
                    mat.GetTechnique(0).GetPass(0).GetFragmentProgramParameters();
                String progName = mat.GetBestTechnique().GetPass(0).FragmentProgramName;
                fixed(float *p_mBloomTexOffsetsVert = &mBloomTexOffsetsVert[0, 0])
                {
                    fparams.SetNamedConstant("sampleOffsets", p_mBloomTexOffsetsVert, 15);
                }

                fixed(float *p_mBloomTexWeights = &mBloomTexWeights[0, 0])
                {
                    fparams.SetNamedConstant("sampleWeights", p_mBloomTexWeights, 15);
                }

                break;
            }
            }
        }
Ejemplo n.º 2
0
        public static string[] GetTextureNames(Entity entity)
        {
            List <string> textures = new List <string>();
            //string[] textures = new string[];
            SubEntity e;

            for (uint i = 0; i < entity.NumSubEntities; i++)
            {
                e = entity.GetSubEntity(i);
                MaterialPtr ptr = MaterialManager.Singleton.GetByName(e.MaterialName);
                if (!ptr.IsLoaded)
                {
                    ptr.Load(false);
                }
                Technique t = ptr.GetBestTechnique();
                Technique.PassIterator iterator = t.GetPassIterator();
                foreach (Pass pass in iterator)
                {
                    Pass.TextureUnitStateIterator iterator2 = pass.GetTextureUnitStateIterator();
                    foreach (TextureUnitState unit in iterator2)
                    {
                        if (unit.GetContentType() == TextureUnitState.ContentType.CONTENT_NAMED)
                        {
                            if (unit.TextureName.Length > 0 && !textures.Contains(unit.TextureName))
                            {
                                textures.Add(unit.TextureName);
                            }
                        }
                    }
                }
            }

            return(textures.ToArray());
        }
Ejemplo n.º 3
0
        public static MaterialPtr CloneMaterial(String orgName, String cloneName)
        {
            if (MaterialManager.Singleton.ResourceExists(cloneName))
            {
                using (ResourcePtr res = MaterialManager.Singleton.GetByName(cloneName))
                    using (MaterialPtr matPtr = res)
                    {
                        if (matPtr.CompilationRequired)
                        {
                            matPtr.Compile();
                        }
                        return(matPtr);
                    }
            }


            using (ResourcePtr res = MaterialManager.Singleton.GetByName(orgName))
                using (MaterialPtr matPtr = res)
                {
                    if (matPtr.IsLoaded)
                    {
                        matPtr.Load();
                    }
                    if (matPtr.CompilationRequired)
                    {
                        matPtr.Compile();
                    }

                    return(matPtr.Clone(cloneName));
                }
        }
Ejemplo n.º 4
0
        protected override void CreateGUI()
        {
            MaterialPtr overlayMaterial = MaterialManager.Singleton.GetByName("SplashScreen");
            string      lang            = "_" + LanguageManager.ActualLanguageCode;

            overlayMaterial.Load();
            overlayMaterial.GetBestTechnique().GetPass(0).GetTextureUnitState(0).SetTextureName(C_SCREEN_NAME + screen +
                                                                                                lang + ".jpg");
            overlayMaterial = null;
            OverlayManager.Singleton.GetOverlayElement("Wof/LoadingScreenText").Caption = "";

            tutorialOverlay.Show();
        }
Ejemplo n.º 5
0
        private void NextScreen()
        {
            TimeSpan diff = DateTime.Now.Subtract(lastChange);
            string   lang = "_" + LanguageManager.ActualLanguageCode;

            if (diff.TotalMilliseconds < 200)
            {
                return;
            }
            lastChange = DateTime.Now;
            screen++;
            if (screen >= 1)
            {
                TextureManager.Singleton.Unload(C_SCREEN_NAME + (screen - 1) + lang + ".jpg");
            }


            if (screen > maxScreens)
            {
                GotoStartScreen();
                return;
            }

            tutorialOverlay.Hide();
            MaterialPtr overlayMaterial = MaterialManager.Singleton.GetByName("SplashScreen");

            overlayMaterial.Load();
            overlayMaterial.GetBestTechnique().GetPass(0).GetTextureUnitState(0).SetTextureName(C_SCREEN_NAME + screen +
                                                                                                lang + ".jpg");

            overlayMaterial = null;
            OverlayManager.Singleton.GetOverlayElement("Wof/LoadingScreenText").Caption = "";


            tutorialOverlay.Show();
        }
Ejemplo n.º 6
0
        private bool initScreen(int i)
        {
            MaterialPtr      overlayMaterial = null;
            TextureUnitState unit            = null;

            animation           = null;
            currentMaterialName = null;
            if (isScreenAnAd[i - 1]) // poczatkowo i = 1
            {
                // pobierz i ustaw na bie¿ac¹
                AdManager.AdStatus status = AdManager.Singleton.GetAd(C_AD_ZONE, 1.0f, out currentAd);

                if (status == AdManager.AdStatus.OK)
                {
                    // pobieranie OK.
                    currentMaterialName = C_AD_MATERIAL;
                    string path = AdManager.Singleton.LoadAdTexture(currentAd);
                    if (path == null)
                    {
                        return(false);
                    }
                    showAdText(viewport);


                    overlayMaterial = MaterialManager.Singleton.GetByName(currentMaterialName);
                    overlayMaterial.Load();
                    unit = overlayMaterial.GetBestTechnique().GetPass(0).GetTextureUnitState(0);

                    unit.SetTextureName(path);
                    AdManager.Singleton.RegisterImpression(currentAd);

                    //   int count;
                    //   count = adAction.Get_Ad_Impression_Counter(currentAd.id);
                    //    Console.WriteLine("Pobrañ: " + count);
                }
                else
                {
                    hideAdText();
                    return(false);
                }
            }
            else
            {
                currentMaterialName = C_TEXTURE_NAME + currentScreen;
                overlayMaterial     = MaterialManager.Singleton.GetByName(currentMaterialName);
                overlayMaterial.Load();
                unit = overlayMaterial.GetBestTechnique().GetPass(0).GetTextureUnitState(0);
                hideAdText();
            }



            textureDimensions = unit.GetTextureDimensions();
            PointD scale = new PointD(1, 1);
            // skaluj overlay tak aby tekstury nie zmienia³y swoich proporcji
            float prop = 1.0f;

            if (isScreenAnAd[currentScreen - 1])
            {
                // reklamy maja zachowac oryginalna rozdzielczosc
                scale = AdSizeUtils.ScaleAdToDisplay(textureDimensions, new PointD(Viewport.ActualWidth, Viewport.ActualHeight), true);
                scale = 0.65f * scale;
            }
            else
            {
                prop = 1.0f / ((1.0f * textureDimensions.first / textureDimensions.second) / (1.0f * Viewport.ActualWidth / Viewport.ActualHeight));
                // wychodzimy poza ekran
                if (scale.Y * prop > 1.0f)
                {
                    float scalingFactor = 1.0f / (scale.Y * prop);
                    scale.X *= scalingFactor; scale.Y *= scalingFactor;
                }

                if (scale.X * prop > 1.0f)
                {
                    float scalingFactor = 1.0f / (scale.X * prop);
                    scale.X *= scalingFactor; scale.Y *= scalingFactor;
                }
            }
            overlay.SetScale(scale.X, scale.Y * prop);



            animation =
                new EffectTextureAnimation(null, unit, screenTimes[i - 1], "QuitAnimation",
                                           VisibilityNodeAnimation.VisibilityType.VISIBLE,
                                           VisibilityNodeAnimation.VisibilityType.VISIBLE);

            animation.Enabled = true;
            animation.Looped  = true;
            OverlayContainer container = overlay.GetChild("Wof/QuitScreen");

            container.MaterialName = currentMaterialName;

            EffectsManager.Singleton.AddCustomEffect(animation);
            lastChange = DateTime.Now;
            return(true);
        }
Ejemplo n.º 7
0
        private bool initScreen(int i)
        {
            MaterialPtr      overlayMaterial = null;
            TextureUnitState unit;

            animation           = null;
            currentMaterialName = null;
            if (isScreenAnAd[i - 1]) // poczatkowo i = 1
            {
                if (Mogre.Math.RangeRandom(0, 1) < (1 - C_INTRO_AD_PROBABILITY))
                {
                    return(false);
                }


                //if(adIds.Count == 0) return false;
                AdManager.AdStatus status = AdManager.Singleton.GetAd(C_AD_ZONE, 1.0f, out currentAd);

                //AdManager.AdStatus status = AdManager.Singleton.GatherAsyncResult(adIds.Dequeue(), AdManager.C_AD_DOWNLOAD_TIMEOUT, out currentAd);
                if (status == AdManager.AdStatus.OK)
                {
                    // pobieranie OK.
                    currentMaterialName = C_AD_MATERIAL;
                    string path = AdManager.Singleton.LoadAdTexture(currentAd);
                    if (path == null)
                    {
                        return(false);
                    }
                    showAdText(viewport);



                    overlayMaterial = MaterialManager.Singleton.GetByName(currentMaterialName);
                    overlayMaterial.Load();
                    unit = overlayMaterial.GetBestTechnique().GetPass(0).GetTextureUnitState(0);

                    unit.SetTextureName(path);
                    AdManager.Singleton.RegisterImpression(currentAd);

                    //   int count;
                    //   count = adAction.Get_Ad_Impression_Counter(currentAd.id);
                    //    Console.WriteLine("Pobrañ: " + count);
                }
                else
                {
                    hideAdText();
                    return(false);
                }
            }
            else
            {
                string matName = EngineConfig.IsEnhancedVersion ? C_TEXTURE_NAME_ENHANCED : C_TEXTURE_NAME;

                currentMaterialName = matName + currentScreen;
                overlayMaterial     = MaterialManager.Singleton.GetByName(currentMaterialName);
                unit = overlayMaterial.GetBestTechnique().GetPass(0).GetTextureUnitState(0);


                hideAdText();
            }

            if (i == 1)
            {
                if (EngineConfig.SoundEnabled)
                {
                    if (ravenSound == null || !ravenSound.HasSound())
                    {
                        ravenSound = SoundManager3D.Instance.CreateAmbientSound(SoundManager3D.C_RAVEN, "ravenSound", false, false);                                               // destroyed together with SoundManager3D singleton
                    }
                    ravenSound.Play();
                }
            }

            textureDimensions = unit.GetTextureDimensions();
            //    Console.WriteLine(textureDimensions.first);

            PointD scale = new PointD(1, 1);
            // skaluj overlay tak aby tekstury nie zmienia³y swoich proporcji
            float prop = 1.0f;

            if (isScreenAnAd[currentScreen - 1])
            {
                // reklamy maja zachowac oryginalna rozdzielczosc
                scale = AdSizeUtils.ScaleAdToDisplay(textureDimensions, new PointD(Viewport.ActualWidth, Viewport.ActualHeight), true);
                scale = 0.65f * scale;
            }
            else
            {
                textureDimensions = new Pair <uint, uint>(1280, 1024);
                //	scale = AdSizeUtils.ScaleAdToDisplay(textureDimensions, new PointD(Viewport.ActualWidth, Viewport.ActualHeight), false);
                prop = 1.0f / ((1.0f * textureDimensions.first / textureDimensions.second) / (1.0f * Viewport.ActualWidth / Viewport.ActualHeight));

                // wychodzimy poza ekran
                if (scale.Y * prop > 1.0f)
                {
                    float scalingFactor = 1.0f / (scale.Y * prop);
                    scale.X *= scalingFactor; scale.Y *= scalingFactor;
                }

                if (scale.X * prop > 1.0f)
                {
                    float scalingFactor = 1.0f / (scale.X * prop);
                    scale.X *= scalingFactor; scale.Y *= scalingFactor;
                }

                //   scale.X *= 0.5f; scale.Y *= 0.5f;
            }
            overlay.SetScale(scale.X, scale.Y * prop);



            animation =
                new EffectTextureAnimation(null, unit, screenTimes[i - 1], "IntroAnimation",
                                           VisibilityNodeAnimation.VisibilityType.VISIBLE,
                                           VisibilityNodeAnimation.VisibilityType.VISIBLE);

            animation.Enabled = true;
            animation.Looped  = true;
            OverlayContainer container = overlay.GetChild("Wof/IntroScreen");

            container.MaterialName = currentMaterialName;

            EffectsManager.Singleton.AddCustomEffect(animation);
            lastChange = DateTime.Now;
            return(true);
        }
Ejemplo n.º 8
0
        private unsafe void NotifyMaterialSetup(uint pass_id, MaterialPtr mat)
        {
            // Prepare the fragment params offsets
            switch (pass_id)
            {
                //case 994: // rt_lum4
                case 993: // rt_lum3
                case 992: // rt_lum2
                case 991: // rt_lum1
                case 990: // rt_lum0
                    break;
                case 800: // rt_brightpass
                    break;
                case 701: // rt_bloom1
                    {
                        // horizontal bloom
                        mat.Load();
                        GpuProgramParametersSharedPtr fparams =
                            mat.GetBestTechnique().GetPass(0).GetFragmentProgramParameters();
                        String progName = mat.GetBestTechnique().GetPass(0).FragmentProgramName;
                        fixed (float* p_mBloomTexOffsetsHorz = &mBloomTexOffsetsHorz[0, 0])
                        {
                            fparams.SetNamedConstant("sampleOffsets", p_mBloomTexOffsetsHorz, 15);
                        }
                        fixed (float* p_mBloomTexWeights = &mBloomTexWeights[0, 0])
                        {
                            fparams.SetNamedConstant("sampleWeights", p_mBloomTexWeights, 15);
                        }

                        break;
                    }
                case 700: // rt_bloom0
                    {
                        // vertical bloom
                        mat.Load();
                        GpuProgramParametersSharedPtr fparams =
                            mat.GetTechnique(0).GetPass(0).GetFragmentProgramParameters();
                        String progName = mat.GetBestTechnique().GetPass(0).FragmentProgramName;
                        fixed (float* p_mBloomTexOffsetsVert = &mBloomTexOffsetsVert[0, 0])
                        {
                            fparams.SetNamedConstant("sampleOffsets", p_mBloomTexOffsetsVert, 15);
                        }
                        fixed (float* p_mBloomTexWeights = &mBloomTexWeights[0, 0])
                        {
                            fparams.SetNamedConstant("sampleWeights", p_mBloomTexWeights, 15);
                        }

                        break;
                    }
            }
        }