Changeset 2806 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Timestamp:
- 06/29/08 02:31:58 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.cpp
r2796 r2806 66 66 { 67 67 mNear = nearDist; 68 } 69 70 71 void Camera::SetFar(float farDist) 72 { 73 mFar = farDist; 68 74 } 69 75 … … 165 171 Vector3 &ntl, Vector3 &ntr, Vector3 &nbl, Vector3 &nbr) 166 172 { 167 float z_near = 0.1f;168 float z_far = 300;173 float z_near = mNear; 174 float z_far = mFar; 169 175 170 176 const float h_near = 2.0f * tan(mFovy / 2) * z_near; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.h
r2796 r2806 48 48 49 49 void CalcFrustum(Frustum &frustum); 50 50 /** Computes the extremal points of this frustum. 51 */ 51 52 void ComputePoints(Vector3 &ftl, Vector3 &ftr, Vector3 &fbl, Vector3 &fbr, 52 53 Vector3 &ntl, Vector3 &ntr, Vector3 &nbl, Vector3 &nbr); 53 54 55 /** Returns the near plane. 56 */ 54 57 inline float GetNear() const { return mNear; } 58 /** Returns the far plane. 59 */ 60 inline float GetFar() const { return mFar; } 61 /** Sets the near plane 62 */ 55 63 void SetNear(float nearDist); 64 /** Sets the far plane. 65 */ 66 void SetFar(float farDist); 56 67 57 inline float GetFar() const { return mFar; }58 59 void SetFar(float farDist) { mFar = farDist; }60 61 68 void SetOrtho(bool ortho); 62 69 … … 64 71 void Pitch(float angle); 65 72 73 float GetPitch() const { return mPitch; } 74 float GetYaw() const { return mYaw; } 75 66 76 67 77 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneQuery.h
r2800 r2806 21 21 SceneQuery(const AxisAlignedBox3 &sceneBox, RenderTraverser *traverser); 22 22 ~SceneQuery() { DEL_ARRAY_PTR(mDepth); } 23 24 /** Calculates intersection of vertical ray at position pt.x, pt.y and 25 stores the intersection point if valid. returns true if the intersection 26 is valid. 27 */ 23 28 bool CalcIntersection(Vector3 &pt); 29 24 30 25 31 protected: -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Visualization.cpp
r2796 r2806 64 64 65 65 /******************************************************/ 66 /* Vizualization implementation */66 /* Vizualization implementation */ 67 67 /******************************************************/ 68 68 … … 78 78 mFrameId(0) 79 79 { 80 mSphere = (GLUquadric *)gluNewQuadric();81 80 } 82 81 … … 84 83 Visualization::~Visualization() 85 84 { 86 //DEL_PTR(mSphere);87 85 } 88 86 … … 110 108 stack<BvhNode *> tStack; 111 109 tStack.push(mBvh->GetRoot()); 112 113 glDisable(GL_LIGHTING);114 115 RenderViewPoint();116 RenderFrustum();117 RenderBoxForViz(mBvh->GetBox());118 119 glEnable(GL_LIGHTING);120 110 121 111 glEnableClientState(GL_VERTEX_ARRAY); … … 147 137 } 148 138 } 149 //leaves.push_back(static_cast<BvhLeaf *>(node));150 139 } 151 140 } 152 141 153 mRenderState->Reset();154 155 142 glDisableClientState(GL_VERTEX_ARRAY); 156 143 glDisableClientState(GL_NORMAL_ARRAY); 157 } 158 159 160 void Visualization::RenderViewPoint() 161 { 162 glPushMatrix(); 163 Vector3 pos = mCamera->GetPosition(); 164 pos.z += 100; 165 glTranslatef(pos.x, pos.y, pos.z); 144 145 146 mRenderState->Reset(); 147 148 glPushAttrib(GL_CURRENT_BIT); 149 glDisable(GL_LIGHTING); 150 glDisable(GL_DEPTH_TEST); 151 152 RenderFrustum(); 153 //RenderBoxForViz(mBvh->GetBox()); 166 154 167 glScalef(5.0f, 5.0f, 5.0f);168 glPushAttrib(GL_CURRENT_BIT);169 170 glColor3f(1.0f, 0.0f, 0.0f);171 172 gluSphere((::GLUquadric *)mSphere,173 2e-3f * Magnitude(mBvh->GetBox().Size()), 6, 6);174 175 155 glPopAttrib(); 176 glPopMatrix();177 156 } 178 157 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Visualization.h
r2796 r2806 20 20 { 21 21 public: 22 22 /** Main constructor taking a bvh, a camera, a visualization camera and the current render state 23 as parameters 24 */ 23 25 Visualization(Bvh *bvh, Camera *camera, Camera *vizCamera, RenderState *renderState); 24 26 … … 49 51 */ 50 52 void RenderFrustum(); 51 /** Renders the current view point.52 */53 void RenderViewPoint();54 53 55 54 … … 67 66 /// the current frame id 68 67 int mFrameId; 69 70 GLUquadric *mSphere;71 68 }; 72 69 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r2803 r2806 163 163 camera = new Camera(winWidth, winHeight, fov); 164 164 camera->SetNear(nearDist); 165 165 166 166 visCamera = new Camera(winWidth, winHeight, fov); 167 167 168 visCamera->SetNear(0.0f); 168 169 visCamera->Yaw(.5 * M_PI); … … 233 234 } 234 235 236 camera->SetFar(0.7f * Magnitude(bvh->GetBox().Diagonal())); 237 235 238 bvh->SetCamera(camera); 236 239 237 240 ResetTraverser(); 238 241 239 //camera->SetDirection(Vector3(0.961829f, 0.273652f, 0.0f));240 242 camera->Pitch(-M_PI * 0.5); 241 243 camera->SetPosition(Vector3(483.398f, 242.364f, 186.078f)); … … 992 994 glColor4f(0.0,0.0,0.0,0.5); 993 995 994 glRecti(winWidth, 0, winWidth - winWidth / 4, winHeight / 3);996 glRecti(winWidth, 0, winWidth - winWidth / 3, winHeight / 3); 995 997 glDisable(GL_BLEND); 996 998 End2D(); … … 1002 1004 const float yoffs = box.Size().y * 0.5f; 1003 1005 1004 Vector3 vizpos = Vector3(box.Center().x, box.Center().y, box.Max().z); 1006 Vector3 pos = camera->GetPosition(); 1007 1008 Vector3 vizpos = Vector3(box.Min().x, box.Min().y + 700, box.Min().z + box.Size().z * 50); 1009 1005 1010 visCamera->SetPosition(vizpos); 1006 1011 1007 glViewport(winWidth - winWidth / 4, winHeight - winHeight / 3, winWidth / 4, winHeight / 3);1012 glViewport(winWidth - winWidth / 3, winHeight - winHeight / 3, winWidth / 3, winHeight / 3); 1008 1013 1009 1014 glMatrixMode(GL_PROJECTION); 1010 1015 glLoadIdentity(); 1011 1016 1012 glOrtho(-xoffs, xoffs, - yoffs, yoffs, 0.0f, box.Size().z);1017 glOrtho(-xoffs, xoffs, -xoffs, xoffs, 0.0f, box.Size().z * 100.0f); 1013 1018 1014 1019 glMatrixMode(GL_MODELVIEW); 1015 1020 1016 1021 visCamera->SetupCameraView(); 1017 1022 1023 Matrix4x4 rotZ = RotationZMatrix(-camera->GetPitch()); 1024 glMultMatrixf((float *)rotZ.x); 1025 1026 glTranslatef(-pos.x, -pos.y, -pos.z); 1027 1028 1018 1029 GLfloat position[] = {0.8f, 1.0f, 1.5f, 0.0f}; 1019 1030 glLightfv(GL_LIGHT0, GL_POSITION, position); … … 1024 1035 glClear(GL_DEPTH_BUFFER_BIT); 1025 1036 1037 1026 1038 //////////// 1027 1039 //-- visualization of the occlusion culling … … 1029 1041 visualization->Render(); 1030 1042 1043 // reset vp 1031 1044 glViewport(0, 0, winWidth, winHeight); 1032 1045 }
Note: See TracChangeset
for help on using the changeset viewer.