From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- .../nel/driver__opengl__matrix_8cpp-source.html | 245 +++++++++++++++++++++ 1 file changed, 245 insertions(+) create mode 100644 docs/doxygen/nel/driver__opengl__matrix_8cpp-source.html (limited to 'docs/doxygen/nel/driver__opengl__matrix_8cpp-source.html') diff --git a/docs/doxygen/nel/driver__opengl__matrix_8cpp-source.html b/docs/doxygen/nel/driver__opengl__matrix_8cpp-source.html new file mode 100644 index 00000000..a48a8c71 --- /dev/null +++ b/docs/doxygen/nel/driver__opengl__matrix_8cpp-source.html @@ -0,0 +1,245 @@ + + + + nevrax.org : docs + + + + + + + + + + + + + + +
# Home   # nevrax.com   
+ + + + +
Nevrax
+ + + + + + + + + + +
+ + +
+ Nevrax.org
+ + + + + + + +
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
+
+ + +
+ + +
+Docs + +
+  + + + + + +
Documentation 
+ +
+Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  
+

driver_opengl_matrix.cpp

Go to the documentation of this file.
00001 
+00007 /* Copyright, 2000 Nevrax Ltd.
+00008  *
+00009  * This file is part of NEVRAX NEL.
+00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
+00011  * it under the terms of the GNU General Public License as published by
+00012  * the Free Software Foundation; either version 2, or (at your option)
+00013  * any later version.
+00014 
+00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
+00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
+00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+00018  * General Public License for more details.
+00019 
+00020  * You should have received a copy of the GNU General Public License
+00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
+00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+00023  * MA 02111-1307, USA.
+00024  */
+00025 
+00026 #include "stdopengl.h"
+00027 
+00028 namespace NL3D {
+00029 
+00030 // ***************************************************************************
+00031 void CDriverGL::setFrustum(float left, float right, float bottom, float top, float znear, float zfar, bool perspective)
+00032 {
+00033         glMatrixMode(GL_PROJECTION);
+00034         glLoadIdentity();
+00035         if (perspective)
+00036         {
+00037                 glFrustum(left,right,bottom,top,znear,zfar);
+00038         }
+00039         else
+00040         {
+00041                 glOrtho(left,right,bottom,top,znear,zfar);
+00042         }
+00043 
+00044         // Backup znear and zfar for zbias setup
+00045         _OODeltaZ = 1 / (zfar - znear);
+00046 
+00047         glMatrixMode(GL_MODELVIEW);
+00048 }
+00049 
+00050 
+00051 // ***************************************************************************
+00052 void CDriverGL::setupViewMatrixEx(const CMatrix& mtx, const CVector &cameraPos)
+00053 {
+00054         _UserViewMtx= mtx;
+00055 
+00056         // Setup the matrix to transform the CScene basis in openGL basis.
+00057         CMatrix         changeBasis;
+00058         CVector         I(1,0,0);
+00059         CVector         J(0,0,-1);
+00060         CVector         K(0,1,0);
+00061 
+00062         changeBasis.identity();
+00063         changeBasis.setRot(I,J,K, true);
+00064         _ViewMtx=changeBasis*mtx;
+00065         // Reset the viewMtx position.
+00066         _ViewMtx.setPos(CVector::Null);
+00067         _PZBCameraPos= cameraPos;
+00068 
+00069         // Anything that depend on the view martix must be updated.
+00070         _LightSetupDirty= true;
+00071         _ModelViewMatrixDirty= true;
+00072         _RenderSetupDirty= true;
+00073 
+00074         _TexMtx = _ViewMtx;
+00075         _TexMtx.setPos(CVector(0.0f,0.0f,0.0f));
+00076         _TexMtx.invert();
+00077         _TexMtx = changeBasis * _TexMtx;
+00078 }
+00079 
+00080 
+00081 // ***************************************************************************
+00082 void CDriverGL::setupViewMatrix(const CMatrix& mtx)
+00083 {
+00084         _UserViewMtx= mtx;
+00085 
+00086         // Setup the matrix to transform the CScene basis in openGL basis.
+00087         CMatrix         changeBasis;
+00088         CVector         I(1,0,0);
+00089         CVector         J(0,0,-1);
+00090         CVector         K(0,1,0);
+00091 
+00092         changeBasis.identity();
+00093         changeBasis.setRot(I,J,K, true);
+00094         _ViewMtx=changeBasis*mtx;
+00095         // Just set the PZBCameraPos to 0.
+00096         _PZBCameraPos= CVector::Null;
+00097 
+00098         // Anything that depend on the view martix must be updated.
+00099         _LightSetupDirty= true;
+00100         _ModelViewMatrixDirty= true;
+00101         _RenderSetupDirty= true;
+00102 
+00103         _TexMtx = _ViewMtx;
+00104         _TexMtx.setPos(CVector(0.0f,0.0f,0.0f));
+00105         _TexMtx.invert();
+00106         _TexMtx = changeBasis * _TexMtx;
+00107 
+00108 }
+00109 
+00110 // ***************************************************************************
+00111 CMatrix CDriverGL::getViewMatrix(void) const
+00112 {
+00113         return _UserViewMtx;
+00114 }
+00115 
+00116 // ***************************************************************************
+00117 void CDriverGL::setupModelMatrix(const CMatrix& mtx)
+00118 {
+00119         // profiling
+00120         _NbSetupModelMatrixCall++;
+00121 
+00122 
+00123         // Dirt flags.
+00124         _ModelViewMatrixDirty= true;
+00125         _RenderSetupDirty= true;
+00126 
+00127 
+00128         // Put the matrix in the opengl eye space, and store it.
+00129         CMatrix         mat= mtx;
+00130         // remove first the _PZBCameraPos
+00131         mat.setPos(mtx.getPos() - _PZBCameraPos);
+00132         _ModelViewMatrix= _ViewMtx*mat;
+00133 }
+00134 
+00135 // ***************************************************************************
+00136 void CDriverGL::multiplyModelMatrix(const CMatrix& mtx)
+00137 {
+00138         // Dirt flags.
+00139         _ModelViewMatrixDirty= true;
+00140         _RenderSetupDirty= true;
+00141 
+00142 
+00143         // multiply this modelMatrix with the _ModelViewMatrix.
+00144         _ModelViewMatrix= _ModelViewMatrix*mtx;
+00145 }
+00146 
+00147 
+00148 // ***************************************************************************
+00149 void CDriverGL::doRefreshRenderSetup()
+00150 {
+00151         // Check if the light setup has been modified first
+00152         if (_LightSetupDirty)
+00153                 // Recompute light setup
+00154                 cleanLightSetup ();
+00155 
+00156         // Check light setup is good
+00157         nlassert (_LightSetupDirty==false);
+00158 
+00159 
+00160         // Check if must update the modelViewMatrix
+00161         if( _ModelViewMatrixDirty )
+00162         {
+00163                 // By default, the first model matrix is active
+00164                 glLoadMatrixf( _ModelViewMatrix.get() );
+00165                 // enable normalize if matrix has scale.
+00166                 enableGlNormalize( _ModelViewMatrix.hasScalePart() || _ForceNormalize );
+00167                 // clear.
+00168                 _ModelViewMatrixDirty= false;
+00169         }
+00170 
+00171         // render setup is cleaned.
+00172         _RenderSetupDirty= false;
+00173 }
+00174 
+00175 
+00176 } // NL3D
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1