gldraw.cpp

Fri, 03 May 2013 23:46:46 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Fri, 03 May 2013 23:46:46 +0300
changeset 155
e21c24bfcdf3
parent 154
cc53e5cbad54
child 156
d35b7e440585
permissions
-rw-r--r--

Added select all

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
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
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
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
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"
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30
147
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
31 static double g_objOffset[3];
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
32 static double g_storedBBoxSize;
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);
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
58
153
03a7bdcce50d Adding objects now actually updates the bounding box like it should be.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 152
diff changeset
59 // 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
60 // 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
61 // 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
62 struct CameraIcon {
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
63 QPixmap* img;
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
64 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
65 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
66 } 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
67
149
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
68 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
69
149
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
70 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
71 GLRenderer::Top,
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
72 GLRenderer::Front,
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
73 GLRenderer::Left,
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
74 GLRenderer::Bottom,
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
75 GLRenderer::Back,
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
76 GLRenderer::Right,
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
77 GLRenderer::Free
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
78 };
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
79
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
80 // =============================================================================
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
81 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
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
82 // =============================================================================
132
577e8e89d8de Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents: 131
diff changeset
83 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
84 resetAngles ();
133
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
85 picking = 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
86 m_camera = (GLRenderer::Camera) gl_camera.value;
149
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
87 drawToolTip = false;
106
46e4202a44fc Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents: 105
diff changeset
88
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
89 pulseTimer = new QTimer (this);
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
90 connect (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
91
149
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
92 toolTipTimer = new QTimer (this);
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
93 toolTipTimer->setSingleShot (true);
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
94 connect (toolTipTimer, SIGNAL (timeout ()), this, SLOT (slot_toolTipTimer ()));
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
95
148
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
96 thickBorderPen = QPen (QColor (0, 0, 0, 208), 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
97 thinBorderPen = thickBorderPen;
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
98 thinBorderPen.setWidth (1);
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
99
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
100 // Init camera icons
149
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
101 for (const GLRenderer::Camera cam : g_Cameras) {
148
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
102 str path;
149
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
103 path.format ("./icons/camera-%s.png", 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
104
149
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
105 CameraIcon* info = &g_CameraIcons[cam];
148
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
106 info->img = new QPixmap (path);
149
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
107 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
108 }
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
109
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
110 calcCameraIconRects ();
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
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
113 // =============================================================================
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
114 GLRenderer::~GLRenderer() {
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
115 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
116 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
117 }
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
118
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
119 // =============================================================================
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 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
123 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
124
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
125 for (CameraIcon& info : g_CameraIcons) {
149
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
126 const long x1 = (width - (info.cam != Free ? 48 : 16)) + ((i % 3) * 16) - 1,
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
127 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
128
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
129 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
130 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
131 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
132 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
133 ++i;
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
134 }
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
135 }
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
136
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
137 // =============================================================================
132
577e8e89d8de Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents: 131
diff changeset
138 void GLRenderer::resetAngles () {
577e8e89d8de Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents: 131
diff changeset
139 rotX = 30.0f;
577e8e89d8de Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents: 131
diff changeset
140 rotY = 325.f;
577e8e89d8de Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents: 131
diff changeset
141 panX = panY = rotZ = 0.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
142 zoom = 5.0f;
132
577e8e89d8de Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents: 131
diff changeset
143 }
577e8e89d8de Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents: 131
diff changeset
144
577e8e89d8de Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents: 131
diff changeset
145 // =============================================================================
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
146 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
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
147 // =============================================================================
106
46e4202a44fc Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents: 105
diff changeset
148 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
149 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
150
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
151 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
152 glPolygonOffset (1.0f, 1.0f);
32
5d22b7ecf110 Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents: 30
diff changeset
153
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
154 glEnable (GL_DEPTH_TEST);
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
155 glShadeModel (GL_SMOOTH);
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
156 glEnable (GL_MULTISAMPLE);
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
157
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
158 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
159 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
160
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
161 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
162 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
163
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
164 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
165
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
166 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
167 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
168 setFocusPolicy (Qt::WheelFocus);
32
5d22b7ecf110 Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents: 30
diff changeset
169 compileObjects ();
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
170 }
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
171
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
172 // =============================================================================
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
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
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
174 // =============================================================================
106
46e4202a44fc Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents: 105
diff changeset
175 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
176 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
177
47
9dd536c1ce39 Made the GL renderer actually use the main color configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents: 46
diff changeset
178 if (!col.isValid ())
147
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
179 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
180
105
53f95a6e351d Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
181 col.setAlpha (gl_maincolor_alpha * 255.f);
53f95a6e351d Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
182 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
183 }
c637b172d565 Further fixes to bad color handling. Allow main color be represented with arbitrary transparency.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 67
diff changeset
184
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
185 // -----------------------------------------------------------------------------
106
46e4202a44fc Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents: 105
diff changeset
186 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
187 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
188
c637b172d565 Further fixes to bad color handling. Allow main color be represented with arbitrary transparency.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 67
diff changeset
189 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
190 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
191
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
192 darkbg = luma (col) < 80;
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
193
144
b2b8b45f6f5f Fixed view going blank after resize
Santeri Piippo <crimsondusk64@gmail.com>
parents: 143
diff changeset
194 col.setAlpha (255);
b2b8b45f6f5f Fixed view going blank after resize
Santeri Piippo <crimsondusk64@gmail.com>
parents: 143
diff changeset
195 qglClearColor (col);
32
5d22b7ecf110 Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents: 30
diff changeset
196 }
5d22b7ecf110 Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents: 30
diff changeset
197
120
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 119
diff changeset
198 // =============================================================================
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 119
diff changeset
199 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
607301744394 Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 119
diff changeset
200 // =============================================================================
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
201 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
202 void GLRenderer::setObjectColor (LDObject* obj) {
105
53f95a6e351d Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
203 QColor qCol;
53f95a6e351d Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
204
132
577e8e89d8de Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents: 131
diff changeset
205 if (picking) {
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
206 // Make the color by the object's index color if we're picking, so we can
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
207 // make the index from the color we get from the picking results.
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
208 long i = obj->getIndex (g_CurrentFile);
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
209
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
210 // 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
211 // 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
212 // 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
213 // its index.
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
214 if (i == -1)
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
215 i = obj->topLevelParent ()->getIndex (g_CurrentFile);
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
216
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
217 // We should have the index now.
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
218 assert (i != -1);
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
219
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
220 // Calculate a color based from this index. This method caters for
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
221 // 16777216 objects. I don't think that'll be exceeded anytime soon. :)
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
222 // 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
223 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
224 g = (i / 256) % 256,
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
225 b = i % 256;
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
226
148
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
227 qglColor (QColor (r, g, b, 255));
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
228 return;
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
229 }
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
230
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
231 if (obj->dColor == -1)
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
232 return;
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
233
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
234 #if 0
54
60f328f352c9 Done the rendering end of the red/green BFC view
Santeri Piippo <crimsondusk64@gmail.com>
parents: 53
diff changeset
235 if (gl_colorbfc &&
60f328f352c9 Done the rendering end of the red/green BFC view
Santeri Piippo <crimsondusk64@gmail.com>
parents: 53
diff changeset
236 obj->getType () != OBJ_Line &&
60f328f352c9 Done the rendering end of the red/green BFC view
Santeri Piippo <crimsondusk64@gmail.com>
parents: 53
diff changeset
237 obj->getType () != OBJ_CondLine)
60f328f352c9 Done the rendering end of the red/green BFC view
Santeri Piippo <crimsondusk64@gmail.com>
parents: 53
diff changeset
238 {
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
239 if (bBackSide)
54
60f328f352c9 Done the rendering end of the red/green BFC view
Santeri Piippo <crimsondusk64@gmail.com>
parents: 53
diff changeset
240 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
241 else
60f328f352c9 Done the rendering end of the red/green BFC view
Santeri Piippo <crimsondusk64@gmail.com>
parents: 53
diff changeset
242 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
243 return;
60f328f352c9 Done the rendering end of the red/green BFC view
Santeri Piippo <crimsondusk64@gmail.com>
parents: 53
diff changeset
244 }
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
245 #endif
54
60f328f352c9 Done the rendering end of the red/green BFC view
Santeri Piippo <crimsondusk64@gmail.com>
parents: 53
diff changeset
246
147
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
247 if (obj->dColor == maincolor)
105
53f95a6e351d Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
248 qCol = getMainColor ();
53f95a6e351d Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
249 else {
53f95a6e351d Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
250 color* col = getColor (obj->dColor);
53f95a6e351d Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
251
53f95a6e351d Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
252 if (col != null)
53f95a6e351d Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
253 qCol = col->qColor;
53f95a6e351d Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
254 else {
53f95a6e351d Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
255 // The color was unknown. Use main color to make the object at least
53f95a6e351d Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
256 // not appear pitch-black.
53f95a6e351d Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
257 qCol = getMainColor ();
53f95a6e351d Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
258
53f95a6e351d Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
259 // Warn about the unknown colors, but only once.
53f95a6e351d Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
260 for (short i : g_daWarnedColors)
53f95a6e351d Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
261 if (obj->dColor == i)
53f95a6e351d Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
262 return;
53f95a6e351d Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
263
53f95a6e351d Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
264 printf ("%s: Unknown color %d!\n", __func__, obj->dColor);
53f95a6e351d Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
265 g_daWarnedColors.push_back (obj->dColor);
53f95a6e351d Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
266 return;
53f95a6e351d Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
267 }
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
268 }
c637b172d565 Further fixes to bad color handling. Allow main color be represented with arbitrary transparency.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 67
diff changeset
269
105
53f95a6e351d Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
270 long r = qCol.red (),
53f95a6e351d Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
271 g = qCol.green (),
53f95a6e351d Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
272 b = qCol.blue (),
53f95a6e351d Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
273 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
274
106
46e4202a44fc Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents: 105
diff changeset
275 // If it's selected, brighten it up, also pulse flash it if desired.
46e4202a44fc Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents: 105
diff changeset
276 if (g_ForgeWindow->isSelected (obj)) {
147
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
277 short tick, numTicks;
106
46e4202a44fc Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents: 105
diff changeset
278
46e4202a44fc Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents: 105
diff changeset
279 if (gl_selflash) {
147
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
280 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
281 numTicks = g_numPulseTicks;
106
46e4202a44fc Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents: 105
diff changeset
282 } else {
147
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
283 tick = 2;
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
284 numTicks = 5;
106
46e4202a44fc Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents: 105
diff changeset
285 }
46e4202a44fc Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents: 105
diff changeset
286
147
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
287 const long add = ((tick * 128) / numTicks);
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
288 r = min (r + add, 255l);
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
289 g = min (g + add, 255l);
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
290 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
291
108
351aef26f444 More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 107
diff changeset
292 // 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
293 }
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
294
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
295 glColor4f (
105
53f95a6e351d Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
296 ((double) r) / 255.0f,
53f95a6e351d Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
297 ((double) g) / 255.0f,
53f95a6e351d Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
298 ((double) b) / 255.0f,
53f95a6e351d Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
299 ((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
300 }
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
301
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
302 // =============================================================================
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
303 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
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
304 // =============================================================================
108
351aef26f444 More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 107
diff changeset
305 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
306 update ();
108
351aef26f444 More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 107
diff changeset
307 swapBuffers ();
351aef26f444 More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 107
diff changeset
308 }
351aef26f444 More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 107
diff changeset
309
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
310 // =============================================================================
106
46e4202a44fc Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents: 105
diff changeset
311 void GLRenderer::hardRefresh () {
32
5d22b7ecf110 Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents: 30
diff changeset
312 compileObjects ();
108
351aef26f444 More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 107
diff changeset
313 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
314
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
315 glLineWidth (gl_linethickness);
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
316 }
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
317
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
318 // =============================================================================
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
319 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
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
320 // =============================================================================
106
46e4202a44fc Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents: 105
diff changeset
321 void GLRenderer::resizeGL (int w, int h) {
133
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
322 width = w;
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
323 height = h;
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
324
148
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
325 calcCameraIconRects ();
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
326
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
327 glViewport (0, 0, w, h);
144
b2b8b45f6f5f Fixed view going blank after resize
Santeri Piippo <crimsondusk64@gmail.com>
parents: 143
diff changeset
328 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
329 glLoadIdentity ();
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
330 gluPerspective (45.0f, (double)w / (double)h, 1.0f, 100.0f);
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
331 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
332 }
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
333
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
334 void GLRenderer::drawGLScene () {
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
335 if (g_CurrentFile == null)
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
336 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
337
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
338 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
339 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
340
147
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
341 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
342 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
343 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
344
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
345 glLoadIdentity ();
147
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
346 glOrtho (-vw, vw, -vh, vh, -100.0f, 100.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
347 glTranslatef (panX, panY, 0.0f);
147
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
348 glRotatef (90.0f, g_staticCameras[m_camera].glrotate[0],
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
349 g_staticCameras[m_camera].glrotate[1],
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
350 g_staticCameras[m_camera].glrotate[2]);
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
351
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
352 // Back camera needs to be handled differently
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
353 if (m_camera == GLRenderer::Back) {
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
354 glRotatef (180.0f, 1.0f, 0.0f, 0.0f);
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
355 glRotatef (180.0f, 0.0f, 0.0f, 1.0f);
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
356 }
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
357 } 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
358 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
359 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
360 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
361
155
e21c24bfcdf3 Added select all
Santeri Piippo <crimsondusk64@gmail.com>
parents: 154
diff changeset
362 glTranslatef (0.0f, 0.0f, -2.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
363 glTranslatef (panX, panY, -zoom);
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 glRotatef (rotX, 1.0f, 0.0f, 0.0f);
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 glRotatef (rotY, 0.0f, 1.0f, 0.0f);
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 glRotatef (rotZ, 0.0f, 0.0f, 1.0f);
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 }
147
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
368
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
369 for (LDObject* obj : g_CurrentFile->objects)
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
370 glCallList (picking == false ? obj->uGLList : obj->uGLPickList);
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
371
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
372 glPopMatrix ();
144
b2b8b45f6f5f Fixed view going blank after resize
Santeri Piippo <crimsondusk64@gmail.com>
parents: 143
diff changeset
373 glMatrixMode (GL_MODELVIEW);
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
374 }
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
375
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
376 // =============================================================================
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
377 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
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
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 void GLRenderer::paintEvent (QPaintEvent* ev) {
147
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
380 Q_UNUSED (ev)
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
381 drawGLScene ();
145
ddf24c380be6 Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 144
diff changeset
382
147
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
383 QPainter paint (this);
149
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
384 QFontMetrics metrics = QFontMetrics (QFont ());
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
385 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
386
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
387 vw = zoom;
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
388 vh = (height * vw) / width;
149
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
389 m_hoverpos = g_Origin;
145
ddf24c380be6 Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 144
diff changeset
390
147
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
391 if (m_camera != Free) {
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
392 const staticCameraMeta* cam = &g_staticCameras[m_camera];
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
393 const Axis axisX = cam->axisX;
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
394 const Axis axisY = cam->axisY;
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
395 const short negXFac = cam->negX ? -1 : 1,
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
396 negYFac = cam->negY ? -1 : 1;
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
397
149
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
398 // Calculate cx and cy - these are the LDraw unit coords the cursor is at.
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
399 double cx = Grid::snap ((-vw + ((2 * mouseX * vw) / width) - panX) * g_storedBBoxSize -
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
400 (negXFac * g_objOffset[axisX]), (Grid::Config) axisX);
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
401 double cy = Grid::snap ((vh - ((2 * mouseY * vh) / height) - panY) * g_storedBBoxSize -
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
402 (negYFac * g_objOffset[axisY]), (Grid::Config) axisY);
147
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
403 cx *= negXFac;
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
404 cy *= negYFac;
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
405
149
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
406 // Set the position we're hovering over based on this
147
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
407 m_hoverpos[axisX] = cx;
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
408 m_hoverpos[axisY] = cy;
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
409
149
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
410 // Paint the coordinates onto the screen.
147
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
411 str text;
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
412 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
413 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
414
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
415 QFontMetrics metrics = QFontMetrics (font ());
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
416 QRect textSize = metrics.boundingRect (0, 0, width, height, Qt::AlignCenter, text);
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
417
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
418 paint.drawText (width - textSize.width (), height - 16, textSize.width (),
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
419 textSize.height (), Qt::AlignCenter, text);
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
420 }
133
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
421
148
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
422 // Camera icons
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
423 if (!picking) {
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
424 // Draw a background for the selected camera
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
425 paint.setPen (thinBorderPen);
149
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
426 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
427 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
428
149
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
429 // 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
430 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
431 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
432
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
433 // 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
434 {
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
435 const ushort margin = 4;
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
436
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
437 str label;
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
438 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
439 paint.setBrush (Qt::black);
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
440 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
441 }
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
442
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
443 // Tool tips
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
444 if (drawToolTip) {
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
445 if (g_CameraIcons[toolTipCamera].destRect.contains (QPoint (mouseX, mouseY)) == false)
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
446 drawToolTip = false;
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
447 else {
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
448 QPen bord = thinBorderPen;
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
449 bord.setBrush (Qt::black);
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
450
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
451 const ushort margin = 2;
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
452 ushort x0 = mouseX,
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
453 y0 = mouseY;
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
454
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
455 str label;
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
456 label.format ("%s Camera", g_CameraNames[toolTipCamera]);
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
457
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
458 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
459 textHeight = metrics.height (),
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
460 fullWidth = textWidth + (2 * margin),
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
461 fullHeight = textHeight + (2 * margin);
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
462
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
463 QRect area (mouseX, mouseY, fullWidth, fullHeight);
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
464
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
465 if (x0 + fullWidth > width)
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
466 x0 -= fullWidth;
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
467
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
468 if (y0 + fullHeight > height)
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
469 y0 -= fullHeight;
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
470
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
471 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
472 paint.setPen (bord);
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
473 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
474
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
475 paint.setBrush (Qt::black);
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
476 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
477 }
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
478 }
148
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
479 }
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
480
133
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
481 // If we're range-picking, draw a rectangle encompassing the selection area.
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
482 if (rangepick && !picking) {
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
483 const short x0 = rangeStart.x (),
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
484 y0 = rangeStart.y (),
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
485 x1 = pos.x (),
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
486 y1 = pos.y ();
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
487
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
488 QRect rect (x0, y0, x1 - x0, y1 - y0);
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
489 QColor fillColor = (addpick ? "#80FF00" : "#00CCFF");
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
490 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
491
148
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
492 paint.setPen (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
493 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
494 paint.drawRect (rect);
133
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
495 }
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
496 }
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
497
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
498 // =============================================================================
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
499 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
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
500 // =============================================================================
106
46e4202a44fc Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents: 105
diff changeset
501 void GLRenderer::compileObjects () {
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
502 objLists.clear ();
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
503
147
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
504 g_objOffset[0] = -(g_BBox.v0[X] + g_BBox.v1[X]) / 2;
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
505 g_objOffset[1] = -(g_BBox.v0[Y] + g_BBox.v1[Y]) / 2;
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
506 g_objOffset[2] = -(g_BBox.v0[Z] + g_BBox.v1[Z]) / 2;
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
507 g_storedBBoxSize = g_BBox.size ();
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
508
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
509 if (!g_CurrentFile) {
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
510 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
511 return;
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
512 }
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
513
106
46e4202a44fc Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents: 105
diff changeset
514 for (LDObject* obj : g_CurrentFile->objects) {
107
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
515 GLuint* upaLists[2] = {
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
516 &obj->uGLList,
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
517 &obj->uGLPickList
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
518 };
106
46e4202a44fc Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents: 105
diff changeset
519
107
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
520 for (GLuint* upMemberList : upaLists) {
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
521 GLuint uList = glGenLists (1);
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
522 glNewList (uList, GL_COMPILE);
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
523
132
577e8e89d8de Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents: 131
diff changeset
524 picking = (upMemberList == &obj->uGLPickList);
107
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
525 compileOneObject (obj);
132
577e8e89d8de Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents: 131
diff changeset
526 picking = false;
107
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
527
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
528 glEndList ();
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
529 *upMemberList = uList;
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
530 }
106
46e4202a44fc Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents: 105
diff changeset
531
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
532 objLists.push_back (obj->uGLList);
106
46e4202a44fc Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents: 105
diff changeset
533 }
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
534 }
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
535
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
536 // =============================================================================
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
537 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
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
538 // =============================================================================
106
46e4202a44fc Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents: 105
diff changeset
539 template<class T> void GLRenderer::compileSubObject (LDObject* obj,
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
540 const GLenum eGLType, const short dVerts)
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
541 {
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
542 T* newobj = static_cast<T*> (obj);
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
543 glBegin (eGLType);
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
544
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
545 for (short i = 0; i < dVerts; ++i)
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
546 compileVertex (newobj->vaCoords[i]);
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
547
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
548 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
549 }
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
550
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
551 // =============================================================================
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
552 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
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
553 // =============================================================================
106
46e4202a44fc Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents: 105
diff changeset
554 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
555 setObjectColor (obj);
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
556
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
557 switch (obj->getType ()) {
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
558 case OBJ_Line:
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
559 compileSubObject<LDLine> (obj, GL_LINES, 2);
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
560 break;
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
561
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
562 case OBJ_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
563 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
564 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
565
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
566 compileSubObject<LDCondLine> (obj, GL_LINES, 2);
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
567
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
568 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
569 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
570
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
571 case OBJ_Triangle:
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
572 compileSubObject<LDTriangle> (obj, GL_TRIANGLES, 3);
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
573 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
574
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
575 case OBJ_Quad:
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
576 compileSubObject<LDQuad> (obj, GL_QUADS, 4);
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
577 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
578
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
579 case OBJ_Subfile:
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
580 {
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
581 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
582 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
583
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
584 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
585 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
586 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
587 }
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
588 }
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
589 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
590
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
591 case OBJ_Radial:
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
592 {
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
593 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
594 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
595
70
e6b8dab8f81a Phased out FOREACH macro in favor of C++11-style for iteration.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 69
diff changeset
596 for (LDObject* obj : objs) {
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
597 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
598 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
599 }
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
600 }
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
601 break;
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
602
103
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
603 #if 0
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
604 TODO: find a proper way to draw vertices without having them be affected by zoom.
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
605 case OBJ_Vertex:
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
606 {
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
607 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
608 LDTriangle* pPoly;
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
609 vertex* vPos = &(pVert->vPosition);
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
610 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
611
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
612 #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
613
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
614 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
615 pPoly = new LDTriangle;
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
616 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
617 pPoly->vaCoords[1] = {
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
618 vPos->x + BIPYRAMID_COORD (0),
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
619 vPos->y,
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
620 vPos->z + BIPYRAMID_COORD (1)
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
621 };
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
622
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
623 pPoly->vaCoords[2] = {
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
624 vPos->x + BIPYRAMID_COORD (1),
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
625 vPos->y,
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
626 vPos->z + BIPYRAMID_COORD (2)
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
627 };
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
628
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
629 pPoly->dColor = pVert->dColor;
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
630 compileOneObject (pPoly);
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
631 delete pPoly;
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
632 }
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
633 }
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
634 break;
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
635 #endif // 0
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
636
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
637 default:
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
638 break;
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
639 }
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
640 }
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
641
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
642 // =============================================================================
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
643 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
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
644 // =============================================================================
132
577e8e89d8de Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents: 131
diff changeset
645 void GLRenderer::compileVertex (vertex& vert) {
60
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 59
diff changeset
646 glVertex3d (
147
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
647 (vert[X] + g_objOffset[0]) / g_storedBBoxSize,
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
648 -(vert[Y] + g_objOffset[1]) / g_storedBBoxSize,
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
649 -(vert[Z] + g_objOffset[2]) / g_storedBBoxSize);
60
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 59
diff changeset
650 }
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 59
diff changeset
651
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
652 // =============================================================================
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
653 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
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
654 // =============================================================================
132
577e8e89d8de Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents: 131
diff changeset
655 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
656 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
657 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
658 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
659 angle -= 360.0;
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
660 }
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
661
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
662 // =============================================================================
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
663 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
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
664 // =============================================================================
132
577e8e89d8de Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents: 131
diff changeset
665 void GLRenderer::mouseReleaseEvent (QMouseEvent* ev) {
133
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
666 if ((lastButtons & Qt::LeftButton) && !(ev->buttons() & Qt::LeftButton)) {
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
667 if (!rangepick)
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
668 addpick = (keymods & Qt::ControlModifier);
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
669
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
670 if (totalmove < 10 || rangepick)
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
671 pick (ev->x (), ev->y ());
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
672
133
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
673 rangepick = false;
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
674 totalmove = 0;
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
675 }
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
676 }
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
677
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
678 // =============================================================================
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
679 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
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
680 // =============================================================================
132
577e8e89d8de Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents: 131
diff changeset
681 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
682 if (ev->buttons () & Qt::LeftButton)
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
683 totalmove = 0;
133
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
684
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
685 if (ev->modifiers () & Qt::ShiftModifier) {
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
686 rangepick = true;
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
687 rangeStart.setX (ev->x ());
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
688 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
689
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
690 addpick = (keymods & Qt::ControlModifier);
133
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
691 }
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
692
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
693 lastButtons = ev->buttons ();
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
694 }
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
695
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
696 // =============================================================================
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
697 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
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
698 // =============================================================================
132
577e8e89d8de Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents: 131
diff changeset
699 void GLRenderer::mouseMoveEvent (QMouseEvent* ev) {
145
ddf24c380be6 Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 144
diff changeset
700 mouseX = pos.x ();
ddf24c380be6 Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 144
diff changeset
701 mouseY = pos.y ();
ddf24c380be6 Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 144
diff changeset
702
133
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
703 int dx = ev->x () - pos.x ();
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
704 int dy = ev->y () - pos.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
705 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
706
133
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
707 if (ev->buttons () & Qt::LeftButton && !rangepick) {
132
577e8e89d8de Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents: 131
diff changeset
708 rotX = rotX + (dy);
577e8e89d8de Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents: 131
diff changeset
709 rotY = rotY + (dx);
133
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
710
132
577e8e89d8de Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents: 131
diff changeset
711 clampAngle (rotX);
577e8e89d8de Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents: 131
diff changeset
712 clampAngle (rotY);
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
713 }
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
714
132
577e8e89d8de Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents: 131
diff changeset
715 if (ev->buttons () & Qt::MidButton) {
145
ddf24c380be6 Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 144
diff changeset
716 panX += 0.03f * dx * (zoom / 7.5f);
ddf24c380be6 Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 144
diff changeset
717 panY -= 0.03f * dy * (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
718 }
577e8e89d8de Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents: 131
diff changeset
719
149
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
720 // Start the tool tip timer
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
721 if (!drawToolTip)
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
722 toolTipTimer->start (1000);
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
723
133
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
724 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
725 update ();
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
726 }
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
727
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
728 // =============================================================================
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
729 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
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
730 // =============================================================================
132
577e8e89d8de Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents: 131
diff changeset
731 void GLRenderer::keyPressEvent (QKeyEvent* ev) {
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
732 keymods = ev->modifiers ();
107
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
733 }
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
734
132
577e8e89d8de Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents: 131
diff changeset
735 void GLRenderer::keyReleaseEvent (QKeyEvent* ev) {
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
736 keymods = ev->modifiers ();
107
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
737 }
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
738
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
739 // =============================================================================
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
740 void GLRenderer::wheelEvent (QWheelEvent* ev) {
145
ddf24c380be6 Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 144
diff changeset
741 zoom *= (ev->delta () < 0) ? 1.2f : (1.0f / 1.2f);
132
577e8e89d8de Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents: 131
diff changeset
742 zoom = clamp (zoom, 0.01, 100.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
743
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
744 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
745 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
746 }
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
747
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
748 // =============================================================================
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
749 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
750 Q_UNUSED (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
751 drawToolTip = false;
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
752 toolTipTimer->stop ();
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
753 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
754 }
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
755
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
756 // =============================================================================
154
cc53e5cbad54 Added context menu and uncolorize action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 153
diff changeset
757 void GLRenderer::contextMenuEvent (QContextMenuEvent* ev) {
cc53e5cbad54 Added context menu and uncolorize action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 153
diff changeset
758 g_ForgeWindow->spawnContextMenu (ev->globalPos ());
cc53e5cbad54 Added context menu and uncolorize action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 153
diff changeset
759 }
cc53e5cbad54 Added context menu and uncolorize action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 153
diff changeset
760
cc53e5cbad54 Added context menu and uncolorize action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 153
diff changeset
761 // =============================================================================
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
762 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
763 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
764 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
765 }
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
766
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
767 // =============================================================================
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
768 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
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
769 // =============================================================================
108
351aef26f444 More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 107
diff changeset
770 void GLRenderer::updateSelFlash () {
135
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 134
diff changeset
771 if (gl_selflash && g_ForgeWindow->sel.size() > 0) {
147
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
772 pulseTimer->start (g_pulseInterval);
291a1fe2d278 Further work on constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents: 146
diff changeset
773 g_pulseTick = 0;
109
f40b35142586 Improved shared selection handling; added select by color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
774 } else
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
775 pulseTimer->stop ();
108
351aef26f444 More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 107
diff changeset
776 }
351aef26f444 More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 107
diff changeset
777
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
778 // =============================================================================
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
779 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
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
780 // =============================================================================
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
781 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
782 // Check if we selected a camera icon
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
783 if (!rangepick) {
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
784 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
785
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
786 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
787 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
788 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
789 update ();
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
790 return;
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
791 }
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
792 }
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
793 }
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
794
133
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
795 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
796 LDObject* removedObject = null;
133
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
797
134
7fd0784471df Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 133
diff changeset
798 // Clear the selection if we do not wish to add to it.
148
ecfbb598db14 Added icons to the renderer for switching between cameras. It works! Yay!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 147
diff changeset
799 if (!addpick) {
135
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 134
diff changeset
800 std::vector<LDObject*> paOldSelection = g_ForgeWindow->sel;
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 134
diff changeset
801 g_ForgeWindow->sel.clear ();
107
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
802
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
803 // Recompile the prior selection to remove the highlight color
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
804 for (LDObject* obj : paOldSelection)
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
805 recompileObject (obj);
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
806 }
105
53f95a6e351d Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
807
133
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
808 picking = true;
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
809
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
810 // Paint the picking scene
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
811 glDisable (GL_DITHER);
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
812 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
813 drawGLScene ();
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
814
133
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
815 glGetIntegerv (GL_VIEWPORT, viewport);
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
816
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
817 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
818 y0 = mouseY;
133
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
819 short x1, y1;
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
820
134
7fd0784471df Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 133
diff changeset
821 // 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
822 // the area given, with single pixel picking, we use an 1 x 1 area.
133
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
823 if (rangepick) {
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
824 x1 = rangeStart.x ();
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
825 y1 = rangeStart.y ();
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
826 } else {
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
827 x1 = x0 + 1;
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
828 y1 = y0 + 1;
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
829 }
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
830
134
7fd0784471df Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 133
diff changeset
831 // 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
832 if (x0 > x1)
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
833 dataswap (x0, x1);
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
834
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
835 if (y0 > y1)
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
836 dataswap (y0, y1);
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
837
133
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
838 // 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
839 x0 = max<short> (0, x0);
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
840 y0 = max<short> (0, y0);
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
841 x1 = min<short> (x1, width);
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
842 y1 = min<short> (y1, height);
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
843
134
7fd0784471df Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 133
diff changeset
844 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
845 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
846 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
847
134
7fd0784471df Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 133
diff changeset
848 // 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
849 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
850 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
851
133
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
852 assert (viewport[3] == height);
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
853
134
7fd0784471df Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 133
diff changeset
854 // 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
855 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
856
134
7fd0784471df Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 133
diff changeset
857 // 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
858 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
859 uint32 idx =
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
860 (*(pixelptr) * 0x10000) +
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
861 (*(pixelptr + 1) * 0x00100) +
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
862 (*(pixelptr + 2) * 0x00001);
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
863 pixelptr += 4;
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
864
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
865 if (idx == 0xFFFFFF)
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
866 continue; // White is background; skip
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
867
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
868 LDObject* obj = g_CurrentFile->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
869
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
870 // 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
871 // we remove it from selection instead.
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
872 if (!rangepick && addpick) {
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
873 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
874
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
875 for (ulong i = 0; i < g_ForgeWindow->sel.size(); ++i) {
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
876 if (g_ForgeWindow->sel[i] == 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
877 g_ForgeWindow->sel.erase (g_ForgeWindow->sel.begin () + i);
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
878 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
879 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
880 }
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
881 }
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
882
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
883 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
884 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
885 }
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
886
135
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 134
diff changeset
887 g_ForgeWindow->sel.push_back (obj);
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
888 }
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
889
133
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
890 delete[] pixeldata;
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
891
134
7fd0784471df Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 133
diff changeset
892 // 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
893 // sorted first.
135
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 134
diff changeset
894 std::vector<LDObject*>& sel = g_ForgeWindow->sel;
133
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
895 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
896 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
897 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
898
134
7fd0784471df Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 133
diff changeset
899 // Update everything now.
109
f40b35142586 Improved shared selection handling; added select by color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
900 g_ForgeWindow->buildObjList ();
106
46e4202a44fc Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents: 105
diff changeset
901
132
577e8e89d8de Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents: 131
diff changeset
902 picking = false;
133
5a8073d713a3 Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 132
diff changeset
903 rangepick = false;
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
904 glEnable (GL_DITHER);
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
905
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
906 setBackground ();
108
351aef26f444 More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 107
diff changeset
907 updateSelFlash ();
107
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
908
135
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 134
diff changeset
909 for (LDObject* obj : g_ForgeWindow->sel)
107
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
910 recompileObject (obj);
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
911
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
912 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
913 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
914
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
915 drawGLScene ();
107
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
916 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
917 update ();
106
46e4202a44fc Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents: 105
diff changeset
918 }
46e4202a44fc Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents: 105
diff changeset
919
46e4202a44fc Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents: 105
diff changeset
920 // ========================================================================= //
46e4202a44fc Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents: 105
diff changeset
921 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46e4202a44fc Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents: 105
diff changeset
922 // ========================================================================= //
107
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
923 void GLRenderer::recompileObject (LDObject* obj) {
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
924 // Replace the old list with the new one.
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
925 for (ulong i = 0; i < objLists.size(); ++i)
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
926 if (objLists[i] == obj->uGLList)
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
927 objLists.erase (objLists.begin() + i);
107
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
928
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
929 GLuint uList = glGenLists (1);
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
930 glNewList (uList, GL_COMPILE);
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
931
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
932 compileOneObject (obj);
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
933
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
934 glEndList ();
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
935 objLists.push_back (uList);
107
195aa036da7f Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents: 106
diff changeset
936 obj->uGLList = uList;
106
46e4202a44fc Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents: 105
diff changeset
937 }
46e4202a44fc Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents: 105
diff changeset
938
132
577e8e89d8de Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents: 131
diff changeset
939 // =============================================================================
143
e3c37b950a68 Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents: 137
diff changeset
940 uchar* GLRenderer::screencap (ushort& w, ushort& h) {
e3c37b950a68 Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents: 137
diff changeset
941 w = width;
e3c37b950a68 Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents: 137
diff changeset
942 h = height;
e3c37b950a68 Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents: 137
diff changeset
943 uchar* cap = new uchar[4 * w * h];
155
e21c24bfcdf3 Added select all
Santeri Piippo <crimsondusk64@gmail.com>
parents: 154
diff changeset
944
e21c24bfcdf3 Added select all
Santeri Piippo <crimsondusk64@gmail.com>
parents: 154
diff changeset
945 screencapping = 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
946 update ();
155
e21c24bfcdf3 Added select all
Santeri Piippo <crimsondusk64@gmail.com>
parents: 154
diff changeset
947 screencapping = false;
143
e3c37b950a68 Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents: 137
diff changeset
948
e3c37b950a68 Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents: 137
diff changeset
949 // Capture the pixels
e3c37b950a68 Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents: 137
diff changeset
950 glReadPixels (0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, cap);
e3c37b950a68 Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents: 137
diff changeset
951
e3c37b950a68 Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents: 137
diff changeset
952 // Restore the background
e3c37b950a68 Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents: 137
diff changeset
953 setBackground ();
e3c37b950a68 Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents: 137
diff changeset
954
e3c37b950a68 Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents: 137
diff changeset
955 return cap;
149
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
956 }
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
957
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
958 // =============================================================================
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
959 void GLRenderer::slot_timerUpdate () {
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
960 ++g_pulseTick %= g_numPulseTicks;
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
961
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
962 for (LDObject* obj : g_ForgeWindow->sel)
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
963 recompileObject (obj);
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
964
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
965 update ();
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
966 }
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
967
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
968 // =============================================================================
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
969 void GLRenderer::slot_toolTipTimer () {
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
970 // 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
971 // 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
972 // a tooltip.
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
973 for (CameraIcon& icon : g_CameraIcons) {
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
974 if (icon.destRect.contains (QPoint (mouseX, mouseY))) {
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
975 toolTipCamera = icon.cam;
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
976 drawToolTip = true;
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
977 update ();
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
978 break;
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
979 }
96b14d5e7365 Corrected camera icon order (and association), added tool tips
Santeri Piippo <crimsondusk64@gmail.com>
parents: 148
diff changeset
980 }
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
981 }

mercurial