Changeset 2961 for GTP/trunk/App/Demos
- Timestamp:
- 09/21/08 23:42:44 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 8 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.sln
r2800 r2961 2 2 Microsoft Visual Studio Solution File, Format Version 9.00 3 3 # Visual Studio 2005 4 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "chc_revisited", "FriendlyCulling.vcproj", "{03661866-4093-4B02-B26A-028EA91AF023}" 4 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "friendlyculling", "FriendlyCulling.vcproj", "{03661866-4093-4B02-B26A-028EA91AF023}" 5 EndProject 6 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Converter", "Converter.vcproj", "{93A522E1-76F0-4D46-9C97-30DC2DDB531D}" 5 7 EndProject 6 8 Global … … 14 16 {03661866-4093-4B02-B26A-028EA91AF023}.Release|Win32.ActiveCfg = Release|Win32 15 17 {03661866-4093-4B02-B26A-028EA91AF023}.Release|Win32.Build.0 = Release|Win32 18 {93A522E1-76F0-4D46-9C97-30DC2DDB531D}.Debug|Win32.ActiveCfg = Debug|Win32 19 {93A522E1-76F0-4D46-9C97-30DC2DDB531D}.Debug|Win32.Build.0 = Debug|Win32 20 {93A522E1-76F0-4D46-9C97-30DC2DDB531D}.Release|Win32.ActiveCfg = Release|Win32 21 {93A522E1-76F0-4D46-9C97-30DC2DDB531D}.Release|Win32.Build.0 = Release|Win32 16 22 EndGlobalSection 17 23 GlobalSection(SolutionProperties) = preSolution -
GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj
r2960 r2961 248 248 </File> 249 249 <File 250 RelativePath=".\src\ObjConverter.cpp"251 >252 </File>253 <File254 RelativePath=".\src\ObjConverter.h"255 >256 </File>257 <File258 250 RelativePath=".\src\PerformanceGraph.cpp" 259 251 > -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ObjConverter.cpp
r2959 r2961 6 6 #include "Material.h" 7 7 #include "Texture.h" 8 #include <map>9 8 10 9 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ObjConverter.h
r2957 r2961 1 #ifndef _ _ObjConverter_H2 #define _ _ObjConverter_H1 #ifndef _OBJCONVERTER_H 2 #define _OBJCONVERTER_H 3 3 4 4 #include "common.h" -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp
r2957 r2961 42 42 if (!hasTrafo) 43 43 { 44 // identity 44 45 trafo = new Transform3(); 45 46 } … … 72 73 str.read(reinterpret_cast<char *>(&numShapes), sizeof(int)); 73 74 75 74 76 LODLevel *lodLevel = new LODLevel(dist); 75 77 … … 102 104 int numTextures; 103 105 str.read(reinterpret_cast<char *>(&numTextures), sizeof(int)); 104 106 105 107 for (int i = 0; i < numTextures; ++ i) 106 108 { 107 // texture109 // load texture name 108 110 int texnameSize; 109 110 111 str.read(reinterpret_cast<char *>(&texnameSize), sizeof(int)); 111 112 … … 201 202 202 203 // end of file reached 203 if (str.eof()) 204 return NULL; 204 if (str.eof()) return NULL; 205 205 206 206 //cout << "vertexcount: " << vertexCount << endl; … … 218 218 { 219 219 texcoords = new float[texCoordCount * 2]; 220 str.read(reinterpret_cast<char *>(texcoords), sizeof(float) * vertexCount * 2);220 str.read(reinterpret_cast<char *>(texcoords), sizeof(float) * texCoordCount * 2); 221 221 } 222 222 else … … 225 225 } 226 226 227 #if 0228 // construct normals229 for (int i = 0; i < vertexCount; i += 3)230 {231 Triangle3 tri(vertices[i], vertices[i + 1], vertices[i + 2]);232 233 normals[i] = tri.GetNormal();234 normals[i+1] = tri.GetNormal();235 normals[i+2] = tri.GetNormal();236 }237 #endif238 227 239 228 return new Geometry(vertices, normals, texcoords, vertexCount, true); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.cpp
r2957 r2961 152 152 AxisAlignedBox3 SceneEntity::GetTransformedBoundingBox() const 153 153 { 154 if (mTransform->IsIdentity()) 155 return mBox; 154 if (mTransform->IsIdentity()) return mBox; 156 155 157 156 Matrix4x4 mat = mTransform->GetMatrix(); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SkyPreetham.cpp
r2960 r2961 114 114 115 115 const float scaleFactor = 80.0f; 116 //const float scaleFactor = 5.0f; 116 117 117 118 position.z -= 3 * scaleFactor; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Transform3.h
r2957 r2961 38 38 /** See Get 39 39 */ 40 inline void SetMatrix(const Matrix4x4 &trafo) { m Matrix = trafo; }40 inline void SetMatrix(const Matrix4x4 &trafo) { mIsIdentity = false; mMatrix = trafo; } 41 41 /** Right multiplies with the given matrix. 42 42 */ 43 inlinevoid MultMatrix(const Matrix4x4 &trafo);43 void MultMatrix(const Matrix4x4 &trafo); 44 44 /** Resets trafo to identiy. 45 45 */ -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r2960 r2961 1 // occquery.cpp : Defines the entry point for the console application.1 // chcdemo.cpp : Defines the entry point for the console application. 2 2 // 3 3 #include "glInterface.h" … … 149 149 bool flyMode = true; 150 150 151 SceneEntityContainer skyGeometry;152 153 151 bool leftKeyPressed = false; 154 152 bool rightKeyPressed = false; … … 415 413 416 414 415 glEnable(GL_MULTISAMPLE_ARB); 416 glHint(GL_MULTISAMPLE_FILTER_HINT_NV, GL_NICEST); 417 418 LeftMotion(0, 0); 419 MiddleMotion(0, 0); 420 421 perfGraph = new PerformanceGraph(1000); 422 423 loader = new ResourceManager(); 424 425 //const string filename("data/city/model/city.dem"); 426 const string filename = string(model_path + "city.dem"); 427 428 if (loader->Load(filename, sceneEntities)) 429 cout << "scene " << filename << " loaded" << endl; 430 else 431 { 432 cerr << "loading scene " << filename << " failed" << endl; 433 CleanUp(); 434 exit(0); 435 } 436 437 const string bvh_filename = string(model_path + "city.bvh"); 438 BvhLoader bvhLoader; 439 bvh = bvhLoader.Load(bvh_filename, sceneEntities); 440 441 if (!bvh) 442 { 443 cerr << "loading bvh " << bvh_filename << " failed" << endl; 444 CleanUp(); 445 exit(0); 446 } 447 448 417 449 Vector3 cubeCenter(470.398f, 240.364f, 182.5f); 418 AxisAlignedBox3 box(cubeCenter - Vector3(2.0f), cubeCenter + Vector3(2.0f));450 /*AxisAlignedBox3 box(cubeCenter - Vector3(2.0f), cubeCenter + Vector3(2.0f)); 419 451 420 452 Material *mat = new Material(RgbaColor(1, 0.4, 0.4, 0)); 421 453 Transform3 *tf = new Transform3(); 422 454 cube = SceneEntityConverter().ConvertBox(box, mat, tf); 423 424 //aeroplane = ObjConverter().Load(model_path + "toyplane.obj"); 425 //if (!aeroplane) cerr << "loadig plane failed" << endl; 426 427 skyDome = ObjConverter().Load(model_path + "sky.obj"); 428 if (!skyDome) cerr << "loadig plane failed" << endl; 429 430 const float turbitiy = 3.0f; 431 preetham = new SkyPreetham(turbitiy, skyDome); 432 433 glEnable(GL_MULTISAMPLE_ARB); 434 glHint(GL_MULTISAMPLE_FILTER_HINT_NV, GL_NICEST); 435 436 LeftMotion(0, 0); 437 MiddleMotion(0, 0); 438 439 perfGraph = new PerformanceGraph(1000); 440 441 loader = new ResourceManager(); 442 443 //const string filename("data/city/model/city.dem"); 444 const string filename = string(model_path + "city.dem"); 445 446 if (loader->Load(filename, sceneEntities)) 447 cout << "scene " << filename << " loaded" << endl; 455 */ 456 457 Matrix4x4 transl = TranslationMatrix(cubeCenter); 458 459 const string aeroplaneStr = model_path + "toyplane.dem"; 460 461 SceneEntityContainer dummy; 462 463 if (loader->Load(aeroplaneStr, dummy)) 464 cout << "successfully loaded " << dummy.size() << " scene entities" << endl; 448 465 else 449 466 { 450 cerr << "loading scene " << filename << " failed" << endl; 467 cerr << "loading file " << aeroplaneStr << " failed" << endl; 468 451 469 CleanUp(); 452 470 exit(0); 453 471 } 454 472 455 SceneEntityContainer dummy; 456 457 const string envname = string(model_path + "env.dem"); 458 459 if (loader->Load(envname, skyGeometry)) 460 cout << "sky box " << filename << " loaded" << endl; 461 else 462 { 463 cerr << "loading sky box " << filename << " failed" << endl; 464 CleanUp(); 465 exit(0); 466 } 467 468 const string bvh_filename = string(model_path + "city.bvh"); 469 BvhLoader bvhLoader; 470 bvh = bvhLoader.Load(bvh_filename, sceneEntities); 471 472 if (!bvh) 473 { 474 cerr << "loading bvh " << bvh_filename << " failed" << endl; 475 CleanUp(); 476 exit(0); 477 } 473 aeroplane = dummy[0]; 474 aeroplane->GetTransform()->MultMatrix(transl); 475 dummy.clear(); 476 478 477 479 478 // set far plane based on scene extent … … 488 487 SkyPreetham::Init(sCgContext); 489 488 489 490 string skyDomeStr(model_path + "sky.dem"); 491 492 if (loader->Load(skyDomeStr, dummy)) 493 cout << "successfully loaded " << dummy.size() << " scene entities" << endl; 494 else 495 { 496 cerr << "loading file " << skyDomeStr << " failed" << endl; 497 498 CleanUp(); 499 exit(0); 500 } 501 502 skyDome = dummy[0]; 503 504 const float turbitiy = 3.0f; 505 preetham = new SkyPreetham(turbitiy, skyDome); 490 506 491 507 // initialize the render traverser … … 628 644 void InitGLstate() 629 645 { 630 glClearColor( 0.4f, 0.4f, 0.4f, 1.0f);646 glClearColor(1.4f, 0.4f, 0.4f, 1.0f); 631 647 632 648 glPixelStorei(GL_UNPACK_ALIGNMENT, 1); … … 1087 1103 1088 1104 1089 1090 1105 /////////////// 1091 1106 //-- render sky … … 1095 1110 1096 1111 RenderSky(); 1097 1112 1113 //state.Reset(); glEnable(GL_TEXTURE_2D); 1114 aeroplane->Render(&state); 1115 1098 1116 1099 1117 if ((renderMethod == RENDER_DEFERRED) || 1100 1118 (renderMethod == RENDER_DEPTH_PASS_DEFERRED)) 1101 1119 { 1102 //glPopAttrib();1103 1120 FrameBufferObject::Release(); 1104 1121 … … 1954 1971 void RenderSky() 1955 1972 { 1956 //glEnable(GL_LIGHTING);1957 1973 cgGLEnableProfile(RenderState::sCgVertexProfile); 1958 1974 … … 1960 1976 state.SetRenderPassType(RenderState::DEFERRED); 1961 1977 1962 SceneEntityContainer::const_iterator sit, sit_end = skyGeometry.end();1963 1964 // for (sit = skyGeometry.begin(); sit != sit_end; ++ sit)1965 // (*sit)->Render(&state);1966 1967 //cube->Render(&state);1968 //aeroplane->Render(&state);1969 //glEnable(GL_LIGHTING);1970 1971 1978 preetham->RenderSkyDome(-light->GetDirection(), camera, &state); 1972 1979 1973 1980 cgGLDisableProfile(RenderState::sCgVertexProfile); 1974 1981 cgGLDisableProfile(RenderState::sCgFragmentProfile); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/common.h
r2913 r2961 163 163 // Clears a container (i.e., a vector of pointers) and deletes the pointers 164 164 #ifndef CLEAR_CONTAINER 165 #define CLEAR_CONTAINER(co) do { for (size_t _i = 0; _i < ( int)(co).size(); ++ _i) { \165 #define CLEAR_CONTAINER(co) do { for (size_t _i = 0; _i < (co).size(); ++ _i) { \ 166 166 DEL_PTR((co)[_i]);} \ 167 167 (co).clear(); } \
Note: See TracChangeset
for help on using the changeset viewer.