protected override void PosWithDepthDraw(PloobsEngine.SceneControl.RenderHelper render, Microsoft.Xna.Framework.GameTime gt, ref Microsoft.Xna.Framework.Matrix activeView, ref Microsoft.Xna.Framework.Matrix activeProjection)
        {        
            Matrix viewIT = Matrix.Invert(Matrix.Transpose(activeView));
            Vector3 position = new Vector3(viewIT.M14, viewIT.M24, viewIT.M34);

            foreach (var item in Billboards)
            {
                if (item.Enabled)
                {
                    SpriteFont font = item.SpriteFont == null ? SpriteFont : item.SpriteFont;

                    basicEffect.World = Matrix.CreateConstrainedBillboard(item.Position, position, Vector3.Down, null, null);

                    basicEffect.View = activeView;
                    basicEffect.Projection = activeProjection;

                    spriteBatch.Begin(0, null, null, DepthStencilState.DepthRead, RasterizerState.CullNone, basicEffect);

                    Vector2 textOrigin = font.MeasureString(item.Message) / 2;

                    spriteBatch.DrawString(font, item.Message, Vector2.Zero, item.Color, 0, textOrigin, item.Scale, 0, 0);

                    spriteBatch.End();
                }
            }
            render.ResyncStates();
        }
Ejemplo n.º 2
0
        protected override void Draw(GameTime gt, PloobsEngine.SceneControl.IObject obj, PloobsEngine.SceneControl.RenderHelper render, PloobsEngine.Cameras.ICamera cam, IList<PloobsEngine.Light.ILight> lights)
        {
            SpriteAnimated sprite = (obj as ISpriteObject).SpriteAnimated;

            basicEffect.World = Matrix.CreateConstrainedBillboard(obj.PhysicObject.WorldMatrix.Translation, cam.Position, Vector3.Down, null, null);
            basicEffect.View =  cam.View;
            basicEffect.Projection = cam.Projection;

            Vector2 nscale = scale * new Vector2(1f/sprite.NumberAnimations, 1f/sprite.Frame);
            spriteBatch.Begin(0, null, SamplerState.AnisotropicClamp, DepthStencilState.DepthRead, RasterizerState.CullNone, basicEffect);
            spriteBatch.Draw(sprite.Texture, Vector2.Zero, sprite.SourceRectangle, Color.White, sprite.Rotation, sprite.Origin, nscale, SpriteEffects.None, 1);
            spriteBatch.End();
            render.ResyncStates();

            base.Draw(gt, obj, render, cam, lights);
        }
        protected override void PosWithDepthDraw(PloobsEngine.SceneControl.RenderHelper render, Microsoft.Xna.Framework.GameTime gt, Microsoft.Xna.Framework.Matrix activeView, Microsoft.Xna.Framework.Matrix activeProjection)
        {        
            Matrix viewIT = Matrix.Invert(Matrix.Transpose(activeView));
            Vector3 position = new Vector3(viewIT.M14, viewIT.M24, viewIT.M34);

            foreach (var item in Billboards)
            {
                basicEffect.World = Matrix.CreateConstrainedBillboard(item.Position, position, Vector3.Up, null, null);

                basicEffect.View = activeView;
                basicEffect.Projection = activeProjection;

                spriteBatch.Begin(0, null, null, DepthStencilState.DepthRead, RasterizerState.CullNone, basicEffect);
                spriteBatch.Draw(item.Texture, Vector2.Zero, item.Texture.Bounds, Color.White, 0, new Vector2(item.Texture.Bounds.Center.X, item.Texture.Bounds.Center.Y), item.Scale, SpriteEffects.None, 1);
                spriteBatch.End();
            }
            render.ResyncStates();
        }
        protected override void PosWithDepthDraw(PloobsEngine.SceneControl.RenderHelper render, Microsoft.Xna.Framework.GameTime gt, ref Microsoft.Xna.Framework.Matrix activeView, ref Microsoft.Xna.Framework.Matrix activeProjection)
        {
            Matrix invertY = Matrix.CreateScale(1, -1, 1);

            basicEffect.World = invertY;
            basicEffect.View = Matrix.Identity;
            basicEffect.Projection = activeProjection;

            spriteBatch.Begin(0, null, null, DepthStencilState.DepthRead, RasterizerState.CullNone, basicEffect);

            foreach (var item in Billboards)
            {
                if (item.Enabled)
                {
                    Vector3 viewSpaceTextPosition = Vector3.Transform(item.Position, activeView * invertY);
                    spriteBatch.Draw(item.Texture, new Vector2(viewSpaceTextPosition.X, viewSpaceTextPosition.Y), item.Texture.Bounds, Color.White, 0, new Vector2(item.Texture.Bounds.Center.X, item.Texture.Bounds.Center.Y), item.Scale, SpriteEffects.None, viewSpaceTextPosition.Z);
                }
            }            
    

            spriteBatch.End();
            render.ResyncStates();
        }
        protected override void PosWithDepthDraw(PloobsEngine.SceneControl.RenderHelper render, Microsoft.Xna.Framework.GameTime gt, ref Microsoft.Xna.Framework.Matrix activeView, ref Microsoft.Xna.Framework.Matrix activeProjection)
        {
            Matrix invertY = Matrix.CreateScale(1, -1, 1);

            basicEffect.World = invertY;
            basicEffect.View = Matrix.Identity;
            basicEffect.Projection = activeProjection;

            spriteBatch.Begin(0, null, null, DepthStencilState.DepthRead, RasterizerState.CullNone, basicEffect);

            foreach (var item in Billboards)
            {
                if (item.Enabled)
                {
                    SpriteFont font = item.SpriteFont == null ? SpriteFont : item.SpriteFont;
                    Vector3 viewSpaceTextPosition = Vector3.Transform(item.Position, activeView * invertY);
                    Vector2 textOrigin = font.MeasureString(item.Message) / 2;
                    spriteBatch.DrawString(font, item.Message, new Vector2(viewSpaceTextPosition.X, viewSpaceTextPosition.Y), item.Color, 0, textOrigin, item.Scale, 0, viewSpaceTextPosition.Z);
                }
            }                

            spriteBatch.End();
            render.ResyncStates();
        }