Sat, 27 Apr 2013 16:22:35 +0300
Base work regarding constrained cameras
30
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
1 | /* |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
104 | 3 | * Copyright (C) 2013 Santeri Piippo |
30
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
4 | * |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
8 | * (at your option) any later version. |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
9 | * |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
13 | * GNU General Public License for more details. |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
14 | * |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
17 | */ |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
18 | |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | #include <QtGui> |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | #include <QGLWidget> |
46
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
21 | #include <GL/glu.h> |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | #include "common.h" |
69
6790dea720a8
Simplified configuration code. Use a std::vector object to contain config pointers and have config objects register themselves upon creation instead of relying on a cfgdefs.h. Removed sections, all configurations are just simply written one after another now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
68
diff
changeset
|
23 | #include "config.h" |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | #include "file.h" |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | #include "gldraw.h" |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | #include "bbox.h" |
52
d71226763607
Colorized polygons now appear colorized in the list view (unless disabled). GL rendered now draws transparent polygons properly.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
47
diff
changeset
|
27 | #include "colors.h" |
104 | 28 | #include "gui.h" |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
29 | #include "misc.h" |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | |
60
961663d05463
Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents:
59
diff
changeset
|
31 | static double g_faObjectOffset[3]; |
961663d05463
Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents:
59
diff
changeset
|
32 | static double g_StoredBBoxSize; |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
33 | |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
34 | static short g_dPulseTick = 0; |
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
35 | static const short g_dNumPulseTicks = 8; |
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
36 | static const short g_dPulseInterval = 65; |
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
37 | |
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
|
38 | 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
|
39 | 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
|
40 | 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
|
41 | 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
|
42 | 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
|
43 | cfg (bool, gl_selflash, false); |
69
6790dea720a8
Simplified configuration code. Use a std::vector object to contain config pointers and have config objects register themselves upon creation instead of relying on a cfgdefs.h. Removed sections, all configurations are just simply written one after another now.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
68
diff
changeset
|
44 | |
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
|
45 | // ============================================================================= |
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
|
46 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
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
|
47 | // ============================================================================= |
132
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
48 | 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
|
49 | resetAngles (); |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
50 | picking = rangepick = false; |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
51 | |
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
|
52 | 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
|
53 | connect (pulseTimer, SIGNAL (timeout ()), this, SLOT (slot_timerUpdate ())); |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
54 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
55 | |
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
|
56 | // ============================================================================= |
132
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
57 | 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
|
58 | 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
|
59 | 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
|
60 | panX = panY = rotZ = 0.0f; |
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
61 | zoom = 1.0f; |
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
62 | } |
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
63 | |
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
64 | // ============================================================================= |
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
|
65 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
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
|
66 | // ============================================================================= |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
67 | void GLRenderer::initializeGL () { |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
68 | glLoadIdentity(); |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
69 | glMatrixMode (GL_MODELVIEW); |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
70 | |
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
|
71 | 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
|
72 | |
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
|
73 | 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
|
74 | glPolygonOffset (1.0f, 1.0f); |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
75 | |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
76 | glEnable (GL_DEPTH_TEST); |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
77 | glShadeModel (GL_SMOOTH); |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
78 | glEnable (GL_MULTISAMPLE); |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
79 | |
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
|
80 | 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
|
81 | 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
|
82 | |
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
|
83 | 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
|
84 | 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
|
85 | |
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
|
86 | 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
|
87 | |
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
|
88 | 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
|
89 | setFocusPolicy (Qt::WheelFocus); |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
90 | compileObjects (); |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
91 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
92 | |
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
|
93 | // ============================================================================= |
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
|
94 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
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
|
95 | // ============================================================================= |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
96 | 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
|
97 | 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
|
98 | |
47
9dd536c1ce39
Made the GL renderer actually use the main color configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
99 | if (!col.isValid ()) |
119 | 100 | return QColor (0, 0, 0); // shouldn't happen |
47
9dd536c1ce39
Made the GL renderer actually use the main color configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
101 | |
105
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
102 | col.setAlpha (gl_maincolor_alpha * 255.f); |
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
103 | 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
|
104 | } |
c637b172d565
Further fixes to bad color handling. Allow main color be represented with arbitrary transparency.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
67
diff
changeset
|
105 | |
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
|
106 | // ----------------------------------------------------------------------------- |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
107 | 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
|
108 | 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
|
109 | |
c637b172d565
Further fixes to bad color handling. Allow main color be represented with arbitrary transparency.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
67
diff
changeset
|
110 | 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
|
111 | 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
|
112 | |
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
|
113 | 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
|
114 | |
144
b2b8b45f6f5f
Fixed view going blank after resize
Santeri Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
115 | col.setAlpha (255); |
b2b8b45f6f5f
Fixed view going blank after resize
Santeri Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
116 | qglClearColor (col); |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
117 | } |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
118 | |
120
607301744394
Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
119
diff
changeset
|
119 | // ============================================================================= |
607301744394
Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
119
diff
changeset
|
120 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
607301744394
Rotation and rounding. Rotation needs work to get proper origin stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
119
diff
changeset
|
121 | // ============================================================================= |
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
|
122 | 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
|
123 | void GLRenderer::setObjectColor (LDObject* obj) { |
105
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
124 | QColor qCol; |
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
125 | |
132
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
126 | if (picking) { |
104 | 127 | // Make the color by the object's index color if we're picking, so we can |
128 | // make the index from the color we get from the picking results. | |
129 | long i = obj->getIndex (g_CurrentFile); | |
130 | ||
131 | // If we couldn't find the index, this object must not be from this file, | |
132 | // therefore it must be an object inlined from another file through a | |
133 | // subfile reference. Use the reference's index. | |
134 | if (i == -1) | |
135 | i = obj->topLevelParent ()->getIndex (g_CurrentFile); | |
136 | ||
137 | // We should have the index now. | |
138 | assert (i != -1); | |
139 | ||
140 | // Calculate a color based from this index. This method caters for | |
141 | // 16777216 objects. I don't think that'll be exceeded anytime soon. :) | |
142 | // 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
|
143 | 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
|
144 | g = (i / 256) % 256, |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
145 | b = i % 256; |
104 | 146 | |
147 | glColor3f (r / 255.f, g / 255.f, b / 255.f); | |
148 | return; | |
149 | } | |
150 | ||
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
|
151 | 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
|
152 | 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
|
153 | |
104 | 154 | #if 0 |
54
60f328f352c9
Done the rendering end of the red/green BFC view
Santeri Piippo <crimsondusk64@gmail.com>
parents:
53
diff
changeset
|
155 | if (gl_colorbfc && |
60f328f352c9
Done the rendering end of the red/green BFC view
Santeri Piippo <crimsondusk64@gmail.com>
parents:
53
diff
changeset
|
156 | obj->getType () != OBJ_Line && |
60f328f352c9
Done the rendering end of the red/green BFC view
Santeri Piippo <crimsondusk64@gmail.com>
parents:
53
diff
changeset
|
157 | obj->getType () != OBJ_CondLine) |
60f328f352c9
Done the rendering end of the red/green BFC view
Santeri Piippo <crimsondusk64@gmail.com>
parents:
53
diff
changeset
|
158 | { |
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
|
159 | if (bBackSide) |
54
60f328f352c9
Done the rendering end of the red/green BFC view
Santeri Piippo <crimsondusk64@gmail.com>
parents:
53
diff
changeset
|
160 | 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
|
161 | else |
60f328f352c9
Done the rendering end of the red/green BFC view
Santeri Piippo <crimsondusk64@gmail.com>
parents:
53
diff
changeset
|
162 | 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
|
163 | return; |
60f328f352c9
Done the rendering end of the red/green BFC view
Santeri Piippo <crimsondusk64@gmail.com>
parents:
53
diff
changeset
|
164 | } |
104 | 165 | #endif |
54
60f328f352c9
Done the rendering end of the red/green BFC view
Santeri Piippo <crimsondusk64@gmail.com>
parents:
53
diff
changeset
|
166 | |
105
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
167 | if (obj->dColor == dMainColor) |
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
168 | qCol = getMainColor (); |
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
169 | else { |
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
170 | color* col = getColor (obj->dColor); |
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
171 | |
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
172 | if (col != null) |
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
173 | qCol = col->qColor; |
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
174 | else { |
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
175 | // 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
|
176 | // not appear pitch-black. |
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
177 | qCol = getMainColor (); |
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
178 | |
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
179 | // 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
|
180 | for (short i : g_daWarnedColors) |
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
181 | if (obj->dColor == i) |
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
182 | return; |
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
183 | |
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
184 | 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
|
185 | g_daWarnedColors.push_back (obj->dColor); |
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
186 | return; |
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
187 | } |
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
|
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 | |
105
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
190 | long r = qCol.red (), |
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
191 | g = qCol.green (), |
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
192 | b = qCol.blue (), |
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
193 | 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
|
194 | |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
195 | // 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
|
196 | if (g_ForgeWindow->isSelected (obj)) { |
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
197 | short dTick, dNumTicks; |
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
198 | |
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
199 | if (gl_selflash) { |
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
200 | dTick = (g_dPulseTick < (g_dNumPulseTicks / 2)) ? g_dPulseTick : (g_dNumPulseTicks - g_dPulseTick); |
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
201 | dNumTicks = g_dNumPulseTicks; |
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
202 | } else { |
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
203 | dTick = 2; |
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
204 | dNumTicks = 5; |
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
205 | } |
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
206 | |
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
207 | const long lAdd = ((dTick * 128) / dNumTicks); |
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
208 | r = min (r + lAdd, 255l); |
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
209 | g = min (g + lAdd, 255l); |
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
210 | b = min (b + lAdd, 255l); |
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
211 | |
108
351aef26f444
More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
212 | // 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
|
213 | } |
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
|
214 | |
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
|
215 | glColor4f ( |
105
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
216 | ((double) r) / 255.0f, |
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
217 | ((double) g) / 255.0f, |
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
218 | ((double) b) / 255.0f, |
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
219 | ((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
|
220 | } |
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
|
221 | |
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
|
222 | // ============================================================================= |
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
|
223 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
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
|
224 | // ============================================================================= |
108
351aef26f444
More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
225 | void GLRenderer::refresh () { |
351aef26f444
More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
226 | paintGL (); |
351aef26f444
More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
227 | swapBuffers (); |
351aef26f444
More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
228 | } |
351aef26f444
More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
229 | |
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
|
230 | // ============================================================================= |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
231 | void GLRenderer::hardRefresh () { |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
232 | compileObjects (); |
108
351aef26f444
More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
233 | 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
|
234 | |
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
|
235 | glLineWidth (gl_linethickness); |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
236 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
237 | |
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
|
238 | // ============================================================================= |
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
|
239 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
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
|
240 | // ============================================================================= |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
241 | 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
|
242 | width = w; |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
243 | height = h; |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
244 | |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
245 | glViewport (0, 0, w, h); |
144
b2b8b45f6f5f
Fixed view going blank after resize
Santeri Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
246 | 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
|
247 | glLoadIdentity (); |
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
|
248 | gluPerspective (45.0f, (double)w / (double)h, 0.1f, 100.0f); |
144
b2b8b45f6f5f
Fixed view going blank after resize
Santeri Piippo <crimsondusk64@gmail.com>
parents:
143
diff
changeset
|
249 | glMatrixMode (GL_MODELVIEW); |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
250 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
251 | |
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
|
252 | // ============================================================================= |
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
|
253 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
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
|
254 | // ============================================================================= |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
255 | void GLRenderer::paintGL () { |
145
ddf24c380be6
Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
256 | if (g_CurrentFile == null) |
ddf24c380be6
Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
257 | return; |
ddf24c380be6
Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
258 | |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
259 | glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
145
ddf24c380be6
Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
260 | |
ddf24c380be6
Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
261 | glMatrixMode (GL_PROJECTION); |
ddf24c380be6
Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
262 | |
ddf24c380be6
Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
263 | glPushMatrix (); |
ddf24c380be6
Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
264 | glLoadIdentity (); |
ddf24c380be6
Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
265 | |
ddf24c380be6
Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
266 | double x = zoom; |
ddf24c380be6
Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
267 | double y = (height * x) / width; |
ddf24c380be6
Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
268 | |
ddf24c380be6
Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
269 | glOrtho (-x, x, -y, y, -100.0, 100.0); |
ddf24c380be6
Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
270 | |
ddf24c380be6
Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
271 | glTranslatef (panX, panY, -5.0f); |
ddf24c380be6
Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
272 | glRotatef (90.f, 0.0f, 1.0f, 0.0f); |
ddf24c380be6
Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
273 | |
ddf24c380be6
Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
274 | for (LDObject* obj : g_CurrentFile->objects) |
ddf24c380be6
Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
275 | glCallList ((picking == false) ? obj->uGLList : obj->uGLPickList); |
ddf24c380be6
Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
276 | glPopMatrix (); |
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
|
277 | glMatrixMode (GL_MODELVIEW); |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
278 | |
145
ddf24c380be6
Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
279 | #if 0 |
ddf24c380be6
Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
280 | glMatrixMode (GL_MODELVIEW); |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
281 | |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
282 | glPushMatrix (); |
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
|
283 | glLoadIdentity (); |
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
|
284 | |
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
|
285 | glTranslatef (0.0f, 0.0f, -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
|
286 | glTranslatef (panX, panY, -zoom); |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
287 | |
132
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
288 | glRotatef (rotX, 1.0f, 0.0f, 0.0f); |
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
289 | glRotatef (rotY, 0.0f, 1.0f, 0.0f); |
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
290 | glRotatef (rotZ, 0.0f, 0.0f, 1.0f); |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
291 | |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
292 | for (LDObject* obj : g_CurrentFile->objects) |
132
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
293 | glCallList ((picking == false) ? obj->uGLList : obj->uGLPickList); |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
294 | glPopMatrix (); |
145
ddf24c380be6
Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
295 | #endif |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
296 | |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
297 | // 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
|
298 | if (rangepick && !picking) { |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
299 | const short x0 = rangeStart.x (), |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
300 | y0 = rangeStart.y (), |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
301 | x1 = pos.x (), |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
302 | y1 = pos.y (); |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
303 | |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
304 | glMatrixMode (GL_PROJECTION); |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
305 | |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
306 | glPushMatrix (); |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
307 | glLoadIdentity (); |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
308 | glOrtho (.0, width, height, .0, -1.0, 1.0); |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
309 | |
135
c243df39913e
Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
134
diff
changeset
|
310 | for (int x : {GL_QUADS, GL_LINE_LOOP}) { |
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
|
311 | if (x == GL_QUADS) { |
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
|
312 | // Use a green color when picking additive, a blue color when normally. |
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
|
313 | if (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
|
314 | glColor4f (0.5f, 1.f, 0.f, 0.2f); |
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
|
315 | else |
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
|
316 | glColor4f (0.f, 0.8f, 1.f, 0.2f); |
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
|
317 | } else { |
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
|
318 | if (darkbg) |
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
|
319 | glColor4f (1.f, 1.f, 1.f, 0.7f); |
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
|
320 | else |
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
|
321 | glColor4f (0.f, 0.f, 0.f, 0.7f); |
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
|
322 | } |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
323 | |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
324 | glBegin (x); |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
325 | glVertex2i (x0, y0); |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
326 | glVertex2i (x1, y0); |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
327 | glVertex2i (x1, y1); |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
328 | glVertex2i (x0, y1); |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
329 | glEnd (); |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
330 | } |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
331 | glPopMatrix (); |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
332 | |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
333 | glMatrixMode (GL_MODELVIEW); |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
334 | } |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
335 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
336 | |
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
|
337 | // ============================================================================= |
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
|
338 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
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
|
339 | // ============================================================================= |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
340 | 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
|
341 | objLists.clear (); |
104 | 342 | |
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
|
343 | g_faObjectOffset[0] = -(g_BBox.v0.x + g_BBox.v1.x) / 2; |
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
|
344 | g_faObjectOffset[1] = -(g_BBox.v0.y + g_BBox.v1.y) / 2; |
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
|
345 | g_faObjectOffset[2] = -(g_BBox.v0.z + g_BBox.v1.z) / 2; |
121
7e87c85ad092
Rotation improvements; allow radials be inlined
Santeri Piippo <crimsondusk64@gmail.com>
parents:
120
diff
changeset
|
346 | 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
|
347 | |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
348 | if (!g_CurrentFile) { |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
349 | 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
|
350 | return; |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
351 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
352 | |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
353 | for (LDObject* obj : g_CurrentFile->objects) { |
107
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
354 | GLuint* upaLists[2] = { |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
355 | &obj->uGLList, |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
356 | &obj->uGLPickList |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
357 | }; |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
358 | |
107
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
359 | for (GLuint* upMemberList : upaLists) { |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
360 | GLuint uList = glGenLists (1); |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
361 | glNewList (uList, GL_COMPILE); |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
362 | |
132
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
363 | picking = (upMemberList == &obj->uGLPickList); |
107
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
364 | 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
|
365 | picking = false; |
107
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
366 | |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
367 | glEndList (); |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
368 | *upMemberList = uList; |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
369 | } |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
370 | |
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
|
371 | 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
|
372 | } |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
373 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
374 | |
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
|
375 | // ============================================================================= |
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 | // ============================================================================= |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
378 | template<class T> void GLRenderer::compileSubObject (LDObject* obj, |
104 | 379 | 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
|
380 | { |
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
|
381 | 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
|
382 | 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
|
383 | |
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
|
384 | 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
|
385 | 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
|
386 | |
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
|
387 | 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
|
388 | } |
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
|
389 | |
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
|
390 | // ============================================================================= |
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
|
391 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
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
|
392 | // ============================================================================= |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
393 | 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
|
394 | setObjectColor (obj); |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
395 | |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
396 | switch (obj->getType ()) { |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
397 | case OBJ_Line: |
104 | 398 | 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
|
399 | break; |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
400 | |
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
|
401 | 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
|
402 | 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
|
403 | 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
|
404 | |
104 | 405 | 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
|
406 | |
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
|
407 | 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
|
408 | 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
|
409 | |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
410 | case OBJ_Triangle: |
104 | 411 | 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
|
412 | 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
|
413 | |
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
|
414 | case OBJ_Quad: |
104 | 415 | 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
|
416 | 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
|
417 | |
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
|
418 | case OBJ_Subfile: |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
419 | { |
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
|
420 | 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
|
421 | 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
|
422 | |
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
|
423 | 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
|
424 | 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
|
425 | 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
|
426 | } |
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
|
427 | } |
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
|
428 | 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
|
429 | |
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
|
430 | 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
|
431 | { |
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
|
432 | 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
|
433 | 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
|
434 | |
70
e6b8dab8f81a
Phased out FOREACH macro in favor of C++11-style for iteration.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
69
diff
changeset
|
435 | for (LDObject* obj : objs) { |
104 | 436 | 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
|
437 | 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
|
438 | } |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
439 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
440 | break; |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
441 | |
103
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
442 | #if 0 |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
443 | 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
|
444 | case OBJ_Vertex: |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
445 | { |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
446 | 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
|
447 | LDTriangle* pPoly; |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
448 | vertex* vPos = &(pVert->vPosition); |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
449 | 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
|
450 | |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
451 | #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
|
452 | |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
453 | 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
|
454 | pPoly = new LDTriangle; |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
455 | 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
|
456 | pPoly->vaCoords[1] = { |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
457 | vPos->x + BIPYRAMID_COORD (0), |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
458 | vPos->y, |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
459 | vPos->z + BIPYRAMID_COORD (1) |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
460 | }; |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
461 | |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
462 | pPoly->vaCoords[2] = { |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
463 | vPos->x + BIPYRAMID_COORD (1), |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
464 | vPos->y, |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
465 | vPos->z + BIPYRAMID_COORD (2) |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
466 | }; |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
467 | |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
468 | pPoly->dColor = pVert->dColor; |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
469 | compileOneObject (pPoly); |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
470 | delete pPoly; |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
471 | } |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
472 | } |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
473 | break; |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
474 | #endif // 0 |
b0a345196435
Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents:
72
diff
changeset
|
475 | |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
476 | default: |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
477 | break; |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
478 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
479 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
480 | |
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
|
481 | // ============================================================================= |
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
|
482 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
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
|
483 | // ============================================================================= |
132
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
484 | void GLRenderer::compileVertex (vertex& vert) { |
60
961663d05463
Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents:
59
diff
changeset
|
485 | glVertex3d ( |
132
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
486 | (vert.x + g_faObjectOffset[0]) / g_StoredBBoxSize, |
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
487 | -(vert.y + g_faObjectOffset[1]) / g_StoredBBoxSize, |
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
488 | -(vert.z + g_faObjectOffset[2]) / g_StoredBBoxSize); |
60
961663d05463
Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents:
59
diff
changeset
|
489 | } |
961663d05463
Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents:
59
diff
changeset
|
490 | |
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
|
491 | // ============================================================================= |
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
|
492 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
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
|
493 | // ============================================================================= |
132
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
494 | 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
|
495 | 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
|
496 | 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
|
497 | 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
|
498 | angle -= 360.0; |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
499 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
500 | |
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
|
501 | // ============================================================================= |
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
|
502 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
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
|
503 | // ============================================================================= |
132
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
504 | 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
|
505 | 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
|
506 | 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
|
507 | 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
|
508 | |
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
|
509 | 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
|
510 | pick (ev->x (), ev->y ()); |
104 | 511 | |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
512 | 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
|
513 | totalmove = 0; |
104 | 514 | } |
515 | } | |
516 | ||
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
|
517 | // ============================================================================= |
132
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
518 | 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
|
519 | 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
|
520 | totalmove = 0; |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
521 | |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
522 | if (ev->modifiers () & Qt::ShiftModifier) { |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
523 | rangepick = true; |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
524 | rangeStart.setX (ev->x ()); |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
525 | 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
|
526 | |
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
|
527 | addpick = (keymods & Qt::ControlModifier); |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
528 | } |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
529 | |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
530 | lastButtons = ev->buttons (); |
104 | 531 | } |
532 | ||
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
|
533 | // ============================================================================= |
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
|
534 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
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
|
535 | // ============================================================================= |
132
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
536 | void GLRenderer::mouseMoveEvent (QMouseEvent* ev) { |
145
ddf24c380be6
Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
537 | mouseX = pos.x (); |
ddf24c380be6
Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
538 | mouseY = pos.y (); |
ddf24c380be6
Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
539 | |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
540 | 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
|
541 | 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
|
542 | 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
|
543 | |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
544 | 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
|
545 | 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
|
546 | rotY = rotY + (dx); |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
547 | |
132
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
548 | 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
|
549 | clampAngle (rotY); |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
550 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
551 | |
132
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
552 | if (ev->buttons () & Qt::MidButton) { |
145
ddf24c380be6
Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
553 | panX += 0.03f * dx * (zoom / 7.5f); |
ddf24c380be6
Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
554 | 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
|
555 | } |
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
556 | |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
557 | pos = ev->pos (); |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
558 | updateGL (); |
104 | 559 | } |
560 | ||
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
|
561 | // ============================================================================= |
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
|
562 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
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
|
563 | // ============================================================================= |
132
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
564 | 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
|
565 | keymods = ev->modifiers (); |
107
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
566 | } |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
567 | |
132
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
568 | 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
|
569 | keymods = ev->modifiers (); |
107
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
570 | } |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
571 | |
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
|
572 | // ============================================================================= |
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
|
573 | void GLRenderer::wheelEvent (QWheelEvent* ev) { |
145
ddf24c380be6
Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
574 | printf ("%.5f -> ", zoom); |
ddf24c380be6
Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
575 | // zoom += (-ev->delta () / 100.0); |
ddf24c380be6
Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
576 | zoom *= (ev->delta () < 0) ? 1.2f : (1.0f / 1.2f); |
ddf24c380be6
Base work regarding constrained cameras
Santeri Piippo <crimsondusk64@gmail.com>
parents:
144
diff
changeset
|
577 | printf ("%.5f\n", zoom); |
132
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
578 | zoom = clamp (zoom, 0.01, 100.0); |
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
|
579 | 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
|
580 | updateGL (); |
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
|
581 | } |
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
|
582 | |
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
|
583 | // ============================================================================= |
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
|
584 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
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
|
585 | // ============================================================================= |
108
351aef26f444
More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
586 | void GLRenderer::updateSelFlash () { |
135
c243df39913e
Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
134
diff
changeset
|
587 | if (gl_selflash && g_ForgeWindow->sel.size() > 0) { |
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
|
588 | pulseTimer->start (g_dPulseInterval); |
108
351aef26f444
More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
589 | g_dPulseTick = 0; |
109
f40b35142586
Improved shared selection handling; added select by color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
590 | } 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
|
591 | pulseTimer->stop (); |
108
351aef26f444
More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
592 | } |
351aef26f444
More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
593 | |
351aef26f444
More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
594 | // ========================================================================= // |
351aef26f444
More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
595 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // |
351aef26f444
More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
596 | // ========================================================================= // |
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
|
597 | void GLRenderer::pick (uint mouseX, uint mouseY) { |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
598 | 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
|
599 | LDObject* removedObject = null; |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
600 | |
134
7fd0784471df
Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
133
diff
changeset
|
601 | // Clear the selection if we do not wish to add to it. |
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
|
602 | if (addpick == false) { |
135
c243df39913e
Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
134
diff
changeset
|
603 | std::vector<LDObject*> paOldSelection = g_ForgeWindow->sel; |
c243df39913e
Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
134
diff
changeset
|
604 | g_ForgeWindow->sel.clear (); |
107
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
605 | |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
606 | // Recompile the prior selection to remove the highlight color |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
607 | for (LDObject* obj : paOldSelection) |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
608 | recompileObject (obj); |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
609 | } |
105
53f95a6e351d
Highlight selected objects with a different color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
104
diff
changeset
|
610 | |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
611 | picking = true; |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
612 | |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
613 | // Paint the picking scene |
104 | 614 | glDisable (GL_DITHER); |
615 | glClearColor (1.0f, 1.0f, 1.0f, 1.0f); | |
616 | paintGL (); | |
617 | ||
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
618 | glGetIntegerv (GL_VIEWPORT, viewport); |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
619 | |
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
|
620 | 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
|
621 | y0 = mouseY; |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
622 | short x1, y1; |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
623 | |
134
7fd0784471df
Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
133
diff
changeset
|
624 | // 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
|
625 | // 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
|
626 | if (rangepick) { |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
627 | x1 = rangeStart.x (); |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
628 | y1 = rangeStart.y (); |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
629 | } else { |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
630 | x1 = x0 + 1; |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
631 | y1 = y0 + 1; |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
632 | } |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
633 | |
134
7fd0784471df
Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
133
diff
changeset
|
634 | // 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
|
635 | if (x0 > x1) |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
636 | dataswap (x0, x1); |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
637 | |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
638 | if (y0 > y1) |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
639 | dataswap (y0, y1); |
104 | 640 | |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
641 | // 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
|
642 | x0 = max<short> (0, x0); |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
643 | y0 = max<short> (0, y0); |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
644 | x1 = min<short> (x1, width); |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
645 | y1 = min<short> (y1, height); |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
646 | |
134
7fd0784471df
Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
133
diff
changeset
|
647 | 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
|
648 | 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
|
649 | 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
|
650 | |
134
7fd0784471df
Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
133
diff
changeset
|
651 | // 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
|
652 | 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
|
653 | 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
|
654 | |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
655 | assert (viewport[3] == height); |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
656 | |
134
7fd0784471df
Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
133
diff
changeset
|
657 | // 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
|
658 | 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
|
659 | |
134
7fd0784471df
Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
133
diff
changeset
|
660 | // 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
|
661 | 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
|
662 | uint32 idx = |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
663 | (*(pixelptr) * 0x10000) + |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
664 | (*(pixelptr + 1) * 0x00100) + |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
665 | (*(pixelptr + 2) * 0x00001); |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
666 | pixelptr += 4; |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
667 | |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
668 | if (idx == 0xFFFFFF) |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
669 | continue; // White is background; skip |
104 | 670 | |
671 | 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
|
672 | |
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
|
673 | // 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
|
674 | // 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
|
675 | 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
|
676 | 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
|
677 | |
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
|
678 | 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
|
679 | 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
|
680 | 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
|
681 | 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
|
682 | 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
|
683 | } |
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
|
684 | } |
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
|
685 | |
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
|
686 | 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
|
687 | 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
|
688 | } |
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 | |
135
c243df39913e
Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
134
diff
changeset
|
690 | g_ForgeWindow->sel.push_back (obj); |
104 | 691 | } |
692 | ||
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
693 | delete[] pixeldata; |
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
694 | |
134
7fd0784471df
Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
133
diff
changeset
|
695 | // 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
|
696 | // sorted first. |
135
c243df39913e
Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
134
diff
changeset
|
697 | 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
|
698 | 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
|
699 | 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
|
700 | 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
|
701 | |
134
7fd0784471df
Save the configuration before exiting so that grid choice is preserved.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
133
diff
changeset
|
702 | // Update everything now. |
109
f40b35142586
Improved shared selection handling; added select by color
Santeri Piippo <crimsondusk64@gmail.com>
parents:
108
diff
changeset
|
703 | g_ForgeWindow->buildObjList (); |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
704 | |
132
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
705 | picking = false; |
133
5a8073d713a3
Area selection! This sure was a *pain* to add.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
132
diff
changeset
|
706 | rangepick = false; |
104 | 707 | glEnable (GL_DITHER); |
708 | ||
709 | setBackground (); | |
108
351aef26f444
More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
107
diff
changeset
|
710 | updateSelFlash (); |
107
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
711 | |
135
c243df39913e
Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
134
diff
changeset
|
712 | for (LDObject* obj : g_ForgeWindow->sel) |
107
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
713 | recompileObject (obj); |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
714 | |
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
|
715 | 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
|
716 | 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
|
717 | |
107
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
718 | paintGL (); |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
719 | swapBuffers (); |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
720 | } |
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
721 | |
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
722 | // ========================================================================= // |
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
723 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // |
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
724 | // ========================================================================= // |
107
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
725 | void GLRenderer::recompileObject (LDObject* obj) { |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
726 | // 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
|
727 | 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
|
728 | 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
|
729 | objLists.erase (objLists.begin() + i); |
107
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
730 | |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
731 | GLuint uList = glGenLists (1); |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
732 | glNewList (uList, GL_COMPILE); |
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 | compileOneObject (obj); |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
735 | |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
736 | 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
|
737 | objLists.push_back (uList); |
107
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
738 | obj->uGLList = uList; |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
739 | } |
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
740 | |
132
577e8e89d8de
Added panning to GL view, added action for resetting angles, zoom and pan
Santeri Piippo <crimsondusk64@gmail.com>
parents:
131
diff
changeset
|
741 | // ============================================================================= |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
742 | void GLRenderer::slot_timerUpdate () { |
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
743 | ++g_dPulseTick %= g_dNumPulseTicks; |
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
744 | |
135
c243df39913e
Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
134
diff
changeset
|
745 | for (LDObject* obj : g_ForgeWindow->sel) |
107
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
746 | recompileObject (obj); |
195aa036da7f
Picking improvements
Santeri Piippo <crimsondusk64@gmail.com>
parents:
106
diff
changeset
|
747 | |
106
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
748 | paintGL (); |
46e4202a44fc
Added additive selection blending, with a toggable flash effect. :P
Santeri Piippo <crimsondusk64@gmail.com>
parents:
105
diff
changeset
|
749 | swapBuffers (); |
143
e3c37b950a68
Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
137
diff
changeset
|
750 | } |
e3c37b950a68
Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
137
diff
changeset
|
751 | |
e3c37b950a68
Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
137
diff
changeset
|
752 | // ============================================================================= |
e3c37b950a68
Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
137
diff
changeset
|
753 | uchar* GLRenderer::screencap (ushort& w, ushort& h) { |
e3c37b950a68
Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
137
diff
changeset
|
754 | w = width; |
e3c37b950a68
Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
137
diff
changeset
|
755 | h = height; |
e3c37b950a68
Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
137
diff
changeset
|
756 | uchar* cap = new uchar[4 * w * h]; |
e3c37b950a68
Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
137
diff
changeset
|
757 | paintGL (); |
e3c37b950a68
Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
137
diff
changeset
|
758 | |
e3c37b950a68
Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
137
diff
changeset
|
759 | // Capture the pixels |
e3c37b950a68
Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
137
diff
changeset
|
760 | glReadPixels (0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, cap); |
e3c37b950a68
Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
137
diff
changeset
|
761 | |
e3c37b950a68
Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
137
diff
changeset
|
762 | // Restore the background |
e3c37b950a68
Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
137
diff
changeset
|
763 | setBackground (); |
e3c37b950a68
Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
137
diff
changeset
|
764 | |
e3c37b950a68
Added screencapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
137
diff
changeset
|
765 | return cap; |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
766 | } |