- Timestamp:
- 11/05/08 18:49:31 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/ObjConverter.cpp
r3089 r3102 368 368 ambient.x = ambient.y = ambient.z = 0.2f; 369 369 diffuse.x = diffuse.y = diffuse.z = 1.0f; 370 black.x = black.y = black.z= .0f;370 black.x = black.y = black.z = .0f; 371 371 372 372 // only write rgb part of the material -
GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj
r3071 r3102 228 228 </File> 229 229 <File 230 RelativePath=".\src\RenderTraverser.cpp"231 >232 <FileConfiguration233 Name="Debug|Win32"234 >235 <Tool236 Name="VCCLCompilerTool"237 ObjectFile="$(IntDir)\$(InputName)1.obj"238 XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"239 />240 </FileConfiguration>241 <FileConfiguration242 Name="Release|Win32"243 >244 <Tool245 Name="VCCLCompilerTool"246 ObjectFile="$(IntDir)\$(InputName)1.obj"247 XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"248 />249 </FileConfiguration>250 </File>251 <File252 230 RelativePath=".\src\SampleGenerator.cpp" 253 231 > … … 325 303 </File> 326 304 <File 327 RelativePath=".\src\CHCTraverser.cpp"328 >329 <FileConfiguration330 Name="Debug|Win32"331 >332 <Tool333 Name="VCCLCompilerTool"334 ObjectFile="$(IntDir)\$(InputName)1.obj"335 XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"336 />337 </FileConfiguration>338 <FileConfiguration339 Name="Release|Win32"340 >341 <Tool342 Name="VCCLCompilerTool"343 ObjectFile="$(IntDir)\$(InputName)1.obj"344 XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"345 />346 </FileConfiguration>347 </File>348 <File349 305 RelativePath=".\src\CHCTraverser.h" 350 306 > … … 389 345 </File> 390 346 <File 347 RelativePath=".\src\CHCTraverser.cpp" 348 > 349 <FileConfiguration 350 Name="Debug|Win32" 351 > 352 <Tool 353 Name="VCCLCompilerTool" 354 ObjectFile="$(IntDir)\$(InputName)1.obj" 355 XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" 356 /> 357 </FileConfiguration> 358 <FileConfiguration 359 Name="Release|Win32" 360 > 361 <Tool 362 Name="VCCLCompilerTool" 363 ObjectFile="$(IntDir)\$(InputName)1.obj" 364 XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" 365 /> 366 </FileConfiguration> 367 </File> 368 <File 391 369 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" 392 392 > 393 393 <FileConfiguration -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.h
r3074 r3102 528 528 */ 529 529 inline BvhNode *GetRoot(); 530 530 /** Returns the static root node of the bvh. 531 */ 532 inline BvhNode *GetStaticRoot(); 533 /** Returns the dynamic root node of the bvh. 534 */ 531 535 inline BvhNode *GetDynamicRoot(); 532 536 /** Returns the bounding box of this bvh. … … 850 854 851 855 856 BvhNode *Bvh::GetStaticRoot() 857 { 858 return mStaticRoot; 859 } 860 861 852 862 const AxisAlignedBox3 &Bvh::GetBox() const 853 863 { -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.cpp
r3063 r3102 276 276 void Camera::GetProjectionMatrix(Matrix4x4 &m)const 277 277 { 278 //glGetFloatv(GL_PROJECTION_MATRIX, (float *)m.x); 278 279 m = mProjection; 279 280 } 280 281 281 282 282 /*********************************************************/ 283 /* Class PerspectiveCamera implementation */ 283 284 /*********************************************************/ 285 /* Class PerspectiveCamera implementation */ 284 286 /*********************************************************/ 285 287 … … 385 387 386 388 389 void PerspectiveCamera::UpdateProjectionMatrix() 390 { 391 mProjection = GetPerspective(mFOVy, 1.0f / mAspect, mNear, mFar); 392 } 393 394 395 387 396 void PerspectiveCamera::ComputePoints(Vector3 &ftl, Vector3 &ftr, Vector3 &fbl, Vector3 &fbr, 388 397 Vector3 &ntl, Vector3 &ntr, Vector3 &nbl, Vector3 &nbr, … … 397 406 398 407 399 void PerspectiveCamera::UpdateProjectionMatrix() 400 { 401 mProjection = GetPerspective(mFOVy, 1.0f / mAspect, mNear, mFar); 402 } 403 404 405 } 408 409 /*********************************************************/ 410 /* Class OrthoCamera implementation */ 411 /*********************************************************/ 412 413 414 OrthoCamera::OrthoCamera(): 415 mLeft(0), mRight(1), mBottom(0), mTop(1) 416 { 417 mNear = 0; mFar = 1; 418 UpdateProjectionMatrix(); 419 } 420 421 422 OrthoCamera::OrthoCamera(float l, float r, float b, float t): 423 mLeft(l), mRight(r), mBottom(b), mTop(t) 424 { 425 mNear = 0; mFar = 1; 426 UpdateProjectionMatrix(); 427 } 428 429 430 OrthoCamera::OrthoCamera(float l, float r, float b, float t, float n, float f): 431 mLeft(l), mRight(r), mBottom(b), mTop(t) 432 { 433 mNear = n; mFar = f; 434 UpdateProjectionMatrix(); 435 } 436 437 438 void OrthoCamera::UpdateProjectionMatrix() 439 { 440 mProjection = GetOrtho(mLeft, mRight, mBottom, mTop, mNear, mFar); 441 } 442 443 444 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.h
r3063 r3102 195 195 }; 196 196 197 197 /** Classs representing an orthographics camera. 198 */ 199 class OrthoCamera: public Camera 200 { 201 friend class ShadowMap; 202 203 public: 204 /** Default constructor. 205 */ 206 OrthoCamera(); 207 /** Camera taking the frustum left, right, bottom, top. 208 */ 209 OrthoCamera(float l, float r, float b, float t); 210 211 /** Camera taking the frustum left, right, bottom, top, near, far. 212 */ 213 OrthoCamera(float l, float r, float b, float t, float n, float f); 214 215 216 protected: 217 /** Calculates the current projection matrix. 218 */ 219 virtual void UpdateProjectionMatrix(); 220 221 222 ////////// 223 //-- members 224 225 float mLeft; 226 float mRight; 227 float mBottom; 228 float mTop; 229 }; 198 230 } 199 231 #endif -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Matrix4x4.cpp
r3078 r3102 751 751 752 752 753 /** The resulti g matrix thatis equal to the result of glOrtho753 /** The resulting matrix is equal to the result of glOrtho 754 754 */ 755 Matrix4x4 GetOrtho(float left, float right, float bottom, float top, float far, float near)755 Matrix4x4 GetOrtho(float left, float right, float bottom, float top, float near, float far) 756 756 { 757 757 Matrix4x4 m; … … 778 778 m.x[3][0] = (right + left) * xDif; 779 779 m.x[3][1] = (top + bottom) * yDif; 780 m.x[3][2] = (far + near) * zDif;780 m.x[3][2] = (far + near) * zDif; 781 781 m.x[3][3] = 1.0f; 782 782 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Matrix4x4.h
r3062 r3102 165 165 Matrix4x4 GetFrustum(float left, float right, float bottom, float top, float near, float far); 166 166 Matrix4x4 LookAt(const Vector3 &pos, const Vector3 &dir, const Vector3& up); 167 Matrix4x4 GetOrtho(float fov, float aspect, float near, float far);167 Matrix4x4 GetOrtho(float left, float right, float bottom, float top, float near, float far); 168 168 Matrix4x4 GetPerspective(float fov, float aspect, float near, float far); 169 169 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.cpp
r3074 r3102 52 52 mShowBounds(false), 53 53 mRenderQueue(NULL), 54 mMaxVisibleDistance(.0f) 54 mMaxVisibleDistance(.0f), 55 mRenderDynamicObjects(true) 55 56 { 56 57 } … … 156 157 157 158 // add root node to queue 158 EnqueueNode(mBvh->GetRoot()); 159 if (mRenderDynamicObjects) 160 EnqueueNode(mBvh->GetRoot()); 161 else 162 EnqueueNode(mBvh->GetStaticRoot()); 163 159 164 160 165 … … 278 283 279 284 280 } 285 void RenderTraverser::SetRenderDynamicObjects(bool dynamic) 286 { 287 mRenderDynamicObjects = dynamic; 288 } 289 290 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.h
r3065 r3102 137 137 */ 138 138 float GetMaxVisibleDistance() const { return mMaxVisibleDistance; } 139 /** Render also dynamic objects. 140 */ 141 void SetRenderDynamicObjects(bool dynamic); 139 142 140 143 … … 210 213 211 214 bool mUseDepthPass; 215 216 bool mRenderDynamicObjects; 212 217 }; 213 218 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.cpp
r3101 r3102 44 44 for (int i = 0; i < l; ++ i) 45 45 { 46 if (mLODLevels[i].GetSquaredDistance() > dist) 47 break; 48 46 if (mLODLevels[i].GetSquaredDistance() > dist) break; 49 47 mCurrentLODLevel = i; 50 48 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.h
r3085 r3102 96 96 static void SetUseLODs(bool useLODs) { sUseLODs = useLODs; } 97 97 98 static bool GetUseLODs() { return sUseLODs; } 99 100 98 101 99 102 protected: -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneQuery.cpp
r3101 r3102 7 7 #include "FrameBufferObject.h" 8 8 #include "RenderState.h" 9 #include "SceneEntity.h" 10 9 11 10 12 #include <IL/il.h> … … 140 142 const float ylen = mSceneBox.Size().y * .5f; 141 143 142 PerspectiveCamera *orthoCam = new PerspectiveCamera(xlen / ylen);143 //orthoCam->SetOrtho(true);144 145 orthoCam->SetNear(0.0f);146 orthoCam->Yaw(.5 * M_PI);147 orthoCam->SetDirection(Vector3(0, 0, -1));148 149 144 Vector3 pos = Vector3(mSceneBox.Center().x, mSceneBox.Center().y, mSceneBox.Max().z); 150 orthoCam->SetPosition(pos);151 145 152 146 FrameBufferObject *fbo = new FrameBufferObject(texWidth, texHeight, FrameBufferObject::DEPTH_32, true); … … 166 160 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 167 161 168 // hack: disable cull face because of alpha textured balconies169 glDisable(GL_CULL_FACE);170 mRenderState->LockCullFaceEnabled(true);171 172 //glDisable(GL_CULL_FACE);173 //glEnable(GL_DEPTH_TEST);174 175 162 glMatrixMode(GL_MODELVIEW); 176 163 glPushMatrix(); 177 glLoadIdentity();164 //glLoadIdentity(); 178 165 179 166 glMatrixMode(GL_PROJECTION); 180 167 glPushMatrix(); 181 glLoadIdentity(); 182 183 glOrtho(xlen, -xlen, ylen, -ylen, 0.0f, mSceneBox.Size().z); 184 //glOrtho(xlen, .0f, ylen, .0f, .0f, mSceneBox.Size().z); 185 186 glMatrixMode(GL_MODELVIEW); 187 188 orthoCam->SetupCameraView(); 168 //glLoadIdentity(); 169 170 OrthoCamera *orthoCam = new OrthoCamera(xlen, -xlen, ylen, -ylen, .0f, mSceneBox.Size().z); 171 172 orthoCam->Yaw(.5 * M_PI); 173 orthoCam->SetDirection(Vector3(0, 0, -1)); 174 orthoCam->SetPosition(pos); 175 176 orthoCam->SetupViewProjection(); 177 178 //glOrtho(xlen, -xlen, ylen, -ylen, 0.0f, mSceneBox.Size().z); 179 //glMatrixMode(GL_MODELVIEW); 180 //orthoCam->SetupCameraView(); 189 181 190 182 mDepth = new float[texHeight * texWidth]; … … 196 188 glEnableClientState(GL_NORMAL_ARRAY); 197 189 190 // hack: use highest lod level for trees (billboards) 191 LODLevel::InitFrame(Vector3(1e6f)); 192 198 193 // forward rendering 199 194 mRenderState->SetRenderTechnique(0); 195 // temporarilly switch off 196 renderer->SetRenderDynamicObjects(false); 200 197 201 198 renderer->RenderScene(); … … 205 202 206 203 renderer->SetCamera(oldCam); 207 208 mRenderState->LockCullFaceEnabled(false); 209 //glEnable(GL_CULL_FACE); 204 // temporarilly switch off 205 renderer->SetRenderDynamicObjects(true); 210 206 211 207 glMatrixMode(GL_MODELVIEW); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r3101 r3102 458 458 //-- load some dynamic stuff 459 459 460 LoadModel("hbuddha.dem", dynamicObjects);460 /*LoadModel("hbuddha.dem", dynamicObjects); 461 461 //LoadModel("hbuddha2.dem", dynamicObjects); 462 462 buddha = dynamicObjects.back(); … … 484 484 } 485 485 486 */ 486 487 487 488 /////////// … … 883 884 884 885 Matrix4x4 mat = TranslationMatrix(planepos); 885 buddha->GetTransform()->SetMatrix(mat);886 //buddha->GetTransform()->SetMatrix(mat); 886 887 887 888 Vector3 oldPos = camera->GetPosition(); … … 1987 1988 shadowMap->ComputeShadowMap(shadowTraverser, viewProjMat); 1988 1989 1989 glEnable(GL_CULL_FACE);1990 1990 camera->SetFar(farDist); 1991 1991 1992 1992 renderState.SetUseAlphaToCoverage(true); 1993 1993 renderState.LockCullFaceEnabled(false); 1994 glEnable(GL_CULL_FACE); 1994 1995 1995 1996 glEnableClientState(GL_NORMAL_ARRAY);
Note: See TracChangeset
for help on using the changeset viewer.