コード例 #1
0
        public void SetCorners(Quadrangle quadrangle)
        {
            manualObject.RenderQueueGroup = (byte)RenderQueueGroupID.RENDER_QUEUE_OVERLAY;
            manualObject.QueryFlags       = 0;
            Vector2 leftBottom  = UnitConverter.LogicToWorldUnits(quadrangle.Peaks[0]);
            Vector2 leftTop     = UnitConverter.LogicToWorldUnits(quadrangle.Peaks[1]);
            Vector2 rightTop    = UnitConverter.LogicToWorldUnits(quadrangle.Peaks[2]);
            Vector2 rightBottom = UnitConverter.LogicToWorldUnits(quadrangle.Peaks[3]);


            manualObject.Clear();
            manualObject.Begin("Misc/BoundingQuadrangle", RenderOperation.OperationTypes.OT_LINE_STRIP);
            manualObject.Position(leftBottom.x, leftBottom.y, 0);
            manualObject.TextureCoord(0, 0);
            manualObject.Position(leftTop.x, leftTop.y, 0);
            manualObject.TextureCoord(0, 1);
            manualObject.Position(rightTop.x, rightTop.y, 0);
            manualObject.TextureCoord(1, 1);
            manualObject.Position(rightBottom.x, rightBottom.y, 0);
            manualObject.TextureCoord(0, 1);
            manualObject.Position(leftBottom.x, leftBottom.y, 0);
            manualObject.TextureCoord(0, 0);
            manualObject.End();

            AxisAlignedBox box = new AxisAlignedBox();

            box.SetInfinite();
            manualObject.BoundingBox = box;
            OnSetCorners();
        }
コード例 #2
0
        public static void Create2DElement(String name, String texture, Vector2 TopLeft, Vector2 BottomRight)
        {
            MaterialPtr material = MaterialManager.Singleton.Create(name, "General");
                material.GetTechnique(0).GetPass(0).CreateTextureUnitState(texture);
                material.GetTechnique(0).GetPass(0).DepthCheckEnabled = false;
                material.GetTechnique(0).GetPass(0).DepthWriteEnabled = false;
                material.GetTechnique(0).GetPass(0).LightingEnabled = false;
                // Create background rectangle covering the whole screen
                Rectangle2D rect = new Rectangle2D(true);
                rect.SetCorners(TopLeft.x * 2 - 1, 1 - TopLeft.y * 2, BottomRight.x * 2 - 1, 1 - BottomRight.y * 2);
                //rect.SetCorners(-1.0f, 1.0f, 1.0f, -1.0f);
                rect.SetMaterial(name);

                // Render the background before everything else
                rect.RenderQueueGroup = (byte)RenderQueueGroupID.RENDER_QUEUE_OVERLAY;

                // Use infinite AAB to always stay visible
                AxisAlignedBox aab = new AxisAlignedBox();
                aab.SetInfinite();
                rect.BoundingBox = aab;

                // Attach background to the scene
                SceneNode node = _OgreEngine.mMgr.RootSceneNode.CreateChildSceneNode("2D__" + name);
                node.AttachObject(rect);
        }
コード例 #3
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);
        }
コード例 #4
0
ファイル: Utils.cs プロジェクト: RainsSoft/ogreflow
        // create a 2D hud element: pos = [-1;1] & size = (pixels)
        public static MovableObject MakeHud(SceneManager mgr, Viewport vp, String materialName, Vector2 pos, Vector2 size)
        {
            // Create a manual object for 2D
            ManualObject manual = mgr.CreateManualObject();

            // Use identity view/projection matrices
            manual.UseIdentityProjection = true;
            manual.UseIdentityView       = true;

            // convert from pixels to screen coords
            float s = size.x / vp.ActualWidth;
            float t = size.y / vp.ActualHeight;

            manual.Begin(materialName, RenderOperation.OperationTypes.OT_TRIANGLE_STRIP);

            manual.Position(pos.x - s, pos.y - t, 0.0f); manual.TextureCoord(0, 1);
            manual.Position(pos.x + s, pos.y - t, 0.0f); manual.TextureCoord(1, 1);
            manual.Position(pos.x + s, pos.y + t, 0.0f); manual.TextureCoord(1, 0);
            manual.Position(pos.x - s, pos.y + t, 0.0f); manual.TextureCoord(0, 0);

            manual.Index(0);
            manual.Index(1);
            manual.Index(2);
            manual.Index(3);
            manual.Index(0);

            manual.End();

            // Use infinite AAB to always stay visible
            AxisAlignedBox aabInf = new AxisAlignedBox();

            aabInf.SetInfinite();
            manual.BoundingBox = aabInf;

            // Render just before overlays
            manual.RenderQueueGroup = (byte)(RenderQueueGroupID.RENDER_QUEUE_OVERLAY - 1);
            manual.CastShadows      = false;

            // Attach to scene
            mgr.RootSceneNode.CreateChildSceneNode().AttachObject(manual);
            return(manual);
        }
コード例 #5
0
ファイル: Utils.cs プロジェクト: RainsSoft/ogreflow
        // create a 2D hud element: pos = [-1;1] & size = (pixels)
        public static MovableObject MakeHud(SceneManager mgr, Viewport vp, String materialName, Vector2 pos, Vector2 size)
        {
            // Create a manual object for 2D
            ManualObject manual = mgr.CreateManualObject();
            // Use identity view/projection matrices
            manual.UseIdentityProjection = true;
            manual.UseIdentityView = true;

            // convert from pixels to screen coords
            float s = size.x / vp.ActualWidth;
            float t = size.y / vp.ActualHeight;

            manual.Begin(materialName, RenderOperation.OperationTypes.OT_TRIANGLE_STRIP);

            manual.Position(pos.x - s, pos.y - t, 0.0f); manual.TextureCoord(0, 1);
            manual.Position(pos.x + s, pos.y - t, 0.0f); manual.TextureCoord(1, 1);
            manual.Position(pos.x + s, pos.y + t, 0.0f); manual.TextureCoord(1, 0);
            manual.Position(pos.x - s, pos.y + t, 0.0f); manual.TextureCoord(0, 0);

            manual.Index(0);
            manual.Index(1);
            manual.Index(2);
            manual.Index(3);
            manual.Index(0);

            manual.End();

            // Use infinite AAB to always stay visible
            AxisAlignedBox aabInf = new AxisAlignedBox();
            aabInf.SetInfinite();
            manual.BoundingBox = aabInf;

            // Render just before overlays
            manual.RenderQueueGroup = (byte)(RenderQueueGroupID.RENDER_QUEUE_OVERLAY-1);
            manual.CastShadows = false;

            // Attach to scene
            mgr.RootSceneNode.CreateChildSceneNode().AttachObject(manual);
            return manual;
        }