protected override void OnMaterialRender(uint passId, Material material, ref bool skipPass)
        {
            base.OnMaterialRender(passId, material, ref skipPass);

            //update texture name
            if (passId == 100)
            {
                TextureUnitState textureUnit = material.Techniques[0].Passes[0].TextureUnitStates[1];

                //we can't change texture by means call SetTextureName() for compositor materials. use _Internal_SetTexture
                Texture texture = null;
                if (!string.IsNullOrEmpty(TextureName))
                {
                    texture = TextureManager.Instance.Load(TextureName, Texture.Type.Type2D);
                }
                if (texture == null)
                {
                    texture = TextureManager.Instance.Load("Base\\FullScreenEffects\\ColorCorrectionLUT\\Textures\\NoEffect.png");
                }
                textureUnit._Internal_SetTexture(texture);
                //if( textureUnit.TextureName != TextureName )
                //   textureUnit.SetTextureName( TextureName );

                GpuProgramParameters parameters = material.Techniques[0].Passes[0].FragmentProgramParameters;
                parameters.SetNamedConstant("multiply", multiply);
                parameters.SetNamedConstant("add", add);
            }
        }
예제 #2
0
        protected override void CreateScene()
        {
            // since whole screen is being redrawn every frame, dont bother clearing
            // option works for GL right now, uncomment to test it out.  huge fps increase
            // also, depth_write in the skybox material must be set to on
            //mainViewport.ClearEveryFrame = false;

            // set some ambient light
            scene.TargetRenderSystem.LightingEnabled = true;
            scene.AmbientLight = ColorEx.Gray;

            // create a point light (default)
            Light light = scene.CreateLight("MainLight");

            light.Position = new Vector3(20, 80, 50);

            CreateScalingPlane();
            CreateScrollingKnot();
            CreateWateryPlane();

            // set up a material for the skydome
            Material skyMaterial = scene.CreateMaterial("SkyMat");

            skyMaterial.Lighting = false;
            // use a cloudy sky
            Pass             pass         = skyMaterial.GetTechnique(0).GetPass(0);
            TextureUnitState textureLayer = pass.CreateTextureUnitState("clouds.jpg");

            // scroll the clouds
            textureLayer.SetScrollAnimation(0.15f, 0);

            // create the skydome
            scene.SetSkyDome(true, "SkyMat", -5, 2);
        }
예제 #3
0
        // Just override the mandatory create scene method
        public override void CreateScene()
        {
            // Set ambient light
            sceneMgr.AmbientLight = new ColourValue(0.5f, 0.5f, 0.5f);

            // Create a point light
            Light l = sceneMgr.CreateLight("MainLight");

            // Accept default settings: point light, white diffuse, just set position
            // NB I could attach the light to a SceneNode if I wanted it to move automatically with
            //  other objects, but I don't
            l.Position = new Vector3(20, 80, 50);

            createScalingPlane();
            createScrollingKnot();
            createWateryPlane();

            // Set up a material for the skydome
            MaterialPtr skyMat = MaterialManager.Singleton.Create("SkyMat",
                                                                  ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);

            // Perform no dynamic lighting on the sky
            skyMat.SetLightingEnabled(false);
            // Use a cloudy sky
            TextureUnitState t = skyMat.GetTechnique(0).GetPass(0).CreateTextureUnitState("clouds.jpg");

            // Scroll the clouds
            t.SetScrollAnimation(0.15f, 0f);

            // System will automatically set no depth write

            // Create a skydome
            sceneMgr.SetSkyDome(true, "SkyMat", -5, 2);
        }
예제 #4
0
        /// <summary>
        ///     Creates a texture layer animator controller.
        /// </summary>
        /// <remarks>
        ///     This helper method creates the Controller, IControllerValue and IControllerFunction classes required
        ///     to animate a texture.
        /// </remarks>
        /// <param name="texUnit">The texture unit to animate.</param>
        /// <param name="sequenceTime">Length of the animation (in seconds).</param>
        /// <returns>A newly created controller object that will be updated during the main render loop.</returns>
        public Controller <Real> CreateTextureAnimator(TextureUnitState texUnit, Real sequenceTime)
        {
            IControllerValue <Real>    val  = new TextureFrameControllerValue(texUnit);
            IControllerFunction <Real> func = new AnimationControllerFunction(sequenceTime);

            return(CreateController(val, func));
        }
 public TexCoordModifierControllerValue(TextureUnitState t, bool translateU, bool translateV, bool scaleU) : this(OgrePINVOKE.new_TexCoordModifierControllerValue__SWIG_2(TextureUnitState.getCPtr(t), translateU, translateV, scaleU), true)
 {
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
예제 #6
0
        /// <summary>
        ///     Creates a basic time-based texture coordinate modifier designed for creating rotating textures.
        /// </summary>
        /// <remarks>
        ///     This simple method allows you to easily create constant-speed rotating textures. If you want more
        ///     control, look up the ControllerManager.CreateTextureWaveTransformer for more complex wave-based
        ///     scrollers / stretchers / rotaters.
        /// </remarks>
        /// <param name="layer">The texture unit to animate.</param>
        /// <param name="speed">Speed of the rotation, in counter-clockwise revolutions per second.</param>
        /// <returns>A newly created controller object that will be updated during the main render loop.</returns>
        public Controller <Real> CreateTextureRotator(TextureUnitState layer, Real speed)
        {
            IControllerValue <Real>    val  = new TexCoordModifierControllerValue(layer, false, false, false, false, true);
            IControllerFunction <Real> func = new MultipyControllerFunction(-speed, true);

            return(CreateController(val, func));
        }
 public TexCoordModifierControllerValue(TextureUnitState t) : this(OgrePINVOKE.new_TexCoordModifierControllerValue__SWIG_5(TextureUnitState.getCPtr(t)), true)
 {
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
        protected override void CreateScene()
        {
            mSceneMgr.AmbientLight = new ColourValue(1, 1, 1);
            //Entity ent = mSceneMgr.CreateEntity("Head", "ogrehead.mesh");
            //SceneNode node = mSceneMgr.RootSceneNode.CreateChildSceneNode("HeadNode");
            //node.AttachObject(ent);
            MaterialPtr      mat  = MaterialManager.Singleton.Create("BoxColor", "General", true);
            Technique        tech = mat.GetTechnique(0);
            Pass             pass = tech.GetPass(0);
            TextureUnitState tex  = pass.CreateTextureUnitState();

            tex.SetTextureName("sphax.jpg", TextureType.TEX_TYPE_2D);
            tex.NumMipmaps        = 0;
            tex.TextureAnisotropy = 0;
            tex.SetTextureFiltering(FilterOptions.FO_POINT, FilterOptions.FO_POINT, FilterOptions.FO_POINT);
            //pass.DepthWriteEnabled=false;
            //pass.SetSceneBlending(SceneBlendType.SBT_TRANSPARENT_ALPHA);
            //pass.CullingMode = CullingMode.CULL_NONE;
            //mCamMan = new Tutorials.CameraMan(mCamera,mc);
            //mCameraMan = null;
            mCamera.SetPosition((float)mc.x, (float)mc.y, (float)mc.z);
            mCamera.Pitch(new Degree(mc.pitch).ValueRadians);
            mCamera.Yaw(new Degree(mc.yaw).ValueRadians);
            oldCamPos = mCamera.Position;
        }
예제 #9
0
        /// <summary>
        /// Helper function to set the texture coordinates.  Instead of taking a movie
        /// object, this takes a specific texture name, video size, texture size, and
        /// material.  Sets a texture matrix to adjust the existing coordinates.
        /// </summary>
        /// <param name="textureName">
        /// The name of the texture to adjust.
        /// </param>
        /// <param name="videoSize">
        /// The size of the video in pixels.
        /// </param>
        /// <param name="textureSize">
        /// The size of the expected texture in pixels.
        /// </param>
        /// <param name="material">
        /// The name of the material to search for textures.
        /// </param>
        /// <returns>
        /// True if any texture coordinates were adjusted, false if not.
        /// </returns>
        public static bool SetTextureCoordinates(string textureName, Size videoSize, Size textureSize, string material)
        {
            bool ans = false;

            Axiom.Graphics.Material m = MaterialManager.Instance.GetByName(material);
            if (m != null)
            {
                for (int i = 0; i < m.NumTechniques; i++)
                {
                    for (int j = 0; j < m.GetTechnique(i).NumPasses; j++)
                    {
                        Pass p = m.GetTechnique(i).GetPass(j);
                        for (int k = 0; k < p.NumTextureUnitStages; k++)
                        {
                            if (p.GetTextureUnitState(k).TextureName == textureName)
                            {
                                TextureUnitState tu     = p.GetTextureUnitState(k);
                                float            uRatio = ((float)videoSize.Width) / ((float)textureSize.Width);
                                float            vRatio = ((float)videoSize.Height) / ((float)textureSize.Height);
                                tu.SetTextureScale(1.0f / uRatio, 1.0f / vRatio);
                                tu.SetTextureScroll(-0.5f * (1.0f - uRatio), -0.5f * (1.0f - vRatio));
                                ans = true;
                            }
                        }
                    }
                }
            }
            return(ans);
        }
예제 #10
0
        private void setupModMenu()
        {
            MaterialPtr thumbMat = MaterialManager.Singleton.Create("ModThumbnail", "General");

            thumbMat.GetTechnique(0).GetPass(0).CreateTextureUnitState();
            MaterialPtr templateMat = MaterialManager.Singleton.GetByName("ModThumbnail");

            foreach (string itr in modThumb)
            {
                string name = "ModThumb" + (modThumbs.Count + 1).ToString();

                MaterialPtr newMat = templateMat.Clone(name);

                TextureUnitState tus = newMat.GetTechnique(0).GetPass(0).GetTextureUnitState(0);
                if (ResourceGroupManager.Singleton.ResourceExists("General", itr))
                {
                    tus.SetTextureName(itr);
                }
                else
                {
                    tus.SetTextureName("thumb_error.png");
                }

                BorderPanelOverlayElement bp = (BorderPanelOverlayElement)
                                               OverlayManager.Singleton.CreateOverlayElementFromTemplate("SdkTrays/Picture", "BorderPanel", (name));


                bp.HorizontalAlignment = (GuiHorizontalAlignment.GHA_RIGHT);
                bp.VerticalAlignment   = (GuiVerticalAlignment.GVA_CENTER);
                bp.MaterialName        = (name);
                GameManager.Instance.trayMgr.getTraysLayer().Add2D(bp);

                modThumbs.Add(bp);
            }
        }
예제 #11
0
 public TexCoordModifierControllerValue(TextureUnitState texUnit, bool scrollU, bool scrollV, bool scaleU, bool scaleV, bool rotate)
 {
     this.texUnit = texUnit;
     this.transU  = scrollU;
     this.transV  = scrollV;
     this.scaleU  = scaleU;
     this.scaleV  = scaleV;
     this.rotate  = rotate;
 }
예제 #12
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--;
                }
            }
        }
        public static ControllerValueRealPtr create(TextureUnitState t, bool translateU, bool translateV, bool scaleU, bool scaleV, bool rotate)
        {
            ControllerValueRealPtr ret = new ControllerValueRealPtr(OgrePINVOKE.TexCoordModifierControllerValue_create__SWIG_0(TextureUnitState.getCPtr(t), translateU, translateV, scaleU, scaleV, rotate), true);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
        public static ControllerValueRealPtr create(TextureUnitState t)
        {
            ControllerValueRealPtr ret = new ControllerValueRealPtr(OgrePINVOKE.TexCoordModifierControllerValue_create__SWIG_5(TextureUnitState.getCPtr(t)), true);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
예제 #15
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)
     {
     }
 }
예제 #16
0
        public ControllerReal createTextureRotater(TextureUnitState layer, float speed)
        {
            global::System.IntPtr cPtr = OgrePINVOKE.ControllerManager_createTextureRotater(swigCPtr, TextureUnitState.getCPtr(layer), speed);
            ControllerReal        ret  = (cPtr == global::System.IntPtr.Zero) ? null : new ControllerReal(cPtr, false);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
예제 #17
0
 /// <summary>
 /// This method applies a texture map to the Cube
 /// </summary>
 private void ManualObjMat()
 {
     using (MaterialPtr manualObjMat = MaterialManager.Singleton.Create("floor_mat", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME))// Creates a new Material
     {
         using (TextureUnitState manualObjTexture =
                    manualObjMat.GetTechnique(0).GetPass(0).CreateTextureUnitState("floor.jpg")) // Sets the texture for the material
         {
             manualObjEntity.SetMaterialName("floor_mat");                                       // Applies the material to the entity
         }
     }
 }
예제 #18
0
        public ControllerReal createTextureWaveTransformer(TextureUnitState layer, TextureUnitState.TextureTransformType ttype, WaveformType waveType)
        {
            global::System.IntPtr cPtr = OgrePINVOKE.ControllerManager_createTextureWaveTransformer__SWIG_4(swigCPtr, TextureUnitState.getCPtr(layer), (int)ttype, (int)waveType);
            ControllerReal        ret  = (cPtr == global::System.IntPtr.Zero) ? null : new ControllerReal(cPtr, false);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
예제 #19
0
 private void CubeMaterial()
 {
     using (MaterialPtr cubeMat = MaterialManager.Singleton.Create("groundMaterial",
                                                                   ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME)) // Creates a new Material
     {
         using (TextureUnitState cubeTexture =
                    cubeMat.GetTechnique(0).GetPass(0).CreateTextureUnitState("Dirt.jpg")) // Sets the texture for the material
         {
             cubeEntity.SetMaterialName("groundMaterial");                                 // Applies the material to the entity
         }
     }
 }
예제 #20
0
        public override bool PreAddToRenderState(TargetRenderState targetRenderState, Pass srcPass, Pass dstPass)
        {
            this.atlasTexcoordPos = 0;
            TextureAtlasSamplerFactory factory = TextureAtlasSamplerFactory.Instance;

            bool hasAtlas = false;
            int  texCount = srcPass.TextureUnitStatesCount;

            for (int i = 0; i < texCount; i++)
            {
                TextureUnitState pState = srcPass.GetTextureUnitState(i);

                var table = factory.GetTextureAtlasTable(pState.TextureName);
                if (table != null)
                {
                    if (table.Count > TextureAtlasSampler.MaxSafeAtlasedTextuers)
                    {
                        Axiom.Core.LogManager.Instance.Write(
                            "Warning: Compiling atlas texture has too many internally defined textures. Shader may fail to compile.");
                    }
                    if (i > TextureAtlasSampler.MaxTextures)
                    {
                        throw new Axiom.Core.AxiomException(
                                  "Texture atlas sub-render does not support more than TextureAtlasSampler.MaxTextures {0} atlas textures",
                                  TextureAtlasSampler.MaxTextures);
                    }
                    if (pState.TextureType != TextureType.TwoD)
                    {
                        throw new Axiom.Core.AxiomException("Texture atlas sub-render state only supports 2d textures.");
                    }

                    this.atlasTableDatas[i]     = table;
                    this.textureAddressings[i]  = pState.TextureAddressingMode;
                    this.isAtlasTextureUnits[i] = true;
                    hasAtlas = true;
                }
            }

            //Gather the materials atlas processing attributes
            //and calculate the position of the indexes
            TextureAtlasAttib attrib;

            factory.HasMaterialAtlasingAttributes(srcPass.Parent.Parent, out attrib);

            this.autoAdjustPollPosition = attrib.autoBorderAdjust;
            this.atlasTexcoordPos       = attrib.positionOffset;
            if (attrib.positionMode == IndexPositionMode.Relative)
            {
                this.atlasTexcoordPos += texCount - 1;
            }

            return(hasAtlas);
        }
예제 #21
0
파일: Cube.cs 프로젝트: VSacr1/Robot-Game
 //public void SetPosition(Vector3 position)
 //{
 //    //cubeNode.Position = position;
 //    //physObj.Position = position;
 //}
 private void CubeMaterial()
 {
     using (MaterialPtr cubeMat = MaterialManager.Singleton.Create("Cube",
                                                                   ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME))
     {
         using (TextureUnitState fieldTexture =
                    cubeMat.GetTechnique(0).GetPass(0).CreateTextureUnitState("Dirt.jpg"))
         {
             ///cube.SetMaterialName("Quad", "Cube");
         }
     }
 }
예제 #22
0
        public void UpdateTextureTransform(TextureUnitState texUnit, float pageX, float pageZ)
        {
            //Axiom.Core.LogManager.Instance.Write("Decal: {0}, {1} page:{2}, {3}", posX, posZ, pageX, pageZ);
            float pageSize = TerrainManager.Instance.PageSize * TerrainManager.oneMeter;
            float scaleX   = sizeX / pageSize;
            float scaleZ   = sizeZ / pageSize;

            texUnit.SetTextureScale(scaleX, scaleZ);
            float centerX = pageX + pageSize / 2f;
            float centerZ = pageZ + pageSize / 2f;

            texUnit.SetTextureScroll((centerX - posX) / (pageSize * scaleX), (centerZ - posZ) / (pageSize * scaleZ));
            texUnit.SetTextureRotate(rot);
        }
예제 #23
0
        /// <summary>
        ///
        /// </summary>
        protected void UpdateMaterials()
        {
            for (int o = 0; o < ImpostorYawAngles; o++)
            {
                for (int i = 0; i < ImpostorPitchAngles; i++)
                {
                    Material         m = mMaterial[i, o];
                    Pass             p = m.GetTechnique(0).GetPass(0);
                    TextureUnitState t = p.GetTextureUnitState(0);

                    t.SetTextureName(mTexture.Name);
                }
            }
        }
예제 #24
0
        public void SetWardrobeTexture(Wardrobe thePieceType, string theTexture)
        {
            if (string.Compare(theTexture, "none", true) == 0 ||
                string.IsNullOrEmpty(theTexture))
            {
                return;
            }

            // gather information about wardrobe
            if (ModelEntity.GetMesh().NumSubMeshes > 0)
            {
                bool needsReload = false;
                foreach (var subMesh in ModelEntity.GetMesh().GetSubMeshIterator())
                {
                    var matPtr = (MaterialPtr)MaterialManager.Singleton.GetByName(subMesh.MaterialName);

                    string suitStr = thePieceType.ToString();
                    if (subMesh.MaterialName.IndexOf(suitStr, StringComparison.OrdinalIgnoreCase) >= 0)
                    {
                        foreach (var mtrPass in matPtr.GetTechnique(0).GetPassIterator())
                        {
                            mtrPass.RemoveAllTextureUnitStates();

                            TextureUnitState baseTex = null;
                            if (WardrobeTextures[(int)Wardrobe.Face] != null)
                            {
                                baseTex = new TextureUnitState(mtrPass, WardrobeTextures[(int)Wardrobe.Face]);
                            }
                            TextureUnitState wardTex = new TextureUnitState(mtrPass, theTexture);
                            wardTex.SetColourOperation(LayerBlendOperation.LBO_ALPHA_BLEND);
                            needsReload = true;
                            if (baseTex != null)
                            {
                                mtrPass.AddTextureUnitState(baseTex);
                            }
                            mtrPass.AddTextureUnitState(wardTex);
                        }

                        WardrobeTextures[(int)thePieceType] = theTexture;
                        break;
                    }
                    if (needsReload)
                    {
                        matPtr.Reload();
                    }
                }
            }
        }
예제 #25
0
        private void PreparePass()
        {
            Technique technique = this.materialPtr.CreateTechnique();            ///UNDONE setShadowCasterMaterial

            this.Pass                   = technique.CreatePass();
            this.Pass.CullingMode       = CullingMode.CULL_NONE;
            this.Pass.DepthCheckEnabled = false;
            this.Pass.DepthWriteEnabled = false;
            this.Pass.LightingEnabled   = false;

            this.Pass.SetSceneBlending(SceneBlendType.SBT_TRANSPARENT_ALPHA);

            TextureUnitState tus = this.Pass.CreateTextureUnitState();

            tus.SetTextureAddressingMode(TextureUnitState.TextureAddressingMode.TAM_WRAP);
        }
예제 #26
0
        public static void CreateEditNode(string key, Vector3 position, Quaternion orientation)
        {
            WorldEntity worldEntity = Engine.World.GetWorldEntity(key);
            SceneNode   sceneNode   = worldEntity.CreateSceneNode(position, orientation);

            if (sceneNode != null)
            {
                EditNode editNode    = new EditNode(key, worldEntity, sceneNode);
                ushort   numObjects  = sceneNode.NumAttachedObjects();
                ushort   numEntities = 0;

                for (ushort i = 0; i < numObjects; i++)
                {
                    Entity entity = sceneNode.GetAttachedObject(i) as Entity;

                    // if we haven't found an entity by now we need to make one ourselves
                    if (entity == null && i == numObjects - 1 && numEntities == 0)
                    {
                        entity = Engine.Graphics.SceneManager.CreateEntity("ball.mesh");
                        sceneNode.AttachObject(entity);
                    }

                    // setup special material scheme used in the editor only
                    if (entity != null)
                    {
                        for (uint j = 0; j < entity.NumSubEntities; j++)
                        {
                            Technique technique = entity.GetSubEntity(j).GetMaterial().CreateTechnique();
                            technique.SchemeName = "WireframeScheme";
                            Pass pass = technique.CreatePass();
                            pass.LightingEnabled = false;
                            TextureUnitState textureUnit = pass.CreateTextureUnitState();
                            textureUnit.SetColourOperationEx(LayerBlendOperationEx.LBX_SOURCE1, LayerBlendSource.LBS_MANUAL, LayerBlendSource.LBS_CURRENT,
                                                             new ColourValue(
                                                                 0.5f + Mogre.Math.RangeRandom(0, 0.5f),
                                                                 0.5f + Mogre.Math.RangeRandom(0, 0.5f),
                                                                 0.5f + Mogre.Math.RangeRandom(0, 0.5f)));
                        }

                        entity.UserObject = editNode;
                        numEntities++;
                    }
                }

                Editor.editNodes.Add(editNode);
            }
        }
예제 #27
0
 public void setMaterial(string name, bool texture)
 {
     if (!texture)
     {
         base.setMaterial(name);
     }
     else
     {
         // If material already exists, use it!
         if (mMaterialPtr == null) // GDZ, codigo original:          if(mMaterialPtr.isNull())
         {
             mMaterialPtr = MaterialManager.Singleton.Create(mInstanceName + "_RenderTextureMaterial", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);
             TextureUnitState t = mMaterialPtr.GetTechnique(0).GetPass(0).CreateTextureUnitState(name);
         }
         mOverlayElement.MaterialName = mMaterialPtr.Name;
     }
 }
예제 #28
0
        //创建场景
        private void CreateScene(int width, int height, string filename)
        {
            string planename = Guid.NewGuid().ToString("N");
            // 地面的法线方向。可以决定地面的朝向,
            Plane p;

            p.normal = Vector3.UNIT_Z;
            p.d      = 0;
            //判断地面模型是否已经创建,主要是处理新建场景后,关闭文档,在次打开时,模型已和纹理材质已创建,在次创建就会报错,在此做判断
            if (!MeshManager.Singleton.ResourceExists(planename))
            {
                //创建场景地面模型,通过指定的长和宽
                MeshManager.Singleton.CreatePlane(planename, ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, p, width, height, 20, 20, true, 1, 1F, 1F, Vector3.UNIT_Y);
                //同上面
                if (!TextureManager.Singleton.ResourceExists(filename))
                {
                    //载入纹理
                    TexturePtr textureptr = TextureManager.Singleton.Load(filename, ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);
                    //创建材质
                    MaterialPtr      materialptr = MaterialManager.Singleton.Load(filename, ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);
                    TextureUnitState state       = materialptr.GetTechnique(0).GetPass(0).CreateTextureUnitState(filename);
                    //设置纹理的寻址模式,如果不设置。有可能在结边的时候出现缝隙
                    state.SetTextureAddressingMode(TextureUnitState.TextureAddressingMode.TAM_MIRROR);
                    //材质相应设置,可参见API文档
                    materialptr.GetTechnique(0).GetPass(0).DepthWriteEnabled = false;
                    materialptr.GetTechnique(0).GetPass(0).DepthFunction     = CompareFunction.CMPF_LESS_EQUAL;
                }
            }
            EsdSceneManager.Singleton.MaterialPtr = MaterialManager.Singleton.GetByName(filename);
            Entity ent = EsdSceneManager.Singleton.SceneManager.CreateEntity("floor", planename);

            EsdSceneManager.Singleton.FloorNode = EsdSceneManager.Singleton.SceneManager.RootSceneNode.CreateChildSceneNode();
            EsdSceneManager.Singleton.FloorNode.AttachObject(ent);
            //设计材质
            ent.SetMaterialName(filename);
            //保存当前场景状态。
            EsdSceneManager.Singleton.ModelDataManage.modelEntry.场景地面图片 = filename;
            EsdSceneManager.Singleton.ModelDataManage.modelEntry.场景宽    = width;
            EsdSceneManager.Singleton.ModelDataManage.modelEntry.场景高    = height;
            EsdSceneManager.Singleton.ModelDataManage.modelEntry.模型名    = planename;

            //开始编辑标志
            EsdSceneManager.Singleton.IsStarEdit = true;
            EsdSceneManager.Singleton.OgreImage.UpdataCamera();
        }
예제 #29
0
        /// <summary>
        ///     Creates a basic time-based texture coordinate modifier designed for creating rotating textures.
        /// </summary>
        /// <remarks>
        ///     This simple method allows you to easily create constant-speed scrolling textures. If you want more
        ///     control, look up the ControllerManager.CreateTextureWaveTransformer for more complex wave-based
        ///     scrollers / stretchers / rotaters.
        /// </remarks>
        /// <param name="layer">The texture unit to animate.</param>
        /// <param name="speedU">Horizontal speed, in wraps per second.</param>
        /// <param name="speedV">Vertical speed, in wraps per second.</param>
        /// <returns>A newly created controller object that will be updated during the main render loop.</returns>
        public Controller <float> CreateTextureScroller(TextureUnitState layer, float speedU, float speedV)
        {
            IControllerValue <float>    val        = null;
            IControllerFunction <float> func       = null;
            Controller <float>          controller = null;

            // if both u and v speeds are the same, we can use a single controller for it
            if (speedU != 0 && (speedU == speedV))
            {
                // create the value and function
                val  = new TexCoordModifierControllerValue(layer, true, true);
                func = new MultipyControllerFunction(-speedU, true);

                // create the controller (uses FrameTime for source by default)
                controller = CreateController(val, func);
            }
            else
            {
                // create seperate for U
                if (speedU != 0)
                {
                    // create the value and function
                    val  = new TexCoordModifierControllerValue(layer, true, false);
                    func = new MultipyControllerFunction(-speedU, true);

                    // create the controller (uses FrameTime for source by default)
                    controller = CreateController(val, func);
                }

                // create seperate for V
                if (speedV != 0)
                {
                    // create the value and function
                    val  = new TexCoordModifierControllerValue(layer, false, true);
                    func = new MultipyControllerFunction(-speedV, true);

                    // create the controller (uses FrameTime for source by default)
                    controller = CreateController(val, func);
                }
            }

            // TODO: Revisit, since we can't return 2 controllers in the case of non equal U and V speeds
            return(controller);
        }
예제 #30
0
        /// <summary>
        ///     Creates a basic time-based texture v coordinate modifier designed for creating scrolling textures.
        /// </summary>
        /// <remarks>
        ///     This simple method allows you to easily create constant-speed scrolling textures. If you want more
        ///     control, look up the <see cref="CreateTextureWaveTransformer"/> for more complex wave-based
        ///     scrollers / stretchers / rotaters.
        /// </remarks>
        /// <param name="layer">The texture unit to animate.</param>
        /// <param name="speed">speed, in wraps per second.</param>
        /// <returns>A newly created controller object that will be updated during the main render loop.</returns>
        public Controller <Real> CreateTextureVScroller(TextureUnitState layer, Real speed)
        {
            IControllerValue <Real>    val        = null;
            IControllerFunction <Real> func       = null;
            Controller <Real>          controller = null;

            // if both u and v speeds are the same, we can use a single controller for it
            if (speed != 0)
            {
                // create the value and function
                val  = new TexCoordModifierControllerValue(layer, false, true);
                func = new MultipyControllerFunction(-speed, true);

                // create the controller (uses FrameTime for source by default)
                controller = CreateController(val, func);
            }

            return(controller);
        }
예제 #31
0
        protected override void OnClearBaseMaterial()
        {
            reflectionMapState = null;

            //clear material
            BaseMaterial.RemoveAllTechniques();

            base.OnClearBaseMaterial();
        }
예제 #32
0
        void UpdateReflectionCubemap( TextureUnitState textureUnitState, Vec3 objectWorldPosition )
        {
            string textureName = "";

            Vec4 reflectionParallax_cubemapPosition = Vec4.Zero;
            Vec3 reflectionParallax_rotationScale0 = Vec3.Zero;
            Vec3 reflectionParallax_rotationScale1 = Vec3.Zero;
            Vec3 reflectionParallax_rotationScale2 = Vec3.Zero;
            Vec3 reflectionParallax_position = Vec3.Zero;

            //get cubemap from CubemapZone's
            if( Map.Instance != null )
            {
                CubemapZone zone = CubemapZone.GetZoneForPoint( objectWorldPosition, true );
                if( zone != null )
                {
                    textureName = zone.GetTextureName();
                    reflectionParallax_cubemapPosition = new Vec4( zone.Position, 0 );
                }

                CubemapZone_BoxParallaxCorrectedZone zone2 = CubemapZone_BoxParallaxCorrectedZone.GetZoneForPoint( objectWorldPosition, 1 );
                if( zone2 != null )
                {
                    Mat3 mat = zone2.GetCachedRotationScaleInverseMatrix();
                    //Mat3 mat = zone2.Rotation.ToMat3() * Mat3.FromScale( zone2.Scale * .5f );
                    //mat = mat.GetInverse();

                    mat.Transpose();
                    reflectionParallax_rotationScale0 = mat[ 0 ];
                    reflectionParallax_rotationScale1 = mat[ 1 ];
                    reflectionParallax_rotationScale2 = mat[ 2 ];
                    reflectionParallax_position = zone2.Position;

                    //enable parallax correction
                    reflectionParallax_cubemapPosition.W = 1;
                }
            }

            UpdateReflectionBoxParallaxCorrectedCubemapsGpuParameters( reflectionParallax_cubemapPosition,
                reflectionParallax_rotationScale0, reflectionParallax_rotationScale1, reflectionParallax_rotationScale2,
                reflectionParallax_position );

            //get cubemap from SkyBox
            if( string.IsNullOrEmpty( textureName ) )
                textureName = SceneManager.Instance.GetSkyBoxTextureName();

            //update state
            textureUnitState.SetCubicTextureName( textureName, true );
        }
예제 #33
0
		void UpdateReflectionCubemap( TextureUnitState textureUnitState, Vec3 objectWorldPosition )
		{
			string textureName = "";

			//get cubemap from CubemapZone's
			if( Map.Instance != null )
			{
				CubemapZone zone = CubemapZone.GetZoneForPoint( objectWorldPosition, true );
				if( zone != null )
					textureName = zone.GetTextureName();
			}

			//get cubemap from SkyBox
			if( string.IsNullOrEmpty( textureName ) )
				textureName = SceneManager.Instance.GetSkyBoxTextureName();

			//update state
			textureUnitState.SetCubicTextureName( textureName, true );
		}
        void UpdateReflectionCubemap( TextureUnitState textureUnitState, Vec3 objectWorldPosition )
        {
            string textureName = "";

            //get cubemap from CubemapZone's
            if( Map.Instance != null )
            {
                Map.Instance.GetObjects( new Bounds( objectWorldPosition ), delegate( MapObject obj )
                {
                    CubemapZone zone = obj as CubemapZone;
                    if( zone != null && !zone.GlobalZone )
                        textureName = zone.GetTextureName();
                } );

                if( string.IsNullOrEmpty( textureName ) )
                {
                    CubemapZone zone = CubemapZone.GetGlobalZone();
                    if( zone != null )
                        textureName = zone.GetTextureName();
                }
            }

            //get cubemap from SkyBox
            if( string.IsNullOrEmpty( textureName ) )
                textureName = SceneManager.Instance.GetSkyBoxTextureName();

            //update state
            textureUnitState.SetCubicTextureName( textureName, true );
        }
예제 #35
0
        void CreateDefaultTechnique( out bool notSupported )
        {
            notSupported = false;

            string sourceFile = "Materials\\Common\\Water.cg_hlsl";

            string vertexSyntax;
            string fragmentSyntax;
            {
                if( RenderSystem.Instance.IsDirect3D() )
                {
                    if( RenderSystem.Instance.HasShaderModel3() )
                    {
                        vertexSyntax = "vs_3_0";
                        fragmentSyntax = "ps_3_0";
                    }
                    else
                    {
                        vertexSyntax = "vs_2_0";
                        fragmentSyntax = "ps_2_0";
                    }
                }
                else
                {
                    vertexSyntax = "arbvp1";
                    fragmentSyntax = "arbfp1";
                }
            }

            if( !RenderSystem.Instance.HasShaderModel2() ||
                !RenderSystem.Instance.Capabilities.UserClipPlanes )
            {
                notSupported = true;
                return;
            }

            BaseMaterial.ReceiveShadows = false;

            Technique tecnhique = BaseMaterial.CreateTechnique();
            Pass pass = tecnhique.CreatePass();

            //generate compileArguments and bind textures
            StringBuilder compileArguments = new StringBuilder( 128 );

            //transparent surface
            if( owner.DeepColor.Alpha != 1 || owner.ShallowColor.Alpha != 1 )
            {
                pass.SourceBlendFactor = SceneBlendFactor.SourceAlpha;
                pass.DestBlendFactor = SceneBlendFactor.OneMinusSourceAlpha;
                pass.DepthWrite = false;

                compileArguments.Append( " -DTRANSPARENT" );
            }

            //disable Direct3D standard fog features
            pass.SetFogOverride( FogMode.None, new ColorValue( 0, 0, 0 ), 0, 0, 0 );

            //bool direct3d = RenderSystem.Instance.Name.Contains( "Direct3D" );
            //compileArguments.Append( direct3d ? " -DDIRECT3D" : " -DOPENGL" );

            //Fog
            FogMode fogMode = SceneManager.Instance.GetFogMode();
            if( fogMode != FogMode.None )
            {
                compileArguments.Append( " -DFOG_ENABLED" );
                compileArguments.Append( " -DFOG_" + fogMode.ToString().ToUpper() );
            }

            //noiseMap
            {
                TextureUnitState state = pass.CreateTextureUnitState();
                state.SetTextureName( "Types\\Special\\WaterPlane\\WaterNoise.dds", Texture.Type.Type2D );
            }

            //reflectionMap
            if( owner.ReflectionLevel != WaterPlane.ReflectionLevels.None )
            {
                compileArguments.Append( " -DREFLECTION_MAP" );

                reflectionMapState = pass.CreateTextureUnitState();
                if( owner.ReflectionTexture != null )
                    reflectionMapState.SetTextureName( owner.ReflectionTexture.Name );
                reflectionMapState.SetTextureAddressingMode( TextureAddressingMode.Clamp );
                reflectionMapState.SetTextureFiltering( FilterOptions.Linear,
                    FilterOptions.Linear, FilterOptions.None );
            }

            //vertex program
            {
                string errorString;

                GpuProgram program = GpuProgramCacheManager.Instance.AddProgram(
                    "WaterPlane_Vertex_", GpuProgramType.VertexProgram, sourceFile,
                    "main_vp", vertexSyntax, compileArguments.ToString(), out errorString );

                if( !string.IsNullOrEmpty( errorString ) )
                    Log.Fatal( errorString );

                if( program != null )
                {
                    GpuProgramParameters parameters = program.DefaultParameters;
                    SetProgramAutoConstants( parameters );
                    pass.VertexProgramName = program.Name;
                }
            }

            //fragment program
            {
                string errorString;

                GpuProgram program = GpuProgramCacheManager.Instance.AddProgram(
                    "WaterPlane_Fragment_", GpuProgramType.FragmentProgram, sourceFile,
                    "main_fp", fragmentSyntax, compileArguments.ToString(), out errorString );

                if( !string.IsNullOrEmpty( errorString ) )
                    Log.Fatal( errorString );

                if( program != null )
                {
                    SetProgramAutoConstants( program.DefaultParameters );
                    pass.FragmentProgramName = program.Name;
                }
            }
        }
예제 #36
0
        public void SetWardrobeTexture(Wardrobe thePieceType, string theTexture)
        {
            if (string.Compare(theTexture, "none", true) == 0 ||
                string.IsNullOrEmpty(theTexture)) return;
            
            // gather information about wardrobe
            if (ModelEntity.GetMesh().NumSubMeshes > 0)
            {
                bool needsReload = false;
                foreach (var subMesh in ModelEntity.GetMesh().GetSubMeshIterator())
                {
                    var matPtr = (MaterialPtr)MaterialManager.Singleton.GetByName(subMesh.MaterialName);

                    string suitStr = thePieceType.ToString();
                    if (subMesh.MaterialName.IndexOf(suitStr, StringComparison.OrdinalIgnoreCase) >= 0)
                    {                    
                        foreach (var mtrPass in matPtr.GetTechnique(0).GetPassIterator())
                        {                            
                            mtrPass.RemoveAllTextureUnitStates();

                            TextureUnitState baseTex = null;
                            if (WardrobeTextures[(int)Wardrobe.Face] != null)
                            {
                                baseTex = new TextureUnitState(mtrPass, WardrobeTextures[(int)Wardrobe.Face]);
                            }
                            TextureUnitState wardTex = new TextureUnitState(mtrPass, theTexture);
                            wardTex.SetColourOperation(LayerBlendOperation.LBO_ALPHA_BLEND);
                            needsReload = true;
                            if (baseTex!=null) mtrPass.AddTextureUnitState(baseTex);
                            mtrPass.AddTextureUnitState(wardTex);
                          
                        }

                        WardrobeTextures[(int)thePieceType] = theTexture;
                        break;
                    }
                    if (needsReload) matPtr.Reload();
                }                
            }
        }
예제 #37
0
파일: Tile.cs 프로젝트: CharcoalStyles/3DRL
        public void make()
        {
            if (type != tileTypes.wall)
            {
                unique++;
                //create a scene node, off the root scene node
                sn = Program.Instance.sceneManager.RootSceneNode.CreateChildSceneNode();
                //Load the mesh into the entity
                ent = Program.Instance.sceneManager.CreateEntity("tile" + unique, "Floor.mesh");
                //Attach the Entity to the scene node
                sn.AttachObject(ent);
                sn.Position = new Vector3(pos.x * Program.Instance.gameManager.tileSpacing, 0, pos.y * Program.Instance.gameManager.tileSpacing);

                MaterialPtr m = ent.GetSubEntity(0).GetMaterial();
                m.Clone("Bmat" + unique);
                MaterialPtr ma = MaterialManager.Singleton.GetByName("Bmat" + unique);
                Technique t = ma.GetTechnique(0);
                Pass p = t.GetPass(0);
                tus = p.GetTextureUnitState(0);

                switch (type)
                {
                    case tileTypes.corridor:
                        tus.SetTextureName("dirt_" + Program.Instance.random.Next(0, 5).ToString() + ".png");
                        break;
                    case tileTypes.room:
                        tus.SetTextureName("room_" + Program.Instance.random.Next(0, 10).ToString() + ".png");
                        break;
                    case tileTypes.door:
                        tus.SetTextureName("cdoor.png");
                        break;
                    case tileTypes.level_start:
                        tus.SetTextureName("up.png");
                        break;
                    case tileTypes.level_end:
                        tus.SetTextureName("down.png");
                        break;
                }

                ent.GetSubEntity(0).MaterialName = "Bmat" + unique;
            }
            else
            {
                if (pos.x > 0 && pos.y > 0 && pos.x < Program.Instance.gameManager.currentLevel.size.x - 1 && pos.y < Program.Instance.gameManager.currentLevel.size.y - 1)
                {
                    Console.WriteLine("MAKING WALL TILE: " + pos.ToString());
                    bool makeWall = false;
                    if (Program.Instance.gameManager.currentLevel.tiles[(int)pos.x - 1, (int)pos.y].type != tileTypes.wall)
                    {
                        makeWall = true;
                    }
                    if (Program.Instance.gameManager.currentLevel.tiles[(int)pos.x + 1, (int)pos.y].type != tileTypes.wall && !makeWall)
                    {
                        makeWall = true;
                    }
                    if (Program.Instance.gameManager.currentLevel.tiles[(int)pos.x, (int)pos.y - 1].type != tileTypes.wall && !makeWall)
                    {
                        makeWall = true;
                    }
                    if (Program.Instance.gameManager.currentLevel.tiles[(int)pos.x, (int)pos.y + 1].type != tileTypes.wall && !makeWall)
                    {
                        makeWall = true;
                    }

                    if (makeWall)
                    {
                        unique++;
                        //create a scene node, off the root scene node
                        sn = Program.Instance.sceneManager.RootSceneNode.CreateChildSceneNode();
                        //Load the mesh into the entity
                        ent = Program.Instance.sceneManager.CreateEntity("wall" + unique, "wall.mesh");
                        //Attach the Entity to the scene node
                        sn.AttachObject(ent);
                        sn.Position = new Vector3(pos.x * Program.Instance.gameManager.tileSpacing, 0, pos.y * Program.Instance.gameManager.tileSpacing);

                    }
                }

            }
        }
예제 #38
0
파일: WaterPlane.cs 프로젝트: whztt07/SDK
        void CreateDefaultTechnique()
        {
            string sourceFile = "Base\\Shaders\\Water.cg_hlsl";

            string vertexSyntax;
            string fragmentSyntax;
            {
                if( RenderSystem.Instance.IsDirect3D() )
                {
                    vertexSyntax = "vs_3_0";
                    fragmentSyntax = "ps_3_0";
                }
                else if( RenderSystem.Instance.IsOpenGLES() )
                {
                    vertexSyntax = "hlsl2glsl";
                    fragmentSyntax = "hlsl2glsl";
                }
                else
                {
                    vertexSyntax = "arbvp1";
                    fragmentSyntax = "arbfp1";
                }
            }

            BaseMaterial.ReceiveShadows = false;

            Technique tecnhique = BaseMaterial.CreateTechnique();
            Pass pass = tecnhique.CreatePass();

            bool transparent = owner.DeepColor.Alpha != 1 || owner.ShallowColor.Alpha != 1;

            //generate compileArguments and bind textures
            StringBuilder compileArguments = new StringBuilder( 128 );

            //general settings
            if( RenderSystem.Instance.IsDirect3D() )
                compileArguments.Append( " -DDIRECT3D" );
            if( RenderSystem.Instance.IsOpenGL() )
                compileArguments.Append( " -DOPENGL" );
            if( RenderSystem.Instance.IsOpenGLES() )
                compileArguments.Append( " -DOPENGL_ES" );
            if( !transparent )
                compileArguments.Append( " -DDEPTH_WRITE" );

            //transparent surface
            if( transparent )
            {
                pass.SourceBlendFactor = SceneBlendFactor.SourceAlpha;
                pass.DestBlendFactor = SceneBlendFactor.OneMinusSourceAlpha;
                pass.DepthWrite = false;

                compileArguments.Append( " -DTRANSPARENT" );
            }

            //disable Direct3D standard fog features
            pass.SetFogOverride( FogMode.None, new ColorValue( 0, 0, 0 ), 0, 0, 0 );

            //Fog
            if( owner.AllowFog )
            {
                FogMode fogMode = SceneManager.Instance.GetFogMode();
                if( fogMode != FogMode.None )
                {
                    compileArguments.Append( " -DFOG_ENABLED" );
                    compileArguments.Append( " -DFOG_" + fogMode.ToString().ToUpper() );
                }
            }

            //noiseMap
            {
                TextureUnitState state = pass.CreateTextureUnitState();
                state.SetTextureName( "Base\\Types\\Water Plane\\WaterNoise.dds", Texture.Type.Type2D );
            }

            //reflectionMap
            if( owner.ReflectionLevel != WaterPlane.ReflectionLevels.None &&
                RenderSystem.Instance.Capabilities.HardwareRenderToTexture )
            {
                compileArguments.Append( " -DREFLECTION_MAP" );

                reflectionMapState = pass.CreateTextureUnitState();
                reflectionMapState.SetTextureAddressingMode( TextureAddressingMode.Clamp );
                reflectionMapState.SetTextureFiltering( FilterOptions.Linear,
                    FilterOptions.Linear, FilterOptions.None );
            }

            //vertex program
            {
                string errorString;

                GpuProgram program = GpuProgramCacheManager.Instance.AddProgram(
                    "WaterPlane_Vertex_", GpuProgramType.Vertex, sourceFile,
                    "main_vp", vertexSyntax, compileArguments.ToString(), out errorString );

                if( !string.IsNullOrEmpty( errorString ) )
                    Log.Fatal( errorString );

                if( program != null )
                {
                    GpuProgramParameters parameters = program.DefaultParameters;
                    SetProgramAutoConstants( parameters );
                    pass.VertexProgramName = program.Name;
                }
            }

            //fragment program
            {
                string errorString;

                GpuProgram program = GpuProgramCacheManager.Instance.AddProgram(
                    "WaterPlane_Fragment_", GpuProgramType.Fragment, sourceFile,
                    "main_fp", fragmentSyntax, compileArguments.ToString(), out errorString );

                if( !string.IsNullOrEmpty( errorString ) )
                    Log.Fatal( errorString );

                if( program != null )
                {
                    SetProgramAutoConstants( program.DefaultParameters );
                    pass.FragmentProgramName = program.Name;
                }
            }
        }