Changeset 3071 for GTP


Ignore:
Timestamp:
10/26/08 20:39:31 (16 years ago)
Author:
mattausch
Message:

worked on dynamic objects

Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling
Files:
15 edited

Legend:

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

    r3055 r3071  
    228228                        </File> 
    229229                        <File 
     230                                RelativePath=".\src\RenderTraverser.cpp" 
     231                                > 
     232                                <FileConfiguration 
     233                                        Name="Debug|Win32" 
     234                                        > 
     235                                        <Tool 
     236                                                Name="VCCLCompilerTool" 
     237                                                ObjectFile="$(IntDir)\$(InputName)1.obj" 
     238                                                XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" 
     239                                        /> 
     240                                </FileConfiguration> 
     241                                <FileConfiguration 
     242                                        Name="Release|Win32" 
     243                                        > 
     244                                        <Tool 
     245                                                Name="VCCLCompilerTool" 
     246                                                ObjectFile="$(IntDir)\$(InputName)1.obj" 
     247                                                XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" 
     248                                        /> 
     249                                </FileConfiguration> 
     250                        </File> 
     251                        <File 
    230252                                RelativePath=".\src\SampleGenerator.cpp" 
    231253                                > 
     
    368390                                <File 
    369391                                        RelativePath=".\src\FrustumCullingTraverser.cpp" 
    370                                         > 
    371                                         <FileConfiguration 
    372                                                 Name="Debug|Win32" 
    373                                                 > 
    374                                                 <Tool 
    375                                                         Name="VCCLCompilerTool" 
    376                                                         ObjectFile="$(IntDir)\$(InputName)1.obj" 
    377                                                         XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" 
    378                                                 /> 
    379                                         </FileConfiguration> 
    380                                         <FileConfiguration 
    381                                                 Name="Release|Win32" 
    382                                                 > 
    383                                                 <Tool 
    384                                                         Name="VCCLCompilerTool" 
    385                                                         ObjectFile="$(IntDir)\$(InputName)1.obj" 
    386                                                         XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" 
    387                                                 /> 
    388                                         </FileConfiguration> 
    389                                 </File> 
    390                                 <File 
    391                                         RelativePath=".\src\RenderTraverser.cpp" 
    392392                                        > 
    393393                                        <FileConfiguration 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp

    r3070 r3071  
    11841184    while (1) 
    11851185        { 
    1186                 while (mGeometry[i]->GetWorldCenter()[axis] < position)  
    1187                 { 
    1188                         //cout<<" i " << i << " " << mGeometry[i]->GetWorldCenter()[axis]; 
    1189                         ++ i; 
    1190                 } 
    1191  
    1192                 while (position < mGeometry[j]->GetWorldCenter()[axis]) 
    1193                 { 
    1194                         //cout<< axis << " j " << j << " " << mGeometry[j]->GetWorldCenter()[axis] << " " << position<< " "; 
    1195                         -- j; 
    1196                 } 
     1186                while (mGeometry[i]->GetWorldCenter()[axis] < position) ++ i; 
     1187                while (position < mGeometry[j]->GetWorldCenter()[axis]) -- j; 
    11971188 
    11981189                // sorting finished 
     
    12161207        // spatial median 
    12171208        float m = leaf->mBox.Center()[axis]; 
    1218         //cout << "here3 " << leaf->mBox << " " << leaf->mFirst << " " << leaf->mLast << endl; 
    12191209        return SortTriangles(leaf, axis, m); 
    12201210} 
     
    12291219                leaf->mIsVirtualLeaf = true; 
    12301220                leaf->mIsMaxDepthForVirtualLeaf = true; 
     1221                cout << "leaf contructed:" << leaf->mBox << " " << leaf->mFirst << " " << leaf->mLast << endl; 
    12311222                return leaf; 
    12321223        } 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/EntityMerger.cpp

    r3070 r3071  
    4848        Geometry *geom = MergeGeometry(geom1, geom2); 
    4949 
    50         Shape *shape = new Shape(geom, mat, parent); 
     50        Shape *shape = new Shape(geom, mat); 
    5151 
    5252        return shape; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrustumCullingTraverser.cpp

    r2802 r3071  
    2424                else 
    2525                { 
    26                         mStats.mNumFrustumCulledNodes ++; 
     26                        ++ mStats.mNumFrustumCulledNodes; 
    2727                } 
    2828        } 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.cpp

    r3061 r3071  
    77#include "Shape.h" 
    88#include "RenderState.h" 
     9#include "Transform3.h" 
     10 
    911 
    1012using namespace std; 
     
    7880        for (; sit != sit_end; ++ sit) 
    7981        { 
    80                 Enqueue(*sit); 
    81         } 
    82 } 
    83  
    84  
    85 void RenderQueue::Enqueue(Shape *shape) 
     82                Enqueue(*sit, entity->GetTransform()); 
     83        } 
     84} 
     85 
     86 
     87void RenderQueue::Enqueue(Shape *shape, Transform3 *trafo) 
    8688{ 
    8789        Technique *tech = shape->GetMaterial()->GetTechnique(mState->GetRenderTechnique()); 
     
    157159        } 
    158160 
    159         bucket->mShapes.push_back(shape); 
     161        bucket->mShapes.push_back(ShapePair(shape, trafo)); 
    160162} 
    161163 
     
    184186        for (size_t i = 0; i < mActiveBuckets.size(); ++ i) 
    185187        { 
    186                 ShapeContainer::const_iterator sit, sit_end = mActiveBuckets[i]->mShapes.end(); 
     188                ShapePairArray::const_iterator sit, sit_end = mActiveBuckets[i]->mShapes.end(); 
    187189 
    188190                for (sit = mActiveBuckets[i]->mShapes.begin(); sit != sit_end; ++ sit) 
    189191                { 
    190                         Shape *shape = *sit; 
     192                        ShapePair s = *sit; 
     193 
     194                        Shape *shape = s.first; 
     195                        Transform3 *t = s.second; 
     196 
     197                        t->Load(mState); 
    191198                        shape->Render(mState); 
     199                        t->Unload(mState); 
    192200                } 
    193201        } 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.h

    r3061 r3071  
    33 
    44#include "common.h" 
    5 #include "Timer/PerfTimer.h" 
    65 
    76 
     
    1211class Camera; 
    1312 
     13typedef std::pair<Shape *, Transform3 *> ShapePair; 
     14typedef std::vector<ShapePair> ShapePairArray; 
    1415 
    1516/** Defines a bucket for scene entities that have the same properties. 
     
    4546 
    4647        /// the shapes that belong to a bucket 
    47         ShapeContainer mShapes; 
     48        ShapePairArray mShapes; 
    4849}; 
    4950 
     
    7374        /** Enqueues a single shape. 
    7475        */ 
    75         void Enqueue(Shape *shape); 
     76        void Enqueue(Shape *shape, Transform3 *trafo); 
    7677        /** Sets the current render state 
    7778        */ 
     
    8687        */ 
    8788        void Clear(); 
     89 
    8890 
    8991protected: 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.cpp

    r3070 r3071  
    158158        EnqueueNode(mBvh->GetRoot()); 
    159159        // add dynamic root 
    160         EnqueueNode(mBvh->GetDynamicRoot()); 
     160        if (mBvh->GetDynamicRoot()) 
     161                EnqueueNode(mBvh->GetDynamicRoot()); 
    161162 
    162163 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp

    r3070 r3071  
    115115 
    116116                        // create shape 
    117                         Shape *shape = new Shape(geom, mat, sceneGeom); 
     117                        Shape *shape = new Shape(geom, mat); 
    118118 
    119119                        mShapes.push_back(shape); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.cpp

    r3070 r3071  
    102102        } 
    103103 
     104        mTransform->Load(state); 
     105 
    104106        for (; sit != sit_end; ++ sit) 
    105107        { 
    106108                (*sit)->Render(state); 
    107109        } 
     110 
     111        mTransform->Unload(state); 
    108112} 
    109113 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.h

    r3070 r3071  
    3636        /** Copy constructur. 
    3737        */ 
    38         //SceneEntity(const SceneEntity &trafo); 
     38        //SceneEntity(const SceneEntity &e); 
    3939        /** Destructor. 
    4040        */ 
     
    112112        /// the bounding box 
    113113        AxisAlignedBox3 mBox; 
    114         /// transform matrix  
     114        /// describes a 3D transform 
    115115        Transform3 *mTransform; 
    116116        /// Stores information about the LOD levels 
     
    120120        /// when this entity was last rendered 
    121121        int mLastRendered; 
    122  
     122        /// the LOD level currently used for rendering 
    123123        int mCurrentLODLevel; 
    124         /// which frame the lod info was last updated 
     124        /// frame number in which the LODs were last updated 
    125125        int mLODLastUpdated; 
    126         /// the center of gravity of this scene entity 
     126        /// the center of gravity of this entity 
    127127        Vector3 mCenter; 
    128128 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntityConverter.cpp

    r3070 r3071  
    4343        Geometry *geom = new Geometry(vertices, normals, NULL, 36, false); 
    4444 
    45         Shape *shape = new Shape(geom, mat, ent); 
     45        Shape *shape = new Shape(geom, mat); 
    4646        ent->AddShape(shape); 
    4747 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Shape.cpp

    r3070 r3071  
    1010{ 
    1111 
    12 Shape::Shape(Geometry *geometry, Material *mat, SceneEntity *parent): 
     12Shape::Shape(Geometry *geometry, Material *mat): 
    1313mGeometry(geometry),  
    14 mMaterial(mat),  
    15 mParent(parent) 
     14mMaterial(mat) 
    1615{ 
    1716        mCenter = GetBoundingBox().Center(); 
     
    2827                mMaterial->Render(state); 
    2928 
    30         mParent->GetTransform()->Load(state); 
    3129        mGeometry->Render(state); 
    32         mParent->GetTransform()->Unload(state); 
    3330} 
    3431 
     
    5350 
    5451 
    55 AxisAlignedBox3 Shape::GetWorldBoundingBox() const 
     52Vector3 Shape::GetCenter() const 
    5653{ 
    57         if (mParent->GetTransform()->IsIdentity()) 
    58                 return mGeometry->GetBoundingBox(); 
    59  
    60         Matrix4x4 mat = mParent->GetTransform()->GetMatrix(); 
    61  
    62         return Transform(mGeometry->GetBoundingBox(), mat); 
    63 } 
    64  
    65  
    66 Vector3 Shape::GetWorldCenter() const 
    67 { 
    68         if (mParent->GetTransform()->IsIdentity()) 
    69                 return mCenter; 
    70  
    71         Matrix4x4 mat = mParent->GetTransform()->GetMatrix(); 
    72  
    73         return mat * mCenter; 
     54        return mCenter; 
    7455} 
    7556 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Shape.h

    r3070 r3071  
    3232        /** Creates a scene entity. 
    3333        */ 
    34         Shape(Geometry *geometry, Material *mat, SceneEntity *parent); 
     34        Shape(Geometry *geometry, Material *mat); 
    3535 
    3636        ~Shape(); 
     
    4343        /** See set 
    4444        */ 
    45         Geometry *GetGeometry() const { return mGeometry; } 
     45        inline Geometry *GetGeometry() const { return mGeometry; } 
    4646        /** Set pointer to the material 
    4747        */ 
     
    5050        */ 
    5151        AxisAlignedBox3 GetBoundingBox() const; 
    52         /** Returns bounding box transformed with the parent transform. 
    53         */ 
    54         AxisAlignedBox3 GetWorldBoundingBox() const; 
    5552        /** Returns material of this shape. 
    5653        */ 
    5754        inline Material *GetMaterial() const  { return mMaterial; } 
    58         /** Returns transformed center point of this shape. 
     55        /** Returns center point of this shape. 
    5956        */ 
    60         Vector3 GetWorldCenter() const; 
     57        Vector3 GetCenter() const; 
    6158 
    6259 
     
    6764        Geometry *mGeometry; 
    6865        Material *mMaterial; 
    69         SceneEntity *mParent; 
    7066}; 
    7167 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Transform3.cpp

    r3070 r3071  
    3232{ 
    3333        if (mIsIdentity) return; 
    34  
    3534        glPopMatrix(); 
    3635} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r3070 r3071  
    497497        LoadModel("hbuddha.dem", dynamicObjects); 
    498498        buddha = dynamicObjects.back(); 
    499         dynamicObjects.clear(); 
    500         Vector3 sceneCenter(470.398f, 240.364f, 182.5f); 
     499         
     500        const Vector3 sceneCenter(470.398f, 240.364f, 182.5f); 
    501501        Matrix4x4 transl = TranslationMatrix(sceneCenter); 
    502502        buddha->GetTransform()->SetMatrix(transl); 
    503503 
    504         Vector3 offs = Vector3::ZERO(); 
    505  
    506504        for (int i = 0; i < 10; ++ i) 
    507505        { 
     
    509507                resourceManager->AddSceneEntity(ent); 
    510508 
    511                 offs.x = RandomValue(.0f, 50.0f); 
    512                 offs.y = RandomValue(.0f, 50.0f); 
     509                Vector3 offs = Vector3::ZERO(); 
     510 
     511                offs.x = RandomValue(.0f, 150.0f); 
     512                offs.y = RandomValue(.0f, 150.0f); 
    513513 
    514514                transl = TranslationMatrix(sceneCenter + offs); 
     
    18731873void RenderSky() 
    18741874{ 
    1875         //buddha->Render(&state); 
    1876  
    18771875        if ((renderMethod == RENDER_DEFERRED) || (renderMethod == RENDER_DEPTH_PASS_DEFERRED)) 
    18781876                state.SetRenderTechnique(DEFERRED); 
     
    20082006                for (sit = (*resourceManager->GetShapes()).begin(); sit != sit_end; ++ sit) 
    20092007                { 
    2010                         renderQueue->Enqueue(*sit); 
     2008                        static Transform3 dummy(IdentityMatrix()); 
     2009                        renderQueue->Enqueue(*sit, &dummy); 
    20112010                } 
    20122011         
Note: See TracChangeset for help on using the changeset viewer.