WVR_GetClippingPlaneBoundary

WVR_EXPORT void WVR_GetClippingPlaneBoundary(WVR_Eye eye, float * left, float * right, float * top, float * bottom)

Function to get the boundary of the clipping plane.

Returns the coordinates of the margin of the clipping plane for the specified eye. These coordinates can be used to compose a custom matrix. Most content should use WVR_GetProjection but some content may need to do something complicated with its projection. These content can use these coordinates to compute the projection.

Version
API Level 1
Parameters
  • eye: Determines which eye the function should return for the corresponding clipping plane.
  • left: Coordinate for the left margin of the clipping plane.
  • right: Coordinate for the right margin of the clipping plane.
  • top: Coordinate for the top margin of the clipping plane.
  • bottom: Coordinate for the bottom margin of the clipping plane.

How to use

Here is an example for the function:

#include <wvr/wvr_projection.h>

Matrix4 getCustomizedProjection(WVR_Eye nEye) {
    float l, r, t, b, f, n;
    WVR_GetClippingPlaneBoundary(nEye, &l, &r, &t, &b);
    f = 1.0f;
    n = 0.01f;
    float r_l = r-l;
    float t_b = b-t;
    float f_n = f-n;
    float rpl = r+l;
    float tpb = t+b;
    float fpn = f+n;
    float fn = f*n;

    Matrix4 mat(
        2*n/r_l,  0,        0,         0,
        0,        2*n/t_b,  0,         0,
        rpl/r_l,  tpb/t_b,  -fpn/f_n,  -1,
        0,        0,        2*fn/-f_n, 1
    );

    return mat;
}