const Matrix4& Perspective::getPerspectiveMatrix() { if(myNeedUpdate) computePerspectiveMatrix(); return myPerspectiveMatrix; }
/* init() * * Set up background, clearcolor, call setupViewport(width, height). */ void init() { // glClearColor(8.0, 0.4, 0.0, 1.0); glClearColor(0, 0, 0, 1); glColor3f(0.5, 0.5, 0.5); setupViewport(INITIAL_WIDTH, INITIAL_HEIGHT); LookAtX = LookAtY = LookAtZ = 0.0f; /***** initialize matrix transforms *****/ // Initial entries for translation matrix float ttv_entries[16] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; TranslateToViewer << ttv_entries; // Initial entries for first rotation matrix float rot1[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; Rotate1 << rot1; // Initial entries for second rotation matrix float rot2[16] = { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }; Rotate2 << rot2; // Initial entries for third rotation matrix float rot3[16] = { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }; Rotate3 << rot3; // Matrix to flip handedness float fh[16] = { 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; FlipHandedness << fh; // Initial entries for P float pentries[] = { ViewPlaneDist, 0, 0, 0, 0, ViewPlaneDist, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 }; P << pentries; // Initial entries for W float ws[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; W << ws; // Calculate the view pipeline for first time computeViewerAngle(0); computePerspectiveMatrix(0); computeWindowMatrix(0); V = TranslateToViewer * Rotate1 * Rotate2 * Rotate3 * FlipHandedness; }
void refreshWindowAndPerspective(int id) { computeWindowMatrix(id); computePerspectiveMatrix(id); }