//public void SetCamera(Camera camera, SetCameraOptions options) //{ //} public void ApplyValuesToCamera(Camera camera, SetCameraOptions options, LayerCameraSettings lastToModify, RenderTarget2D renderTarget = null) { var viewport = camera.GetViewport(this, renderTarget); Renderer.GraphicsDevice.Viewport = viewport; camera.Orthogonal = Orthogonal; camera.OrthogonalHeight = OrthogonalHeight; camera.OrthogonalWidth = OrthogonalWidth; if (lastToModify == null) { // January 11, 2014 // We used to only do // offsets if the Layer // was both orthogonal and // if its orthogonal width and // height matched the destination. // Baron runs on multiple resolutions // and introduced situations where the // ortho width/height may not match the // destination rectangles because we may // scale everything up on larrger resolutions. // In that situation we still want to have the layers // offset properly. // bool offsetOrthogonal = Orthogonal && OrthogonalWidth == RightDestination - LeftDestination && // OrthogonalHeight == BottomDestination - TopDestination; bool offsetOrthogonal = Orthogonal; // But don't do this if we're on a render target, because render targets render full-screen: if (offsetOrthogonal && renderTarget == null) { int differenceX; int differenceY; DetermineOffsetDifference(camera, this, out differenceX, out differenceY); camera.X += differenceX; camera.Y -= differenceY; } } else { bool offsetOrthogonal = lastToModify.Orthogonal; // Undo what we did before if (offsetOrthogonal && renderTarget == null) { int differenceX; int differenceY; DetermineOffsetDifference(camera, lastToModify, out differenceX, out differenceY); camera.X -= differenceX; camera.Y += differenceY; } } if (options == SetCameraOptions.ApplyMatrix) { // This will set the matrix and individual values... camera.RotationMatrix = storedRotationMatrix; // ...now set individual values to make sure they dont change: camera.mRotationX = storedRotationX; camera.mRotationY = storedRotationY; camera.mRotationZ = storedRotationZ; camera.UpVector = mOldUpVector; } else { if (ExtraRotationZ != 0) { camera.RotationMatrix *= Matrix.CreateFromAxisAngle(camera.RotationMatrix.Backward, ExtraRotationZ); } camera.UpVector = camera.RotationMatrix.Up; } if (this.OffsetParent != null) { camera.Position -= this.OffsetParent.Position; } // Set FieldOfView last so it updates the matrices camera.FieldOfView = FieldOfView; }