Пример #1
0
        public Game()
        {
            graphics = new GraphicsDeviceManager(this);
            graphics.PreferredBackBufferWidth       = 1024;
            graphics.PreferredBackBufferHeight      = 768;
            graphics.SynchronizeWithVerticalRetrace = false;
            graphics.ApplyChanges();
            IsFixedTimeStep       = false;
            Content.RootDirectory = "Content";

            var trans = new Transform();

            trans.MakeIdentity();
            //trans.Translation.X += 10;
            trans.Scale    = Vec3.ScaleIdentity * 0.5f;
            trans.Rotation = Quat.FromAxisAngle(1, 0, 0, (float)Math.PI);
            trans.Rotation = Quat.FromEulerAngles(0, (float)Math.PI, 0);

            var v1 = new Vec3(1, 0, 0);
            var v2 = trans.ApplyForward(v1);

            var m = new Mat4();

            trans.ToMatrix(out m);
            var v3 = m.Mul(v1);

            Debug.WriteLine("v2: " + v2);
            Debug.WriteLine("v3: " + v3);

            Debug.WriteLine("sizeof(Transform): " + Marshal.SizeOf(typeof(Transform)));
            Debug.WriteLine("sizeof(Mat4): " + Marshal.SizeOf(typeof(Mat4)));

            trans.MakeIdentity();
            trans.Translation = new Vec3(1, 1, 0);
            trans.ToMatrix(out m);

            Debug.WriteLine("Mat0: " + Matrix.CreateTranslation(1, 1, 0));
            Debug.WriteLine("Mat1: " + m);


            trans.MakeIdentity();
            trans.Rotation = Quat.FromAxisAngle(new Vec3(1, 2, 3).Normalized, 1f);
            Vec3 ax, ay, az;

            trans.GetAxes(out ax, out ay, out az);
            Debug.WriteLine("ax: " + ax);
            Debug.WriteLine("ay: " + ay);
            Debug.WriteLine("az: " + az);
            Debug.WriteLine("ax x ay: " + ax.Cross(ay));

            var bx = trans.Rotation * Vec3.UnitX;
            var by = trans.Rotation * Vec3.UnitY;
            var bz = trans.Rotation * Vec3.UnitZ;

            Debug.WriteLine("bx: " + bx);
            Debug.WriteLine("by: " + by);
            Debug.WriteLine("bz: " + bz);
        }