|
Yep, krypton works quite well with 2d cameras as long as you feed it the right matrix..
public void CreateTransformationMatrix(out Matrix matrix){
//create matrices
var translate = Matrix.CreateTranslation(-Location.X, -Location.Y, 0);
var offset = Matrix.CreateTranslation(viewWidth / 2, viewHeight / 2, 0);
var scale = Matrix.CreateScale(zoom, zoom, 1);
var rotation = Matrix.CreateRotationZ(Rotation);
// transform them into one another
matrix = translate;
Matrix.Multiply(ref matrix, ref scale, out matrix);
Matrix.Multiply(ref matrix, ref rotation, out matrix);
Matrix.Multiply(ref matrix, ref offset, out matrix);
}
That is how my camera's overall transformation matrix is computed. Notice that I don't use a projection matrix here since SpriteBatch already does that for you. The only thing I had to make sure of was that I set spriteBatchCompatibilityMode = true
on the krypton light renderer like so:
lightingEngine.SpriteBatchCompatablityEnabled = true;
lightingEngine.CullMode = CullMode.CullClockwiseFace;
That extra line is there because (atleast from what I can tell) the batch compatibility mode reverses the scale resulting in the quad thatthe sprite gets rendered on facing backwards.
EDIT: I noticed that I didn't set the out parameters to the "matrix" variable.. sorry about the silly mistake and I hope it clears up some stuff if anyone was confused :P.
|