示例#1
0
文件: Plane.cs 项目: tom95/godot
        public Vector3 intersect_3(Plane b, Plane c)
        {
            float denom = normal.cross(b.normal).dot(c.normal);

            if (Mathf.abs(denom) <= Mathf.Epsilon)
            {
                return(new Vector3());
            }

            Vector3 result = (b.normal.cross(c.normal) * this.d) +
                             (c.normal.cross(normal) * b.d) +
                             (normal.cross(b.normal) * c.d);

            return(result / denom);
        }
示例#2
0
        public void set_look_at(Vector3 eye, Vector3 target, Vector3 up)
        {
            // Make rotation matrix
            // Z vector
            Vector3 zAxis = eye - target;

            zAxis.normalize();

            Vector3 yAxis = up;

            Vector3 xAxis = yAxis.cross(zAxis);

            // Recompute Y = Z cross X
            yAxis = zAxis.cross(xAxis);

            xAxis.normalize();
            yAxis.normalize();

            basis = Basis.create_from_axes(xAxis, yAxis, zAxis);

            origin = eye;
        }