- Timestamp:
- 06/22/08 09:23:45 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneQuery.cpp
r2782 r2796 18 18 19 19 const static int viewport[4] = {0, 0, 512, 512}; 20 // static DepthComponent<float> *sDepth = NULL;20 //const static int viewport[4] = {0, 0, 1024, 768}; 21 21 22 22 23 23 24 24 SceneQuery::SceneQuery(const AxisAlignedBox3 &sceneBox, RenderTraverser *renderer): 25 mSceneBox(sceneBox) 25 mSceneBox(sceneBox), mDepth(NULL) 26 26 { 27 27 Prepare(renderer); … … 32 32 { 33 33 int px = (pt.x - mSceneBox.Min(0)) * (viewport[2] - 1) / mSceneBox.Size(0); 34 int py = (pt.y - mSceneBox.Min( 2)) * (viewport[3] - 1) / mSceneBox.Size(2);34 int py = (pt.y - mSceneBox.Min(1)) * (viewport[3] - 1) / mSceneBox.Size(1); 35 35 36 const float d = 1.0f;// - sDepth->getPixel(px, py);36 const float d = mDepth[px + py * viewport[1]]; 37 37 38 38 if (d > 0.0f) 39 39 { 40 pt.z = mSceneBox.Size(2) * d + mSceneBox.Min(2);40 pt.z = mSceneBox.Min().z + mSceneBox.Size().z * d; 41 41 cout << "new depth " << pt.z << " (" << d << ")" << endl; 42 42 … … 52 52 cout << "Preparing scene queries" << endl; 53 53 54 // center camera on "highest" point 55 Vector3 pos; 56 57 pos.x = mSceneBox.Center(0); 58 pos.y = mSceneBox.Max(1); 59 pos.z = mSceneBox.Center(2); 60 61 // for ortho cam this is the width 62 const Vector3 len = mSceneBox.Size(); 63 64 Camera *orthoCam = new Camera(len.x, len.y); 65 //orthoCam->SetOrtho(true); 54 const float xlen = mSceneBox.Size().x * 0.5f; 55 const float ylen = mSceneBox.Size().y * 0.5f; 56 57 Camera *orthoCam = new Camera(xlen, ylen); 58 orthoCam->SetOrtho(true); 66 59 67 60 orthoCam->SetNear(0.0f); 68 //orthoCam->SetFar(len.z);61 orthoCam->Yaw(M_PI * 0.5f); 69 62 63 Vector3 pos = Vector3(mSceneBox.Center().x, mSceneBox.Center().y, mSceneBox.Max().z); 70 64 orthoCam->SetPosition(pos); 71 65 72 cout << "fov: " << orthoCam->GetFov() << endl; 73 cout << "near: " << orthoCam->GetNear() << endl; 74 //cout << "far: " << orthoCam->GetFar() << endl; 75 cout << "aspect: " << orthoCam->GetAspect() << endl; 66 glPixelStorei(GL_PACK_ROW_LENGTH, viewport[2]); 76 67 77 cout << "pos: " << orthoCam->GetPosition() << endl; 78 cout << "view: " << orthoCam->GetDirection() << endl; 79 cout << "up: " << orthoCam->GetUpVector() << endl; 68 // hack: should create offscreen buffer for this 69 glViewport(0, 0, viewport[2], viewport[3]); 80 70 81 //orthoCam->SetDirection(Vector3(0, 1, 0));82 //orthoCam->Yaw(M_PI * 0.5f);71 glMatrixMode(GL_PROJECTION); 72 glLoadIdentity(); 83 73 84 renderer->SetCamera(orthoCam); 74 glOrtho(-xlen, xlen, -ylen, ylen, 0.0f, mSceneBox.Size().z); 75 76 glMatrixMode(GL_MODELVIEW); 77 78 orthoCam->SetupCameraView(); 85 79 86 //OffscreenRenderArea *of = new OffscreenRenderArea(); 87 //of->Init(viewport[2], viewport[3]); 80 glClear(GL_DEPTH_BUFFER_BIT); 81 82 mDepth = new float[viewport[2] * viewport[3]]; 83 84 //renderer->SetCamera(orthoCam); 88 85 89 86 renderer->RenderScene(); 90 //sDepth = of->GetDepthFloat();91 87 92 delete orthoCam; 88 glReadPixels(0, 0, viewport[2], viewport[3], GL_DEPTH_COMPONENT, GL_FLOAT, mDepth); 89 90 DEL_PTR(orthoCam); 93 91 } 94 92
Note: See TracChangeset
for help on using the changeset viewer.