Thank you in advance...
The Issue:
I am calling a grid of 100 quads (10x10) of which their PaintSurface is called and within which defines a SK3dView camera that I learned from the MS Docs. The problem is when animating the mView.TranslateZ(mTransZ); with a slider all of quads individually zoom away into the distance instead of them acting as one entity. Its as if the view is affecting and acting upon each of the quads separately. But I want them to stay together and zoom collectively.
The Request:
Please could you show/describe how I should do this properly. I am choosing this method also because the SKMatrix44's CreateTranslation upon the Z axis is lost when converting it to a 2D SKMatrix. Once again if anyone knows how to do this properly please advise. This is roughly the rendering code that runs for each of the quads:
The Code:
public void CanvasViewOnPaintSurface(object sender, SKPaintSurfaceEventArgs e)
{
SKImageInfo imgInfo = e.Info;
SKSurface surface = e.Surface;
mCanvas = surface.Canvas;
// The camera
mView = new SK3dView();
mCanvas.Clear();
using (new SKAutoCanvasRestore(mCanvas, true))
{
mView.Save();
/* <=== Slider controls this but each one of these quads
* gets zoomed individually! instead of staying together
* as a whole and zooming away. */
mView.TranslateZ(mTransZ);
/*
* CalculateMetricsHereForTheScaleRotationAndTranslation(...);
*
*/
#region MatrixOps
mMatrix = SKMatrix.CreateIdentity();
// Scale X Y
SKMatrix.PostConcat(ref mMatrix, SKMatrix.MakeScale(fScale2, fScale2));
// Rotation X Y Z
mMatrix44 = SKMatrix44.CreateIdentity();
mMatrix44.PostConcat(SKMatrix44.CreateRotationDegrees(1, 0, 0, (float)gData.dRotX));
mMatrix44.PostConcat(SKMatrix44.CreateRotationDegrees(0, 1, 0, (float)gData.dRotY));
mMatrix44.PostConcat(SKMatrix44.CreateRotationDegrees(0, 0, 1, (float)gData.dRotZ));
// Perspective divide by 3 (arbitrary number seems nice)
mPerspectiveMatrix = SKMatrix44.CreateIdentity();
mPerspectiveMatrix[3, 2] = (-1 / fDepth) / 3f;
mMatrix44.PostConcat(mPerspectiveMatrix);
// Translate X Y Z
// (How do you use the Z component - it has no effect
// because of the 2D Matrix conversion.
mMatrix44.PostConcat(SKMatrix44.CreateTranslation(
(float)mTransX, (float)mTransY, (float)mTransZ));
// Concatenate with 2D matrix
SKMatrix.PostConcat(ref mMatrix, mMatrix44.Matrix);
// Set the matrix and display the text
mCanvas.SetMatrix(mMatrix);
#endregion MatrixOps
mView.ApplyToCanvas(mCanvas);
mView.Restore();
mCanvas.DrawPicture(App.mImages.GetImage(miImageIndex).Picture);
}
}
My apologies for the unformatted text previously. I have tidied it up now :)