Example #1
0
        public TerrainComponent(HouseRenderState state)
        {
            var textureBase = GameFacade.GameFilePath("gamedata/terrain/newformat/");
            var grass       = Texture2D.FromFile(GameFacade.GraphicsDevice, Path.Combine(textureBase, "gr.tga"));

            Texture = grass;

            Effect = new BasicEffect(GameFacade.GraphicsDevice, null);
            Effect.TextureEnabled = true;
            Effect.Texture        = Texture;

            Geom = new VertexPositionTexture[4];

            var repeatX = state.Size / 2.5f;
            var repeatY = repeatX;

            var tl = state.GetWorldFromTile(new Vector2(1, 1));
            var tr = state.GetWorldFromTile(new Vector2(state.Size - 1, 1));
            var bl = state.GetWorldFromTile(new Vector2(1, state.Size - 1));
            var br = state.GetWorldFromTile(new Vector2(state.Size - 1, state.Size - 1));

            Geom[0] = new VertexPositionTexture(tl, new Vector2(0, 0));
            Geom[1] = new VertexPositionTexture(tr, new Vector2(repeatX, 0));
            Geom[2] = new VertexPositionTexture(br, new Vector2(repeatX, repeatY));
            Geom[3] = new VertexPositionTexture(bl, new Vector2(0, repeatY));
        }
Example #2
0
        public override void Draw(HouseRenderState state, HouseBatch batch)
        {
            //ZBuffer

            batch.Draw(Sprite);
            //batch.DrawZ(Texture, ZBuffer, new Microsoft.Xna.Framework.Rectangle(0, 0, Texture.Width, Texture.Height), Color.White);
        }
        public override void Draw(HouseRenderState state, HouseBatch batch)
        {
            //ZBuffer

            batch.Draw(Sprite);
            //batch.DrawZ(Texture, ZBuffer, new Microsoft.Xna.Framework.Rectangle(0, 0, Texture.Width, Texture.Height), Color.White);
        }
        public override void Draw(HouseRenderState state, HouseBatch batch)
        {
            if (!m_Active) { return; }

            if (m_Dirty)
            {
                if (FloorStyle == 0) { m_Active = false; return; }

                var floorStyle = ArchitectureCatalog.GetFloor(FloorStyle);
                if (floorStyle == null) { m_Active = false; return; }

                var position = state.TileToScreen(Position);
                PaintCoords = new Rectangle((int)position.X, (int)position.Y, state.CellWidth, state.CellHeight);
                Texture = floorStyle.GetTexture(state.Zoom, state.Rotation);
                m_Dirty = false;
            }

            batch.Draw(new HouseBatchSprite {
                Pixel = Texture,
                DestRect = PaintCoords,
                SrcRect = new Rectangle(0, 0, Texture.Width, Texture.Height),
                RenderMode = HouseBatchRenderMode.NO_DEPTH
            });
            //batch.Draw(Texture, PaintCoords, Color.White);
        }
        public TerrainComponent(HouseRenderState state)
        {
            var textureBase = GameFacade.GameFilePath("gamedata/terrain/newformat/");
            var grass = Texture2D.FromFile(GameFacade.GraphicsDevice, Path.Combine(textureBase, "gr.tga"));
            Texture = grass;

            Effect = new BasicEffect(GameFacade.GraphicsDevice, null);
            Effect.TextureEnabled = true;
            Effect.Texture = Texture;

            Geom = new VertexPositionTexture[4];

            var repeatX = state.Size / 2.5f;
            var repeatY = repeatX;

            var tl = state.GetWorldFromTile(new Vector2(1, 1));
            var tr = state.GetWorldFromTile(new Vector2(state.Size-1, 1));
            var bl = state.GetWorldFromTile(new Vector2(1, state.Size-1));
            var br = state.GetWorldFromTile(new Vector2(state.Size-1, state.Size-1));

            Geom[0] = new VertexPositionTexture(tl, new Vector2(0, 0));
            Geom[1] = new VertexPositionTexture(tr, new Vector2(repeatX, 0));
            Geom[2] = new VertexPositionTexture(br, new Vector2(repeatX, repeatY));
            Geom[3] = new VertexPositionTexture(bl, new Vector2(0, repeatY));
        }
Example #6
0
        public override void Draw(HouseRenderState state, HouseBatch batch)
        {
            var position = state.TileToScreen(Position);



            if ((WallInfo.Segments & WallSegments.BottomLeft) == WallSegments.BottomLeft)
            {
                var wall = ArchitectureCatalog.GetWallPattern(WallInfo.BottomLeftPattern);
                if (wall != null)
                {
                    var tx = wall.Far.RightTexture;

                    //batch.Draw(tx, new Rectangle((int)position.X, (int)position.Y - 49, 16, 67), Color.White);
                    //batch.Draw(tx, new Rectangle((int)position.X, (int)position.Y - 49, 16, 67), Color.White);
                }
            }

            if ((WallInfo.Segments & WallSegments.BottomRight) == WallSegments.BottomRight)
            {
                var wall = ArchitectureCatalog.GetWallPattern(WallInfo.BottomRightPattern);
                if (wall != null)
                {
                    var tx = wall.Far.LeftTexture;

                    //batch.Draw(tx, new Rectangle((int)position.X, (int)position.Y - 49, 16, 67), Color.White);
                    //batch.Draw(tx, new Rectangle((int)position.X + 16, (int)position.Y - 49, 16, 67), Color.White);
                }
            }



            //if ((WallInfo.Segments & WallSegments.BottomRight) == WallSegments.BottomRight)
            //{
            //    var wall = ArchitectureCatalog.GetWallPattern(WallInfo.BottomRightPattern);
            //    if (wall != null)
            //    {
            //        var tx = wall.Far.LeftTexture;

            //        //batch.Draw(tx, new Rectangle((int)position.X, (int)position.Y - 49, 16, 67), Color.White);
            //        batch.Draw(tx, new Rectangle((int)position.X + 16, (int)position.Y - 49, 16, 67), Color.White);
            //    }
            //}


            //if ((WallInfo.Segments & WallSegments.BottomRight) == WallSegments.BottomRight)
            //{
            //    var wall = ArchitectureCatalog.GetWallPattern(WallInfo.BottomLeftPattern);
            //    if (wall != null)
            //    {
            //        var tx = wall.Far.LeftTexture;
            //        batch.Draw(tx, new Rectangle((int)position.X, (int)position.Y - 58, 16, 67), Color.White);
            //    }
            //}
        }
Example #7
0
        /// <summary>
        /// Setup the rendering scene
        /// </summary>
        public void Init()
        {
            //Default render state
            RenderState          = new HouseRenderState();
            RenderState.Rotation = HouseRotation.Angle90;
            RenderState.Zoom     = HouseZoom.FarZoom;
            RenderState.Device   = GameFacade.GraphicsDevice;


            Init2DWorld();
            Init3DWorld();
        }
        public override void Draw(HouseRenderState state, HouseBatch batch)
        {
            var position = state.TileToScreen(Position);

            if ((WallInfo.Segments & WallSegments.BottomLeft) == WallSegments.BottomLeft)
            {
                var wall = ArchitectureCatalog.GetWallPattern(WallInfo.BottomLeftPattern);
                if (wall != null)
                {
                    var tx = wall.Far.RightTexture;

                    //batch.Draw(tx, new Rectangle((int)position.X, (int)position.Y - 49, 16, 67), Color.White);
                    //batch.Draw(tx, new Rectangle((int)position.X, (int)position.Y - 49, 16, 67), Color.White);
                }
            }

            if ((WallInfo.Segments & WallSegments.BottomRight) == WallSegments.BottomRight)
            {
                var wall = ArchitectureCatalog.GetWallPattern(WallInfo.BottomRightPattern);
                if (wall != null)
                {
                    var tx = wall.Far.LeftTexture;

                    //batch.Draw(tx, new Rectangle((int)position.X, (int)position.Y - 49, 16, 67), Color.White);
                    //batch.Draw(tx, new Rectangle((int)position.X + 16, (int)position.Y - 49, 16, 67), Color.White);
                }
            }

            //if ((WallInfo.Segments & WallSegments.BottomRight) == WallSegments.BottomRight)
            //{
            //    var wall = ArchitectureCatalog.GetWallPattern(WallInfo.BottomRightPattern);
            //    if (wall != null)
            //    {
            //        var tx = wall.Far.LeftTexture;

            //        //batch.Draw(tx, new Rectangle((int)position.X, (int)position.Y - 49, 16, 67), Color.White);
            //        batch.Draw(tx, new Rectangle((int)position.X + 16, (int)position.Y - 49, 16, 67), Color.White);
            //    }
            //}

            //if ((WallInfo.Segments & WallSegments.BottomRight) == WallSegments.BottomRight)
            //{
            //    var wall = ArchitectureCatalog.GetWallPattern(WallInfo.BottomLeftPattern);
            //    if (wall != null)
            //    {
            //        var tx = wall.Far.LeftTexture;
            //        batch.Draw(tx, new Rectangle((int)position.X, (int)position.Y - 58, 16, 67), Color.White);
            //    }
            //}
        }
Example #9
0
        public override void Draw(GraphicsDevice device, HouseRenderState state)
        {
            Effect.World      = state.World;
            Effect.View       = state.Camera.View;
            Effect.Projection = state.Camera.Projection;

            device.SamplerStates[0].AddressU = TextureAddressMode.Wrap;
            device.SamplerStates[0].AddressV = TextureAddressMode.Wrap;
            device.VertexDeclaration         = new VertexDeclaration(device, VertexPositionTexture.VertexElements);

            Effect.Begin();
            foreach (var pass in Effect.CurrentTechnique.Passes)
            {
                pass.Begin();
                device.DrawUserPrimitives <VertexPositionTexture>(PrimitiveType.TriangleFan, Geom, 0, 2);
                pass.End();
            }
            Effect.End();
        }
Example #10
0
        public override void Draw(GraphicsDevice device, HouseRenderState state)
        {
            device.VertexDeclaration = new VertexDeclaration(device, VertexPositionColor.VertexElements);

            Effect.World = state.World * Matrix.CreateTranslation(Position);
            Effect.View = state.Camera.View;
            Effect.Projection = state.Camera.Projection;
            Effect.VertexColorEnabled = true;
            //Effect.EnableDefaultLighting();

            Effect.Begin();
            foreach (var pass in Effect.CurrentTechnique.Passes)
            {
                pass.Begin();
                device.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.TriangleList, Geom, 0, Geom.Length / 3);
                pass.End();
            }
            Effect.End();
        }
        public override void Draw(GraphicsDevice device, HouseRenderState state)
        {
            Effect.World = state.World;
            Effect.View = state.Camera.View;
            Effect.Projection = state.Camera.Projection;

            device.SamplerStates[0].AddressU = TextureAddressMode.Wrap;
            device.SamplerStates[0].AddressV = TextureAddressMode.Wrap;
            device.VertexDeclaration = new VertexDeclaration(device, VertexPositionTexture.VertexElements);

            Effect.Begin();
            foreach (var pass in Effect.CurrentTechnique.Passes)
            {
                pass.Begin();
                device.DrawUserPrimitives<VertexPositionTexture>(PrimitiveType.TriangleFan, Geom, 0, 2);
                pass.End();
            }
            Effect.End();
        }
Example #12
0
        public void SetModel(HouseData house)
        {
            this.House = house;

            StaticLayer = new List <House2DComponent>();

            //StaticLayer.Add(new TerrainComponent());

            foreach (var floor in house.World.Floors.Where(x => x.Level == 0))
            {
                StaticLayer.Add(new FloorComponent {
                    Position = new Microsoft.Xna.Framework.Point(floor.X, floor.Y)
                });
            }

            foreach (var wall in house.World.Walls.Where(x => x.Level == 0))
            {
                StaticLayer.Add(new WallComponent(wall)
                {
                    Position = new Microsoft.Xna.Framework.Point(wall.X, wall.Y)
                });
            }


            RenderState          = new HouseRenderState();
            RenderState.Rotation = HouseRotation.Angle360;
            RenderState.Size     = 64;
            //RenderState.ScrollOffset = new Microsoft.Xna.Framework.Vector2(32, 32);
            RenderState.Zoom   = HouseZoom.FarZoom;
            RenderState.Device = GameFacade.GraphicsDevice;



            /*this.Layers = new LotLevel[2];
             * for (var i = 0; i < 2; i++)
             * {
             *  var layer = new LotLevel(i);
             *  layer.Process(house);
             *  layer.ProcessGeometry();
             *  Layers[i] = layer;
             * }*/
        }
        public override void Draw(GraphicsDevice device, HouseRenderState state)
        {
            device.VertexDeclaration = new VertexDeclaration(device, VertexPositionColor.VertexElements);


            Effect.World              = state.World * Matrix.CreateTranslation(Position);
            Effect.View               = state.Camera.View;
            Effect.Projection         = state.Camera.Projection;
            Effect.VertexColorEnabled = true;
            //Effect.EnableDefaultLighting();

            Effect.Begin();
            foreach (var pass in Effect.CurrentTechnique.Passes)
            {
                pass.Begin();
                device.DrawUserPrimitives <VertexPositionColor>(PrimitiveType.TriangleList, Geom, 0, Geom.Length / 3);
                pass.End();
            }
            Effect.End();
        }
Example #14
0
        public void Draw(GraphicsDevice device, HouseRenderState state)
        {
            var batch = new HouseBatch(device);
            //batch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.SaveState);
            batch.Begin();
            Floor.Draw(device, batch, state);
            Walls.Draw(device, batch, state);

            /** Draw indicator in center of screen **/
            var rectSize = 5;
            var gw = GlobalSettings.Default.GraphicsWidth;
            var gh = GlobalSettings.Default.GraphicsHeight;

            batch.Draw(new TSOClient.Code.Rendering.Lot.Framework.HouseBatchSprite {
                DestRect = new Rectangle((gw-rectSize)/2, (gh-rectSize)/2, rectSize, rectSize),
                SrcRect = new Rectangle(0, 0, 1, 1),
                Pixel = TextureUtils.TextureFromColor(device, Color.Pink),
                RenderMode = TSOClient.Code.Rendering.Lot.Framework.HouseBatchRenderMode.NO_DEPTH
            });

            batch.End();
        }
Example #15
0
        public void SetModel(HouseData house)
        {
            this.House = house;

            StaticLayer = new List<House2DComponent>();

            //StaticLayer.Add(new TerrainComponent());

            foreach (var floor in house.World.Floors.Where(x => x.Level == 0))
            {
                StaticLayer.Add(new FloorComponent {
                    Position = new Microsoft.Xna.Framework.Point(floor.X, floor.Y)
                });
            }

            foreach (var wall in house.World.Walls.Where(x => x.Level == 0))
            {
                StaticLayer.Add(new WallComponent (wall){
                    Position = new Microsoft.Xna.Framework.Point(wall.X, wall.Y)
                });
            }

            RenderState = new HouseRenderState();
            RenderState.Rotation = HouseRotation.Angle360;
            RenderState.Size = 64;
            //RenderState.ScrollOffset = new Microsoft.Xna.Framework.Vector2(32, 32);
            RenderState.Zoom = HouseZoom.FarZoom;
            RenderState.Device = GameFacade.GraphicsDevice;

            /*this.Layers = new LotLevel[2];
            for (var i = 0; i < 2; i++)
            {
                var layer = new LotLevel(i);
                layer.Process(house);
                layer.ProcessGeometry();
                Layers[i] = layer;
            }*/
        }
Example #16
0
        public void Draw(GraphicsDevice device, HouseRenderState state)
        {
            var batch = new HouseBatch(device);

            //batch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.SaveState);
            batch.Begin();
            Floor.Draw(device, batch, state);
            Walls.Draw(device, batch, state);

            /** Draw indicator in center of screen **/
            var rectSize = 5;
            var gw       = GlobalSettings.Default.GraphicsWidth;
            var gh       = GlobalSettings.Default.GraphicsHeight;

            batch.Draw(new TSOClient.Code.Rendering.Lot.Framework.HouseBatchSprite {
                DestRect   = new Rectangle((gw - rectSize) / 2, (gh - rectSize) / 2, rectSize, rectSize),
                SrcRect    = new Rectangle(0, 0, 1, 1),
                Pixel      = TextureUtils.TextureFromColor(device, Color.Pink),
                RenderMode = TSOClient.Code.Rendering.Lot.Framework.HouseBatchRenderMode.NO_DEPTH
            });

            batch.End();
        }
Example #17
0
        public override void Draw(HouseRenderState state, HouseBatch batch)
        {
            if (!m_Active)
            {
                return;
            }

            if (m_Dirty)
            {
                if (FloorStyle == 0)
                {
                    m_Active = false; return;
                }

                var floorStyle = ArchitectureCatalog.GetFloor(FloorStyle);
                if (floorStyle == null)
                {
                    m_Active = false; return;
                }


                var position = state.TileToScreen(Position);
                PaintCoords = new Rectangle((int)position.X, (int)position.Y, state.CellWidth, state.CellHeight);
                Texture     = floorStyle.GetTexture(state.Zoom, state.Rotation);
                m_Dirty     = false;
            }



            batch.Draw(new HouseBatchSprite {
                Pixel      = Texture,
                DestRect   = PaintCoords,
                SrcRect    = new Rectangle(0, 0, Texture.Width, Texture.Height),
                RenderMode = HouseBatchRenderMode.NO_DEPTH
            });
            //batch.Draw(Texture, PaintCoords, Color.White);
        }
Example #18
0
 public override void OnScrollChange(HouseRenderState state)
 {
     m_Dirty = true;
 }
Example #19
0
 public void OnScrollChange(HouseRenderState state)
 {
     Components.ForEach(x => x.OnScrollChange(state));
     m_Dirty = true;
 }
Example #20
0
 public virtual void OnScrollChange(HouseRenderState state)
 {
 }
 public override void Draw(HouseRenderState state, HouseBatch batch)
 {
 }
Example #22
0
 public void OnRotationChange(HouseRenderState state)
 {
     Floor.OnRotationChange(state);
     Walls.OnRotationChange(state);
 }
 public abstract void Draw(GraphicsDevice device, HouseRenderState state);
Example #24
0
 /// <summary>
 /// Render the 3D objects to the screen
 /// </summary>
 /// <param name="device"></param>
 /// <param name="state"></param>
 public void Draw(GraphicsDevice device, HouseRenderState state)
 {
     Components.ForEach(x => x.Draw(device, state));
 }
Example #25
0
 public void OnRotationChange(HouseRenderState state)
 {
     Floor.OnRotationChange(state);
     Walls.OnRotationChange(state);
 }
 public House3DScene(HouseRenderState state)
 {
     this.RenderState = state;
     this.Camera      = (OrthographicCamera)state.Camera;
     this.Components  = new List <House3DComponent>();
 }
 public override void OnScrollChange(HouseRenderState state)
 {
     m_Dirty = true;
 }
Example #28
0
 public virtual void OnZoomChanged(HouseRenderState state)
 {
 }
Example #29
0
 public virtual void OnRotationChanged(HouseRenderState state)
 {
 }
Example #30
0
        /// <summary>
        /// Setup the rendering scene
        /// </summary>
        public void Init()
        {
            //Default render state
            RenderState = new HouseRenderState();
            RenderState.Rotation = HouseRotation.Angle90;
            RenderState.Zoom = HouseZoom.FarZoom;
            RenderState.Device = GameFacade.GraphicsDevice;

            Init2DWorld();
            Init3DWorld();
        }
Example #31
0
 public void OnZoomChange(HouseRenderState state)
 {
     Components.ForEach(x => x.OnZoomChanged(state));
     m_Dirty = true;
 }
Example #32
0
 public House3DScene(HouseRenderState state)
 {
     this.RenderState = state;
     this.Camera = (OrthographicCamera)state.Camera;
     this.Components = new List<House3DComponent>();
 }
Example #33
0
 public abstract void Draw(GraphicsDevice device, HouseRenderState state);
Example #34
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="device"></param>
 /// <param name="batch"></param>
 /// <param name="state"></param>
 public void Draw(GraphicsDevice device, HouseBatch batch, HouseRenderState state)
 {
     Components.ForEach(x => x.Draw(state, batch));
 }
 public virtual void OnZoomChanged(HouseRenderState state)
 {
 }
Example #36
0
 public void OnScrollChange(HouseRenderState state)
 {
     Floor.OnScrollChange(state);
     Walls.OnScrollChange(state);
 }
Example #37
0
 public void OnZoomChange(HouseRenderState state)
 {
     Floor.OnZoomChange(state);
     Walls.OnZoomChange(state);
 }
Example #38
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="device"></param>
 /// <param name="batch"></param>
 /// <param name="state"></param>
 public void Draw(GraphicsDevice device, HouseBatch batch, HouseRenderState state)
 {
     Components.ForEach(x => x.Draw(state, batch));
 }
Example #39
0
 public void OnRotationChange(HouseRenderState state)
 {
     Components.ForEach(x => x.OnRotationChanged(state));
     m_Dirty = true;
 }
 public abstract void Draw(HouseRenderState state, HouseBatch batch);
Example #41
0
 public abstract void Draw(HouseRenderState state, HouseBatch batch);
 /// <summary>
 /// Render the 3D objects to the screen
 /// </summary>
 /// <param name="device"></param>
 /// <param name="state"></param>
 public void Draw(GraphicsDevice device, HouseRenderState state)
 {
     Components.ForEach(x => x.Draw(device, state));
 }
 public virtual void OnRotationChanged(HouseRenderState state)
 {
 }
Example #44
0
 public void OnZoomChange(HouseRenderState state)
 {
     Floor.OnZoomChange(state);
     Walls.OnZoomChange(state);
 }
 public virtual void OnScrollChange(HouseRenderState state)
 {
 }
Example #46
0
 public void OnScrollChange(HouseRenderState state)
 {
     Floor.OnScrollChange(state);
     Walls.OnScrollChange(state);
 }
Example #47
0
 public override void Draw(HouseRenderState state, HouseBatch batch)
 {
 }