# 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  

trav_scene.h

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 #ifndef NL_TRAV_SCENE_H
00027 #define NL_TRAV_SCENE_H
00028 
00029 
00030 #include "nel/misc/matrix.h"
00031 #include "nel/misc/smart_ptr.h"
00032 
00033 
00034 
00035 namespace       NL3D
00036 {
00037 
00038 class CScene;
00039 
00040 using NLMISC::CVector;
00041 using NLMISC::CPlane;
00042 using NLMISC::CMatrix;
00043 
00044 
00045 // ***************************************************************************
00061 class ITravScene : public ITrav
00062 {       
00063 public:
00064         CScene  *Scene; // the scene owning this traversal (if any)
00065 public:
00067         ITravScene() : Scene(NULL) {}
00076         virtual sint    getRenderOrder() const =0;
00077 
00081         virtual void    traverse() =0;
00082 
00083 protected:
00086         virtual         void addedToMOT(CMOT *mot);     
00087 };
00088 
00089 
00090 // ***************************************************************************
00095 class ITravCameraScene : public ITravScene
00096 {
00097 public:
00102         // NB: znear and zfar are >0 (if perspective).
00103         float                           Left, Right, Bottom, Top, Near, Far;
00104         bool                            Perspective;
00105         NLMISC::CMatrix         CamMatrix;              // The camera matrix.
00106         NLMISC::CMatrix         ViewMatrix;             // ViewMatrix= CamMatrix.inverted();
00107         NLMISC::CVector         CamPos;                 // The camera position in world space.
00108         NLMISC::CVector         CamLook;                // The Y direction of the camera in world space.
00110 
00111 
00112 public:
00114         void            setFrustum(float left, float right, float bottom, float top, float znear, float zfar, bool perspective= true)
00115         {
00116                 Left= left;
00117                 Right= right;
00118                 Bottom= bottom;
00119                 Top= top;
00120                 Near= znear;
00121                 Far= zfar;
00122                 Perspective= perspective;
00123         }
00125         void            setFrustum(float width, float height, float znear, float zfar, bool perspective= true)
00126         {
00127                 setFrustum(-width/2, width/2, -height/2, height/2, znear, zfar, perspective);
00128         }
00130         void            setCamMatrix(const NLMISC::CMatrix      &camMatrix)
00131         {
00132                 CamMatrix= camMatrix;
00133         }
00134 
00135 
00137         ITravCameraScene()
00138         {
00139                 setFrustum(1.0f, 1.0f, 0.01f, 1.0f);
00140                 CamMatrix.identity();
00141                 ViewMatrix.identity();
00142                 CamPos= NLMISC::CVector::Null;
00143                 CamLook= NLMISC::CVector::Null;
00144         }
00145 
00146 
00147 protected:
00148 
00150         void    update()
00151         {
00152                 ViewMatrix= CamMatrix.inverted();
00153                 CamPos= CamMatrix.getPos();
00154                 CamLook= CamMatrix.mulVector(NLMISC::CVector::J);
00155         }
00156 
00157 
00158 };
00159 
00160 
00161 }
00162 
00163 
00164 #endif // NL_TRAV_SCENE_H
00165 
00166 /* End of trav_scene.h */