- Timestamp:
- 09/22/08 10:10:01 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/ObjConverter.cpp
r2961 r2963 41 41 int index = (int)strtol(str, NULL, 10) - 1; 42 42 43 str = strtok_s(substrings[i], "/", &next_token); 43 int tIndex = index; 44 int nIndex = index; 45 46 /*str = strtok_s(substrings[i], "/", &next_token); 44 47 int tIndex = (int)strtol(str, NULL, 10) - 1; 45 48 46 49 str = strtok_s(substrings[i], "/", &next_token); 47 50 int nIndex = (int)strtol(str, NULL, 10) - 1; 48 51 */ 49 52 // store indices 50 53 if (index >= 0) … … 70 73 faceVertices.push_back(vertices[indices[idx2]]); 71 74 faceVertices.push_back(vertices[indices[idx3]]); 72 75 76 Vector3 dummy(1, 0, 0); 77 faceNormals.push_back(dummy); 78 faceNormals.push_back(dummy); 79 faceNormals.push_back(dummy); 80 81 /* 82 const Vector3 v2 = mVertices[2] - mVertices[1]; 83 Normalize(CrossProd(v2, v1)); 84 73 85 faceNormals.push_back(normals[nIndices[idx1]]); 74 86 faceNormals.push_back(normals[nIndices[idx2]]); … … 78 90 faceTexcoords.push_back(texcoords[tIndices[idx2]]); 79 91 faceTexcoords.push_back(texcoords[tIndices[idx3]]); 92 */ 80 93 } 81 94 } … … 129 142 geom->mNormals[i].z = faceNormals[i].y; 130 143 131 geom->mTexcoords[i].first = faceTexcoords[i].first; 132 geom->mTexcoords[i].second = faceTexcoords[i].second; 144 if (i <= geom->mTexcoordCount) 145 { 146 geom->mTexcoords[i].first = faceTexcoords[i].first; 147 geom->mTexcoords[i].second = faceTexcoords[i].second; 148 } 133 149 } 134 150 … … 228 244 faceVertices, faceNormals, faceTexcoords); 229 245 246 if (((line % 100) == 99) && 247 !faceVertices.empty()) 248 { 249 ++ mNumShapes; 250 251 LoadShape(faceVertices, faceNormals, faceTexcoords); 252 253 faceVertices.clear(); 254 faceNormals.clear(); 255 faceTexcoords.clear(); 256 } 257 230 258 break; 231 259 } // end face … … 286 314 //-- texture 287 315 288 //int texId = -1;289 int texId = 0;316 int texId = -1; 317 //int texId = 0; 290 318 str.write(reinterpret_cast<char *>(&texId), sizeof(int)); 291 319 … … 330 358 //-- write textures 331 359 332 int textureCount = 1;333 //int textureCount = 0;360 //int textureCount = 1; 361 int textureCount = 0; 334 362 335 363 ofile.write(reinterpret_cast<char *>(&textureCount), sizeof(int)); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/main.cpp
r2961 r2963 21 21 } 22 22 */ 23 if (!converter.Convert(model_path + "toyplane.obj", model_path + "toyplane.dem"))24 cerr << "conversion failed" << endl;23 //if (!converter.Convert(model_path + "toyplane.obj", model_path + "toyplane.dem")) 24 // cerr << "conversion failed" << endl; 25 25 26 26 //if (!converter.Convert(model_path + "sky.obj", model_path + "sky.dem")) 27 27 // cerr << "conversion failed" << endl; 28 29 if (!converter.Convert(model_path + "city_full.obj", model_path + "city_full.dem")) 30 cerr << "conversion failed" << endl; 28 31 29 32 cout << "conversion successful" << endl; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp
r2954 r2963 427 427 else 428 428 { 429 // hack: use dummy wrapper in order to use function 429 430 static BvhNodeContainer dummy(1); 430 431 dummy[0] = node; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhLoader.cpp
r2962 r2963 77 77 newRoot->mLast = root->mLast; 78 78 79 // create 'dynamic' leaf which basic ly is a container79 // create 'dynamic' leaf which basically is a container 80 80 // for all dynamic objects 81 81 BvhLeaf *dynamicLeaf = new BvhLeaf(newRoot); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp
r2961 r2963 235 235 str.read(reinterpret_cast<char *>(&entityCount), sizeof(int)); 236 236 237 entities.res ize(entityCount);237 entities.reserve(entityCount); 238 238 239 239 for (int i = 0; i < entityCount; ++ i) 240 240 { 241 241 SceneEntity *ent = LoadSceneEntity(str); 242 entities[i] = ent; 243 242 243 // return loaded entities 244 entities.push_back(ent); 245 // also store internally 244 246 mSceneEntities.push_back(ent); 245 247 } … … 275 277 mGeometryTable.clear(); 276 278 mMaterialTable.clear(); 277 //mShapesTable.clear();278 279 279 280 return true; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShadowMapping.cpp
r2954 r2963 156 156 157 157 158 static void DrawPoly (Polyhedron *poly, const Vector3 &color)158 static void DrawPolyhedron(Polyhedron *poly, const Vector3 &color) 159 159 { 160 160 if (!poly) return; … … 179 179 180 180 181 void ShadowMap:: DrawPolys()182 { 183 DrawPoly (lightPoly, Vector3(1, 0, 1));184 DrawPoly (polyhedron, Vector3(0, 1, 0));181 void ShadowMap::VisualizeFrustra() 182 { 183 DrawPolyhedron(lightPoly, Vector3(1, 0, 1)); 184 DrawPolyhedron(polyhedron, Vector3(0, 1, 0)); 185 185 } 186 186 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShadowMapping.h
r2952 r2963 21 21 class DirectionalLight; 22 22 23 /** This class implements a the computation of single shadow map 23 /** This class implements a the computation of single shadow map using 24 LispSM (light space perspective shadow mapping) 24 25 */ 25 26 class ShadowMap … … 28 29 public: 29 30 /** Constructor taking the scene boundig box and the current camera. 30 The shadow map has resolution size * size.31 The shadow map has resolution size squared. 31 32 */ 32 33 ShadowMap(DirectionalLight *light, int size, const AxisAlignedBox3 &sceneBox, Camera *cam); … … 39 40 */ 40 41 unsigned int GetShadowColorTexture() const; 41 42 /** Returns the depth texture used for shadow comparison. 43 */ 42 44 unsigned int GetDepthTexture() const; 43 44 45 /** Returns computed texture matrix. It must be applied on the 45 46 the world space positions. … … 53 54 */ 54 55 int GetSize() const { return mSize; } 55 56 /** Returns the camera used for light view rendering. 57 */ 56 58 Camera *GetShadowCamera() const { return mShadowCam; } 57 59 /** Renders the scene from shadow view using conventional shading. 60 */ 58 61 void RenderShadowView(RenderTraverser *renderer, const Matrix4x4 &projView); 59 60 static void DrawPolys(); 62 /** Draws LispSM intersection body B and the used light frustrum 63 */ 64 static void VisualizeFrustra(); 61 65 62 66 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Visualization.cpp
r2931 r2963 154 154 RenderFrustum(); 155 155 156 ShadowMap:: DrawPolys();156 ShadowMap::VisualizeFrustra(); 157 157 158 158 Vector3 pos = mCamera->GetPosition(); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r2961 r2963 447 447 448 448 449 450 // set far plane based on scene extent 451 farDist = 10.0f * Magnitude(bvh->GetBox().Diagonal()); 452 bvh->SetVirtualLeaves(trianglesPerVirtualLeaf); 453 454 camera->SetFar(Magnitude(bvh->GetBox().Diagonal())); 455 456 InitCg(); 457 458 DeferredRenderer::Init(sCgContext); 459 SkyPreetham::Init(sCgContext); 460 449 461 Vector3 cubeCenter(470.398f, 240.364f, 182.5f); 450 462 /*AxisAlignedBox3 box(cubeCenter - Vector3(2.0f), cubeCenter + Vector3(2.0f)); … … 457 469 Matrix4x4 transl = TranslationMatrix(cubeCenter); 458 470 459 const string aeroplaneStr = model_path + "toyplane.dem"; 471 //const string aeroplaneStr = model_path + "toyplane.dem"; 472 const string aeroplaneStr = model_path + "city_full.dem"; 460 473 461 474 SceneEntityContainer dummy; … … 471 484 } 472 485 473 aeroplane = dummy[0];474 aeroplane->GetTransform()->MultMatrix(transl);475 dummy.clear();476 477 478 // set far plane based on scene extent479 farDist = 10.0f * Magnitude(bvh->GetBox().Diagonal());480 bvh->SetVirtualLeaves(trianglesPerVirtualLeaf);481 482 camera->SetFar(Magnitude(bvh->GetBox().Diagonal()));483 484 InitCg();485 486 DeferredRenderer::Init(sCgContext);487 SkyPreetham::Init(sCgContext);488 489 490 486 string skyDomeStr(model_path + "sky.dem"); 491 487 … … 500 496 } 501 497 502 skyDome = dummy[0]; 503 498 aeroplane = dummy[0]; 499 skyDome = dummy[1]; 500 501 aeroplane->GetTransform()->MultMatrix(transl); 502 504 503 const float turbitiy = 3.0f; 505 504 preetham = new SkyPreetham(turbitiy, skyDome); … … 1087 1086 { 1088 1087 // actually render the scene geometry using the specified algorithm 1089 traverser->RenderScene(); 1088 //traverser->RenderScene(); 1089 state.Reset(); 1090 /* SceneEntityContainer::const_iterator sit, sit_end = sceneEntities.end(); 1091 1092 for (sit = sceneEntities.begin(); sit != sit_end; ++ sit) 1093 { 1094 renderQueue->Enqueue(*sit); 1095 }*/ 1096 1097 aeroplane->Render(&state); 1098 1099 renderQueue->Apply(); 1090 1100 } 1091 1101 … … 1112 1122 1113 1123 //state.Reset(); glEnable(GL_TEXTURE_2D); 1114 aeroplane->Render(&state);1124 //aeroplane->Render(&state); 1115 1125 1116 1126
Note: See TracChangeset
for help on using the changeset viewer.