/**************************************************************************** Copyright (C) 2002-2006 Gilles Debunne (Gilles.Debunne@imag.fr) This file is part of the QGLViewer library. Version 2.2.4-1, released on December 12, 2006. http://artis.imag.fr/Members/Gilles.Debunne/QGLViewer libQGLViewer is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. libQGLViewer is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libQGLViewer; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *****************************************************************************/ // TP OpenGL: Joerg Liebelt, Serigne Sow // classe derivee de terrain pour implementer un terrain optimise dynamiquement par Quadtrees #ifndef __QUADTREE_H__ #define __QUADTREE_H__ #include "terrain.h" #include #define QT_LR_NODE 0 #define QT_LL_NODE 1 #define QT_UL_NODE 2 #define QT_UR_NODE 3 //codes decrivant le type de suite de triangles a creer, selon la presence d'enfants recursives #define QT_COMPLETE_FAN 0 #define QT_LL_UR 5 #define QT_LR_UL 10 #define QT_NO_FAN 15 #define VIEW_RIGHT 0 #define VIEW_LEFT 1 #define VIEW_BOTTOM 2 #define VIEW_TOP 3 #define VIEW_FAR 4 #define VIEW_NEAR 5 struct SQT_VERTEX { float height; }; class QUADTREE : public TERRAIN { private: //matrice quadtree unsigned char* quadMatrix; //matrice decrivant la region vue par la camera float viewMatrix[6][4]; float pX,pY,pZ; //camera position; parametres de SimpleViewer-Object //niveau de detail float detailLevel; //souhaite float minResolution; //minimum void PropagateRoughness( void ); void RefineNode( float x, float z, int edgeLength ); void RenderNode( float x, float z, int edgeLength, bool multiTextures= true, bool detail= true ); void RenderVertex( float x, float z, float u, float v, bool multiTextures ); inline int GetMatrixIndex( int X, int Z ) { return ( ( Z*sizeHeightMap )+X ); } public: bool Init( void ); void Shutdown( void ); void Update(float x, float y, float z ); void Render( void ); void ComputeView( void ); bool CubeViewTest( float x, float y, float z, float size ); inline void setCameraPosition(float x, float y, float z) { pX=x; pY=y; pZ=z; } inline void SetDetailLevel( float detail ) { detailLevel= detail; } inline void SetMinResolution( float res ) { minResolution= res; } inline unsigned char GetQuadMatrixData( int X, int Z ) { if ((X>sizeHeightMap) || (X<0) || (Z>sizeHeightMap) || (Z<0)) { printf("Matrix limits exceeded: %d,%d\n",X,Z); return 255; } return quadMatrix[ ( Z*sizeHeightMap )+X]; } QUADTREE( void ) { detailLevel= 2.5f; //50.0f; minResolution = 1.2f; //10.0f; } ~QUADTREE( void ) { } }; #endif //__QUADTREE_H__