Exemplo n.º 1
0
        public OverlayContainer createStaticImage(Vector4 posAndSize, String imageName, bool topLevel)
        {
            mGUI.tc++;
            MaterialPtr ptr = Wof.Misc.ViewHelper.CloneMaterial("bgui.image", "bgui.image_" + imageName + mO.Name + StringConverter.ToString(mGUI.tc));

            ptr.GetBestTechnique().GetPass(0).GetTextureUnitState(0).SetTextureName(imageName);

            //  alpha_op_ex source1 src_manual src_texture 0.5
            // ptr.GetBestTechnique().GetPass(0).GetTextureUnitState(0).SetAlphaOperation(LayerBlendOperationEx.LBX_SOURCE1, LayerBlendSource.LBS_MANUAL, LayerBlendSource.LBS_TEXTURE, 0.5f);


            Overlay o;

            if (topLevel)
            {
                o = mGUI.mOTop;
            }
            else
            {
                o = mGUI.mO;
            }

            OverlayContainer x = mGUI.createOverlay(mO.Name + StringConverter.ToString(mGUI.tc) + imageName,
                                                    new Vector2(posAndSize.x, posAndSize.y), new Vector2(posAndSize.z, posAndSize.w), ptr.Name, "", false, o);

            ptr = null;

            mO.AddChild(x);
            x.Show();
            mI.Add(x);

            return(x);
        }
Exemplo n.º 2
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));
                }
        }
Exemplo n.º 3
0
        public MaterialPtr RenderPreview()
        {
            string textureName  = "RttTex_Character_" + Guid.NewGuid().ToString();
            string materialName = "RttMat_Character_" + Guid.NewGuid().ToString();

            TexturePtr rttTexture =
                TextureManager.Singleton.CreateManual(
                    textureName,
                    ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
                    TextureType.TEX_TYPE_2D,
                    GameManager.Instance.renderWindow.Width,
                    GameManager.Instance.renderWindow.Height,
                    0,
                    PixelFormat.PF_R8G8B8,
                    (int)TextureUsage.TU_RENDERTARGET);

            RenderTexture renderTexture = rttTexture.GetBuffer().GetRenderTarget();

            renderTexture.AddViewport(camera);
            renderTexture.GetViewport(0).SetClearEveryFrame(false);
            renderTexture.GetViewport(0).BackgroundColour = new ColourValue(0, 0, 0, 0);
            renderTexture.Update();

            MaterialPtr materialPtr = MaterialManager.Singleton.Create(materialName, ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);

            materialPtr.GetTechnique(0).GetPass(0).SetSceneBlending(SceneBlendType.SBT_TRANSPARENT_ALPHA);
            materialPtr.GetTechnique(0).GetPass(0).CreateTextureUnitState().SetTextureName(textureName);

            return(materialPtr);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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());
        }
Exemplo n.º 6
0
 public MaterialPtr(MaterialPtr r) : this(OgrePINVOKE.new_MaterialPtr__SWIG_2(MaterialPtr.getCPtr(r)), true)
 {
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemplo n.º 7
0
        public void StartBackground(string value, params object[] param)
        {
            var sceneManager = param[0] as SceneManager;

            MaterialManager.Singleton.Remove("Background");

            MaterialPtr material = MaterialManager.Singleton.Create("Background", "General");

            material.GetTechnique(0).GetPass(0).CreateTextureUnitState(value);
            material.GetTechnique(0).GetPass(0).DepthCheckEnabled = false;
            material.GetTechnique(0).GetPass(0).DepthWriteEnabled = false;
            material.GetTechnique(0).GetPass(0).LightingEnabled   = false;

            Rectangle2D rect = new Rectangle2D(true);

            rect.SetCorners(-1.0f, 1.0f, 1.0f, -1.0f);
            rect.SetMaterial("Background");

            rect.RenderQueueGroup = (byte)RenderQueueGroupID.RENDER_QUEUE_BACKGROUND;

            AxisAlignedBox aab = new AxisAlignedBox();

            aab.SetInfinite();
            rect.BoundingBox = aab;

            SceneNode node = sceneManager.RootSceneNode.CreateChildSceneNode(Guid.NewGuid().ToString());

            node.AttachObject(rect);
        }
Exemplo n.º 8
0
        /// <summary>
        ///
        /// </summary>
        public void Create()
        {
            Remove();

            //Data manager
            this.DataManager = new DataManager(this);
            this.DataManager.Create(128, 128, 20);

            //Geometry manager
            this.GeometryManager = new GeometryManager(this, _height, _radius, _alpha, _beta, _numberOfBlocks, _na, _nb, _nc);
            this.GeometryManager.Create();
            using (MaterialPtr mat = (MaterialPtr)MaterialManager.Singleton.GetByName("SkyX_VolClouds")) {
                mat.GetTechnique(0).GetPass(0).GetVertexProgramParameters().SetNamedConstant("uRadius", _radius);
            }

            this.IsCreated = true;

            // Update MaterialPtr parameters
            this.SunColor       = _sunColor;
            this.AmbientColor   = _ambientColor;
            this.LightResponse  = _lightResponse;
            this.AmbientFactors = _ambientFactors;

            // Set current wheater
            int nforced = (_numberOfForcedUpdates == -1) ? 2 : _numberOfForcedUpdates;

            SetWeather(_weather.x, _weather.y, nforced);
        }
Exemplo n.º 9
0
        protected void drawLine(SceneNode p_Node, string lineName, Vector3 p_Point1, Vector3 p_Point2)
        {
            // create material (colour)
            MaterialPtr moMaterial = MaterialManager.Singleton.Create(lineName, "debugger");

            moMaterial.ReceiveShadows = false;
            moMaterial.GetTechnique(0).SetLightingEnabled(true);
            moMaterial.GetTechnique(0).GetPass(0).SetDiffuse(0, 0, 1, 0);
            moMaterial.GetTechnique(0).GetPass(0).SetAmbient(0, 0, 1);
            moMaterial.GetTechnique(0).GetPass(0).SetSelfIllumination(0, 0, 1);
            moMaterial.Dispose();  // dispose pointer, not the material


            // create line object
            ManualObject manOb = mSceneManager.CreateManualObject(lineName);

            manOb.Begin(lineName, RenderOperation.OperationTypes.OT_LINE_LIST);
            manOb.Position(p_Point1.x, p_Point1.y, p_Point1.z);
            manOb.Position(p_Point2.x, p_Point2.y, p_Point2.z);
            // ... maybe more points
            manOb.End();

            // create SceneNode and attach the line
            //            p_Node.Position = Vector3.ZERO;
            p_Node.AttachObject(manOb);
        }
Exemplo n.º 10
0
        public MovableText(string name, SceneManager sceneMgr, SceneNode node, Size size)
        {
            this.texture = TextureManager.Singleton.CreateManual(
                name + "Texture",
                ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
                TextureType.TEX_TYPE_2D,
                (uint)size.Width,
                (uint)size.Height,
                0,
                PixelFormat.PF_A8R8G8B8);

            this.material = MaterialManager.Singleton.Create(name + "Material", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);
            this.material.GetTechnique(0).GetPass(0).CreateTextureUnitState(this.texture.Name);
            this.material.SetSceneBlending(SceneBlendType.SBT_TRANSPARENT_ALPHA);
            this.material.SetDepthCheckEnabled(false);

            this.billboardSet = sceneMgr.CreateBillboardSet();
            this.billboardSet.SetMaterialName(this.material.Name);
            this.billboardSet.RenderQueueGroup = (byte)RenderQueueGroupID.RENDER_QUEUE_OVERLAY;

            this.billboard = this.billboardSet.CreateBillboard(Vector3.ZERO);
            this.billboard.SetDimensions(size.Width, size.Height);
            this.billboard.Colour = ColourValue.ZERO;

            node.AttachObject(this.billboardSet);
            this.sceneMgr = sceneMgr;
            this.size     = size;
        }
Exemplo n.º 11
0
        private void CreateLine(ManualObject mo, Vector3 origin, Vector3 final, int useMaterial, Vector4 color)
        {
            float lineWidth = 0.1f;

            RenderOperation.OperationTypes operation = RenderOperation.OperationTypes.OT_TRIANGLE_FAN;
            switch (useMaterial)
            {
            case 1:
                mo.Begin("SharpMap/Line3D_v1", operation);
                break;

            default:
                MaterialPtr material = MaterialManager.Singleton.CreateOrRetrieve("Test/ColourLines3d",
                                                                                  ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME).first;
                material.GetTechnique(0).GetPass(0).VertexColourTracking =
                    (int)TrackVertexColourEnum.TVC_AMBIENT;
                mo.Begin("Test/ColourLines3d", operation);

                break;
            }

            Vector3 delta = final - origin;

            delta = new Vector3(-delta.y, delta.x, delta.z).NormalisedCopy *lineWidth;
            mo.Position(origin);
            mo.Position(final);
            mo.Position(final + delta);
            mo.Position(origin + delta);
            //lines3d.TextureCoord((float)i / (float)pointsList.Count);

            ManualObject.ManualObjectSection section = lines3d.End();
            section.SetCustomParameter(constantColor, color);
        }
Exemplo n.º 12
0
        public static void CalculateAllAlphas(MaterialPtr material)
        {
            if (material == null)
            {
                return;
            }

            foreach (var technique in material.GetTechniqueIterator())
            {
                foreach (var pass in technique.GetPassIterator())
                {
                    foreach (var textureUnit in pass.GetTextureUnitStateIterator())
                    {
                        if (string.IsNullOrEmpty(textureUnit.TextureName))
                        {
                            return;
                        }

                        if (TextureManager.Singleton.GetByName(textureUnit.TextureName) == null)
                        {
                            var texture = TextureManager.Singleton.Load(textureUnit.TextureName, material.Group,
                                                                        TextureType.TEX_TYPE_2D,
                                                                        textureUnit.NumMipmaps, 1, false,
                                                                        PixelFormat.PF_A8R8G8B8);
                            CalculateAplha(texture);
                        }
                    }
                }
            }
        }
Exemplo n.º 13
0
        /// <summary>
        ///
        /// </summary>
        public void Update()
        {
            if (!this.IsCreated)
            {
                return;
            }

            float radius = this.SkyX.Camera.FarClipDistance * 0.95f;
            float size   = radius * this.MoonSize;

            this.MoonBillboard.CommonDirection = (this.SkyX.AtmosphereManager.SunDirection).NormalisedCopy.Perpendicular;

            Vector3 moonRelativePos = this.SkyX.AtmosphereManager.SunDirection *
                                      Utility.Cos(Utility.ASin((size / 2.0f) / radius)) * radius;

            this.MoonSceneNode.Position = this.SkyX.Camera.DerivedPosition + moonRelativePos;

            if (moonRelativePos.y < -size / 2)
            {
                this.MoonSceneNode.SetVisible(false);
            }
            else
            {
                //this.MoonSceneNode.IsVisible = true;
                this.MoonSceneNode.SetVisible(true);

                using (MaterialPtr mat = MaterialManager.Singleton.GetByName("SkyX_Moon")) {
                    //mat.GetTechnique(0).GetPass(0).VertexProgramParameters.SetNamedConstant("uSkydomeCenter", this.SkyX.Camera.DerivedPosition);
                    mat.GetTechnique(0).GetPass(0).GetVertexProgramParameters().SetNamedConstant("uSkydomeCenter", this.SkyX.Camera.DerivedPosition);
                }
            }
        }
Exemplo n.º 14
0
        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;
        }
Exemplo n.º 15
0
        public MovableText(string name, SceneManager sceneMgr, SceneNode node, Size size)
        {
            this.texture = TextureManager.Singleton.CreateManual(
                name + "Texture",
                ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
                TextureType.TEX_TYPE_2D,
                (uint)size.Width,
                (uint)size.Height,
                0,
                PixelFormat.PF_A8R8G8B8);

            this.material = MaterialManager.Singleton.Create(name + "Material", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);
            this.material.GetTechnique(0).GetPass(0).CreateTextureUnitState(this.texture.Name);
            this.material.SetSceneBlending(SceneBlendType.SBT_TRANSPARENT_ALPHA);
            this.material.SetDepthCheckEnabled(false);

            this.billboardSet = sceneMgr.CreateBillboardSet();
            this.billboardSet.SetMaterialName(this.material.Name);
            this.billboardSet.RenderQueueGroup = (byte)RenderQueueGroupID.RENDER_QUEUE_OVERLAY;

            this.billboard = this.billboardSet.CreateBillboard(Vector3.ZERO);
            this.billboard.SetDimensions(size.Width, size.Height);
            this.billboard.Colour = ColourValue.ZERO;

            node.AttachObject(this.billboardSet);
            this.sceneMgr = sceneMgr;
            this.size = size;
        }
Exemplo n.º 16
0
        protected unsafe void setupVideoGraphicsObject()
        {
            this.mCubeTexture = TextureManager.Singleton.CreateManual(
                "MyCubeTexture",
                ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
                TextureType.TEX_TYPE_2D,
                (uint)this.TexWidth,
                (uint)this.TexHeight,
                0,
                Mogre.PixelFormat.PF_A8R8G8B8);

            MaterialPtr inMat = MaterialManager.Singleton.Create("MyCubeMat", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);

            inMat.GetTechnique(0).GetPass(0).CreateTextureUnitState("MyCubeTexture");
            mCubeEntity.SetMaterialName("MyCubeMat");

            // draw bitmap to texture
            HardwarePixelBufferSharedPtr texBuffer = this.mCubeTexture.GetBuffer();

            texBuffer.Lock(HardwareBuffer.LockOptions.HBL_DISCARD);
            PixelBox pb = texBuffer.CurrentLock;

            using (Bitmap bm = new Bitmap(
                       (int)this.mCubeTexture.Width,
                       (int)this.mCubeTexture.Height,
                       (int)((this.mCubeTexture.Width * 4) + (pb.RowSkip * 4)),
                       System.Drawing.Imaging.PixelFormat.Format32bppArgb,
                       pb.data))
            {
                mVideoGraphics = Graphics.FromImage(bm);
            }

            texBuffer.Unlock();
            texBuffer.Dispose();
        }
Exemplo n.º 17
0
        public void AddHydraxDepthTechnique(String materialName)
        {
            if (hydrax == null || !hydrax.IsCreated)
            {
                return;
            }

            MaterialPtr m = MaterialManager.Singleton.GetByName(materialName);

            if (m != null && m.GetTechnique("_Hydrax_Depth_Technique") == null)
            {
                hydraxDepthMaterialsMap[materialName] = ((MaterialPtr)m).NumTechniques;
                hydraxDepthMaterials.Add(materialName);

                Technique t = m.CreateTechnique();

                hydrax.MaterialManager.AddDepthTechnique(t);

                m = null;
            }

            foreach (Technique t in hydrax.MaterialManager.DepthTechniques)
            {
                t.SetFog(true, FogMode.FOG_NONE);
            }
        }
Exemplo n.º 18
0
        private void setMaterialTexture(Entity p_Entity)
        {
            MaterialPtr inMat = MaterialManager.Singleton.Create("MyCubeMat", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);

            inMat.GetTechnique(0).GetPass(0).CreateTextureUnitState("MyCubeTexture");
            mCubeEntity.SetMaterialName("MyCubeMat");
        }
Exemplo n.º 19
0
        public void createScene()
        {
            Mogre.Vector3 vectLightPos = new Mogre.Vector3(75, 75, 75);
            m_pSceneMgr.CreateLight("Light").Position = vectLightPos;//(75, 75, 75);

            DotSceneLoader pDotSceneLoader = new DotSceneLoader();

            pDotSceneLoader.ParseDotScene("CubeScene.xml", "General", m_pSceneMgr, m_pSceneMgr.RootSceneNode);
            pDotSceneLoader = null;

            m_pSceneMgr.GetEntity("Cube01").QueryFlags = 1 << 1;
            m_pSceneMgr.GetEntity("Cube02").QueryFlags = 1 << 1; //(CUBE_MASK);
            m_pSceneMgr.GetEntity("Cube03").QueryFlags = 1 << 1; //(CUBE_MASK);

            m_pOgreHeadEntity            = m_pSceneMgr.CreateEntity("Cube", "ogrehead.mesh");
            m_pOgreHeadEntity.QueryFlags = 1 << 0;
            m_pOgreHeadNode = m_pSceneMgr.RootSceneNode.CreateChildSceneNode("CubeNode");
            m_pOgreHeadNode.AttachObject(m_pOgreHeadEntity);
            Mogre.Vector3 vectOgreHeadNodePos = new Mogre.Vector3(0, 0, -25);
            m_pOgreHeadNode.Position = vectOgreHeadNodePos;// (Vector3(0, 0, -25));

            m_pOgreHeadMat     = m_pOgreHeadEntity.GetSubEntity(1).GetMaterial();
            m_pOgreHeadMatHigh = m_pOgreHeadMat.Clone("OgreHeadMatHigh");
            ColourValue cvAmbinet = new Mogre.ColourValue(1, 0, 0);

            m_pOgreHeadMatHigh.GetTechnique(0).GetPass(0).Ambient = cvAmbinet;
            ColourValue cvDiffuse = new Mogre.ColourValue(1, 0, 0, 0);

            m_pOgreHeadMatHigh.GetTechnique(0).GetPass(0).Diffuse = cvDiffuse;

            physxScene.Simulate(0);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Initializes a new instance of the RenderManager class.
        /// </summary>
        internal MogreRenderManager(MiyagiSystem miyagiSystem)
            : base(miyagiSystem)
        {
            renderManagerCount++;

            // get SceneManager
            using (SceneManagerEnumerator.SceneManagerIterator sci = Root.Singleton.GetSceneManagerIterator())
            {
                sci.MoveNext();
                this.SceneManager = sci.Current;
            }

            // get Camera
            if (this.SceneManager != null)
            {
                using (SceneManager.CameraIterator ci = this.SceneManager.GetCameraIterator())
                {
                    ci.MoveNext();
                    if (ci.Current != null)
                    {
                        this.MainViewport = new MogreViewport(ci.Current, miyagiSystem.Backend.Width, miyagiSystem.Backend.Height);
                    }
                }
            }

            this.DefaultRenderQueue = (byte)RenderQueueGroupID.RENDER_QUEUE_OVERLAY;
            this.MainRenderer       = new MogreSpriteRenderer2D(this);
            ((IMogreSpriteRenderer)this.MainRenderer).RenderOnRenderQueueEnded = true;

            this.materialPtr = MaterialManager.Singleton.CreateOrRetrieve(
                "Miyagi_Material" + renderManagerCount,
                this.MiyagiSystem.Backend.ResourceGroupName).first;
            this.PreparePass();
        }
Exemplo n.º 21
0
        public override void CreateScene()
        {
            // Set some camera params
            camera.FarClipDistance  = 30000;
            camera.NearClipDistance = 20;

            camera.SetPosition(20000, 500, 20000);
            camera.SetDirection(1, 0, 0);

            // Create our text area for display SkyX parameters
            CreateTextArea();

            manager = new SkyManager(base.sceneMgr, base.camera);
            manager.Create();

            // Add our ground atmospheric scattering pass to terrain material
            MaterialPtr material = MaterialManager.Singleton.GetByName(TerrainMaterialName);

            manager.GPUManager.AddGroundPass(material.GetTechnique(0).CreatePass(), 5000, SceneBlendType.SBT_TRANSPARENT_COLOUR);

            // Create our terrain
            sceneMgr.SetWorldGeometry("Terrain.cfg");

            // Add a basic cloud layer
            manager.CloudsManager.Add(new CloudLayer.LayerOptions());

            //Add frame evnet
            root.FrameStarted += new FrameListener.FrameStartedHandler(FrameStarted);
        }
Exemplo n.º 22
0
 public ManualObjectSection(ManualObject parent, MaterialPtr mat, RenderOperation.OperationType opType) : this(OgrePINVOKE.new_ManualObject_ManualObjectSection__SWIG_2(ManualObject.getCPtr(parent), MaterialPtr.getCPtr(mat), (int)opType), true)
 {
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemplo n.º 23
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);
            }
        }
Exemplo n.º 24
0
 public int Add(MaterialPtr sn)
 {
     if (IndexOf(sn.Name) > 0) throw new InvalidOperationException("A MaterialPtr with the name \"" + sn.Name + "\" already exists.");
     lock (allMaterials)
     {
         return allMaterials.Add(((MaterialPtr)sn));
     }
 }
Exemplo n.º 25
0
 public void setShadowReceiverMaterial(MaterialPtr val)
 {
     OgrePINVOKE.Technique_setShadowReceiverMaterial__SWIG_0(swigCPtr, MaterialPtr.getCPtr(val));
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemplo n.º 26
0
 public void setMaterial(MaterialPtr mat)
 {
     OgrePINVOKE.ManualObject_ManualObjectSection_setMaterial(swigCPtr, MaterialPtr.getCPtr(mat));
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemplo n.º 27
0
 public virtual void setMaterial(uint subIndex, MaterialPtr mat)
 {
     OgrePINVOKE.ManualObject_setMaterial(swigCPtr, subIndex, MaterialPtr.getCPtr(mat));
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemplo n.º 28
0
 public virtual void begin(MaterialPtr mat)
 {
     OgrePINVOKE.ManualObject_begin__SWIG_4(swigCPtr, MaterialPtr.getCPtr(mat));
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemplo n.º 29
0
 public virtual void begin(MaterialPtr mat, RenderOperation.OperationType opType)
 {
     OgrePINVOKE.ManualObject_begin__SWIG_3(swigCPtr, MaterialPtr.getCPtr(mat), (int)opType);
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemplo n.º 30
0
        public static void ColorMaterialWithZone(MaterialPtr eMat, Zones z)
        {
            eMat.SetSceneBlending(SceneBlendType.SBT_TRANSPARENT_ALPHA);
            ColourValue c = CityManager.GetZoneColor(z);

            eMat.SetDiffuse(c.r, c.g, c.b, 0.5f);
            eMat.SetDepthWriteEnabled(false);
        }
Exemplo n.º 31
0
 public void _setMaterial(MaterialPtr mat)
 {
     OgreOverlayPINVOKE.Font__setMaterial(swigCPtr, MaterialPtr.getCPtr(mat));
     if (OgreOverlayPINVOKE.SWIGPendingException.Pending)
     {
         throw OgreOverlayPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemplo n.º 32
0
 public void setMaterial(MaterialPtr mat)
 {
     OgrePINVOKE.Frustum_setMaterial(swigCPtr, MaterialPtr.getCPtr(mat));
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemplo n.º 33
0
 public Boolean Contains(MaterialPtr a)
 {
     foreach (MaterialPtr tex in allMaterials)
     {
         if (tex.Name == a.Name)
         {
             return true;
         }
     }
     return false;
 }
Exemplo n.º 34
0
 public void Dispose()
 {
     if (material != null)
     {
         material.Dispose();
         material = null;
     }
     if (root != null)
     {
         root.Dispose();
         root = null;
     }
 }
Exemplo n.º 35
0
        public static void CalculateAllAlphas(MaterialPtr material)
        {
            if (material == null) return;

            foreach (var technique in material.GetTechniqueIterator())
            {
                foreach (var pass in technique.GetPassIterator())
                {
                    foreach (var textureUnit in pass.GetTextureUnitStateIterator())
                    {
                        if (string.IsNullOrEmpty(textureUnit.TextureName)) return;

                        if (TextureManager.Singleton.GetByName(textureUnit.TextureName) == null)
                        {
                            var texture = TextureManager.Singleton.Load(textureUnit.TextureName, material.Group,
                                                                        TextureType.TEX_TYPE_2D,
                                                                        textureUnit.NumMipmaps, 1, false,
                                                                        PixelFormat.PF_A8R8G8B8);
                            CalculateAplha(texture);
                        }
                    }
                }
            }
        }
Exemplo n.º 36
0
            public void selectComponent(string name)
            {
                // Restore old material to previously selected component
                if (curComponent != null)
                  curComponent.SetMaterial(restoreMat);

                if (string.IsNullOrEmpty(name))
                {
                  curComponent = null;
                  return;
                }

                // Set the new current component and add a wireframe highlight to indicated selection
                curComponent = mainStick.GetSubEntity(name);
                restoreMat = curComponent.GetMaterial();
                MaterialPtr newMat = MaterialManager.Singleton.Create("Highlight", "General");
                Pass highlight = newMat.GetTechnique(0).GetPass(0);
                highlight.LightingEnabled = false;
                highlight.PolygonMode = PolygonMode.PM_WIREFRAME;
                highlight = newMat.GetTechnique(0).CreatePass();
                highlight = curComponent.Technique.GetPass(0);

                curComponent.SetMaterial(newMat);

                Messenger<Material>.Broadcast("CurSelectedMaterial", restoreMat);
            }
Exemplo n.º 37
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;
                    }
            }
        }
Exemplo n.º 38
0
 private void SetMaterialFragmentParameter(MaterialPtr mat, ushort passIndex, string constantName, ColourValue colour)
 {
     var ps = mat.GetTechnique(0).GetPass(passIndex).GetFragmentProgramParameters();
         ps.SetNamedConstant(constantName, colour);
     mat.GetTechnique(0).GetPass(passIndex).SetFragmentProgramParameters(ps);
 }
Exemplo n.º 39
0
        public void InitMogre()
        {
            //-----------------------------------------------------
            // 1 enter ogre
            //-----------------------------------------------------
            root = new Root();

            //-----------------------------------------------------
            // 2 configure resource paths
            //-----------------------------------------------------
            ConfigFile cf = new ConfigFile();
            cf.Load("resources.cfg", "\t:=", true);

            // Go through all sections & settings in the file
            ConfigFile.SectionIterator seci = cf.GetSectionIterator();

            String secName, typeName, archName;

            // Normally we would use the foreach syntax, which enumerates the values, but in this case we need CurrentKey too;
            while (seci.MoveNext())
            {
                secName = seci.CurrentKey;
                ConfigFile.SettingsMultiMap settings = seci.Current;
                foreach (KeyValuePair<string, string> pair in settings)
                {
                    typeName = pair.Key;
                    archName = pair.Value;
                    ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName);
                }
            }

            //-----------------------------------------------------
            // 3 Configures the application and creates the window
            //-----------------------------------------------------
            bool foundit = false;
            foreach (RenderSystem rs in root.GetAvailableRenderers())
            {
                root.RenderSystem = rs;
                String rname = root.RenderSystem.Name;
                if (rname == "Direct3D9 Rendering Subsystem")
                {
                    foundit = true;
                    break;
                }
            }

            if (!foundit)
                return; //we didn't find it... Raise exception?

            //we found it, we might as well use it!
            root.RenderSystem.SetConfigOption("Full Screen", "No");
            root.RenderSystem.SetConfigOption("Video Mode", "640 x 480 @ 32-bit colour");

            root.Initialise(false);
            NameValuePairList misc = new NameValuePairList();
            misc["externalWindowHandle"] = hWnd.ToString();
            window = root.CreateRenderWindow("Simple Mogre Form Window", 0, 0, false, misc);
            ResourceGroupManager.Singleton.InitialiseAllResourceGroups();

            //-----------------------------------------------------
            // 4 Create the SceneManager
            //
            //		ST_GENERIC = octree
            //		ST_EXTERIOR_CLOSE = simple terrain
            //		ST_EXTERIOR_FAR = nature terrain (depreciated)
            //		ST_EXTERIOR_REAL_FAR = paging landscape
            //		ST_INTERIOR = Quake3 BSP
            //-----------------------------------------------------
            sceneMgr = root.CreateSceneManager(SceneType.ST_GENERIC, "SceneMgr");
            sceneMgr.AmbientLight = new ColourValue(1f, 1f, 1f);

            //-----------------------------------------------------
            // 5 Create the camera
            //-----------------------------------------------------
            camera = sceneMgr.CreateCamera("SimpleCamera");
            camera.Position = new Vector3(400f, 0f, 0f);
            // Look back along -Z
            camera.LookAt(new Vector3(-1f, 0f, 0f));
            camera.NearClipDistance = 5;

            viewport = window.AddViewport(camera);
            viewport.BackgroundColour = new ColourValue(0.0f, 0.0f, 0.0f, 1.0f);

            material = MaterialManager.Singleton.Create("front", "General");
            material.GetTechnique(0).GetPass(0).CreateTextureUnitState("snow3.jpg");
            material = MaterialManager.Singleton.Create("other", "General");
            material.GetTechnique(0).GetPass(0).CreateTextureUnitState("snow.jpg");
            material = MaterialManager.Singleton.Create("back", "General");
            material.GetTechnique(0).GetPass(0).CreateTextureUnitState("back2.jpg");

            Vector3 moveVector3 = new Vector3(0f,-60f,110f);
            for (int i = 0; i < cubeCount; i++)
            {
                Cube cube = new Cube();
                cube.CubeName = "cube" + i.ToString();
                cube.BuildCube("front", ref sceneMgr);

                ManualObject manual = sceneMgr.GetManualObject(cube.CubeName);
                manual.ConvertToMesh("cubeMesh"+i.ToString());
                Entity ent = sceneMgr.CreateEntity("box"+i.ToString(), "cubeMesh"+i.ToString());
                SceneNode node = sceneMgr.RootSceneNode.CreateChildSceneNode("boxNode"+i.ToString());
                ent.CastShadows = true;
                node.AttachObject(ent);
                float y = i * (Cube.cubeHeight + 10) + moveVector3.y;
                node.Position = new Vector3(0f, y, moveVector3.z);
            }

            Plane plane = new Plane();
            plane.BuildPlane("back",ref sceneMgr);
            ManualObject manualPlane = sceneMgr.GetManualObject(plane.PlaneName);
            manualPlane.ConvertToMesh("planeMesh");
            Entity planeEntity = sceneMgr.CreateEntity("planeEntity", "planeMesh");
            SceneNode planeNode = sceneMgr.RootSceneNode.CreateChildSceneNode("planeNode");
            planeNode.AttachObject(planeEntity);
        }
Exemplo n.º 40
0
        public void Dispose()
        {
            this.billboardSet.DetachFromParent();
            this.sceneMgr.DestroyBillboardSet(this.billboardSet);
            this.billboardSet.Dispose();
            this.billboardSet = null;
            this.sceneMgr = null;

            this.material.Unload();
            MaterialManager.Singleton.Remove(this.material.Handle);
            this.material.Dispose();
            this.material = null;

            this.texture.Unload();
            TextureManager.Singleton.Remove(this.texture.Handle);
            this.texture.Dispose();
            this.texture = null;

            GC.SuppressFinalize(this);
        }