visual_collision_entity.h

Go to the documentation of this file.
00001 
00005 /* Copyright, 2001 Nevrax Ltd.
00006  *
00007  * This file is part of NEVRAX NEL.
00008  * NEVRAX NEL is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2, or (at your option)
00011  * any later version.
00012 
00013  * NEVRAX NEL is distributed in the hope that it will be useful, but
00014  * WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00016  * General Public License for more details.
00017 
00018  * You should have received a copy of the GNU General Public License
00019  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00020  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00021  * MA 02111-1307, USA.
00022  */
00023 
00024 #ifndef NL_VISUAL_COLLISION_ENTITY_H
00025 #define NL_VISUAL_COLLISION_ENTITY_H
00026 
00027 #include "nel/misc/types_nl.h"
00028 #include "nel/3d/point_light_influence.h"
00029 #include "nel/3d/patch.h"
00030 #include "nel/3d/landscape_collision_grid.h"
00031 
00032 
00033 namespace NL3D
00034 {
00035 
00036 
00037 class   CVisualCollisionManager;
00038 class   IDriver;
00039 struct  CSurfaceInfo;
00040 
00041 // ***************************************************************************
00048 class CVisualCollisionEntity
00049 {
00050 public:
00051 
00053     CVisualCollisionEntity(CVisualCollisionManager *owner);
00054     ~CVisualCollisionEntity();
00055 
00056 
00062     bool    snapToGround(CVector &pos);
00063 
00064 
00071     bool    snapToGround(CVector &pos, CVector &normal);
00072 
00073 
00074 
00078     void    setGroundMode(bool groundMode) {_GroundMode= groundMode;}
00079 
00080 
00084     void    setCeilMode(bool ceilMode) {_CeilMode= ceilMode;}
00085 
00086 
00087     bool    getGroundMode() const {return _GroundMode;}
00088     bool    getCeilMode() const {return _CeilMode;}
00089 
00090 
00095     void    setSnapToRenderedTesselation(bool snapMode) {_SnapToRenderedTesselation= snapMode;}
00096     bool    getSnapToRenderedTesselation() const {return _SnapToRenderedTesselation;}
00097 
00098 
00104     bool    getSurfaceInfo(const CVector &pos, CSurfaceInfo &info);
00105 
00106 
00108     // @{
00110     static const float                  BBoxRadius;
00117     static const float                  BBoxRadiusZ;
00118     // @}
00119 
00120 
00122     // @{
00130     bool        getStaticLightSetup(NLMISC::CRGBA sunAmbient, const CVector &pos, std::vector<CPointLightInfluence> &pointLightList, uint8 &sunContribution, NLMISC::CRGBA &localAmbient);
00131     // @}
00132 
00133 
00135     // @{
00136 
00138     void        displayDebugGrid(IDriver &drv) const;
00139 
00140     // @}
00141 
00142 
00143 // ***********************
00144 private:
00145     CVisualCollisionManager     *_Owner;
00146 
00147     bool    _CeilMode;
00148     bool    _GroundMode;
00149     bool    _SnapToRenderedTesselation;
00150 
00151 
00153     // @{
00155     static const uint32                 _StartPatchQuadBlockSize;
00157     static std::vector<CPatchBlockIdent>    _TmpBlockIds;
00159     static std::vector<CPatchQuadBlock*>    _TmpPatchQuadBlocks;
00160 
00165     std::vector<CPatchQuadBlock*>       _PatchQuadBlocks;
00167     CLandscapeCollisionGrid             _LandscapeQuadGrid;
00169     CAABBox                             _CurrentBBoxValidity;
00171     bool                                _LastGPTValid;
00172     CVector                             _LastGPTPosInput;
00173     CVector                             _LastGPTPosOutput;
00174     CTrianglePatch                      _LastGPTTrianglePatch;
00175 
00177     static bool triangleIntersect2DGround(CTriangle &tri, const CVector &pos0);
00178     static bool triangleIntersect2DCeil(CTriangle &tri, const CVector &pos0);
00179 
00181     bool        triangleIntersect(CTriangle &tri, const CVector &pos0, const CVector &pos1, CVector &hit);
00182 
00183 
00185     void        testComputeLandscape(const CVector &pos);
00187     void        doComputeLandscape(const CVector &pos);
00188 
00190     void        snapToLandscapeCurrentTesselation(CVector &pos, const CTrianglePatch &tri);
00191 
00193     static void computeUvForPos(const CTrianglePatch &tri, const CVector &pos, CUV &uv);
00194 
00199     CTrianglePatch      *getPatchTriangleUnderUs(const CVector &pos, CVector &res);
00200 
00201     // @}
00202 
00203 
00204 };
00205 
00206 
00207 } // NL3D
00208 
00209 
00210 #endif // NL_VISUAL_COLLISION_ENTITY_H
00211 
00212 /* End of visual_collision_entity.h */

Generated on Thu Jan 7 08:26:21 2010 for NeL by  doxygen 1.6.1