/** * Defines a projection matrix in terms of six clip planes. * * @param m the float array that holds the output perspective matrix * @param offset the offset into float array m where the perspective * matrix data is written * @param left * @param right * @param bottom * @param top * @param near * @param far */publicstaticvoidfrustumM(float[]m,intoffset,floatleft,floatright,floatbottom,floattop,floatnear,floatfar)
需要注意的是 near 和 far 变量的值必须要大于 0 。因为它们都是相对于视点的距离,也就是照相机的距离。
当用视图矩阵确定了照相机的位置时,要确保物体距离视点的位置在 near 和 far 的区间范围内,否则就会看不到物体。
由于透视投影会产生近大远小的效果,当照相机位置不变,改变 near 的值时也会改变物体大小,near 越小,则离视点越近,相当于物体越远,那么显示的物体也就越小了。
/** * Defines a projection matrix in terms of a field of view angle, an * aspect ratio, and z clip planes. * * @param m the float array that holds the perspective matrix * @param offset the offset into float array m where the perspective * matrix data is written * @param fovy field of view in y direction, in degrees * @param aspect width to height aspect ratio of the viewport * @param zNear * @param zFar */publicstaticvoidperspectiveM(float[]m,intoffset,floatfovy,floataspect,floatzNear,floatzFar)