35 #include "documentmanager.h" |
35 #include "documentmanager.h" |
36 #include "grid.h" |
36 #include "grid.h" |
37 |
37 |
38 const QPen GLRenderer::thinBorderPen {QColor {0, 0, 0, 208}, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin}; |
38 const QPen GLRenderer::thinBorderPen {QColor {0, 0, 0, 208}, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin}; |
39 |
39 |
|
40 // Transformation matrices for the fixed cameras. |
|
41 const GLRotationMatrix GLRenderer::topCameraMatrix = GLRotationMatrix {}; |
|
42 const GLRotationMatrix GLRenderer::frontCameraMatrix = {{1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1}}; |
|
43 const GLRotationMatrix GLRenderer::leftCameraMatrix = {{0, -1, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, 0, 0, 1}}; |
|
44 const GLRotationMatrix GLRenderer::bottomCameraMatrix = {{1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1}}; |
|
45 const GLRotationMatrix GLRenderer::backCameraMatrix = {{-1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1}}; |
|
46 const GLRotationMatrix GLRenderer::rightCameraMatrix = {{0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1}}; |
|
47 |
|
48 // Conversion matrix from LDraw to OpenGL coordinates. |
|
49 const GLRotationMatrix GLRenderer::ldrawToGLAdapterMatrix = {{1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1}}; |
|
50 |
40 /* |
51 /* |
41 * Constructs a GL renderer. |
52 * Constructs a GL renderer. |
42 */ |
53 */ |
43 GLRenderer::GLRenderer(const Model* model, QWidget* parent) : |
54 GLRenderer::GLRenderer(const Model* model, QWidget* parent) : |
44 QGLWidget {parent}, |
55 QGLWidget {parent}, |
45 HierarchyElement {parent}, |
56 HierarchyElement {parent}, |
46 m_model {model}, |
57 m_model {model}, |
47 m_cameras { |
58 m_cameras { |
48 {"Top camera", {1, 0, 0, X, Z, false, false, false}}, // top |
59 {"Top camera", {topCameraMatrix, X, Z, false, false, false}}, // top |
49 {"Front camera", {0, 0, 1, X, Y, false, true, false}}, // front |
60 {"Front camera", {frontCameraMatrix, X, Y, false, true, false}}, // front |
50 {"Left camera", {0, 1, 0, Z, Y, true, true, false}}, // left |
61 {"Left camera", {leftCameraMatrix, Z, Y, true, true, false}}, // left |
51 {"Bottom camera", {-1, 0, 0, X, Z, false, true, true}}, // bottom |
62 {"Bottom camera", {bottomCameraMatrix, X, Z, false, true, true}}, // bottom |
52 {"Back camera", {0, 0, -1, X, Y, true, true, true}}, // back |
63 {"Back camera", {backCameraMatrix, X, Y, true, true, true}}, // back |
53 {"Right camera", {0, -1, 0, Z, Y, false, true, true}}, // right |
64 {"Right camera", {rightCameraMatrix, Z, Y, false, true, true}}, // right |
54 {"Free camera", GLCamera::FreeCamera}, // free |
65 {"Free camera", GLCamera::FreeCamera}, // free |
55 } |
66 } |
56 { |
67 { |
57 m_camera = (Camera) m_config->camera(); |
68 m_camera = (Camera) m_config->camera(); |
58 m_compiler = new GLCompiler (this); |
69 m_compiler = new GLCompiler (this); |