src/glcamera.cpp

changeset 1404
16eb4257e662
parent 1326
69a90bd2dba2
child 1437
1a77c6156db7
equal deleted inserted replaced
1403:7a2d84112983 1404:16eb4257e662
234 const QString& GLCamera::name() const 234 const QString& GLCamera::name() const
235 { 235 {
236 return m_name; 236 return m_name;
237 } 237 }
238 238
239 const GLRotationMatrix& GLCamera::transformationMatrix() const 239 const QMatrix4x4& GLCamera::transformationMatrix() const
240 { 240 {
241 return m_rotationMatrix; 241 return m_rotationMatrix;
242 } 242 }
243 243
244 /* 244 /*
245 * Returns the camera's transformation matrix, scaled by the given scale value. 245 * Returns the camera's transformation matrix, scaled by the given scale value.
246 */ 246 */
247 GLRotationMatrix GLCamera::transformationMatrix(double scale) const 247 QMatrix4x4 GLCamera::transformationMatrix(double scale) const
248 { 248 {
249 GLRotationMatrix matrix = m_rotationMatrix; 249 QMatrix4x4 matrix = m_rotationMatrix;
250 250
251 for (int i = 0; i < 4; ++i) 251 for (int i = 0; i < 4; ++i)
252 for (int j = 0; j < 4; ++j) 252 for (int j = 0; j < 4; ++j)
253 matrix(i, j) *= scale; 253 matrix(i, j) *= scale;
254 254
255 return matrix; 255 return matrix;
256 } 256 }
257 257
258 static const GLRotationMatrix ldrawToIdealAdapterMatrix = {1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1}; 258 static const QMatrix4x4 ldrawToIdealAdapterMatrix = {1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1};
259 259
260 /* 260 /*
261 * Converts from rea co-ordinates to ideal co-ordinates. 261 * Converts from rea co-ordinates to ideal co-ordinates.
262 * In ideal co-ordinates, X and Y axes correspond to the 2D X and Y as seen in the camera, and +Z is "outwards" from the screen. 262 * In ideal co-ordinates, X and Y axes correspond to the 2D X and Y as seen in the camera, and +Z is "outwards" from the screen.
263 */ 263 */
273 { 273 {
274 // The adapter matrix would be inverted here, but it is its own inverse so let's not bother. 274 // The adapter matrix would be inverted here, but it is its own inverse so let's not bother.
275 return idealCoordinates.transformed(ldrawToIdealAdapterMatrix).transformed(m_rotationMatrix.inverted()); 275 return idealCoordinates.transformed(ldrawToIdealAdapterMatrix).transformed(m_rotationMatrix.inverted());
276 } 276 }
277 277
278 GLRotationMatrix GLCamera::realMatrix() const 278 QMatrix4x4 GLCamera::realMatrix() const
279 { 279 {
280 /* glOrtho(-virtualSize.width(), virtualSize.width(), 280 /* glOrtho(-virtualSize.width(), virtualSize.width(),
281 -virtualSize.height(), virtualSize.height(), 281 -virtualSize.height(), virtualSize.height(),
282 -1000.0f, 1000.0f); */ 282 -1000.0f, 1000.0f); */
283 GLRotationMatrix ortho { 283 QMatrix4x4 ortho {
284 1 / float(m_virtualSize.width()), 0, 0, 0, 284 1 / float(m_virtualSize.width()), 0, 0, 0,
285 0, 1 / float(m_virtualSize.height()), 0, 0, 285 0, 1 / float(m_virtualSize.height()), 0, 0,
286 0, 0, -0.0001, 0, 286 0, 0, -0.0001, 0,
287 0, 0, 0, 1 287 0, 0, 0, 1
288 }; 288 };
289 289
290 GLRotationMatrix panningMatrix { 290 QMatrix4x4 panningMatrix {
291 1, 0, 0, float(m_panningX), 291 1, 0, 0, float(m_panningX),
292 0, 1, 0, float(m_panningY), 292 0, 1, 0, float(m_panningY),
293 0, 0, 1, 0, 293 0, 0, 1, 0,
294 0, 0, 0, 1 294 0, 0, 0, 1
295 }; 295 };

mercurial