コード例 #1
0
        protected void BuildFrustum()
        {
            // save off the composite matrix to the base
            base.matrix = Matrix4F.Mult(view, projection);

            // compute vectors of frustum edges
            float xs = (float)System.Math.Abs(1.0f / projection.Column0.X);
            float ys = (float)System.Math.Abs(1.0f / projection.Column1.Y);

            edge = new Vector3F[4];

            edge[0] = ViewDir - (xs * RightVec) - (ys * Up);
            edge[1] = ViewDir + (xs * RightVec) - (ys * Up);
            edge[2] = ViewDir + (xs * RightVec) + (ys * Up);
            edge[3] = ViewDir - (xs * RightVec) + (ys * Up);

            // make frustum planes
            this.near.Normal = ViewDir;
            this.near.D      = -Vector3F.Dot(EyePoint, ViewDir);

            makePlane(edge[0], edge[3], EyePoint, ref this.left);
            makePlane(edge[2], edge[1], EyePoint, ref this.right);
            makePlane(edge[1], edge[0], EyePoint, ref this.bottom);
            makePlane(edge[3], edge[2], EyePoint, ref this.top);

            this.far.Normal = near.Normal * -1;
            this.far.D      = near.D + farClip;

            CreateCorners();
        }