Changeset 2980


Ignore:
Timestamp:
09/29/08 10:33:56 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling
Files:
2 added
7 edited

Legend:

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

    r2975 r2980  
    609609                                </File> 
    610610                                <File 
     611                                        RelativePath=".\src\EntityMerger.cpp" 
     612                                        > 
     613                                </File> 
     614                                <File 
     615                                        RelativePath=".\src\EntityMerger.h" 
     616                                        > 
     617                                </File> 
     618                                <File 
    611619                                        RelativePath=".\src\FrameBufferObject.cpp" 
    612620                                        > 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Geometry.cpp

    r2795 r2980  
    1010Geometry::Geometry(Vector3 *vertices,  
    1111                                   Vector3 *normals, 
    12                                    float *texcoords, 
     12                                   Texcoord2 *texcoords, 
    1313                                   int numVertices, 
    1414                                   bool delData): 
     
    6262        if (mTexCoords) 
    6363        { 
    64                 for (int i = 0; i < mNumVertices * 2; ++ i) 
    65                         data[mNumVertices * 6 + i] = mTexCoords[i]; 
     64                for (int i = 0; i < mNumVertices; ++ i) 
     65                        ((Texcoord2 *)data)[mNumVertices * 3 + i] = mTexCoords[i]; 
    6666        } 
    6767 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Geometry.h

    r2953 r2980  
    1212class RenderState; 
    1313 
    14 /** Represents drawable geometry consisting of triangles 
     14 
     15/** Represents drawable geometry consisting of triangles. 
    1516*/ 
    1617class Geometry 
    1718{ 
    18 friend class ResourceManager; 
     19        friend class ResourceManager; 
     20        friend class EntityMerger; 
    1921 
    2022public: 
     
    2729        Geometry(Vector3 *vertices,  
    2830                     Vector3 *normals,  
    29                          float *texcoords,  
     31                         Texcoord2 *texcoords,  
    3032                         int numVertices,  
    3133                         bool delData); 
     
    5658        Vector3 *mNormals; 
    5759 
    58         float *mTexCoords; 
     60        Texcoord2 *mTexCoords; 
    5961 
    6062        unsigned int mVboId; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp

    r2963 r2980  
    192192        Vector3 *vertices; 
    193193        Vector3 *normals; 
    194         float *texcoords; 
     194        Texcoord2 *texcoords; 
    195195 
    196196 
     
    217217        if (texCoordCount) 
    218218        { 
    219                 texcoords = new float[texCoordCount * 2]; 
    220                 str.read(reinterpret_cast<char *>(texcoords), sizeof(float) * texCoordCount * 2); 
     219                texcoords = new Texcoord2[texCoordCount]; 
     220                str.read(reinterpret_cast<char *>(texcoords), sizeof(Texcoord2) * texCoordCount); 
    221221        } 
    222222        else 
     
    224224                texcoords = NULL; 
    225225        } 
    226          
    227  
    228         return new Geometry(vertices, normals, texcoords, vertexCount, true); 
     226 
     227        // return new Geometry(vertices, normals, texcoords, vertexCount, true); 
     228        return new Geometry(vertices, normals, texcoords, vertexCount, false); 
    229229} 
    230230 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.h

    r2865 r2980  
    2727{ 
    2828        friend class RenderQueue; 
     29        friend class EntityMerger; 
    2930 
    3031public: 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r2978 r2980  
    4040#include "SkyPreetham.h" 
    4141#include "Texture.h" 
     42#include "EntityMerger.h" 
    4243 
    4344 
     
    5859/// the renderable scene geometry 
    5960SceneEntityContainer sceneEntities; 
     61SceneEntityContainer sceneEntities2; 
    6062// traverses and renders the hierarchy 
    6163RenderTraverser *traverser = NULL; 
     
    262264 
    263265 
    264  
    265266///////// 
    266267//-- cg stuff 
     
    449450        } 
    450451 
    451          
    452          
     452        SceneEntityContainer::const_iterator sit, sit_end = sceneEntities.end(); 
     453 
     454        int merged = 0; 
     455         
     456        SceneEntity *oldEnt = NULL; 
     457 
     458        cout << "merging entities .. " << endl; 
     459 
     460        for (sit = sceneEntities.begin(); sit < sit_end; ++ sit) 
     461        { 
     462                SceneEntity *newEnt = (*sit); 
     463 
     464                if (!newEnt->GetTransform()->IsIdentity()) 
     465                { 
     466                        sceneEntities2.push_back(newEnt); 
     467                        continue; 
     468                } 
     469 
     470                if (oldEnt) 
     471                { 
     472                        EntityMerger merger(newEnt, oldEnt); 
     473                        SceneEntity *ent = merger.Merge(); 
     474 
     475                        sceneEntities2.push_back(ent); 
     476 
     477                        oldEnt = NULL; 
     478 
     479                        ++ merged; 
     480                } 
     481                else 
     482                { 
     483                        oldEnt = newEnt; 
     484                } 
     485        } 
     486 
     487        if (oldEnt && oldEnt->GetTransform()->IsIdentity()) 
     488                sceneEntities2.push_back(oldEnt); 
     489 
     490        cout << "merged " << merged << " of " << (int)sceneEntities.size() << " entities " << endl; 
     491 
    453492        // set far plane based on scene extent 
    454493        farDist = 10.0f * Magnitude(bvh->GetBox().Diagonal()); 
     
    611650{ 
    612651        PrintGLerror("fbo start"); 
     652 
    613653        // this fbo basicly stores the scene information we get from standard rendering of a frame 
    614654        // we store colors, normals, positions (for the ssao) 
     
    10961136        { 
    10971137                // actually render the scene geometry using the specified algorithm 
    1098                 traverser->RenderScene(); 
     1138                //traverser->RenderScene(); 
     1139 
    10991140        /* 
    11001141                state.Reset(); 
    11011142                aeroplane->Render(&state); 
    1102  
    1103         SceneEntityContainer::const_iterator sit, sit_end = sceneEntities.end(); 
     1143*/ 
     1144 
     1145#if 0 
     1146                SceneEntityContainer::const_iterator sit, sit_end = sceneEntities.end(); 
    11041147 
    11051148                for (sit = sceneEntities.begin(); sit != sit_end; ++ sit) 
    1106                 { 
    11071149                        renderQueue->Enqueue(*sit); 
    1108                 } 
    1109  
     1150#else 
     1151 
     1152                SceneEntityContainer::const_iterator sit, sit_end = sceneEntities2.end(); 
     1153 
     1154                for (sit = sceneEntities2.begin(); sit != sit_end; ++ sit) 
     1155                        renderQueue->Enqueue(*sit); 
     1156#endif 
    11101157                renderQueue->Apply(); 
    1111                 */ 
    11121158        } 
    11131159 
     
    11151161        ///////// 
    11161162        //-- do the rest of the rendering 
    1117  
    11181163         
    11191164        // reset depth pass and render visible objects 
     
    17721817        DEL_PTR(fbo); 
    17731818        DEL_PTR(ssaoShader); 
     1819 
     1820        CLEAR_CONTAINER(sceneEntities2); 
    17741821 
    17751822        if (sCgMrtVertexProgram) 
     
    20852132        state.SetUseAlphaToCoverage(false); 
    20862133 
    2087         // change CHC++ set of state variables (must be done for each change of camera because 
     2134        // change CHC++ set of state variables  
     2135        // this must be done for each change of camera because 
    20882136        // otherwise the temporal coherency is broken 
    20892137        BvhNode::SetCurrentState(1); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/common.h

    r2966 r2980  
    3131class Polygon3; 
    3232class Vector3; 
    33  
     33class Geometry; 
    3434 
    3535 
     
    492492 
    493493typedef std::vector<Shape *> ShapeContainer; 
     494typedef std::vector<Geometry *> GeometryContainer; 
    494495typedef std::vector<LODLevel *> LODLevelContainer; 
    495496typedef std::vector<Polygon3 *> PolygonContainer; 
     
    497498typedef std::vector<Vector3> VertexArray; 
    498499 
     500typedef std::pair<float, float> Texcoord2; 
     501 
    499502 
    500503static std::ofstream Debug("debug.log"); 
Note: See TracChangeset for help on using the changeset viewer.