/// <summary>
        /// A view component has changed (rotation, zoom, scroll).
        /// We need to adjust the camera
        /// </summary>
        private void InvalidateCamera()
        {
            //Camera.Translation = new Vector3(-radius, 0.0f, -radius);

            //Camera translation for scroll position
            var offsetX = RenderState.TileToWorld(RenderState.FocusTile.X);
            var offsetY = RenderState.TileToWorld(RenderState.FocusTile.Y);

            var centerX = Camera.Target.X;
            var centerY = Camera.Target.Z;

            offsetX -= centerX;
            offsetY -= centerY;// *1.03f;

            switch (RenderState.Zoom)
            {
            case HouseZoom.FarZoom:
                Camera.Zoom = 152;
                break;

            case HouseZoom.MediumZoom:
                Camera.Zoom = 76;
                break;

            case HouseZoom.CloseZoom:
                Camera.Zoom = 38;
                break;
            }
            Camera.Translation = new Vector3(offsetX, 0.0f, offsetY);

            //Camera.Target = new Vector3(offsetX, 0.0f, offsetY);
            //Camera.Position = new Vector3(offsetX + 96.0f, Camera.Position.Y, offsetY + 96.0f);
        }
Example #2
0
        /// <summary>
        /// Load a house from its definition
        /// </summary>
        /// <param name="house"></param>
        public void LoadHouse(HouseData house)
        {
            RenderState.Size = house.Size;

            /**
             * Camera should be at the edge of the screen looking onto the
             * center point of the lot at a 30 degree angle
             */
            /** Size is how many tiles, the last tile has a size too so the actual vertex position is +1) **/
            var worldEdge = house.Size + 1.0f;
            var radius    = RenderState.TileToWorld((worldEdge / 2.0f));
            var opposite  = (float)Math.Cos(MathHelper.ToRadians(30.0f)) * radius;

            Camera.Position = new Vector3(radius * 2, opposite, radius * 2);
            Camera.Target   = new Vector3(radius, 0.0f, radius);
            //Camera.Translation = new Vector3(-radius, 0.0f, -radius);
            Camera.Zoom = 178;

            /**
             * Setup the 2D space
             */
            Model = new HouseModel();
            Model.LoadHouse(house);

            Scene2D.LoadHouse(Model);
            Scene3D.LoadHouse(Model);

            //Center point of the center most tile
            ViewCenter = new Vector2((RenderState.Size / 2.0f) + 30, (RenderState.Size / 2.0f) + 30);
        }