# 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  

transform_shape.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_TRANSFORM_SHAPE_H
00027 #define NL_TRANSFORM_SHAPE_H
00028 
00029 #include "nel/misc/types_nl.h"
00030 #include "nel/misc/matrix.h"
00031 #include "3d/transform.h"
00032 #include "3d/shape.h"
00033 #include "3d/load_balancing_trav.h"
00034 #include <vector>
00035 
00036 
00037 namespace NL3D 
00038 {
00039 
00040 
00041 using NLMISC::CSmartPtr;
00042 using NLMISC::CPlane;
00043 
00044 
00045 class   CTransformShapeClipObs;
00046 class   CTransformShapeRenderObs;
00047 class   CTransformShapeLoadBalancingObs;
00048 class   CRenderTrav;
00049 class   CMRMLevelDetail;
00050 class   CMaterial;
00051 
00052 
00053 // ***************************************************************************
00054 // ClassIds.
00055 const NLMISC::CClassId          TransformShapeId=NLMISC::CClassId(0x1e6115e6, 0x63502517);
00056 
00057 
00058 // ***************************************************************************
00065 class CTransformShape : public CTransform
00066 {
00067 public:
00069         static  void    registerBasic();
00070 
00071 public:
00073         CSmartPtr<IShape>               Shape;
00074 
00075 #ifdef NL_DEBUG
00076         std::string NameForDebug; // \todo traptemp
00077 #endif
00078 
00079 
00082         virtual void            getAABBox(NLMISC::CAABBox &bbox) const;
00083 
00086         virtual uint            getNumMaterial () const;
00087 
00090         virtual const CMaterial *getMaterial (uint materialId) const;
00091 
00094         virtual CMaterial       *getMaterial (uint materialId);
00095 
00097         // @{
00098 
00106         virtual float           getNumTriangles (float distance);
00107 
00112         float                           getNumTrianglesAfterLoadBalancing() {return _NumTrianglesAfterLoadBalancing;}
00113 
00115         virtual const   CMRMLevelDetail         *getMRMLevelDetail() const {return NULL;}
00116 
00117         // @}
00118 
00119 
00121         // @{
00123         void                            changeLightSetup(CRenderTrav *rdrTrav);
00124         // @}
00125 
00127         virtual bool            canStartStop() { return false; }
00128         // For instance that have a start/stop caps
00129         virtual void            start() {};
00130         // For instance that have a start/stop caps
00131         virtual void            stop()  {};
00132         // For instance that have a start/stop caps
00133         virtual bool            isStarted() const { return false; }
00134         
00135         // Get the model distmax. At startup it is setupped with the shape value
00136         float               getDistMax() const { return _DistMax; }     
00137         // Set the model distmax.
00138         void                setDistMax(float distMax) { _DistMax = distMax; }
00139 protected:
00141         CTransformShape();
00143         virtual ~CTransformShape() {}
00144 
00148         void                    setupCurrentLightContribution(CLightContribution *lightContrib, bool useLocalAtt);
00149 
00150 private:
00151         static IModel   *creator() {return new CTransformShape;}
00152         friend class    CTransformShapeClipObs;
00153         friend class    CTransformShapeRenderObs;
00154         friend class    CTransformShapeLoadBalancingObs;
00155 
00156         float                   _NumTrianglesAfterLoadBalancing;
00157 
00158 
00159         // return the contribution of lights (for redner Observer).
00160         CLightContribution      &getLightContribution() {return _LightContribution;}
00161 
00162 private:
00163         /* The Activated lightContribution, and localAttenuation setup for this instance.
00164                 This may be our lightContribution, or our ancestore skeleton contribution.
00165         */
00166         CLightContribution              *_CurrentLightContribution;
00167         // true If this instance use localAttenuation.
00168         bool                                    _CurrentUseLocalAttenuation;
00169 private:
00170         // The max dist for this model.
00171         float                   _DistMax;       
00172 };
00173 
00174 
00175 
00176 // ***************************************************************************
00177 // ***************************************************************************
00178 // Observers implementation.
00179 // ***************************************************************************
00180 // ***************************************************************************
00181 
00182 
00183 // ***************************************************************************
00195 class   CTransformShapeClipObs : public CTransformClipObs
00196 {
00197         bool    _ClipDueToDistMax;
00198 public:
00199 
00201         virtual bool    clip(IBaseClipObs *caller);
00202 
00204         bool                    isLastClipDueToDistMax() const {return _ClipDueToDistMax;}
00205 
00206         static IObs     *creator() {return new CTransformShapeClipObs;}
00207 };
00208 
00209 
00210 // ***************************************************************************
00220 class   CTransformShapeRenderObs : public CTransformRenderObs
00221 {
00222 public:
00223 
00225         virtual void    traverse(IObs *caller);
00226         
00227         static IObs     *creator() {return new CTransformShapeRenderObs;}
00228 };
00229 
00230 
00231 // ***************************************************************************
00242 class   CTransformShapeLoadBalancingObs : public IBaseLoadBalancingObs
00243 {
00244 public:
00245 
00250         virtual void    traverse(IObs *caller);
00251 
00252         static IObs     *creator() {return new CTransformShapeLoadBalancingObs;}
00253 
00254 
00255 protected:
00256 
00257         // The number of face computed in Pass0.
00258         float           _FaceCount;
00259 
00260 
00261         void            traversePass0();
00262         void            traversePass1();
00263 
00264 };
00265 
00266 
00267 } // NL3D
00268 
00269 
00270 #endif // NL_TRANSFORM_SHAPE_H
00271 
00272 /* End of transform_shape.h */