public void Update(ITimer timer)
        {
            float t = timer == null ? 0.0f : (float)timer.TotalSeconds;

            this.worldMatrix1 = XMMatrix.RotationY(t);

            XMMatrix spin      = XMMatrix.RotationZ(-t);
            XMMatrix orbit     = XMMatrix.RotationY(-t * 2.0f);
            XMMatrix translate = XMMatrix.Translation(-4.0f, 0.0f, 0.0f);
            XMMatrix scale     = XMMatrix.Scaling(0.3f, 0.3f, 0.3f);

            this.worldMatrix2 = scale * spin * translate * orbit;
        }
Beispiel #2
0
        static void Transform(XMMatrix target, Viewport viewport, float angle, float scale, float w, float h)
        {
            using var r = new XMMatrix();
            using var b = new XMMatrix();
            using var s = new XMMatrix();
            using var t = new XMMatrix();

            r.RotationZ((float)(angle / 180 * Math.PI));
            s.Scaling(scale, scale, 1.0f);
            t.Translation(viewport.Width / 2 - w * scale / 2, viewport.Height / 2 - h * scale / 2, 0.0f);
            b.Translation(-viewport.Width / 2, -viewport.Height / 2, 0.0f);
            b.Multiply(r);
            r.Set(b);
            b.Identity();
            b.Translation(viewport.Width / 2, viewport.Height / 2, 0.0f);
            r.Multiply(b);

            s.Multiply(t);
            s.Multiply(r);

            target.Set(s);
        }