Changeset 2762 for GTP/trunk/App/Demos/Vis/CHC_revisited/Camera.cpp
- Timestamp:
- 06/15/08 23:35:07 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/CHC_revisited/Camera.cpp
r2760 r2762 65 65 void Camera::LookAtBox(const AxisAlignedBox3 &box) 66 66 { 67 mDirection = box.Min() - box.Max();68 mPosition = box.Max() - mDirection;67 mDirection = Vector3(0, 0, box.Min().z - box.Max().z); 68 mPosition = Vector3(0);//box.Max() - mDirection; 69 69 70 70 Precompute(); … … 92 92 GetProjectionMatrix(matProjectionView); 93 93 94 matProjectionView *= matViewing;95 96 float fInvLength;94 matProjectionView = matViewing * matProjectionView; 95 //matProjectionView = matProjectionView * matViewing; 96 97 97 float planes[6][4]; 98 98 99 99 100 ////////// … … 118 119 // the clipping planes look outward the frustum, 119 120 // so distances > 0 mean that a point is outside 120 fInvLength = -1.0f / sqrt(planes[i][0] * planes[i][0] + 121 planes[i][1] * planes[i][1] + 122 planes[i][2] * planes[i][2]); 121 float fInvLength = -1.0f / 122 sqrt(planes[i][0] * planes[i][0] + 123 planes[i][1] * planes[i][1] + 124 planes[i][2] * planes[i][2]); 123 125 124 126 planes[i][0] *= fInvLength; … … 127 129 planes[i][3] *= fInvLength; 128 130 129 Vector3 normal(planes[i][0], planes[i][1], planes[i][2]);130 frustum.mClipPlanes[i] = Plane3(normal, planes[i][3]);131 frustum.mClipPlanes[i].mNormal = Vector3(planes[i][0], planes[i][1], planes[i][2]); 132 frustum.mClipPlanes[i].mD = planes[i][3]; 131 133 } 132 134 } … … 156 158 157 159 158 } 159 160 161 void Camera::ComputePoints(Vector3 &ftl, Vector3 &ftr, Vector3 &fbl, Vector3 &fbr, 162 Vector3 &ntl, Vector3 &ntr, Vector3 &nbl, Vector3 &nbr) 163 { 164 float z_near = 0.1f; 165 float z_far = 300; 166 167 const float h_near = 2.0f * tan(mFovy / 2) * z_near; 168 const float w_near = h_near * GetAspect(); 169 const float h_far = 2.0f * tan(mFovy / 2) * z_far; 170 const float w_far = h_far * GetAspect(); 171 172 const Vector3 view = mDirection; 173 const Vector3 fc = mPosition + view * z_far; 174 175 const Vector3 up = mUp; 176 177 const Vector3 right = mRight; 178 179 Vector3 t1, t2; 180 181 t1 = h_far * 0.5f * up; 182 t2 = w_far * 0.5f * right; 183 184 ftl = fc + t1 - t2; 185 ftr = fc + t1 + t2; 186 fbl = fc - t1 - t2; 187 fbr = fc - t1 + t2; 188 189 const Vector3 nc = mPosition + mDirection * z_near; 190 191 t1 = h_near * 0.5f * up; 192 t2 = w_near * 0.5f * right; 193 194 ntl = nc + t1 - t2; 195 ntr = nc + t1 + t2; 196 nbl = nc - t1 - t2; 197 nbr = nc - t1 + t2; 198 } 199 200 201 } 202
Note: See TracChangeset
for help on using the changeset viewer.