Ignore:
Timestamp:
01/13/09 10:43:20 (15 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhExporter.cpp

    r3261 r3272  
    6161 
    6262                ConstructTriangleRangeMap(bvh, interior->GetFront(), first, m); 
    63                 ConstructTriangleRangeMap(bvh, interior->GetBack(), m, last); 
     63                int newFirst = m + 1; 
     64                ConstructTriangleRangeMap(bvh, interior->GetBack(), newFirst, last); 
    6465 
    6566                mTriangleRangeMap[node] = pair<int, int>(first, last); 
     
    6869        { 
    6970                //first = currentIdx; 
    70                 last = first + bvh->CountTriangles(node); 
     71                last = first + bvh->CountTriangles(node) - 1; 
    7172                //currentIdx = last; 
    7273 
     
    9192         buffer[0] = MAGIC; 
    9293         buffer[1] = BVH_VERSION * 1000; 
    93          //buffer[2] = triangles.size(); 
    9494         buffer[3] = 0; // construction method 
    9595         buffer[4] = 1; // termination leaves 
    9696         buffer[5] = bvh->CountNumNodes(bvh->GetStaticRoot()); 
    9797 
    98          fwrite(buffer, sizeof(int), 6, fw); 
    99  
    100          int first, last; 
     98         int first = 0, last; 
    10199         ConstructTriangleRangeMap(bvh, bvh->GetStaticRoot(), first, last); 
    102100 
    103          BvhNodeContainer nodes; 
    104          bvh->CollectNodes(bvh->GetStaticRoot(), nodes); 
     101         BvhLeafContainer nodes; 
     102         bvh->CollectLeaves(bvh->GetStaticRoot(), nodes); 
    105103 
    106104         vector<int> triangles; 
    107105 
    108          BvhNodeContainer::const_iterator it, it_end = nodes.end(); 
     106         BvhLeafContainer::const_iterator it, it_end = nodes.end(); 
    109107 
    110108         for (it = nodes.begin(); it != it_end; ++ it) 
     
    113111 
    114112                 int f = mTriangleRangeMap[node].first; 
    115                  int b = mTriangleRangeMap[node].second; 
     113                 int l = mTriangleRangeMap[node].second; 
    116114 
    117                  for (int i = f; i < b; ++ i) 
     115                 for (int i = f; i <= l; ++ i) 
    118116                 { 
    119117                         triangles.push_back(i); 
     
    121119         } 
    122120 
     121         buffer[2] = (int)triangles.size(); 
     122         fwrite(buffer, sizeof(int), 6, fw); 
     123 
    123124         cout << "writing " << (int)triangles.size() << " triangle ids ..." << endl; 
    124125 
    125126         // export sorted triangle IDs 
    126          for (int i = 0; i < (int)triangles.size(); ++i)  
     127         for (size_t i = 0; i < triangles.size(); ++ i)  
    127128         { 
    128129                 fwrite(&triangles[i], sizeof(int), 1, fw); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ObjExporter.cpp

    r3261 r3272  
    2525        Vector3 *vertices = geom->GetVertices(numVertices); 
    2626 
     27        char str[100]; 
     28 
    2729        //cout << "vtx: " << numVertices << endl; 
    2830        for (int i = 0; i < numVertices; ++ i) 
    2931        { 
    3032                Vector3 v = vertices[i]; 
    31                 ostream << "v " << v.x << " " << v.y << " " << v.z << endl; 
     33                sprintf(str, "v %f %f %f\n", v.x, v.z, -v.y); 
     34                ostream << str; 
    3235        } 
    3336 
     
    7376                 { 
    7477                         ShapeContainer::iterator sit, send; 
    75  
    7678                         entities[i]->GetLODLevel(0, sit, send); 
    7779 
     
    7981                         { 
    8082                                 Geometry *geom = (*sit)->GetGeometry(); 
     83                                  
     84                                 int dummy; 
     85                                 if (!geom->GetVertices(dummy)) 
     86                                 { 
     87                                         cerr << "error: geometry was deleted on loading, exporting obj failed" << endl; 
     88                                         return false; 
     89                                 } 
     90 
    8191                                 numVertices += WriteGeometry(geom, ostream); 
    8292                         } 
     
    8999         for (int i = 0; i < numVertices; i += 3) 
    90100         { 
    91                  ostream << "f " << i << " " << i + 1 << " " << i + 2 << endl; 
     101                 ostream << "f " << i + 2 << " " << i + 2 << " " << i + 3 << endl; 
    92102         } 
    93103 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp

    r3271 r3272  
    382382        } 
    383383 
    384         const bool delGeometry = true; 
    385         //const bool delGeometry = false; 
     384        //const bool delGeometry = true; 
     385        const bool delGeometry = false; 
    386386        return new Geometry(vertices, normals, texcoords, vertexCount, delGeometry, NULL);//tangents); 
    387387} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntityConverter.cpp

    r3271 r3272  
    115115        } 
    116116 
     117 
    117118        Geometry *geom = new Geometry(vertices, normals, tex, 6, true, NULL); 
    118119 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SkyPreetham.cpp

    r3271 r3272  
    109109 
    110110        // scale the sky dome so no intersection with the scene is visible 
    111         //const float scaleFactor = 80.0f; 
    112         const float scaleFactor = 1000.0f; 
     111        const float scaleFactor = 80.0f; 
     112        //const float scaleFactor = 1000.0f; 
    113113 
    114114        position.z -= 3.0f * scaleFactor; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r3271 r3272  
    595595        //LoadModel("sibenik.dem", dynamicObjects); 
    596596 
    597 #if 1 
    598597 
    599598        AxisAlignedBox3 pompeiiBox = SceneEntity::ComputeBoundingBox(staticObjects); 
    600599 
     600        cout << "here34 " << pompeiiBox << endl; 
     601         
     602#if 0 
    601603        // todo: dispose texture 
    602604        Texture *floorTex = new Texture(model_path + "stairs.c.01.tif"); 
     
    722724 
    723725 
    724         //ObjExporter().Export(model_path + "mycity.obj", bvh); 
    725         //BvhExporter().Export(model_path + "mycity.bvh", bvh); 
     726        //ObjExporter().Export(model_path + "myvienna.obj", bvh); 
     727        //BvhExporter().Export(model_path + "myvienna.bv", bvh); 
    726728 
    727729 
     
    13661368                        ((PvsCollectionRenderer *)traverser)->SetViewCell(usePvs ? viewCell : NULL); 
    13671369 
     1370                //for (size_t i = 0; i < staticObjects.size(); ++ i) 
     1371                //      staticObjects[i]->Render(&renderState); 
     1372                 
    13681373                // actually render the scene geometry using the specified algorithm 
    13691374                traverser->RenderScene(); 
Note: See TracChangeset for help on using the changeset viewer.