# 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  

mesh_base_instance.h

Go to the documentation of this file.
00001 
00007 /* Copyright, 2001 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_MESH_BASE_INSTANCE_H
00027 #define NL_MESH_BASE_INSTANCE_H
00028 
00029 #include "nel/misc/types_nl.h"
00030 #include "3d/transform_shape.h"
00031 #include "3d/material.h"
00032 #include "3d/animated_material.h"
00033 #include "3d/animated_lightmap.h"
00034 #include "3d/animated_morph.h"
00035 #include "3d/async_texture_block.h"
00036 
00037 
00038 namespace NL3D
00039 {
00040 
00041 
00042 class CMeshBase;
00043 class CMesh;
00044 class CMeshMRM;
00045 class CMeshBaseInstanceAnimDetailObs;
00046 class CAnimatedLightmap;
00047 class CAsyncTextureManager;
00048 
00049 
00050 // ***************************************************************************
00051 // ClassIds.
00052 const NLMISC::CClassId          MeshBaseInstanceId=NLMISC::CClassId(0xef44331, 0x739f6bcf);
00053 
00054 
00055 // ***************************************************************************
00064 class CMeshBaseInstance : public CTransformShape
00065 {
00066 public:
00068         static  void    registerBasic();
00069 
00070 public:
00071 
00072 
00077         std::vector<CMaterial>                  Materials;
00078 
00084         std::vector<CAsyncTextureBlock> AsyncTextures;
00085 
00086 
00088         // @{
00089         enum    TAnimValues
00090         {
00091                 OwnerBit= CTransformShape::AnimValueLast, 
00092 
00093                 AnimValueLast,
00094         };
00095 
00096 
00097         virtual void    registerToChannelMixer(CChannelMixer *chanMixer, const std::string &prefix);
00098 
00099         // @}
00100 
00102         // @{
00103         virtual uint            getNumMaterial () const;
00104         virtual const CMaterial *getMaterial (uint materialId) const;
00105         virtual CMaterial       *getMaterial (uint materialId);
00106         // @}
00107 
00109         // @{
00111         virtual ITrack* getDefaultTrack (uint valueId);
00112         // @}
00113 
00115         // @{
00116         uint32 getNbLightMap();
00117         void getLightMapName( uint32 nLightMapNb, std::string &LightMapName );
00118         void setLightMapFactor( const std::string &LightMapName, CRGBA nFactor );
00119         // @}
00120 
00121         // To build lightmap
00122         void setAnimatedLightmap (CAnimatedLightmap *alm);
00123 
00125         // @{
00126         // Interface
00127         uint32 getNbBlendShape();
00128         void getBlendShapeName (uint32 nBlendShapeNb, std::string &BlendShapeName );
00129         void setBlendShapeFactor (const std::string &BlendShapeName, float rFactor);
00130 
00131         // Internal
00132         std::vector<CAnimatedMorph>* getBlendShapeFactors()
00133         {
00134                 return &_AnimatedMorphFactor;
00135         }
00136         // @}
00137 
00138 
00140         CScene                          *getScene() const {return _OwnerScene;}
00141 
00142 
00150         virtual void            changeMRMDistanceSetup(float distanceFinest, float distanceMiddle, float distanceCoarsest) {}
00151 
00155         void selectTextureSet(uint id);
00156 
00157 
00159         // @{
00169         void                    enableAsyncTextureMode(bool enable);
00170         bool                    getAsyncTextureMode() const {return _AsyncTextureMode;}
00176         void                    startAsyncTextureLoading();
00182         bool                    isAsyncTextureReady();
00183 
00186         void                    setAsyncTextureDistance(float dist) {_AsyncTextureDistance= dist;}
00187         float                   getAsyncTextureDistance() const {return _AsyncTextureDistance;}
00188 
00193         void                    setAsyncTextureDirty(bool flag) {_AsyncTextureDirty= flag;}
00195         bool                    isAsyncTextureDirty() const {return _AsyncTextureDirty;}
00196 
00201         sint                    getAsyncTextureId(uint matId, uint stage) const;
00202 
00203         // @}
00204 
00205 
00206 protected:
00208         CMeshBaseInstance();
00210         virtual ~CMeshBaseInstance();
00211 
00212 
00213 private:
00214         static IModel   *creator() {return new CMeshBaseInstance;}
00215         friend  class CMeshBase;
00216         friend  class CMeshBaseInstanceAnimDetailObs;
00217 
00218 
00221         std::vector<CAnimatedMaterial>  _AnimatedMaterials;
00222 
00223         std::vector<CAnimatedLightmap*> _AnimatedLightmap;
00224 
00225         std::vector<CAnimatedMorph> _AnimatedMorphFactor; 
00226 
00228         CScene          *_OwnerScene;
00229 
00231         // @{
00233         friend  class   CAsyncTextureManager;
00234         sint                                                    _AsyncTextureToLoadRefCount;
00235         bool                                                    _AsyncTextureDirty;
00236         bool                                                    _AsyncTextureMode;
00237         bool                                                    _AsyncTextureReady;
00238         // A copy of AsyncTextures done at each startAsyncTextureLoading().
00239         std::vector<CAsyncTextureBlock> _CurrentAsyncTextures;
00240         // distance for texture load balancing
00241         float                                                   _AsyncTextureDistance;
00242 
00243         void                    releaseCurrentAsyncTextures();
00244 
00245         // @}
00246 
00248 public:
00249 
00251         float           _VPWindTreePhase;               // Phase time of the wind animation. 0-1
00252 
00253 };
00254 
00255 
00256 // ***************************************************************************
00267 class   CMeshBaseInstanceAnimDetailObs : public CTransformAnimDetailObs
00268 {
00269 public:
00270 
00275         virtual void    traverse(IObs *caller);
00276 
00277 
00278 public:
00279         static IObs     *creator() {return new CMeshBaseInstanceAnimDetailObs;}
00280 };
00281 
00282 
00283 
00284 } // NL3D
00285 
00286 
00287 #endif // NL_MESH_BASE_INSTANCE_H
00288 
00289 /* End of mesh_base_instance.h */