From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/viewport_8cpp-source.html | 181 +++++++++++++++++++++++++++++ 1 file changed, 181 insertions(+) create mode 100644 docs/doxygen/nel/viewport_8cpp-source.html (limited to 'docs/doxygen/nel/viewport_8cpp-source.html') diff --git a/docs/doxygen/nel/viewport_8cpp-source.html b/docs/doxygen/nel/viewport_8cpp-source.html new file mode 100644 index 00000000..68f919c5 --- /dev/null +++ b/docs/doxygen/nel/viewport_8cpp-source.html @@ -0,0 +1,181 @@ + + + + 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  
+

viewport.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 "std3d.h"
+00027 
+00028 #include "nel/3d/viewport.h"
+00029 #include "nel/misc/common.h"
+00030 
+00031 using namespace NLMISC;
+00032 
+00033 
+00034 namespace NL3D
+00035 {
+00036 
+00037 CViewport::CViewport()
+00038 {
+00039         NL3D_MEM_VIEWPORT
+00040         initFullScreen ();
+00041 }
+00042 
+00043 
+00044 void CViewport::init (float x, float y, float width, float height)
+00045 {
+00046         NL3D_MEM_VIEWPORT
+00047         // Simply copy
+00048         _X=x;
+00049         clamp (_X, 0.f, 1.f);
+00050         _Y=y;
+00051         clamp (_Y, 0.f, 1.f);
+00052         _Width=width;
+00053         clamp (_Width, 0.f, 1.f-_X);
+00054         _Height=height;
+00055         clamp (_Height, 0.f, 1.f-_Y);
+00056 }
+00057 
+00058 
+00059 void CViewport::initFullScreen ()
+00060 {
+00061         NL3D_MEM_VIEWPORT
+00062         // Very easy
+00063         _X=0.f;
+00064         _Y=0.f;
+00065         _Width=1.f;
+00066         _Height=1.f;
+00067 }
+00068 
+00069 
+00070 void CViewport::init16_9 ()
+00071 {
+00072         NL3D_MEM_VIEWPORT
+00073         // Very easy
+00074         _X=0.f;
+00075         _Y=(1.f-0.75f)/2;
+00076         _Width=1.f;
+00077         _Height=0.75f;
+00078 }
+00079 
+00080 
+00081 void CViewport::getRayWithPoint (float x, float y, CVector& pos, CVector& dir, const CMatrix& camMatrix, const CFrustum& camFrust) const
+00082 {
+00083         NL3D_MEM_VIEWPORT
+00084         float xVP=(x-_X)/_Width;
+00085         float yVP=(y-_Y)/_Height;
+00086 
+00087         // Pos of the ray
+00088         pos= camMatrix.getPos();
+00089 
+00090         // Get camera frustrum
+00091         float left;
+00092         float right;
+00093         float bottom;
+00094         float top;
+00095         float znear;
+00096         float zfar;
+00097         camFrust.getValues (left, right, bottom, top, znear, zfar);
+00098 
+00099         // Get a local direction
+00100         dir.x=left+(right-left)*xVP;
+00101         dir.y=znear;
+00102         dir.z=bottom+(top-bottom)*yVP;
+00103 
+00104         // Get a world direction
+00105         CMatrix mat=camMatrix;
+00106         mat.setPos (CVector (0,0,0));
+00107         dir=mat*dir;
+00108 }
+00109 
+00110 
+00111 } // NL3D
+00112 
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1