"L. Spiro Engine"

F:/My Projects/LSEngine/Modules/LSEngine/Src/Models/LSEDrawableModelInstance.h

00001 
00016 #ifndef __LSE_DRAWABLEMODELINSTANCE_H__
00017 #define __LSE_DRAWABLEMODELINSTANCE_H__
00018 
00019 #include "../LSEEngine.h"
00020 #include "BoundingBoxes/LSPCappedKDop.h"
00021 #include "Intersections/LSPTest.h"
00022 #include "LSEDrawableMeshInstance.h"
00023 #include "LSEModelInstance.h"
00024 
00025 namespace lse {
00026 
00033         class CDrawableModelInstance : public CModelInstance {
00034         public :
00035                 // == Various constructors.
00036                 LSE_CALLCTOR                                                    CDrawableModelInstance();
00037                 virtual LSE_CALLCTOR                                    ~CDrawableModelInstance();
00038 
00039 
00040                 // == Types.
00044                 typedef CVectorPoD<CDrawableMeshInstance *, LSUINT32, 1024UL>
00045                                                                                                 CDrawableMeshInstanceArray;
00046 
00047 
00048                 // == Functions.
00054                 virtual LSUINT32 LSE_CALL                               ModelType() const;
00055 
00061                 virtual LSUINT32 LSE_CALL                               EntityType() const;
00062 
00071                 LSBOOL LSE_CALL                                                 AddMeshInFrustum( const CFrustum &_fFrustum, CDrawableMeshInstanceArray &_miaArray );
00072 
00081                 template <unsigned _uMax>
00082                 LSBOOL LSE_CALL                                                 AddMeshInKDop( const CCappedKDop<_uMax> &_ckdKDop, CDrawableMeshInstanceArray &_miaArray );
00083                 
00089                 LSVOID LSE_CALL                                                 SetCastsShadow( LSBOOL _bValue );
00090 
00096                 LSVOID LSE_CALL                                                 SetVertexLighting( LSBOOL _bValue );
00097 
00103                 LSVOID LSE_CALL                                                 SetCellShading( LSBOOL _bValue );
00104 
00110                 LSVOID LSE_CALL                                                 SetCookTorranceShading( LSBOOL _bValue );
00111 
00115                 LSVOID LSE_CALL                                                 DebugRender();
00116 
00117 
00118                 // == Members.
00122                 static CModelManager<CDrawableSharedModelPtr>
00123                                                                                                 m_mmDrawableModelMan;
00124 
00125 
00126         protected :
00127                 // == Members.
00128 
00129 
00130                 // == Functions.
00138                 virtual CSharedModelPtr LSE_CALL                GetModel( const LSCHAR * _pcPath ) const;
00139 
00145                 virtual CMeshInstance * LSE_CALL                CreateMesh() const;
00146 
00152                 virtual LSBOOL LSE_CALL                                 LoadFinished();
00153 
00154 
00155         private :
00156                 typedef CModelInstance                                  Parent;
00157         };
00158 
00159 
00160         // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00161         // DEFINITIONS
00162         // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00163         // == Types.
00167         typedef CSharedPtr<CDrawableModelInstance>      CDrawableModelInstancePtr;
00168 
00169         // == Functions.
00178         template <unsigned _uMax>
00179         LSBOOL LSE_CALL CDrawableModelInstance::AddMeshInKDop( const CCappedKDop<_uMax> &_ckdKDop, CDrawableMeshInstanceArray &_miaArray ) {
00180                 if ( !m_mlMeshes.Length() ) { return false; }
00181                 // Firstly, test ourselves for being in the frustum.
00182                 LSBOOL bFully;
00183                 if ( !CTest::AabbKDop( Aabb(), _ckdKDop, bFully ) ) { return false; }
00184 
00185                 // We are partially or fully inside the frustum.  If fully, add all meshes without testing boxes.
00186                 if ( bFully ) {
00187                         bFully = false;
00188                         for ( LSUINT32 I = m_mlMeshes.Length(); I--; ) {
00189                                 if ( reinterpret_cast<CDrawableMeshInstance *>(m_mlMeshes[I])->CastsShadow() ) {
00190                                         bFully = true;
00191                                         _miaArray.Push( reinterpret_cast<CDrawableMeshInstance *>(m_mlMeshes[I]) );
00192                                 }
00193                         }
00194                 }
00195                 else {
00196                         // Let's change the meaning of bFully.  Now it will be set to true if we add anything.
00197                         for ( LSUINT32 I = m_mlMeshes.Length(); I--; ) {
00198                                 if ( reinterpret_cast<CDrawableMeshInstance *>(m_mlMeshes[I])->CastsShadow() ) {
00199                                         if ( CTest::AabbKDop( m_mlMeshes[I]->Aabb(), _ckdKDop ) ) {
00200                                                 bFully = true;
00201                                                 _miaArray.Push( reinterpret_cast<CDrawableMeshInstance *>(m_mlMeshes[I]) );
00202                                         }
00203                                 }
00204                         }
00205                 }
00206                 return bFully;
00207         }
00208 
00209 }       // namespace lse
00210 
00211 #endif  // __LSE_DRAWABLEMODELINSTANCE_H__
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator