Пример #1
0
        public void BuildMaterialPasses(PageDecalInfo pageInfo)
        {
            Technique t = FindPageTechnique(pageInfo.Coord);

            if (t != null)
            {
                float pageX = pageInfo.Coord.X * TerrainManager.Instance.PageSize * TerrainManager.oneMeter;
                float pageZ = pageInfo.Coord.Z * TerrainManager.Instance.PageSize * TerrainManager.oneMeter;

                int availableTexUnits = 0;
                int curTexUnit        = 0;
                int texUnitsPerPass   = 8;

                Pass p = null;

                foreach (DecalElement element in pageInfo.Decals)
                {
                    // if there are no texture units available, allocate a new pass
                    if (availableTexUnits == 0)
                    {
                        p = t.CreatePass();
                        pageInfo.Passes.Add(p);

                        p.SetSceneBlending(SceneBlendType.TransparentAlpha);
                        // TODO: Unclear what should happen here.  The new Ogre interface
                        // supports SetDepthBias(constantBias, slopeBias), but the units are
                        // different.  Ask Jeff.
                        p.DepthBias = 1;

                        curTexUnit        = 0;
                        availableTexUnits = texUnitsPerPass;
                    }

                    TextureUnitState texUnit = p.CreateTextureUnitState(element.ImageName, 0);

                    if (curTexUnit == 0)
                    {
                        texUnit.SetColorOperation(LayerBlendOperation.Replace);
                        texUnit.SetAlphaOperation(LayerBlendOperationEx.Source1, LayerBlendSource.Texture, LayerBlendSource.Current, 0, 0, 0);
                    }
                    else
                    {
                        texUnit.SetColorOperation(LayerBlendOperation.AlphaBlend);
                        texUnit.SetAlphaOperation(LayerBlendOperationEx.AddSmooth, LayerBlendSource.Texture, LayerBlendSource.Current, 0, 0, 0);
                    }
                    texUnit.TextureAddressing  = TextureAddressing.Border;
                    texUnit.TextureBorderColor = new ColorEx(0, 0, 0, 0);

                    element.UpdateTextureTransform(texUnit, pageX, pageZ);

                    // bump the counts
                    curTexUnit++;
                    availableTexUnits--;
                }
            }
        }
Пример #2
0
 protected void ResetOpacity()
 {
     try
     {
         TextureUnitState state = ManualObject.GetSection(0).GetMaterial().GetBestTechnique().GetPass(0).GetTextureUnitState(0);
         state.SetAlphaOperation(LayerBlendOperationEx.LBX_MODULATE, LayerBlendSource.LBS_TEXTURE, LayerBlendSource.LBS_MANUAL, 1.0f, 1.0f);
     }
     catch (Exception)
     {
     }
 }
Пример #3
0
        public bool DecreaseOpacity(float o)
        {
            if (opacity < 0)
            {
                return(false);
            }
            opacity -= o;
            if (opacity < 0)
            {
                ManualObject.Visible = false;
                opacity = 0;
                return(false);
            }

            TextureUnitState state = ManualObject.GetSection(0).GetMaterial().GetBestTechnique().GetPass(0).GetTextureUnitState(0);

            state.SetAlphaOperation(LayerBlendOperationEx.LBX_MODULATE, LayerBlendSource.LBS_TEXTURE, LayerBlendSource.LBS_MANUAL, 1.0f, opacity);
            return(true);
        }