Пример #1
0
        public void DeriveVectors()
        {
            Matrix3D m = world_to_object.Clone();

            m.Invert();

            double d = target.Sub(location).Length();

            if (d <= 0)
            {
                d = 10;
            }

            location.SetVector(new Vector3D(0, 0, 0));
            location.TransformTranspose(m);

            direction.SetVector(new Vector3D(0, 0, -1));
            direction.RotateTranspose(m);
            direction.Normalize();

            up.SetVector(new Vector3D(0, 1, 0));
            up.RotateTranspose(m);
            up.Normalize();

            right.SetVector(new Vector3D(1, 0, 0));
            right.RotateTranspose(m);
            right.Normalize();

            target = location.clone().Add(direction.clone().Scale(d));
        }
Пример #2
0
        public void DeriveMatrix()
        {
            world_to_object.Identity();
            world_to_object.XX = right.X;
            world_to_object.YX = right.Y;
            world_to_object.ZX = right.Z;

            world_to_object.XY = up.X;
            world_to_object.YY = up.Y;
            world_to_object.ZY = up.Z;

            world_to_object.XZ = -direction.X;
            world_to_object.YZ = -direction.Y;
            world_to_object.ZZ = -direction.Z;

            Vector3D v = new Vector3D();

            for (int i = 0; i < 3; i++)
            {
                v.SetVector(new Vector3D(world_to_object.raw[0, i], world_to_object.raw[1, i], world_to_object.raw[2, i]));
                world_to_object.raw[3, i] = -1 * location.Dot(v);
            }
        }
Пример #3
0
        public void DeriveMatrix()
        {
            world_to_object.Identity();
            world_to_object.XX = right.X;
            world_to_object.YX = right.Y;
            world_to_object.ZX = right.Z;

            world_to_object.XY = up.X;
            world_to_object.YY = up.Y;
            world_to_object.ZY = up.Z;

            world_to_object.XZ = -direction.X;
            world_to_object.YZ = -direction.Y;
            world_to_object.ZZ = -direction.Z;

            Vector3D v = new Vector3D();
            for (int i = 0; i < 3; i++)
            {
                v.SetVector(new Vector3D(world_to_object.raw[0, i], world_to_object.raw[1, i], world_to_object.raw[2, i]));
                world_to_object.raw[3, i] = -1 * location.Dot(v);
            }
        }