Пример #1
0
        private void UpdateOffsetSpritePosition()
        {
            //float whereCameraShouldBe = mManagers.Renderer.Camera.ClientHeight / (2.0f );
            //float whereCameraIs = mManagers.Renderer.Camera.Y;

            //float difference = whereCameraIs - whereCameraShouldBe;


            //mOffsetSprite.Y = -difference ;

            RenderingLibrary.Camera camera = mManagers.Renderer.Camera;

            if (RulerSide == Wireframe.RulerSide.Left)
            {
                float halfResolutionHeight = camera.ClientHeight / (2.0f);
                if (camera.CameraCenterOnScreen == CameraCenterOnScreen.TopLeft)
                {
                    halfResolutionHeight = 0;
                }
                mOffsetSprite.X = 0;
                mOffsetSprite.Y = Math.MathFunctions.RoundToInt(
                    -camera.Y * mZoomValue + halfResolutionHeight);
            }
            else // top
            {
                float halfResolutionWidth = camera.ClientWidth / (2.0f);
                if (camera.CameraCenterOnScreen == CameraCenterOnScreen.TopLeft)
                {
                    halfResolutionWidth = 0;
                }
                mOffsetSprite.Y = 0;
                mOffsetSprite.X = Math.MathFunctions.RoundToInt(
                    -camera.X * mZoomValue + halfResolutionWidth);
            }
        }
Пример #2
0
        public CameraController(RenderingLibrary.Camera camera, SystemManagers managers, Cursor cursor, Keyboard keyboard, GraphicsDeviceControl control, Ruler topRuler, Ruler leftRuler)
        {
            this.TopRuler  = topRuler;
            this.LeftRuler = leftRuler;
            Cursor         = cursor;
            Camera         = camera;
            Managers       = managers;

            cameraPanningLogic = new CameraPanningLogic(control, managers, cursor, keyboard);
        }
Пример #3
0
        public CameraController(RenderingLibrary.Camera camera, SystemManagers managers, Cursor cursor, GraphicsDeviceControl control, Ruler topRuler, Ruler leftRuler)
        {
            this.TopRuler = topRuler;
            this.LeftRuler = leftRuler;
            Cursor = cursor;
            Camera = camera;
            Managers = managers;

            cameraPanningLogic = new CameraPanningLogic(control, managers, cursor, null);

        }
        public CameraPanningLogic(GraphicsDeviceControl graphicsControl, SystemManagers managers, Cursor cursor, Keyboard keyboard)
        {
            mManagers = managers;

            mKeyboard = keyboard;

            mCursor = cursor;
            mCursor.Initialize(graphicsControl);
            mCamera = managers.Renderer.Camera;
            mControl = graphicsControl;
            graphicsControl.XnaUpdate += new Action(Activity);
        }
        public static void AdjustCameraPositionAfterZoom(float oldCursorWorldX, float oldCursorWorldY, 
            float oldCameraX, float oldCameraY, float oldZoom, float newZoom, Camera camera)
        {
            float differenceX = oldCameraX - oldCursorWorldX;
            float differenceY = oldCameraY - oldCursorWorldY;

            float zoomAsFloat = newZoom / 100.0f;

            float modifiedDifferenceX = differenceX * oldZoom / zoomAsFloat;
            float modifiedDifferenceY = differenceY * oldZoom / zoomAsFloat;

            camera.X = oldCursorWorldX + modifiedDifferenceX;
            camera.Y = oldCursorWorldY + modifiedDifferenceY;

            // This makes the zooming behavior feel weird.  We'll do this when the user selects a new 
            // AnimationChain, but not when zooming.
            //BringSpriteInView();
        }
Пример #6
0
        internal Microsoft.Xna.Framework.Rectangle GetScissorRectangleFor(Camera camera, IRenderableIpso ipso)
        {
            if (ipso == null)
            {
                return new Microsoft.Xna.Framework.Rectangle(
                    0, 0,
                    camera.ClientWidth,
                    camera.ClientHeight

                    );
            }
            else
            {

                float worldX = ipso.GetAbsoluteLeft();
                float worldY = ipso.GetAbsoluteTop();

                float screenX;
                float screenY;
                camera.WorldToScreen(worldX, worldY, out screenX, out screenY);

                int left = global::RenderingLibrary.Math.MathFunctions.RoundToInt(screenX);
                int top = global::RenderingLibrary.Math.MathFunctions.RoundToInt(screenY);

                worldX = ipso.GetAbsoluteRight();
                worldY = ipso.GetAbsoluteBottom();
                camera.WorldToScreen(worldX, worldY, out screenX, out screenY);

                int right = global::RenderingLibrary.Math.MathFunctions.RoundToInt(screenX);
                int bottom = global::RenderingLibrary.Math.MathFunctions.RoundToInt(screenY);



                left = System.Math.Max(0, left);
                top = System.Math.Max(0, top);
                right = System.Math.Max(0, right);
                bottom = System.Math.Max(0, bottom);

                left = System.Math.Min(left, camera.ClientWidth);
                right = System.Math.Min(right, camera.ClientWidth);

                top = System.Math.Min(top, camera.ClientHeight);
                bottom = System.Math.Min(bottom, camera.ClientHeight);


                int width = System.Math.Max(0, right - left);
                int height = System.Math.Max(0, bottom - top);


                Microsoft.Xna.Framework.Rectangle thisRectangle = new Microsoft.Xna.Framework.Rectangle(
                    left,
                    top,
                    width,
                    height);

                return thisRectangle;
            }

        }
Пример #7
0
        public void Initialize(GraphicsDevice graphicsDevice, SystemManagers managers)
        {
            SamplerState = SamplerState.LinearClamp;
            mCamera = new RenderingLibrary.Camera(managers);
            mLayersReadOnly = new ReadOnlyCollection<Layer>(mLayers);

            mLayers.Add(new Layer());
            mLayers[0].Name = "Main Layer";

            mGraphicsDevice = graphicsDevice;

            spriteRenderer.Initialize(graphicsDevice);

            mSinglePixelTexture = new Texture2D(mGraphicsDevice, 1, 1, false, SurfaceFormat.Color);
            Color[] pixels = new Color[1];
            pixels[0] = Color.White;
            mSinglePixelTexture.Name = "Rendering Library Single Pixel Texture";
            mSinglePixelTexture.SetData<Color>(pixels);

            mDottedLineTexture = new Texture2D(mGraphicsDevice, 2, 1, false, SurfaceFormat.Color);
            pixels = new Color[2];
            pixels[0] = Color.White;
            pixels[1] = Color.Transparent;
            mDottedLineTexture.SetData<Color>(pixels);

            mCamera.UpdateClient();
        }