Changeset 2839


Ignore:
Timestamp:
07/16/08 10:46:32 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling
Files:
7 added
9 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj

    r2837 r2839  
    511511                                </File> 
    512512                                <File 
     513                                        RelativePath=".\src\LODInfo.h" 
     514                                        > 
     515                                </File> 
     516                                <File 
    513517                                        RelativePath=".\src\Material.h" 
    514518                                        > 
     
    535539                                </File> 
    536540                                <File 
     541                                        RelativePath=".\src\Shape.h" 
     542                                        > 
     543                                </File> 
     544                                <File 
    537545                                        RelativePath=".\src\Texture.h" 
     546                                        > 
     547                                </File> 
     548                                <File 
     549                                        RelativePath=".\src\Transform.h" 
    538550                                        > 
    539551                                </File> 
     
    679691                                </File> 
    680692                                <File 
     693                                        RelativePath=".\src\Shape.cpp" 
     694                                        > 
     695                                </File> 
     696                                <File 
    681697                                        RelativePath=".\src\Texture.cpp" 
    682698                                        > 
     
    699715                                                /> 
    700716                                        </FileConfiguration> 
     717                                </File> 
     718                                <File 
     719                                        RelativePath=".\src\Transform.cpp" 
     720                                        > 
    701721                                </File> 
    702722                                <File 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp

    r2825 r2839  
    799799        for (int i = node->mFirst; i <= node->mLast; ++ i) 
    800800        { 
     801#ifdef TODO 
    801802                numTriangles += mGeometry[i]->GetGeometry()->GetNumTriangles(); 
     803#endif 
    802804        } 
    803805 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.cpp

    r2826 r2839  
    5858 
    5959 
    60 bool RenderQueue::FitsInBucket(SceneEntity *ent, size_t idx) const 
    61 { 
     60bool RenderQueue::FitsInBucket(Shape *ent, size_t idx) const 
     61{ 
     62#ifdef TODO 
    6263        Material *mat = ent->GetMaterial(); 
    63  
     64#else 
     65        Material *mat = NULL; 
     66#endif 
    6467        // test if entity belongs to this bucket 
    6568        // note: rather slows down the application for some reason!! 
     
    8992        RenderQueueBucket *bucket; 
    9093        ++ mSize; 
    91  
     94#ifdef TODO 
    9295        if (entity->mRenderQueueBucket) 
    9396        { 
     
    135138                entity->mRenderQueueBucket = bucket; 
    136139        } 
    137  
     140#endif 
    138141        bucket->mEntities.push_back(entity); 
    139142} 
     
    185188                { 
    186189                        SceneEntity *ent = *sit; 
    187          
     190        #ifdef TODO 
    188191                        Material *mat = ent->GetMaterial(); 
    189192                        int tsize = mat->GetTexture() ? mat->GetTexture()->GetByteSize() : 0; 
    190193                        float dist = SqrMagnitude(ent->GetBoundingBox().Center() - mCamera->GetPosition()); 
    191194                        Debug << "e: " << ent << " a: " << mat->IsAlphaTestEnabled() << " s: " << tsize << " d: " << dist << " " << endl; 
     195#endif 
    192196                } 
    193197        } 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.h

    r2805 r2839  
    2929        float mMinDistance; 
    3030 
    31         SceneEntityContainer mEntities; 
     31        ShapeContainer mShapes; 
    3232}; 
    3333 
     
    7070protected: 
    7171 
    72         inline bool FitsInBucket(SceneEntity *ent, size_t idx) const; 
     72        inline bool FitsInBucket(Shape *shape, size_t idx) const; 
    7373 
    7474        /** Sorts the render queue by materials / textures. 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.cpp

    r2825 r2839  
    109109                { 
    110110                        SceneEntity *ent = entities[i]; 
     111#ifdef TODO 
    111112                        mStats.mNumRenderedTriangles += ent->GetGeometry()->GetNumTriangles(); 
    112  
     113#endif 
    113114                        if (mUseRenderQueue) 
    114115                                mRenderQueue->Enqueue(ent); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp

    r2833 r2839  
    5757 
    5858        // use instancing 
    59         sceneGeom = new SceneEntity(geom, mat, trafo); 
     59        sceneGeom = new SceneEntity(trafo); 
    6060 
    6161        return sceneGeom; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.cpp

    r2825 r2839  
    1313CGparameter SceneEntity::sModelMatrixParam; 
    1414 
    15 SceneEntity::SceneEntity(Geometry *geometry,  
    16                                                  Material *mat, 
    17                                                  Matrix4x4 *trafo): 
    18 mGeometry(geometry), mMaterial(mat), mTransform(trafo), mRenderQueueBucket(NULL) 
     15SceneEntity::SceneEntity(Matrix4x4 *trafo): mTransform(trafo) 
    1916{ 
    2017} 
     
    2623 
    2724 
     25ShapeContainer *SceneEntity::GetCurrentLOD() 
     26{ 
     27        if (mLODInfos.empty()) 
     28                return &mShapes; 
     29 
     30        float mDistance = 0.0f; 
     31 
     32        int i = 0; 
     33 
     34        for (int i = 0; i < mLODInfos.size(); ++ i) 
     35        { 
     36                if (mLODInfos[i].mDistance > mDistance) 
     37                        return mShapes[i]; 
     38        } 
     39 
     40        return mShapes.last(); 
     41} 
     42 
     43 
    2844void SceneEntity::Render(RenderState *state) 
    2945{ 
    30         if (mMaterial) mMaterial->Render(state); 
     46        //if (mMaterial) mMaterial->Render(state); 
     47        float mDistance = 0.0f; 
    3148 
    32         if (mTransform) 
     49        ShapeContainer *shapes; 
     50 
     51        shspes = GetCurrentLOD(mDistance); 
     52 
     53        for (int i = 0; i < shapes->size(); ++ i) 
    3354        { 
    34                 if (state->GetRenderType() == RenderState::DEFERRED) 
    35                 { 
    36                         cgGLSetMatrixParameterfc(sModelMatrixParam, (const float *)mTransform->x); 
    37  
    38                         mGeometry->Render(state); 
    39  
    40                         static Matrix4x4 identity = IdentityMatrix(); 
    41                         cgGLSetMatrixParameterfc(sModelMatrixParam, (const float *)identity.x); 
    42                 } 
    43                 else 
    44                 { 
    45                         glPushMatrix(); 
    46                         glMultMatrixf((float *)mTransform->x); 
    47                          
    48                         mGeometry->Render(state); 
    49  
    50                         glPopMatrix(); 
    51                 } 
    52         } 
    53         else 
    54         { 
    55                 mGeometry->Render(state); 
     55                (shapes*)[i]->Render(state); 
    5656        } 
    5757} 
    5858 
    5959 
    60 void SceneEntity::SetGeometry(Geometry *geom) 
     60void SceneEntity::AddShape(Shape *shape) 
    6161{ 
    62         mGeometry = geom; 
     62        mShapes.push_back(shape); 
    6363} 
    6464 
     
    6767{ 
    6868        mTransform = trafo; 
    69 } 
    70  
    71  
    72 void SceneEntity::SetMaterial(Material *mat) 
    73 { 
    74         mMaterial = mat; 
    7569} 
    7670 
     
    9084AxisAlignedBox3 SceneEntity::GetBoundingBox() const 
    9185{ 
     86#ifdef TODO 
    9287        AxisAlignedBox3 box = mGeometry->GetBoundingBox(); 
     88#else 
     89        AxisAlignedBox3 box; 
     90#endif 
    9391        if (mTransform) Transform(box, *mTransform); 
    9492 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.h

    r2819 r2839  
    88#include "AxisAlignedBox3.h" 
    99#include "Triangle3.h" 
     10#include "LODInfo.h" 
    1011 
    1112 
    1213namespace CHCDemoEngine  
    1314{ 
    14  
    15  
    1615 
    1716class Material; 
     
    2827 
    2928public: 
    30         static CGparameter sModelMatrixParam; 
     29         
    3130        /** Creates a scene entity. 
    3231        */ 
    33         SceneEntity(Geometry *geometry, Material *mat, Matrix4x4 *trafo); 
     32        SceneEntity(Transformation *trafo); 
    3433 
    3534        ~SceneEntity(); 
     
    3736        */ 
    3837        void Render(RenderState *state);         
     38        /** Set pointer to the shape 
     39        */ 
     40        void AddShape(Shape *shape); 
     41        /** See set 
     42        */ 
     43        inline Shape *GetShape(int i) const { return mShapes[i]; } 
     44        /** Returns number of shapes in vector. 
     45        */ 
     46        inline int GetNumShapes() { return (int)mShapes.size(); } 
    3947        /** Set pointer to the geometry 
    4048        */ 
    41         void SetGeometry(Geometry *geom); 
    42         /** See set 
    43         */ 
    44         Geometry *GetGeometry() const { return mGeometry; } 
    45         /** Set pointer to the geometry 
    46         */ 
    47         void SetTransformation(Matrix4x4 *trafo); 
    48         /** Set pointer to the material 
    49         */ 
    50         void SetMaterial(Material *mat); 
     49        void SetTransformation(Transformation *trafo); 
    5150        /** Returns the transformed bounding box. 
    5251        */ 
     
    5857        */ 
    5958        int GetLastRendered() const; 
    60  
    61         inline Material *GetMaterial() const  { return mMaterial; } 
    62         inline Matrix4x4 *GetTransformation() const  { return mTransform; } 
     59        /** Returns the trafo of this scene entity. 
     60        */ 
     61        inline Transformation *GetTransformation() const  { return mTransform; } 
    6362 
    6463protected: 
    6564 
    6665        /// transform matrix  
    67         Matrix4x4 *mTransform; 
    68         Geometry *mGeometry; 
    69         Material *mMaterial; 
    70          
     66        Transformation *mTransform; 
     67 
     68        LODInfoContainer mLODInfos; 
     69 
     70        ShapeContainer mShapes; 
     71                 
    7172        int mLastRendered; 
    72         /// pointer to the renderqueue bucket this entity belongs to 
    73         RenderQueueBucket *mRenderQueueBucket; 
    7473}; 
    7574 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/common.h

    r2801 r2839  
    494494#define INITIAL_TRIANGLES_PER_VIRTUAL_LEAVES 1000 
    495495 
    496 // #define PRINT_VERBOSE_BENCHMARKS 
    497 } 
    498  
    499 #endif 
    500  
    501  
    502  
    503  
    504  
    505  
    506  
    507  
     496class Shape; 
     497typedef std::vector<Shape *> ShapeContainer; 
     498 
     499struct LODInfo; 
     500typedef std::vector<LODInfo *> LODInfoContainer; 
     501 
     502} 
     503 
     504#endif 
     505 
     506 
     507 
     508 
     509 
     510 
     511 
     512 
Note: See TracChangeset for help on using the changeset viewer.