Changeset 2927
- Timestamp:
- 09/10/08 10:50:21 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.cpp
r2926 r2927 12 12 13 13 // our coordinate system has the positive z axis pointing up 14 static const Vector3 baseDir = Vector3::UNIT_Y();14 static Vector3 baseDir = Vector3(0, 1, 0); 15 15 16 16 … … 51 51 void Camera::Precompute(const Vector3 &direction) 52 52 { 53 Vector3 up = Vector3 ::UNIT_Z();54 Vector3 right = Normalize(CrossProd(up, -direction));55 up = Normalize(CrossProd( -direction, right));56 57 mBaseOrientation = Matrix4x4(right, up, -direction);53 Vector3 up = Vector3(0, 0, 1); 54 Vector3 right = Normalize(CrossProd(up, direction)); 55 up = Normalize(CrossProd(direction, right)); 56 57 mBaseOrientation = Matrix4x4(right, up, direction); 58 58 mViewOrientation = mBaseOrientation; 59 59 } … … 88 88 mat = mViewOrientation; 89 89 90 constVector3 pos = mViewOrientation * -mPosition;90 Vector3 pos = mViewOrientation * -mPosition; 91 91 92 92 mat.x[3][0] = pos.x; 93 93 mat.x[3][1] = pos.y; 94 mat.x[3][2] = -pos.z;94 mat.x[3][2] = pos.z; 95 95 96 96 //glGetFloatv(GL_MODELVIEW_MATRIX, (float *)mat.x); … … 129 129 Matrix4x4 viewOrientation = mViewOrientation; 130 130 131 constVector3 pos = mViewOrientation * -mPosition;131 Vector3 pos = mViewOrientation * -mPosition; 132 132 133 133 viewOrientation.x[3][0] = pos.x; 134 134 viewOrientation.x[3][1] = pos.y; 135 viewOrientation.x[3][2] = -pos.z;135 viewOrientation.x[3][2] = pos.z; 136 136 137 137 glLoadMatrixf((float *)viewOrientation.x); … … 220 220 void Camera::SetDirection(const Vector3 &dir) 221 221 { 222 Vector3 ndir = Normalize(dir);222 Vector3 ndir = -Normalize(dir); 223 223 224 224 mPitch = -atan2(ndir.x, ndir.y); … … 243 243 Vector3 Camera::GetDirection() const 244 244 { 245 return Vector3(mViewOrientation.x[0][2], mViewOrientation.x[1][2], mViewOrientation.x[2][2]);245 return -Vector3(mViewOrientation.x[0][2], mViewOrientation.x[1][2], mViewOrientation.x[2][2]); 246 246 } 247 247 … … 261 261 Vector3 Camera::GetBaseDirection() const 262 262 { 263 return Vector3(mBaseOrientation.x[0][2], mBaseOrientation.x[1][2], mBaseOrientation.x[2][2]);263 return -Vector3(mBaseOrientation.x[0][2], mBaseOrientation.x[1][2], mBaseOrientation.x[2][2]); 264 264 } 265 265 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r2925 r2927 70 70 int renderMode = RenderTraverser::CHCPLUSPLUS; 71 71 // eye near plane distance 72 float nearDist = 2.0f; 72 float nearDist = 0.1f; 73 float farDist = 1e6f; 73 74 /// the field of view 74 75 float fov = 50.0f; … … 104 105 double accumulatedTime = 1000; 105 106 float fps = 1e3f; 106 107 float myfar = 0;108 107 109 108 glfont::GLFont myfont; … … 428 427 429 428 // set far plane based on scene extent 430 myfar= 10.0f * Magnitude(bvh->GetBox().Diagonal());429 farDist = 10.0f * Magnitude(bvh->GetBox().Diagonal()); 431 430 bvh->SetVirtualLeaves(trianglesPerVirtualLeaf); 432 431 … … 512 511 Material::sAmbientTexParam = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "ambient"); 513 512 514 cgGLSetParameter1f(sMaxDepthParamTex, MAX_DEPTH_CONST / myfar);513 cgGLSetParameter1f(sMaxDepthParamTex, MAX_DEPTH_CONST / farDist); 515 514 //Debug << "maxdepth: " << MAX_DEPTH_CONST / myfar << endl; 516 515 } … … 534 533 Material::sAmbientParam = cgGetNamedParameter(RenderState::sCgMrtFragmentProgram, "ambient"); 535 534 536 cgGLSetParameter1f(sMaxDepthParam, MAX_DEPTH_CONST / myfar);535 cgGLSetParameter1f(sMaxDepthParam, MAX_DEPTH_CONST / farDist); 537 536 } 538 537 else … … 791 790 glLoadIdentity(); 792 791 793 gluPerspective(fov, winAspectRatio, nearDist, myfar);792 gluPerspective(fov, winAspectRatio, nearDist, farDist); 794 793 795 794 glMatrixMode(GL_MODELVIEW); … … 1025 1024 cgGLDisableProfile(RenderState::sCgFragmentProfile); 1026 1025 1027 if (!ssaoShader) ssaoShader = new DeferredRenderer(texWidth, texHeight, camera, myfar/ MAX_DEPTH_CONST);1026 if (!ssaoShader) ssaoShader = new DeferredRenderer(texWidth, texHeight, camera, farDist / MAX_DEPTH_CONST); 1028 1027 1029 1028 DeferredRenderer::SHADING_METHOD shadingMethod; … … 1373 1372 glLoadIdentity(); 1374 1373 1375 gluPerspective(fov, winAspectRatio, nearDist, myfar);1374 gluPerspective(fov, winAspectRatio, nearDist, farDist); 1376 1375 1377 1376 glMatrixMode(GL_MODELVIEW);
Note: See TracChangeset
for help on using the changeset viewer.