Wed, 08 May 2013 14:57:48 +0300
Viewport no longer offsets stuff based on bbox size, that was stupid. Only use bbox size for initial zoom.
30
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
1 | /* |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
104 | 3 | * Copyright (C) 2013 Santeri Piippo |
30
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
4 | * |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
8 | * (at your option) any later version. |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
9 | * |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
13 | * GNU General Public License for more details. |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
14 | * |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
17 | */ |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
18 | |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | #include <QtGui> |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | #include <QGLWidget> |
46
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
21 | #include <GL/glu.h> |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | #include "common.h" |
69
6790dea720a8
Simplified configuration code. Use a std::vector object to contain config pointers and have config objects register themselves upon creation instead of relying on a cfgdefs.h. Removed sections, all configurations are just simply written one after another now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
68
diff
changeset
|
23 | #include "config.h" |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | #include "file.h" |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | #include "gldraw.h" |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | #include "bbox.h" |
52
d71226763607
Colorized polygons now appear colorized in the list view (unless disabled). GL rendered now draws transparent polygons properly.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
47
diff
changeset
|
27 | #include "colors.h" |
104 | 28 | #include "gui.h" |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
29 | #include "misc.h" |
163
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
30 | #include "history.h" |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | |
147
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
32 | static double g_objOffset[3]; |
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
33 | |
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
34 | static short g_pulseTick = 0; |
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
35 | static const short g_numPulseTicks = 8; |
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
36 | static const short g_pulseInterval = 65; |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
37 | |
147
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
38 | static const struct staticCameraMeta { |
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
39 | const char glrotate[3]; |
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
40 | const Axis axisX, axisY; |
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
41 | const bool negX, negY; |
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
42 | } g_staticCameras[6] = { |
149
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
43 | { { 1, 0, 0 }, X, Z, false, false }, |
147
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
44 | { { 0, 0, 0 }, X, Y, false, true }, |
149
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
45 | { { 0, 1, 0 }, Z, Y, true, true }, |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
46 | { { -1, 0, 0 }, X, Z, false, true }, |
147
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
47 | { { 0, 0, 0 }, X, Y, true, true }, |
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
48 | { { 0, -1, 0 }, Z, Y, false, true }, |
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
49 | }; |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
50 | |
69
6790dea720a8
Simplified configuration code. Use a std::vector object to contain config pointers and have config objects register themselves upon creation instead of relying on a cfgdefs.h. Removed sections, all configurations are just simply written one after another now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
68
diff
changeset
|
51 | cfg (str, gl_bgcolor, "#CCCCD9"); |
6790dea720a8
Simplified configuration code. Use a std::vector object to contain config pointers and have config objects register themselves upon creation instead of relying on a cfgdefs.h. Removed sections, all configurations are just simply written one after another now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
68
diff
changeset
|
52 | cfg (str, gl_maincolor, "#707078"); |
6790dea720a8
Simplified configuration code. Use a std::vector object to contain config pointers and have config objects register themselves upon creation instead of relying on a cfgdefs.h. Removed sections, all configurations are just simply written one after another now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
68
diff
changeset
|
53 | cfg (float, gl_maincolor_alpha, 1.0); |
6790dea720a8
Simplified configuration code. Use a std::vector object to contain config pointers and have config objects register themselves upon creation instead of relying on a cfgdefs.h. Removed sections, all configurations are just simply written one after another now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
68
diff
changeset
|
54 | cfg (int, gl_linethickness, 2); |
6790dea720a8
Simplified configuration code. Use a std::vector object to contain config pointers and have config objects register themselves upon creation instead of relying on a cfgdefs.h. Removed sections, all configurations are just simply written one after another now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
68
diff
changeset
|
55 | cfg (bool, gl_colorbfc, true); |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
56 | cfg (bool, gl_selflash, false); |
152
552e46650a95
Camera is now stored to configuration so it is preserved across program shutdown. I don't know how significant this is but eh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
151
diff
changeset
|
57 | cfg (int, gl_camera, GLRenderer::Free); |
156
d35b7e440585
Added axes rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
155
diff
changeset
|
58 | cfg (bool, gl_blackedges, true); |
d35b7e440585
Added axes rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
155
diff
changeset
|
59 | cfg (bool, gl_axes, false); |
69
6790dea720a8
Simplified configuration code. Use a std::vector object to contain config pointers and have config objects register themselves upon creation instead of relying on a cfgdefs.h. Removed sections, all configurations are just simply written one after another now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
68
diff
changeset
|
60 | |
153
03a7bdcce50d
Adding objects now actually updates the bounding box like it should be.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
152
diff
changeset
|
61 | // CameraIcon::img is a heap-allocated QPixmap because otherwise it gets |
03a7bdcce50d
Adding objects now actually updates the bounding box like it should be.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
152
diff
changeset
|
62 | // initialized before program gets to main() and constructs a QApplication |
03a7bdcce50d
Adding objects now actually updates the bounding box like it should be.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
152
diff
changeset
|
63 | // and Qt doesn't like that. |
148
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
64 | struct CameraIcon { |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
65 | QPixmap* img; |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
66 | QRect srcRect, destRect, selRect; |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
67 | GLRenderer::Camera cam; |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
68 | } g_CameraIcons[7]; |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
69 | |
149
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
70 | const char* g_CameraNames[7] = { "Top", "Front", "Left", "Bottom", "Back", "Right", "Free" }; |
148
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
71 | |
149
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
72 | const GLRenderer::Camera g_Cameras[7] = { |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
73 | GLRenderer::Top, |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
74 | GLRenderer::Front, |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
75 | GLRenderer::Left, |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
76 | GLRenderer::Bottom, |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
77 | GLRenderer::Back, |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
78 | GLRenderer::Right, |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
79 | GLRenderer::Free |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
80 | }; |
163
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
81 | |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
82 | const struct GLAxis { |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
83 | const QColor col; |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
84 | const vertex vert; |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
85 | } g_GLAxes[3] = { |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
86 | { QColor (255, 0, 0), vertex (10000, 0, 0) }, |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
87 | { QColor (128, 192, 0), vertex (0, 10000, 0) }, |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
88 | { QColor (0, 160, 192), vertex (0, 0, 10000) }, |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
89 | }; |
149
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
90 | |
131
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
91 | // ============================================================================= |
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
92 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
93 | // ============================================================================= |
132
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
94 | GLRenderer::GLRenderer (QWidget* parent) : QGLWidget (parent) { |
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
95 | resetAngles (); |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
96 | m_picking = m_rangepick = false; |
152
552e46650a95
Camera is now stored to configuration so it is preserved across program shutdown. I don't know how significant this is but eh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
151
diff
changeset
|
97 | m_camera = (GLRenderer::Camera) gl_camera.value; |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
98 | m_drawToolTip = false; |
162
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
99 | m_planeDraw = false; |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
100 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
101 | m_pulseTimer = new QTimer (this); |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
102 | connect (m_pulseTimer, SIGNAL (timeout ()), this, SLOT (slot_timerUpdate ())); |
148
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
103 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
104 | m_toolTipTimer = new QTimer (this); |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
105 | m_toolTipTimer->setSingleShot (true); |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
106 | connect (m_toolTipTimer, SIGNAL (timeout ()), this, SLOT (slot_toolTipTimer ())); |
149
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
107 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
108 | m_thickBorderPen = QPen (QColor (0, 0, 0, 208), 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
109 | m_thinBorderPen = m_thickBorderPen; |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
110 | m_thinBorderPen.setWidth (1); |
148
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
111 | |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
112 | // Init camera icons |
149
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
113 | for (const GLRenderer::Camera cam : g_Cameras) { |
158
499286fcbf37
Compile the icon resources to a QRC file, so that they are embedded in the application
Santeri Piippo <crimsondusk64@gmail.com>
parents:
156
diff
changeset
|
114 | str iconname; |
499286fcbf37
Compile the icon resources to a QRC file, so that they are embedded in the application
Santeri Piippo <crimsondusk64@gmail.com>
parents:
156
diff
changeset
|
115 | iconname.format ("camera-%s", str (g_CameraNames[cam]).tolower ().chars ()); |
148
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
116 | |
149
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
117 | CameraIcon* info = &g_CameraIcons[cam]; |
158
499286fcbf37
Compile the icon resources to a QRC file, so that they are embedded in the application
Santeri Piippo <crimsondusk64@gmail.com>
parents:
156
diff
changeset
|
118 | info->img = new QPixmap (getIcon (iconname)); |
149
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
119 | info->cam = cam; |
148
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
120 | } |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
121 | |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
122 | calcCameraIconRects (); |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
123 | } |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
124 | |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
125 | // ============================================================================= |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
126 | GLRenderer::~GLRenderer() { |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
127 | for (CameraIcon& info : g_CameraIcons) |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
128 | delete info.img; |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
129 | } |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
130 | |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
131 | // ============================================================================= |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
132 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
133 | // ============================================================================= |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
134 | void GLRenderer::calcCameraIconRects () { |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
135 | ushort i = 0; |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
136 | |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
137 | for (CameraIcon& info : g_CameraIcons) { |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
138 | const long x1 = (m_width - (info.cam != Free ? 48 : 16)) + ((i % 3) * 16) - 1, |
149
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
139 | y1 = ((i / 3) * 16) + 1; |
148
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
140 | |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
141 | info.srcRect = QRect (0, 0, 16, 16); |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
142 | info.destRect = QRect (x1, y1, 16, 16); |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
143 | info.selRect = QRect (info.destRect.x (), info.destRect.y (), |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
144 | info.destRect.width () + 1, info.destRect.height () + 1); |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
145 | ++i; |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
146 | } |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
147 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
148 | |
131
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
149 | // ============================================================================= |
132
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
150 | void GLRenderer::resetAngles () { |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
151 | m_rotX = 30.0f; |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
152 | m_rotY = 325.f; |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
153 | m_panX = m_panY = m_rotZ = 0.0f; |
182
9374fea8f77f
Viewport no longer offsets stuff based on bbox size, that was stupid. Only use bbox size for initial zoom.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
170
diff
changeset
|
154 | |
9374fea8f77f
Viewport no longer offsets stuff based on bbox size, that was stupid. Only use bbox size for initial zoom.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
170
diff
changeset
|
155 | // Set the default zoom based on the bounding box |
9374fea8f77f
Viewport no longer offsets stuff based on bbox size, that was stupid. Only use bbox size for initial zoom.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
170
diff
changeset
|
156 | m_zoom = g_BBox.size () * 6; |
132
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
157 | } |
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
158 | |
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
159 | // ============================================================================= |
131
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
160 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
161 | // ============================================================================= |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
162 | void GLRenderer::initializeGL () { |
68
c637b172d565
Further fixes to bad color handling. Allow main color be represented with arbitrary transparency.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
67
diff
changeset
|
163 | setBackground (); |
46
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
164 | |
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
165 | glEnable (GL_POLYGON_OFFSET_FILL); |
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
166 | glPolygonOffset (1.0f, 1.0f); |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
167 | |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
168 | glEnable (GL_DEPTH_TEST); |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
169 | glShadeModel (GL_SMOOTH); |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
170 | glEnable (GL_MULTISAMPLE); |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
171 | |
46
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
172 | glEnable (GL_BLEND); |
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
173 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
174 | |
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
175 | glEnable (GL_LINE_SMOOTH); |
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
176 | glHint (GL_LINE_SMOOTH_HINT, GL_NICEST); |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
177 | |
53
170cdffe1056
Make line thickness user-configurable, draw conditional lines dashed, use the bounding box to offset the model so that it is centered properly.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
178 | glLineWidth (gl_linethickness); |
170cdffe1056
Make line thickness user-configurable, draw conditional lines dashed, use the bounding box to offset the model so that it is centered properly.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
179 | |
146
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
180 | setAutoFillBackground (false); |
53
170cdffe1056
Make line thickness user-configurable, draw conditional lines dashed, use the bounding box to offset the model so that it is centered properly.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
181 | setMouseTracking (true); |
137
2b8b63be67fb
Fixed additive selection; use a green selection area background instead of blue when selecting additive; selection area borders now appear black on bright backgrounds; single additive picking an already-selected object un-selects it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
182 | setFocusPolicy (Qt::WheelFocus); |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
183 | compileObjects (); |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
184 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
185 | |
131
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
186 | // ============================================================================= |
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
187 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
188 | // ============================================================================= |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
189 | QColor GLRenderer::getMainColor () { |
68
c637b172d565
Further fixes to bad color handling. Allow main color be represented with arbitrary transparency.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
67
diff
changeset
|
190 | QColor col (gl_maincolor.value.chars()); |
46
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
191 | |
47
9dd536c1ce39
Made the GL renderer actually use the main color configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
192 | if (!col.isValid ()) |
147
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
193 | return QColor (0, 0, 0); |
47
9dd536c1ce39
Made the GL renderer actually use the main color configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
194 | |
105
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
195 | col.setAlpha (gl_maincolor_alpha * 255.f); |
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
196 | return col; |
68
c637b172d565
Further fixes to bad color handling. Allow main color be represented with arbitrary transparency.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
67
diff
changeset
|
197 | } |
c637b172d565
Further fixes to bad color handling. Allow main color be represented with arbitrary transparency.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
67
diff
changeset
|
198 | |
131
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
199 | // ----------------------------------------------------------------------------- |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
200 | void GLRenderer::setBackground () { |
68
c637b172d565
Further fixes to bad color handling. Allow main color be represented with arbitrary transparency.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
67
diff
changeset
|
201 | QColor col (gl_bgcolor.value.chars()); |
c637b172d565
Further fixes to bad color handling. Allow main color be represented with arbitrary transparency.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
67
diff
changeset
|
202 | |
c637b172d565
Further fixes to bad color handling. Allow main color be represented with arbitrary transparency.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
67
diff
changeset
|
203 | if (!col.isValid ()) |
c637b172d565
Further fixes to bad color handling. Allow main color be represented with arbitrary transparency.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
67
diff
changeset
|
204 | return; |
c637b172d565
Further fixes to bad color handling. Allow main color be represented with arbitrary transparency.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
67
diff
changeset
|
205 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
206 | m_darkbg = luma (col) < 80; |
137
2b8b63be67fb
Fixed additive selection; use a green selection area background instead of blue when selecting additive; selection area borders now appear black on bright backgrounds; single additive picking an already-selected object un-selects it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
207 | |
144
b2b8b45f6f5f
Fixed view going blank after resize
Santeri Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
208 | col.setAlpha (255); |
b2b8b45f6f5f
Fixed view going blank after resize
Santeri Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
209 | qglClearColor (col); |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
210 | } |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
211 | |
120
607301744394
Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
119
diff
changeset
|
212 | // ============================================================================= |
607301744394
Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
119
diff
changeset
|
213 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
607301744394
Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
119
diff
changeset
|
214 | // ============================================================================= |
67
d523a370a17a
57181.dat (Philo's model of the XL-motor) showcased a new problem.. there was no handling of unknown colors which led into crashes. Added stdout warnings, also added mid and dark stone colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
66
diff
changeset
|
215 | static vector<short> g_daWarnedColors; |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
216 | void GLRenderer::setObjectColor (LDObject* obj) { |
164 | 217 | QColor qcol; |
218 | ||
219 | if (!obj->isColored()) | |
220 | return; | |
105
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
221 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
222 | if (m_picking) { |
104 | 223 | // Make the color by the object's index color if we're picking, so we can |
224 | // make the index from the color we get from the picking results. | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
225 | long i = obj->getIndex (g_curfile); |
104 | 226 | |
227 | // If we couldn't find the index, this object must not be from this file, | |
148
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
228 | // therefore it must be an object inlined from a subfile reference or |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
229 | // decomposed from a radial. Find the top level parent object and use |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
230 | // its index. |
104 | 231 | if (i == -1) |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
232 | i = obj->topLevelParent ()->getIndex (g_curfile); |
104 | 233 | |
234 | // We should have the index now. | |
235 | assert (i != -1); | |
236 | ||
237 | // Calculate a color based from this index. This method caters for | |
238 | // 16777216 objects. I don't think that'll be exceeded anytime soon. :) | |
239 | // ATM biggest is 53588.dat with 12600 lines. | |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
240 | double r = (i / (256 * 256)) % 256, |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
241 | g = (i / 256) % 256, |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
242 | b = i % 256; |
104 | 243 | |
148
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
244 | qglColor (QColor (r, g, b, 255)); |
104 | 245 | return; |
246 | } | |
247 | ||
248 | #if 0 | |
54
60f328f352c9
Done the rendering end of the red/green BFC view
Santeri Piippo <crimsondusk64@gmail.com>
parents:
53
diff
changeset
|
249 | if (gl_colorbfc && |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
250 | obj->getType () != LDObject::Line && |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
251 | obj->getType () != LDObject::CondLine) |
54
60f328f352c9
Done the rendering end of the red/green BFC view
Santeri Piippo <crimsondusk64@gmail.com>
parents:
53
diff
changeset
|
252 | { |
62
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
253 | if (bBackSide) |
54
60f328f352c9
Done the rendering end of the red/green BFC view
Santeri Piippo <crimsondusk64@gmail.com>
parents:
53
diff
changeset
|
254 | glColor4f (0.9f, 0.0f, 0.0f, 1.0f); |
60f328f352c9
Done the rendering end of the red/green BFC view
Santeri Piippo <crimsondusk64@gmail.com>
parents:
53
diff
changeset
|
255 | else |
60f328f352c9
Done the rendering end of the red/green BFC view
Santeri Piippo <crimsondusk64@gmail.com>
parents:
53
diff
changeset
|
256 | glColor4f (0.0f, 0.8f, 0.0f, 1.0f); |
60f328f352c9
Done the rendering end of the red/green BFC view
Santeri Piippo <crimsondusk64@gmail.com>
parents:
53
diff
changeset
|
257 | return; |
60f328f352c9
Done the rendering end of the red/green BFC view
Santeri Piippo <crimsondusk64@gmail.com>
parents:
53
diff
changeset
|
258 | } |
104 | 259 | #endif |
54
60f328f352c9
Done the rendering end of the red/green BFC view
Santeri Piippo <crimsondusk64@gmail.com>
parents:
53
diff
changeset
|
260 | |
147
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
261 | if (obj->dColor == maincolor) |
164 | 262 | qcol = getMainColor (); |
105
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
263 | else { |
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
264 | color* col = getColor (obj->dColor); |
164 | 265 | qcol = col->qColor; |
156
d35b7e440585
Added axes rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
155
diff
changeset
|
266 | } |
d35b7e440585
Added axes rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
155
diff
changeset
|
267 | |
d35b7e440585
Added axes rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
155
diff
changeset
|
268 | if (obj->dColor == edgecolor) { |
164 | 269 | qcol = Qt::black; |
156
d35b7e440585
Added axes rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
155
diff
changeset
|
270 | color* col; |
105
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
271 | |
156
d35b7e440585
Added axes rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
155
diff
changeset
|
272 | if (!gl_blackedges && obj->parent != null && (col = getColor (obj->parent->dColor)) != null) |
164 | 273 | qcol = col->qEdge; |
156
d35b7e440585
Added axes rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
155
diff
changeset
|
274 | } |
d35b7e440585
Added axes rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
155
diff
changeset
|
275 | |
164 | 276 | if (qcol.isValid () == false) { |
156
d35b7e440585
Added axes rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
155
diff
changeset
|
277 | // The color was unknown. Use main color to make the object at least |
d35b7e440585
Added axes rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
155
diff
changeset
|
278 | // not appear pitch-black. |
d35b7e440585
Added axes rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
155
diff
changeset
|
279 | if (obj->dColor != edgecolor) |
164 | 280 | qcol = getMainColor (); |
156
d35b7e440585
Added axes rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
155
diff
changeset
|
281 | |
d35b7e440585
Added axes rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
155
diff
changeset
|
282 | // Warn about the unknown colors, but only once. |
d35b7e440585
Added axes rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
155
diff
changeset
|
283 | for (short i : g_daWarnedColors) |
d35b7e440585
Added axes rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
155
diff
changeset
|
284 | if (obj->dColor == i) |
d35b7e440585
Added axes rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
155
diff
changeset
|
285 | return; |
d35b7e440585
Added axes rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
155
diff
changeset
|
286 | |
d35b7e440585
Added axes rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
155
diff
changeset
|
287 | printf ("%s: Unknown color %d!\n", __func__, obj->dColor); |
d35b7e440585
Added axes rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
155
diff
changeset
|
288 | g_daWarnedColors.push_back (obj->dColor); |
d35b7e440585
Added axes rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
155
diff
changeset
|
289 | return; |
68
c637b172d565
Further fixes to bad color handling. Allow main color be represented with arbitrary transparency.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
67
diff
changeset
|
290 | } |
c637b172d565
Further fixes to bad color handling. Allow main color be represented with arbitrary transparency.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
67
diff
changeset
|
291 | |
164 | 292 | long r = qcol.red (), |
293 | g = qcol.green (), | |
294 | b = qcol.blue (), | |
295 | a = qcol.alpha (); | |
68
c637b172d565
Further fixes to bad color handling. Allow main color be represented with arbitrary transparency.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
67
diff
changeset
|
296 | |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
297 | // If it's selected, brighten it up, also pulse flash it if desired. |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
298 | if (g_win->isSelected (obj)) { |
147
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
299 | short tick, numTicks; |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
300 | |
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
301 | if (gl_selflash) { |
147
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
302 | tick = (g_pulseTick < (g_numPulseTicks / 2)) ? g_pulseTick : (g_numPulseTicks - g_pulseTick); |
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
303 | numTicks = g_numPulseTicks; |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
304 | } else { |
147
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
305 | tick = 2; |
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
306 | numTicks = 5; |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
307 | } |
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
308 | |
147
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
309 | const long add = ((tick * 128) / numTicks); |
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
310 | r = min (r + add, 255l); |
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
311 | g = min (g + add, 255l); |
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
312 | b = min (b + add, 255l); |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
313 | |
108
351aef26f444
More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
314 | // a = 255; |
52
d71226763607
Colorized polygons now appear colorized in the list view (unless disabled). GL rendered now draws transparent polygons properly.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
47
diff
changeset
|
315 | } |
68
c637b172d565
Further fixes to bad color handling. Allow main color be represented with arbitrary transparency.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
67
diff
changeset
|
316 | |
72
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
70
diff
changeset
|
317 | glColor4f ( |
105
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
318 | ((double) r) / 255.0f, |
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
319 | ((double) g) / 255.0f, |
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
320 | ((double) b) / 255.0f, |
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
321 | ((double) a) / 255.0f); |
52
d71226763607
Colorized polygons now appear colorized in the list view (unless disabled). GL rendered now draws transparent polygons properly.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
47
diff
changeset
|
322 | } |
d71226763607
Colorized polygons now appear colorized in the list view (unless disabled). GL rendered now draws transparent polygons properly.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
47
diff
changeset
|
323 | |
131
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
324 | // ============================================================================= |
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
325 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
326 | // ============================================================================= |
108
351aef26f444
More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
327 | void GLRenderer::refresh () { |
146
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
328 | update (); |
108
351aef26f444
More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
329 | swapBuffers (); |
351aef26f444
More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
330 | } |
351aef26f444
More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
331 | |
131
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
332 | // ============================================================================= |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
333 | void GLRenderer::hardRefresh () { |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
334 | compileObjects (); |
108
351aef26f444
More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
335 | refresh (); |
53
170cdffe1056
Make line thickness user-configurable, draw conditional lines dashed, use the bounding box to offset the model so that it is centered properly.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
336 | |
170cdffe1056
Make line thickness user-configurable, draw conditional lines dashed, use the bounding box to offset the model so that it is centered properly.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
337 | glLineWidth (gl_linethickness); |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
338 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
339 | |
131
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
340 | // ============================================================================= |
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
341 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
342 | // ============================================================================= |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
343 | void GLRenderer::resizeGL (int w, int h) { |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
344 | m_width = w; |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
345 | m_height = h; |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
346 | |
148
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
347 | calcCameraIconRects (); |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
348 | |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
349 | glViewport (0, 0, w, h); |
144
b2b8b45f6f5f
Fixed view going blank after resize
Santeri Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
350 | glMatrixMode (GL_PROJECTION); |
46
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
351 | glLoadIdentity (); |
182
9374fea8f77f
Viewport no longer offsets stuff based on bbox size, that was stupid. Only use bbox size for initial zoom.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
170
diff
changeset
|
352 | gluPerspective (45.0f, (double)w / (double)h, 1.0f, 10000.0f); |
146
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
353 | glMatrixMode (GL_MODELVIEW); |
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
354 | } |
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
355 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
356 | void GLRenderer::drawGLScene () const { |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
357 | if (g_curfile == null) |
146
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
358 | return; |
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
359 | |
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
360 | glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
361 | glEnable (GL_DEPTH_TEST); |
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
362 | |
147
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
363 | if (m_camera != GLRenderer::Free) { |
146
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
364 | glMatrixMode (GL_PROJECTION); |
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
365 | glPushMatrix (); |
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
366 | |
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
367 | glLoadIdentity (); |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
368 | glOrtho (-m_virtWidth, m_virtWidth, -m_virtHeight, m_virtHeight, -100.0f, 100.0f); |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
369 | glTranslatef (m_panX, m_panY, 0.0f); |
147
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
370 | glRotatef (90.0f, g_staticCameras[m_camera].glrotate[0], |
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
371 | g_staticCameras[m_camera].glrotate[1], |
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
372 | g_staticCameras[m_camera].glrotate[2]); |
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
373 | |
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
374 | // Back camera needs to be handled differently |
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
375 | if (m_camera == GLRenderer::Back) { |
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
376 | glRotatef (180.0f, 1.0f, 0.0f, 0.0f); |
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
377 | glRotatef (180.0f, 0.0f, 0.0f, 1.0f); |
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
378 | } |
146
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
379 | } else { |
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
380 | glMatrixMode (GL_MODELVIEW); |
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
381 | glPushMatrix (); |
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
382 | glLoadIdentity (); |
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
383 | |
155 | 384 | glTranslatef (0.0f, 0.0f, -2.0f); |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
385 | glTranslatef (m_panX, m_panY, -m_zoom); |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
386 | glRotatef (m_rotX, 1.0f, 0.0f, 0.0f); |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
387 | glRotatef (m_rotY, 0.0f, 1.0f, 0.0f); |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
388 | glRotatef (m_rotZ, 0.0f, 0.0f, 1.0f); |
146
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
389 | } |
147
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
390 | |
170
2247a32e63a8
Added visibility toggling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
391 | for (LDObject* obj : g_curfile->m_objs) { |
2247a32e63a8
Added visibility toggling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
392 | if (obj->hidden ()) |
2247a32e63a8
Added visibility toggling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
393 | continue; // Don't draw hidden objects |
2247a32e63a8
Added visibility toggling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
394 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
395 | glCallList (m_picking == false ? obj->uGLList : obj->uGLPickList); |
170
2247a32e63a8
Added visibility toggling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
396 | } |
147
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
397 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
398 | if (gl_axes && !m_picking) |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
399 | glCallList (m_axeslist); |
156
d35b7e440585
Added axes rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
155
diff
changeset
|
400 | |
146
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
401 | glPopMatrix (); |
144
b2b8b45f6f5f
Fixed view going blank after resize
Santeri Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
402 | glMatrixMode (GL_MODELVIEW); |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
403 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
404 | |
163
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
405 | // ============================================================================= |
162
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
406 | vertex GLRenderer::coord_2to3 (const QPoint& pos2d, const bool snap) const { |
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
407 | vertex pos3d; |
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
408 | const staticCameraMeta* cam = &g_staticCameras[m_camera]; |
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
409 | const Axis axisX = cam->axisX; |
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
410 | const Axis axisY = cam->axisY; |
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
411 | const short negXFac = cam->negX ? -1 : 1, |
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
412 | negYFac = cam->negY ? -1 : 1; |
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
413 | |
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
414 | // Calculate cx and cy - these are the LDraw unit coords the cursor is at. |
182
9374fea8f77f
Viewport no longer offsets stuff based on bbox size, that was stupid. Only use bbox size for initial zoom.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
170
diff
changeset
|
415 | double cx = (-m_virtWidth + ((2 * pos2d.x () * m_virtWidth) / m_width) - m_panX) - (negXFac * g_objOffset[axisX]); |
9374fea8f77f
Viewport no longer offsets stuff based on bbox size, that was stupid. Only use bbox size for initial zoom.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
170
diff
changeset
|
416 | double cy = (m_virtHeight - ((2 * pos2d.y () * m_virtHeight) / m_height) - m_panY) - (negYFac * g_objOffset[axisY]); |
162
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
417 | |
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
418 | if (snap) { |
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
419 | cx = Grid::snap (cx, (Grid::Config) axisX); |
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
420 | cy = Grid::snap (cy, (Grid::Config) axisY); |
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
421 | } |
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
422 | |
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
423 | cx *= negXFac; |
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
424 | cy *= negYFac; |
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
425 | |
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
426 | pos3d = g_origin; |
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
427 | pos3d[axisX] = cx; |
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
428 | pos3d[axisY] = cy; |
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
429 | return pos3d; |
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
430 | } |
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
431 | |
163
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
432 | // ============================================================================= |
162
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
433 | QPoint GLRenderer::coord_3to2 (const vertex& pos3d) const { |
163
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
434 | /* |
182
9374fea8f77f
Viewport no longer offsets stuff based on bbox size, that was stupid. Only use bbox size for initial zoom.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
170
diff
changeset
|
435 | cx = (-m_virtWidth + ((2 * pos2d.x () * m_virtWidth) / m_width) - m_panX) - (negXFac * g_objOffset[axisX]); |
163
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
436 | |
182
9374fea8f77f
Viewport no longer offsets stuff based on bbox size, that was stupid. Only use bbox size for initial zoom.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
170
diff
changeset
|
437 | cx = (-vw + ((2 * x * vw) / w) - panx) - (neg * ofs) |
9374fea8f77f
Viewport no longer offsets stuff based on bbox size, that was stupid. Only use bbox size for initial zoom.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
170
diff
changeset
|
438 | cx + (neg * ofs) = (-vw + ((2 * x * vw) / w) - panx) |
9374fea8f77f
Viewport no longer offsets stuff based on bbox size, that was stupid. Only use bbox size for initial zoom.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
170
diff
changeset
|
439 | cx + (neg * ofs) = ((2 * x * vw) / w) - vw - panx |
9374fea8f77f
Viewport no longer offsets stuff based on bbox size, that was stupid. Only use bbox size for initial zoom.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
170
diff
changeset
|
440 | (cx + (neg * ofs)) + vw + panx = (2 * x * vw) / w |
9374fea8f77f
Viewport no longer offsets stuff based on bbox size, that was stupid. Only use bbox size for initial zoom.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
170
diff
changeset
|
441 | ((cx + (neg * ofs)) + vw + panx) * w = 2 * vw * x |
163
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
442 | |
182
9374fea8f77f
Viewport no longer offsets stuff based on bbox size, that was stupid. Only use bbox size for initial zoom.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
170
diff
changeset
|
443 | x = (((cx + (neg * ofs)) + vw + panx) * w) / (2 * vw) |
163
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
444 | */ |
162
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
445 | |
163
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
446 | QPoint pos2d; |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
447 | const staticCameraMeta* cam = &g_staticCameras[m_camera]; |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
448 | const Axis axisX = cam->axisX; |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
449 | const Axis axisY = cam->axisY; |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
450 | const short negXFac = cam->negX ? -1 : 1, |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
451 | negYFac = cam->negY ? -1 : 1; |
162
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
452 | |
182
9374fea8f77f
Viewport no longer offsets stuff based on bbox size, that was stupid. Only use bbox size for initial zoom.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
170
diff
changeset
|
453 | short x1 = (((pos3d[axisX] + (negXFac * g_objOffset[axisX])) + |
163
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
454 | m_virtWidth + m_panX) * m_width) / (2 * m_virtWidth); |
182
9374fea8f77f
Viewport no longer offsets stuff based on bbox size, that was stupid. Only use bbox size for initial zoom.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
170
diff
changeset
|
455 | short y1 = -(((pos3d[axisY] + (negYFac * g_objOffset[axisY])) - |
163
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
456 | m_virtHeight + m_panY) * m_height) / (2 * m_virtHeight); |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
457 | |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
458 | x1 *= negXFac; |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
459 | y1 *= negYFac; |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
460 | |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
461 | pos2d = QPoint (x1, y1); |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
462 | return pos2d; |
162
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
463 | } |
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
464 | |
131
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
465 | // ============================================================================= |
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
466 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
467 | // ============================================================================= |
146
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
468 | void GLRenderer::paintEvent (QPaintEvent* ev) { |
147
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
469 | Q_UNUSED (ev) |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
470 | m_virtWidth = m_zoom; |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
471 | m_virtHeight = (m_height * m_virtWidth) / m_width; |
146
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
472 | drawGLScene (); |
145
ddf24c380be6
Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
473 | |
147
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
474 | QPainter paint (this); |
149
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
475 | QFontMetrics metrics = QFontMetrics (QFont ()); |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
476 | paint.setRenderHint (QPainter::Antialiasing); |
148
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
477 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
478 | m_hoverpos = g_origin; |
145
ddf24c380be6
Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
479 | |
147
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
480 | if (m_camera != Free) { |
162
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
481 | // Calculate 3d position of the cursor |
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
482 | m_hoverpos = coord_2to3 (m_pos, true); |
147
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
483 | |
149
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
484 | // Paint the coordinates onto the screen. |
147
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
485 | str text; |
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
486 | text.format ("X: %s, Y: %s, Z: %s", ftoa (m_hoverpos[X]).chars (), |
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
487 | ftoa (m_hoverpos[Y]).chars (), ftoa (m_hoverpos[Z]).chars ()); |
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
488 | |
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
489 | QFontMetrics metrics = QFontMetrics (font ()); |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
490 | QRect textSize = metrics.boundingRect (0, 0, m_width, m_height, Qt::AlignCenter, text); |
147
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
491 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
492 | paint.drawText (m_width - textSize.width (), m_height - 16, textSize.width (), |
147
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
493 | textSize.height (), Qt::AlignCenter, text); |
162
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
494 | |
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
495 | // If we're plane drawing, draw the vertices onto the screen. |
163
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
496 | if (m_planeDraw) { |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
497 | ushort numverts = m_planeDrawVerts.size () + 1; |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
498 | const short blipsize = 8; |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
499 | |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
500 | if (numverts > 0) { |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
501 | QPoint* poly = new QPoint[numverts]; |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
502 | |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
503 | uchar i = 0; |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
504 | for (vertex& vert : m_planeDrawVerts) { |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
505 | poly[i] = coord_3to2 (vert); |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
506 | ++i; |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
507 | } |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
508 | |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
509 | // Draw the cursor vertex as the last one in the list. |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
510 | if (numverts < 5) |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
511 | poly[i] = coord_3to2 (m_hoverpos); |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
512 | else |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
513 | numverts = 4; |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
514 | |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
515 | paint.setPen (m_thinBorderPen); |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
516 | paint.setBrush (QColor (128, 192, 0)); |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
517 | |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
518 | // Draw vertex blips |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
519 | for (ushort i = 0; i < numverts; ++i) { |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
520 | QPoint& blip = poly[i]; |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
521 | paint.drawEllipse (blip.x () - blipsize / 2, blip.y () - blipsize / 2, |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
522 | blipsize, blipsize); |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
523 | } |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
524 | |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
525 | paint.setPen (m_thickBorderPen); |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
526 | paint.setBrush (QColor (128, 192, 0, 128)); |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
527 | paint.drawPolygon (poly, numverts); |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
528 | |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
529 | delete[] poly; |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
530 | } |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
531 | } |
147
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
532 | } |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
533 | |
148
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
534 | // Camera icons |
162
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
535 | if (!m_picking && m_planeDraw == false) { |
148
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
536 | // Draw a background for the selected camera |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
537 | paint.setPen (m_thinBorderPen); |
149
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
538 | paint.setBrush (QBrush (QColor (0, 128, 160, 128))); |
148
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
539 | paint.drawRect (g_CameraIcons[camera ()].selRect); |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
540 | |
149
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
541 | // Draw the actual icons |
148
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
542 | for (CameraIcon& info : g_CameraIcons) |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
543 | paint.drawPixmap (info.destRect, *info.img, info.srcRect); |
149
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
544 | |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
545 | // Draw a label for the current camera in the top left corner |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
546 | { |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
547 | const ushort margin = 4; |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
548 | |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
549 | str label; |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
550 | label.format ("%s Camera", g_CameraNames[camera ()]); |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
551 | paint.setBrush (Qt::black); |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
552 | paint.drawText (QPoint (margin, margin + metrics.ascent ()), label); |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
553 | } |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
554 | |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
555 | // Tool tips |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
556 | if (m_drawToolTip) { |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
557 | if (g_CameraIcons[m_toolTipCamera].destRect.contains (m_pos) == false) |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
558 | m_drawToolTip = false; |
149
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
559 | else { |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
560 | QPen bord = m_thinBorderPen; |
149
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
561 | bord.setBrush (Qt::black); |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
562 | |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
563 | const ushort margin = 2; |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
564 | ushort x0 = m_pos.x (), |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
565 | y0 = m_pos.y (); |
149
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
566 | |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
567 | str label; |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
568 | label.format ("%s Camera", g_CameraNames[m_toolTipCamera]); |
149
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
569 | |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
570 | const ushort textWidth = metrics.width (label), |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
571 | textHeight = metrics.height (), |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
572 | fullWidth = textWidth + (2 * margin), |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
573 | fullHeight = textHeight + (2 * margin); |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
574 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
575 | QRect area (m_pos.x (), m_pos.y (), fullWidth, fullHeight); |
149
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
576 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
577 | if (x0 + fullWidth > m_width) |
149
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
578 | x0 -= fullWidth; |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
579 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
580 | if (y0 + fullHeight > m_height) |
149
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
581 | y0 -= fullHeight; |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
582 | |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
583 | paint.setBrush (QColor (0, 128, 255, 208)); |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
584 | paint.setPen (bord); |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
585 | paint.drawRect (x0, y0, fullWidth, fullHeight); |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
586 | |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
587 | paint.setBrush (Qt::black); |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
588 | paint.drawText (QPoint (x0 + margin, y0 + margin + metrics.ascent ()), label); |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
589 | } |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
590 | } |
148
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
591 | } |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
592 | |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
593 | // If we're range-picking, draw a rectangle encompassing the selection area. |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
594 | if (m_rangepick && !m_picking) { |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
595 | const short x0 = m_rangeStart.x (), |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
596 | y0 = m_rangeStart.y (), |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
597 | x1 = m_pos.x (), |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
598 | y1 = m_pos.y (); |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
599 | |
146
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
600 | QRect rect (x0, y0, x1 - x0, y1 - y0); |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
601 | QColor fillColor = (m_addpick ? "#80FF00" : "#00CCFF"); |
146
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
602 | fillColor.setAlphaF (0.2f); |
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
603 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
604 | paint.setPen (m_thickBorderPen); |
146
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
605 | paint.setBrush (QBrush (fillColor)); |
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
606 | paint.drawRect (rect); |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
607 | } |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
608 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
609 | |
131
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
610 | // ============================================================================= |
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
611 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
612 | // ============================================================================= |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
613 | void GLRenderer::compileObjects () { |
164 | 614 | if (g_BBox.empty () == false) { |
615 | g_objOffset[X] = -(g_BBox.v0 ()[X] + g_BBox.v1 ()[X]) / 2; | |
616 | g_objOffset[Y] = -(g_BBox.v0 ()[Y] + g_BBox.v1 ()[Y]) / 2; | |
617 | g_objOffset[Z] = -(g_BBox.v0 ()[Z] + g_BBox.v1 ()[Z]) / 2; | |
618 | } else { | |
619 | // use a default bbox if we need | |
620 | g_objOffset[X] = g_objOffset[Y] = g_objOffset[Z] = 0; | |
621 | } | |
53
170cdffe1056
Make line thickness user-configurable, draw conditional lines dashed, use the bounding box to offset the model so that it is centered properly.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
622 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
623 | if (!g_curfile) { |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
624 | printf ("renderer: no files loaded, cannot compile anything\n"); |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
625 | return; |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
626 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
627 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
628 | for (LDObject* obj : g_curfile->m_objs) { |
107
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
629 | GLuint* upaLists[2] = { |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
630 | &obj->uGLList, |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
631 | &obj->uGLPickList |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
632 | }; |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
633 | |
107
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
634 | for (GLuint* upMemberList : upaLists) { |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
635 | GLuint uList = glGenLists (1); |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
636 | glNewList (uList, GL_COMPILE); |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
637 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
638 | m_picking = (upMemberList == &obj->uGLPickList); |
107
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
639 | compileOneObject (obj); |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
640 | m_picking = false; |
107
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
641 | |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
642 | glEndList (); |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
643 | *upMemberList = uList; |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
644 | } |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
645 | } |
156
d35b7e440585
Added axes rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
155
diff
changeset
|
646 | |
d35b7e440585
Added axes rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
155
diff
changeset
|
647 | // Compile axes |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
648 | m_axeslist = glGenLists (1); |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
649 | glNewList (m_axeslist, GL_COMPILE); |
156
d35b7e440585
Added axes rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
155
diff
changeset
|
650 | glBegin (GL_LINES); |
d35b7e440585
Added axes rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
155
diff
changeset
|
651 | for (const GLAxis& ax : g_GLAxes) { |
d35b7e440585
Added axes rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
155
diff
changeset
|
652 | qglColor (ax.col); |
d35b7e440585
Added axes rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
155
diff
changeset
|
653 | compileVertex (ax.vert); |
d35b7e440585
Added axes rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
155
diff
changeset
|
654 | compileVertex (-ax.vert); |
d35b7e440585
Added axes rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
155
diff
changeset
|
655 | } |
d35b7e440585
Added axes rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
155
diff
changeset
|
656 | glEnd (); |
d35b7e440585
Added axes rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
155
diff
changeset
|
657 | glEndList (); |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
658 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
659 | |
131
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
660 | // ============================================================================= |
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
661 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
662 | // ============================================================================= |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
663 | void GLRenderer::compileSubObject (LDObject* obj, const GLenum gltype) { |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
664 | glBegin (gltype); |
62
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
665 | |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
666 | const short numverts = (obj->getType () != LDObject::CondLine) ? obj->vertices () : 2; |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
667 | |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
668 | for (short i = 0; i < numverts; ++i) |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
669 | compileVertex (obj->vaCoords[i]); |
62
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
670 | |
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
671 | glEnd (); |
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
672 | } |
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
673 | |
131
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
674 | // ============================================================================= |
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
675 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
676 | // ============================================================================= |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
677 | void GLRenderer::compileOneObject (LDObject* obj) { |
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
678 | setObjectColor (obj); |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
679 | |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
680 | switch (obj->getType ()) { |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
681 | case LDObject::Line: |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
682 | compileSubObject (obj, GL_LINES); |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
683 | break; |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
684 | |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
685 | case LDObject::CondLine: |
62
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
686 | glLineStipple (1, 0x6666); |
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
687 | glEnable (GL_LINE_STIPPLE); |
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
688 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
689 | compileSubObject (obj, GL_LINES); |
62
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
690 | |
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
691 | glDisable (GL_LINE_STIPPLE); |
53
170cdffe1056
Make line thickness user-configurable, draw conditional lines dashed, use the bounding box to offset the model so that it is centered properly.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
692 | break; |
170cdffe1056
Make line thickness user-configurable, draw conditional lines dashed, use the bounding box to offset the model so that it is centered properly.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
52
diff
changeset
|
693 | |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
694 | case LDObject::Triangle: |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
695 | compileSubObject (obj, GL_TRIANGLES); |
62
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
696 | break; |
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
697 | |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
698 | case LDObject::Quad: |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
699 | compileSubObject (obj, GL_QUADS); |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
700 | break; |
62
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
701 | |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
702 | case LDObject::Subfile: |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
703 | { |
62
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
704 | LDSubfile* ref = static_cast<LDSubfile*> (obj); |
111
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
110
diff
changeset
|
705 | vector<LDObject*> objs = ref->inlineContents (true, true); |
62
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
706 | |
111
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
110
diff
changeset
|
707 | for (LDObject* obj : objs) { |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
110
diff
changeset
|
708 | compileOneObject (obj); |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
110
diff
changeset
|
709 | delete obj; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
110
diff
changeset
|
710 | } |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
110
diff
changeset
|
711 | } |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
110
diff
changeset
|
712 | break; |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
110
diff
changeset
|
713 | |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
714 | case LDObject::Radial: |
111
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
110
diff
changeset
|
715 | { |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
110
diff
changeset
|
716 | LDRadial* pRadial = static_cast<LDRadial*> (obj); |
125e8031dbf1
Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
110
diff
changeset
|
717 | std::vector<LDObject*> objs = pRadial->decompose (true); |
62
915fc477cb6a
Got inlining working. 3002.dat renders properly now! Now just to iron out the bugs and hone the behavior..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
718 | |
70
e6b8dab8f81a
Phased out FOREACH macro in favor of C++11-style for iteration.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
69
diff
changeset
|
719 | for (LDObject* obj : objs) { |
104 | 720 | compileOneObject (obj); |
70
e6b8dab8f81a
Phased out FOREACH macro in favor of C++11-style for iteration.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
69
diff
changeset
|
721 | delete obj; |
66
12aca5d5a51e
Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents:
64
diff
changeset
|
722 | } |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
723 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
724 | break; |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
725 | |
103
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
726 | #if 0 |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
727 | TODO: find a proper way to draw vertices without having them be affected by zoom. |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
164
diff
changeset
|
728 | case LDObject::Vertex: |
103
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
729 | { |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
730 | LDVertex* pVert = static_cast<LDVertex*> (obj); |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
731 | LDTriangle* pPoly; |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
732 | vertex* vPos = &(pVert->vPosition); |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
733 | const double fPolyScale = max (fZoom, 1.0); |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
734 | |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
735 | #define BIPYRAMID_COORD(N) ((((i + N) % 4) >= 2 ? 1 : -1) * 0.3f * fPolyScale) |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
736 | |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
737 | for (int i = 0; i < 8; ++i) { |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
738 | pPoly = new LDTriangle; |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
739 | pPoly->vaCoords[0] = {vPos->x, vPos->y + ((i >= 4 ? 1 : -1) * 0.4f * fPolyScale), vPos->z}; |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
740 | pPoly->vaCoords[1] = { |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
741 | vPos->x + BIPYRAMID_COORD (0), |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
742 | vPos->y, |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
743 | vPos->z + BIPYRAMID_COORD (1) |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
744 | }; |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
745 | |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
746 | pPoly->vaCoords[2] = { |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
747 | vPos->x + BIPYRAMID_COORD (1), |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
748 | vPos->y, |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
749 | vPos->z + BIPYRAMID_COORD (2) |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
750 | }; |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
751 | |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
752 | pPoly->dColor = pVert->dColor; |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
753 | compileOneObject (pPoly); |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
754 | delete pPoly; |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
755 | } |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
756 | } |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
757 | break; |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
758 | #endif // 0 |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
759 | |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
760 | default: |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
761 | break; |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
762 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
763 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
764 | |
131
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
765 | // ============================================================================= |
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
766 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
767 | // ============================================================================= |
156
d35b7e440585
Added axes rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
155
diff
changeset
|
768 | void GLRenderer::compileVertex (const vertex& vrt) { |
60
961663d05463
Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents:
59
diff
changeset
|
769 | glVertex3d ( |
182
9374fea8f77f
Viewport no longer offsets stuff based on bbox size, that was stupid. Only use bbox size for initial zoom.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
170
diff
changeset
|
770 | (vrt[X] + g_objOffset[0]), |
9374fea8f77f
Viewport no longer offsets stuff based on bbox size, that was stupid. Only use bbox size for initial zoom.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
170
diff
changeset
|
771 | -(vrt[Y] + g_objOffset[1]), |
9374fea8f77f
Viewport no longer offsets stuff based on bbox size, that was stupid. Only use bbox size for initial zoom.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
170
diff
changeset
|
772 | -(vrt[Z] + g_objOffset[2])); |
60
961663d05463
Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents:
59
diff
changeset
|
773 | } |
961663d05463
Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents:
59
diff
changeset
|
774 | |
131
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
775 | // ============================================================================= |
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
776 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
777 | // ============================================================================= |
132
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
778 | void GLRenderer::clampAngle (double& angle) { |
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
779 | while (angle < 0) |
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
780 | angle += 360.0; |
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
781 | while (angle > 360.0) |
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
782 | angle -= 360.0; |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
783 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
784 | |
131
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
785 | // ============================================================================= |
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
786 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
787 | // ============================================================================= |
132
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
788 | void GLRenderer::mouseReleaseEvent (QMouseEvent* ev) { |
163
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
789 | const bool wasLeft = (m_lastButtons & Qt::LeftButton) && !(ev->buttons() & Qt::LeftButton); |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
790 | const bool wasRight = (m_lastButtons & Qt::RightButton) && !(ev->buttons() & Qt::RightButton); |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
791 | |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
792 | if (wasLeft) { |
162
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
793 | if (m_planeDraw) { |
163
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
794 | // If we picked an already-existing vertex, stop drawing |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
795 | for (vertex& vert : m_planeDrawVerts) { |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
796 | if (vert == m_hoverpos) { |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
797 | endPlaneDraw (true); |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
798 | return; |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
799 | } |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
800 | } |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
801 | |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
802 | // Also, if have 4 verts, also stop drawing. |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
803 | if (m_planeDrawVerts.size () >= 4) |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
804 | endPlaneDraw (true); |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
805 | |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
806 | m_planeDrawVerts.push_back (m_hoverpos); |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
807 | |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
808 | update (); |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
809 | return; |
162
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
810 | } else { |
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
811 | if (!m_rangepick) |
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
812 | m_addpick = (m_keymods & Qt::ControlModifier); |
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
813 | |
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
814 | if (m_totalmove < 10 || m_rangepick) |
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
815 | pick (ev->x (), ev->y ()); |
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
816 | } |
104 | 817 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
818 | m_rangepick = false; |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
819 | m_totalmove = 0; |
163
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
820 | return; |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
821 | } |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
822 | |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
823 | if (wasRight && m_planeDraw) { |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
824 | if (m_planeDrawVerts.size () > 0) { |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
825 | // Remove the last vertex |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
826 | m_planeDrawVerts.erase (m_planeDrawVerts.end () - 1); |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
827 | } else { |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
828 | endPlaneDraw (false); |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
829 | return; |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
830 | } |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
831 | |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
832 | update (); |
104 | 833 | } |
834 | } | |
835 | ||
131
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
836 | // ============================================================================= |
146
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
837 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
838 | // ============================================================================= |
132
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
839 | void GLRenderer::mousePressEvent (QMouseEvent* ev) { |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
840 | if (ev->buttons () & Qt::LeftButton) |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
841 | m_totalmove = 0; |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
842 | |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
843 | if (ev->modifiers () & Qt::ShiftModifier) { |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
844 | m_rangepick = true; |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
845 | m_rangeStart.setX (ev->x ()); |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
846 | m_rangeStart.setY (ev->y ()); |
137
2b8b63be67fb
Fixed additive selection; use a green selection area background instead of blue when selecting additive; selection area borders now appear black on bright backgrounds; single additive picking an already-selected object un-selects it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
847 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
848 | m_addpick = (m_keymods & Qt::ControlModifier); |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
849 | } |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
850 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
851 | m_lastButtons = ev->buttons (); |
104 | 852 | } |
853 | ||
131
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
854 | // ============================================================================= |
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
855 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
856 | // ============================================================================= |
132
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
857 | void GLRenderer::mouseMoveEvent (QMouseEvent* ev) { |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
858 | int dx = ev->x () - m_pos.x (); |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
859 | int dy = ev->y () - m_pos.y (); |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
860 | m_totalmove += abs (dx) + abs (dy); |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
861 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
862 | if (ev->buttons () & Qt::LeftButton && !m_rangepick) { |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
863 | m_rotX = m_rotX + (dy); |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
864 | m_rotY = m_rotY + (dx); |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
865 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
866 | clampAngle (m_rotX); |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
867 | clampAngle (m_rotY); |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
868 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
869 | |
132
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
870 | if (ev->buttons () & Qt::MidButton) { |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
871 | m_panX += 0.03f * dx * (m_zoom / 7.5f); |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
872 | m_panY -= 0.03f * dy * (m_zoom / 7.5f); |
132
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
873 | } |
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
874 | |
149
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
875 | // Start the tool tip timer |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
876 | if (!m_drawToolTip) |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
877 | m_toolTipTimer->start (1000); |
149
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
878 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
879 | m_pos = ev->pos (); |
146
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
880 | update (); |
104 | 881 | } |
882 | ||
131
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
883 | // ============================================================================= |
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
884 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
885 | // ============================================================================= |
132
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
886 | void GLRenderer::keyPressEvent (QKeyEvent* ev) { |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
887 | m_keymods = ev->modifiers (); |
107
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
888 | } |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
889 | |
132
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
890 | void GLRenderer::keyReleaseEvent (QKeyEvent* ev) { |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
891 | m_keymods = ev->modifiers (); |
107
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
892 | } |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
893 | |
131
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
894 | // ============================================================================= |
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
895 | void GLRenderer::wheelEvent (QWheelEvent* ev) { |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
896 | m_zoom *= (ev->delta () < 0) ? 1.2f : (1.0f / 1.2f); |
182
9374fea8f77f
Viewport no longer offsets stuff based on bbox size, that was stupid. Only use bbox size for initial zoom.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
170
diff
changeset
|
897 | m_zoom = clamp (m_zoom, 0.01, 10000.0); |
146
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
898 | |
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
899 | update (); |
131
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
900 | ev->accept (); |
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
901 | } |
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
902 | |
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
903 | // ============================================================================= |
151
15fe6c51de54
Switched the object list from a QTreeWidget to a QListWidget-derivative. Derivative because I'm going to add a context menu.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
149
diff
changeset
|
904 | void GLRenderer::leaveEvent (QEvent* ev) { |
15fe6c51de54
Switched the object list from a QTreeWidget to a QListWidget-derivative. Derivative because I'm going to add a context menu.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
149
diff
changeset
|
905 | Q_UNUSED (ev); |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
906 | m_drawToolTip = false; |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
907 | m_toolTipTimer->stop (); |
151
15fe6c51de54
Switched the object list from a QTreeWidget to a QListWidget-derivative. Derivative because I'm going to add a context menu.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
149
diff
changeset
|
908 | update (); |
15fe6c51de54
Switched the object list from a QTreeWidget to a QListWidget-derivative. Derivative because I'm going to add a context menu.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
149
diff
changeset
|
909 | } |
15fe6c51de54
Switched the object list from a QTreeWidget to a QListWidget-derivative. Derivative because I'm going to add a context menu.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
149
diff
changeset
|
910 | |
15fe6c51de54
Switched the object list from a QTreeWidget to a QListWidget-derivative. Derivative because I'm going to add a context menu.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
149
diff
changeset
|
911 | // ============================================================================= |
154
cc53e5cbad54
Added context menu and uncolorize action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
153
diff
changeset
|
912 | void GLRenderer::contextMenuEvent (QContextMenuEvent* ev) { |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
913 | g_win->spawnContextMenu (ev->globalPos ()); |
154
cc53e5cbad54
Added context menu and uncolorize action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
153
diff
changeset
|
914 | } |
cc53e5cbad54
Added context menu and uncolorize action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
153
diff
changeset
|
915 | |
cc53e5cbad54
Added context menu and uncolorize action
Santeri Piippo <crimsondusk64@gmail.com>
parents:
153
diff
changeset
|
916 | // ============================================================================= |
152
552e46650a95
Camera is now stored to configuration so it is preserved across program shutdown. I don't know how significant this is but eh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
151
diff
changeset
|
917 | void GLRenderer::setCamera (const GLRenderer::Camera cam) { |
552e46650a95
Camera is now stored to configuration so it is preserved across program shutdown. I don't know how significant this is but eh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
151
diff
changeset
|
918 | m_camera = cam; |
552e46650a95
Camera is now stored to configuration so it is preserved across program shutdown. I don't know how significant this is but eh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
151
diff
changeset
|
919 | gl_camera = (int) cam; |
552e46650a95
Camera is now stored to configuration so it is preserved across program shutdown. I don't know how significant this is but eh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
151
diff
changeset
|
920 | } |
552e46650a95
Camera is now stored to configuration so it is preserved across program shutdown. I don't know how significant this is but eh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
151
diff
changeset
|
921 | |
552e46650a95
Camera is now stored to configuration so it is preserved across program shutdown. I don't know how significant this is but eh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
151
diff
changeset
|
922 | // ============================================================================= |
131
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
923 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
3ccb10f6ed0b
Use mouse wheel for zooming instead of pressing the mouse button and detecting vertical movement.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
121
diff
changeset
|
924 | // ============================================================================= |
108
351aef26f444
More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
925 | void GLRenderer::updateSelFlash () { |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
926 | if (gl_selflash && g_win->sel ().size() > 0) { |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
927 | m_pulseTimer->start (g_pulseInterval); |
147
291a1fe2d278
Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
146
diff
changeset
|
928 | g_pulseTick = 0; |
109
f40b35142586
Improved shared selection handling; added select by color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
929 | } else |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
930 | m_pulseTimer->stop (); |
108
351aef26f444
More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
931 | } |
351aef26f444
More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
932 | |
146
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
933 | // ============================================================================= |
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
934 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
935 | // ============================================================================= |
137
2b8b63be67fb
Fixed additive selection; use a green selection area background instead of blue when selecting additive; selection area borders now appear black on bright backgrounds; single additive picking an already-selected object un-selects it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
936 | void GLRenderer::pick (uint mouseX, uint mouseY) { |
148
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
937 | // Check if we selected a camera icon |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
938 | if (!m_rangepick) { |
148
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
939 | QPoint pos (mouseX, mouseY); |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
940 | |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
941 | for (CameraIcon& info : g_CameraIcons) { |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
942 | if (info.destRect.contains (pos)) { |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
943 | setCamera (info.cam); |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
944 | update (); |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
945 | return; |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
946 | } |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
947 | } |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
948 | } |
ecfbb598db14
Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
147
diff
changeset
|
949 | |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
950 | GLint viewport[4]; |
137
2b8b63be67fb
Fixed additive selection; use a green selection area background instead of blue when selecting additive; selection area borders now appear black on bright backgrounds; single additive picking an already-selected object un-selects it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
951 | LDObject* removedObject = null; |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
952 | |
134
7fd0784471df
Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
133
diff
changeset
|
953 | // Clear the selection if we do not wish to add to it. |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
954 | if (!m_addpick) { |
163
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
955 | std::vector<LDObject*> oldsel = g_win->sel (); |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
956 | g_win->sel ().clear (); |
107
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
957 | |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
958 | // Recompile the prior selection to remove the highlight color |
163
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
959 | for (LDObject* obj : oldsel) |
107
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
960 | recompileObject (obj); |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
961 | } |
105
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
962 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
963 | m_picking = true; |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
964 | |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
965 | // Paint the picking scene |
104 | 966 | glDisable (GL_DITHER); |
967 | glClearColor (1.0f, 1.0f, 1.0f, 1.0f); | |
146
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
968 | drawGLScene (); |
104 | 969 | |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
970 | glGetIntegerv (GL_VIEWPORT, viewport); |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
971 | |
137
2b8b63be67fb
Fixed additive selection; use a green selection area background instead of blue when selecting additive; selection area borders now appear black on bright backgrounds; single additive picking an already-selected object un-selects it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
972 | short x0 = mouseX, |
2b8b63be67fb
Fixed additive selection; use a green selection area background instead of blue when selecting additive; selection area borders now appear black on bright backgrounds; single additive picking an already-selected object un-selects it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
973 | y0 = mouseY; |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
974 | short x1, y1; |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
975 | |
134
7fd0784471df
Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
133
diff
changeset
|
976 | // Determine how big an area to read - with range picking, we pick by |
7fd0784471df
Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
133
diff
changeset
|
977 | // the area given, with single pixel picking, we use an 1 x 1 area. |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
978 | if (m_rangepick) { |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
979 | x1 = m_rangeStart.x (); |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
980 | y1 = m_rangeStart.y (); |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
981 | } else { |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
982 | x1 = x0 + 1; |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
983 | y1 = y0 + 1; |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
984 | } |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
985 | |
134
7fd0784471df
Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
133
diff
changeset
|
986 | // x0 and y0 must be less than x1 and y1, respectively. |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
987 | if (x0 > x1) |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
988 | dataswap (x0, x1); |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
989 | |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
990 | if (y0 > y1) |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
991 | dataswap (y0, y1); |
104 | 992 | |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
993 | // Clamp the values to ensure they're within bounds |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
994 | x0 = max<short> (0, x0); |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
995 | y0 = max<short> (0, y0); |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
996 | x1 = min<short> (x1, m_width); |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
997 | y1 = min<short> (y1, m_height); |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
998 | |
134
7fd0784471df
Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
133
diff
changeset
|
999 | const short areawidth = (x1 - x0); |
7fd0784471df
Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
133
diff
changeset
|
1000 | const short areaheight = (y1 - y0); |
7fd0784471df
Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
133
diff
changeset
|
1001 | const long numpixels = areawidth * areaheight; |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
1002 | |
134
7fd0784471df
Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
133
diff
changeset
|
1003 | // Allocate space for the pixel data. |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
1004 | uchar* const pixeldata = new uchar[4 * numpixels]; |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
1005 | uchar* pixelptr = &pixeldata[0]; |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
1006 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
1007 | assert (viewport[3] == m_height); |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
1008 | |
134
7fd0784471df
Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
133
diff
changeset
|
1009 | // Read pixels from the color buffer. |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
1010 | glReadPixels (x0, viewport[3] - y1, areawidth, areaheight, GL_RGBA, GL_UNSIGNED_BYTE, pixeldata); |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
1011 | |
134
7fd0784471df
Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
133
diff
changeset
|
1012 | // Go through each pixel read and add them to the selection. |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
1013 | for (long i = 0; i < numpixels; ++i) { |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
1014 | uint32 idx = |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
1015 | (*(pixelptr) * 0x10000) + |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
1016 | (*(pixelptr + 1) * 0x00100) + |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
1017 | (*(pixelptr + 2) * 0x00001); |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
1018 | pixelptr += 4; |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
1019 | |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
1020 | if (idx == 0xFFFFFF) |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
1021 | continue; // White is background; skip |
104 | 1022 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
1023 | LDObject* obj = g_curfile->object (idx); |
137
2b8b63be67fb
Fixed additive selection; use a green selection area background instead of blue when selecting additive; selection area borders now appear black on bright backgrounds; single additive picking an already-selected object un-selects it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
1024 | |
2b8b63be67fb
Fixed additive selection; use a green selection area background instead of blue when selecting additive; selection area borders now appear black on bright backgrounds; single additive picking an already-selected object un-selects it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
1025 | // If this is an additive single pick and the object is currently selected, |
2b8b63be67fb
Fixed additive selection; use a green selection area background instead of blue when selecting additive; selection area borders now appear black on bright backgrounds; single additive picking an already-selected object un-selects it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
1026 | // we remove it from selection instead. |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
1027 | if (!m_rangepick && m_addpick) { |
137
2b8b63be67fb
Fixed additive selection; use a green selection area background instead of blue when selecting additive; selection area borders now appear black on bright backgrounds; single additive picking an already-selected object un-selects it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
1028 | bool removed = false; |
2b8b63be67fb
Fixed additive selection; use a green selection area background instead of blue when selecting additive; selection area borders now appear black on bright backgrounds; single additive picking an already-selected object un-selects it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
1029 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
1030 | for (ulong i = 0; i < g_win->sel ().size(); ++i) { |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
1031 | if (g_win->sel ()[i] == obj) { |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
1032 | g_win->sel ().erase (g_win->sel ().begin () + i); |
137
2b8b63be67fb
Fixed additive selection; use a green selection area background instead of blue when selecting additive; selection area borders now appear black on bright backgrounds; single additive picking an already-selected object un-selects it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
1033 | removedObject = obj; |
2b8b63be67fb
Fixed additive selection; use a green selection area background instead of blue when selecting additive; selection area borders now appear black on bright backgrounds; single additive picking an already-selected object un-selects it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
1034 | removed = true; |
2b8b63be67fb
Fixed additive selection; use a green selection area background instead of blue when selecting additive; selection area borders now appear black on bright backgrounds; single additive picking an already-selected object un-selects it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
1035 | } |
2b8b63be67fb
Fixed additive selection; use a green selection area background instead of blue when selecting additive; selection area borders now appear black on bright backgrounds; single additive picking an already-selected object un-selects it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
1036 | } |
2b8b63be67fb
Fixed additive selection; use a green selection area background instead of blue when selecting additive; selection area borders now appear black on bright backgrounds; single additive picking an already-selected object un-selects it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
1037 | |
2b8b63be67fb
Fixed additive selection; use a green selection area background instead of blue when selecting additive; selection area borders now appear black on bright backgrounds; single additive picking an already-selected object un-selects it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
1038 | if (removed) |
2b8b63be67fb
Fixed additive selection; use a green selection area background instead of blue when selecting additive; selection area borders now appear black on bright backgrounds; single additive picking an already-selected object un-selects it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
1039 | break; |
2b8b63be67fb
Fixed additive selection; use a green selection area background instead of blue when selecting additive; selection area borders now appear black on bright backgrounds; single additive picking an already-selected object un-selects it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
1040 | } |
2b8b63be67fb
Fixed additive selection; use a green selection area background instead of blue when selecting additive; selection area borders now appear black on bright backgrounds; single additive picking an already-selected object un-selects it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
1041 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
1042 | g_win->sel ().push_back (obj); |
104 | 1043 | } |
1044 | ||
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
1045 | delete[] pixeldata; |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
1046 | |
134
7fd0784471df
Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
133
diff
changeset
|
1047 | // Remove duplicate entries. For this to be effective, the vector must be |
7fd0784471df
Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
133
diff
changeset
|
1048 | // sorted first. |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
1049 | std::vector<LDObject*>& sel = g_win->sel (); |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
1050 | std::sort (sel.begin(), sel.end ()); |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
1051 | std::vector<LDObject*>::iterator pos = std::unique (sel.begin (), sel.end ()); |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
1052 | sel.resize (std::distance (sel.begin (), pos)); |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
1053 | |
134
7fd0784471df
Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
133
diff
changeset
|
1054 | // Update everything now. |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
1055 | g_win->buildObjList (); |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
1056 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
1057 | m_picking = false; |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
1058 | m_rangepick = false; |
104 | 1059 | glEnable (GL_DITHER); |
1060 | ||
1061 | setBackground (); | |
108
351aef26f444
More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
1062 | updateSelFlash (); |
107
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
1063 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
1064 | for (LDObject* obj : g_win->sel ()) |
107
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
1065 | recompileObject (obj); |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
1066 | |
137
2b8b63be67fb
Fixed additive selection; use a green selection area background instead of blue when selecting additive; selection area borders now appear black on bright backgrounds; single additive picking an already-selected object un-selects it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
1067 | if (removedObject != null) |
2b8b63be67fb
Fixed additive selection; use a green selection area background instead of blue when selecting additive; selection area borders now appear black on bright backgrounds; single additive picking an already-selected object un-selects it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
1068 | recompileObject (removedObject); |
2b8b63be67fb
Fixed additive selection; use a green selection area background instead of blue when selecting additive; selection area borders now appear black on bright backgrounds; single additive picking an already-selected object un-selects it.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
1069 | |
146
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
1070 | drawGLScene (); |
107
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
1071 | swapBuffers (); |
146
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
1072 | update (); |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
1073 | } |
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
1074 | |
163
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1075 | // ============================================================================= |
162
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
1076 | void GLRenderer::beginPlaneDraw () { |
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
1077 | if (m_camera == Free) |
163
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1078 | return; // Cannot draw with the free camera |
162
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
1079 | |
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
1080 | m_planeDraw = true; |
163
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1081 | |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1082 | // Disable the context menu - we need the right mouse button |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1083 | // for removing vertices. |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1084 | setContextMenuPolicy (Qt::NoContextMenu); |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1085 | |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1086 | // Use the crosshair cursor when plane drawing. |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1087 | setCursor (Qt::CrossCursor); |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1088 | |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1089 | // Clear the selection when beginning to draw onto a plane. |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1090 | // FIXME: make the selection clearing stuff in ::pick a method and use it |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1091 | // here! This code doesn't update the GL lists. |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1092 | g_win->sel ().clear (); |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1093 | g_win->updateSelection (); |
162
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
1094 | update (); |
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
1095 | } |
b7d65e89861a
matrix is now templated with N=int (usually 3)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
160
diff
changeset
|
1096 | |
163
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1097 | // ============================================================================= |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1098 | void GLRenderer::endPlaneDraw (bool accept) { |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1099 | // If we accepted, clean the selection and create the object |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1100 | if (accept) { |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1101 | vector<vertex>& verts = m_planeDrawVerts; |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1102 | LDObject* obj = null; |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1103 | |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1104 | switch (verts.size ()) { |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1105 | case 1: |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1106 | { |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1107 | // 1 vertex - add a vertex object |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1108 | obj = new LDVertex; |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1109 | static_cast<LDVertex*> (obj)->vPosition = verts[0]; |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1110 | obj->dColor = maincolor; |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1111 | } |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1112 | break; |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1113 | |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1114 | case 2: |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1115 | { |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1116 | // 2 verts - make a line |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1117 | obj = new LDLine; |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1118 | obj->dColor = edgecolor; |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1119 | for (ushort i = 0; i < 2; ++i) |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1120 | obj->vaCoords[i] = verts[i]; |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1121 | } |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1122 | break; |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1123 | |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1124 | case 3: |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1125 | case 4: |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1126 | { |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1127 | obj = (verts.size () == 3) ? |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1128 | static_cast<LDObject*> (new LDTriangle) : |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1129 | static_cast<LDObject*> (new LDQuad); |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1130 | |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1131 | obj->dColor = maincolor; |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1132 | for (ushort i = 0; i < obj->vertices (); ++i) |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1133 | obj->vaCoords[i] = verts[i]; |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1134 | } |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1135 | break; |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1136 | } |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1137 | |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1138 | if (obj) { |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1139 | g_curfile->addObject (obj); |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1140 | recompileObject (obj); |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1141 | g_win->refresh (); |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1142 | |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1143 | History::addEntry (new AddHistory ({(ulong) obj->getIndex (g_curfile)}, {obj->clone ()})); |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1144 | } |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1145 | } |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1146 | |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1147 | m_planeDraw = false; |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1148 | m_planeDrawVerts.clear (); |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1149 | |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1150 | unsetCursor (); |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1151 | |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1152 | // Restore the context menu |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1153 | setContextMenuPolicy (Qt::DefaultContextMenu); |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1154 | |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1155 | update (); |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1156 | } |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1157 | |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1158 | // ============================================================================= |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1159 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
46955613626d
Plane drawing is functional at last!!!11 Also added meta function findAction to find an action by name so I don't have to extern all of them manually in gui.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
162
diff
changeset
|
1160 | // ============================================================================= |
107
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
1161 | void GLRenderer::recompileObject (LDObject* obj) { |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
1162 | // Replace the old list with the new one. |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
1163 | GLuint uList = glGenLists (1); |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
1164 | glNewList (uList, GL_COMPILE); |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
1165 | |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
1166 | compileOneObject (obj); |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
1167 | |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
1168 | glEndList (); |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
1169 | obj->uGLList = uList; |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
1170 | } |
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
1171 | |
132
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
1172 | // ============================================================================= |
143
e3c37b950a68
Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
137
diff
changeset
|
1173 | uchar* GLRenderer::screencap (ushort& w, ushort& h) { |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
1174 | w = m_width; |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
1175 | h = m_height; |
143
e3c37b950a68
Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
137
diff
changeset
|
1176 | uchar* cap = new uchar[4 * w * h]; |
155 | 1177 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
1178 | m_screencap = true; |
146
2ab24976acaa
Now capable of calculating coordinates based on mouse x and y and snapping them to the grid
Santeri Piippo <crimsondusk64@gmail.com>
parents:
145
diff
changeset
|
1179 | update (); |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
1180 | m_screencap = false; |
143
e3c37b950a68
Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
137
diff
changeset
|
1181 | |
e3c37b950a68
Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
137
diff
changeset
|
1182 | // Capture the pixels |
e3c37b950a68
Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
137
diff
changeset
|
1183 | glReadPixels (0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, cap); |
e3c37b950a68
Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
137
diff
changeset
|
1184 | |
e3c37b950a68
Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
137
diff
changeset
|
1185 | // Restore the background |
e3c37b950a68
Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
137
diff
changeset
|
1186 | setBackground (); |
e3c37b950a68
Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
137
diff
changeset
|
1187 | |
e3c37b950a68
Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
137
diff
changeset
|
1188 | return cap; |
149
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
1189 | } |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
1190 | |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
1191 | // ============================================================================= |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
1192 | void GLRenderer::slot_timerUpdate () { |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
1193 | ++g_pulseTick %= g_numPulseTicks; |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
1194 | |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
1195 | for (LDObject* obj : g_win->sel ()) |
149
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
1196 | recompileObject (obj); |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
1197 | |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
1198 | update (); |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
1199 | } |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
1200 | |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
1201 | // ============================================================================= |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
1202 | void GLRenderer::slot_toolTipTimer () { |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
1203 | // We come here if the cursor has stayed in one place for longer than a |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
1204 | // a second. Check if we're holding it over a camera icon - if so, draw |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
1205 | // a tooltip. |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
1206 | for (CameraIcon& icon : g_CameraIcons) { |
160
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
1207 | if (icon.destRect.contains (m_pos)) { |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
1208 | m_toolTipCamera = icon.cam; |
edcb03f3ef75
Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
158
diff
changeset
|
1209 | m_drawToolTip = true; |
149
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
1210 | update (); |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
1211 | break; |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
1212 | } |
96b14d5e7365
Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents:
148
diff
changeset
|
1213 | } |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1214 | } |