ldtypes.cpp

Sun, 21 Apr 2013 04:17:05 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Sun, 21 Apr 2013 04:17:05 +0300
changeset 120
607301744394
parent 117
7eb7a43a511b
child 127
a6e2067bb2f1
permissions
-rw-r--r--

Rotation and rounding. Rotation needs work to get proper origin stuff

30
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
1 /*
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
2 * LDForge: LDraw parts authoring CAD
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
3 * Copyright (C) 2013 Santeri Piippo
30
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
4 *
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
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: 29
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: 29
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: 29
diff changeset
8 * (at your option) any later version.
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
9 *
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
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: 29
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: 29
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: 29
diff changeset
13 * GNU General Public License for more details.
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
14 *
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
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: 29
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: 29
diff changeset
17 */
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
18
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 #include "common.h"
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 #include "ldtypes.h"
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 24
diff changeset
21 #include "file.h"
18
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
22 #include "misc.h"
108
351aef26f444 More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
23 #include "gui.h"
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24
29
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
25 char const* g_saObjTypeNames[] = {
96
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
26 "subfile",
111
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
27 "radial",
96
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
28 "quadrilateral",
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
29 "triangle",
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
30 "line",
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
31 "condline",
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
32 "vertex",
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
33 "bfc",
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
34 "comment",
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35 "unknown",
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36 "empty",
96
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
37 "unidentified",
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38 };
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39
96
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
40 // Should probably get rid of this array sometime
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 32
diff changeset
41 char const* g_saObjTypeIcons[] = {
96
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
42 "subfile",
111
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
43 "radial",
96
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
44 "quad",
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
45 "triangle",
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
46 "line",
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
47 "condline",
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
48 "vertex",
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
49 "bfc",
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
50 "comment",
41
4ca63da5546b Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 40
diff changeset
51 "error",
4ca63da5546b Added insert vertex function and added vertex icons.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 40
diff changeset
52 "empty",
96
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
53 "error",
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 32
diff changeset
54 };
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 32
diff changeset
55
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
56 // =============================================================================
32
5d22b7ecf110 Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents: 30
diff changeset
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
5d22b7ecf110 Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents: 30
diff changeset
58 // =============================================================================
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
59 // LDObject constructors
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
60 LDObject::LDObject () {
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
61 qObjListEntry = null;
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
62 parent = null;
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
63 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
64
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
65 LDGibberish::LDGibberish () {
50
7fd213c6b844 Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 43
diff changeset
66 dColor = -1;
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
67 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
68
11
323390a03294 Color gibberish red. Check for line code length for gibberish (must be 1 to be valid)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
69 LDGibberish::LDGibberish (str _zContent, str _zReason) {
14
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
70 zContents = _zContent;
11
323390a03294 Color gibberish red. Check for line code length for gibberish (must be 1 to be valid)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
71 zReason = _zReason;
50
7fd213c6b844 Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 43
diff changeset
72 dColor = -1;
11
323390a03294 Color gibberish red. Check for line code length for gibberish (must be 1 to be valid)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
73 }
323390a03294 Color gibberish red. Check for line code length for gibberish (must be 1 to be valid)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
74
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
75 LDEmpty::LDEmpty () {
50
7fd213c6b844 Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 43
diff changeset
76 dColor = -1;
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
77 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
78
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
79 LDComment::LDComment () {
50
7fd213c6b844 Turned the test palette action into a set color action for mass object coloring.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 43
diff changeset
80 dColor = -1;
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
81 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
82
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
83 LDSubfile::LDSubfile () {
111
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
84
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
85 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
86
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
87 LDLine::LDLine () {
111
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
88
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
89 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
90
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
91 LDTriangle::LDTriangle () {
111
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
92
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
93 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
94
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
95 LDQuad::LDQuad () {
111
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
96
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
97 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
98
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
99 LDCondLine::LDCondLine () {
111
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
100
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
101 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
102
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
103 LDVertex::LDVertex () {
111
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
104
13
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
105 }
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
106
73
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
107 LDBFC::LDBFC () {
111
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
108
73
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
109 }
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
110
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: 57
diff changeset
111 // =============================================================================
14
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
112 str LDComment::getContents () {
116
4fde8fdf258a Some renaming
Santeri Piippo <crimsondusk64@gmail.com>
parents: 114
diff changeset
113 return format ("0 %s", zText.chars ());
14
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
114 }
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
115
18
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
116 str LDSubfile::getContents () {
116
4fde8fdf258a Some renaming
Santeri Piippo <crimsondusk64@gmail.com>
parents: 114
diff changeset
117 str val = format ("1 %d %s ", dColor, vPosition.getStringRep (false).chars ());
113
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
118 val += mMatrix.getStringRep ();
65
e4f25b44e240 Reverted changes on LDSubfile::getContents, I had a temporary, hackier solution there and forgot to change it back
Santeri Piippo <crimsondusk64@gmail.com>
parents: 64
diff changeset
119 val += zFileName;
e4f25b44e240 Reverted changes on LDSubfile::getContents, I had a temporary, hackier solution there and forgot to change it back
Santeri Piippo <crimsondusk64@gmail.com>
parents: 64
diff changeset
120 return val;
18
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
121 }
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
122
14
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
123 str LDLine::getContents () {
116
4fde8fdf258a Some renaming
Santeri Piippo <crimsondusk64@gmail.com>
parents: 114
diff changeset
124 str val = format ("2 %d", dColor);
18
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
125
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
126 for (ushort i = 0; i < 2; ++i)
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
127 val.appendformat (" %s", vaCoords[i].getStringRep (false).chars ());
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
128
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
129 return val;
14
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
130 }
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
131
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
132 str LDTriangle::getContents () {
116
4fde8fdf258a Some renaming
Santeri Piippo <crimsondusk64@gmail.com>
parents: 114
diff changeset
133 str val = format ("3 %d", dColor);
18
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
134
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
135 for (ushort i = 0; i < 3; ++i)
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
136 val.appendformat (" %s", vaCoords[i].getStringRep (false).chars ());
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
137
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
138 return val;
14
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
139 }
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
140
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
141 str LDQuad::getContents () {
116
4fde8fdf258a Some renaming
Santeri Piippo <crimsondusk64@gmail.com>
parents: 114
diff changeset
142 str val = format ("4 %d", dColor);
18
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
143
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
144 for (ushort i = 0; i < 4; ++i)
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
145 val.appendformat (" %s", vaCoords[i].getStringRep (false).chars ());
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
146
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
147 return val;
14
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
148 }
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
149
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
150 str LDCondLine::getContents () {
116
4fde8fdf258a Some renaming
Santeri Piippo <crimsondusk64@gmail.com>
parents: 114
diff changeset
151 str val = format ("5 %d", dColor);
18
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
152
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
153 // Add the coordinates
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
154 for (ushort i = 0; i < 4; ++i)
18
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
155 val.appendformat (" %s", vaCoords[i].getStringRep (false).chars ());
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
156
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
157 return val;
14
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
158 }
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
159
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
160 str LDGibberish::getContents () {
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
161 return zContents;
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
162 }
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
163
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
164 str LDVertex::getContents () {
116
4fde8fdf258a Some renaming
Santeri Piippo <crimsondusk64@gmail.com>
parents: 114
diff changeset
165 return format ("0 !LDFORGE VERTEX %d %s", dColor, vPosition.getStringRep (false).chars());
14
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
166 }
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
167
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
168 str LDEmpty::getContents () {
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
169 return str ();
21
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
170 }
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
171
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: 57
diff changeset
172 // =============================================================================
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: 57
diff changeset
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
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: 57
diff changeset
174 // =============================================================================
73
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
175 const char* LDBFC::saStatements[] = {
88
652028158792 Allow the user to alter the tool bar icon size
Santeri Piippo <crimsondusk64@gmail.com>
parents: 84
diff changeset
176 "CERTIFY CCW",
73
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
177 "CCW",
88
652028158792 Allow the user to alter the tool bar icon size
Santeri Piippo <crimsondusk64@gmail.com>
parents: 84
diff changeset
178 "CERTIFY CW",
73
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
179 "CW",
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
180 "NOCERTIFY",
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
181 "INVERTNEXT",
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
182 };
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
183
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
184 str LDBFC::getContents () {
116
4fde8fdf258a Some renaming
Santeri Piippo <crimsondusk64@gmail.com>
parents: 114
diff changeset
185 return format ("0 BFC %s", LDBFC::saStatements[eStatement]);
73
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
186 }
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
187
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
188 // =============================================================================
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
190 // =============================================================================
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
191 vector<LDTriangle*> LDQuad::splitToTriangles () {
21
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
192 // Create the two triangles based on this quadrilateral:
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
193 // 0---3 0---3 3
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
194 // | | | / /|
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
195 // | | = | / / |
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
196 // | | |/ / |
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
197 // 1---2 1 1---2
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
198 LDTriangle* tri1 = new LDTriangle;
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
199 tri1->vaCoords[0] = vaCoords[0];
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
200 tri1->vaCoords[1] = vaCoords[1];
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
201 tri1->vaCoords[2] = vaCoords[3];
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
202
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
203 LDTriangle* tri2 = new LDTriangle;
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
204 tri2->vaCoords[0] = vaCoords[1];
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
205 tri2->vaCoords[1] = vaCoords[2];
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
206 tri2->vaCoords[2] = vaCoords[3];
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
207
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
208 // The triangles also inherit the quad's color
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
209 tri1->dColor = tri2->dColor = dColor;
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
210
73
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
211 vector<LDTriangle*> triangles;
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
212 triangles.push_back (tri1);
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
213 triangles.push_back (tri2);
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
214 return triangles;
24
d2d4d0154338 added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 22
diff changeset
215 }
d2d4d0154338 added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 22
diff changeset
216
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: 57
diff changeset
217 // =============================================================================
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: 57
diff changeset
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
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: 57
diff changeset
219 // =============================================================================
29
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
220 void LDObject::replace (LDObject* replacement) {
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
221 // Replace all instances of the old object with the new object
90
03f718ed5b33 Added history handling for set contents
Santeri Piippo <crimsondusk64@gmail.com>
parents: 88
diff changeset
222 for (LDObject*& obj : g_CurrentFile->objects)
84
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 76
diff changeset
223 if (obj == this)
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 76
diff changeset
224 obj = replacement;
29
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
225
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
226 // Remove the old object
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
227 delete this;
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
228 }
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
229
84
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 76
diff changeset
230 // =============================================================================
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 76
diff changeset
231 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 76
diff changeset
232 // =============================================================================
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 76
diff changeset
233 void LDObject::swap (LDObject* other) {
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 76
diff changeset
234 for (LDObject*& obj : g_CurrentFile->objects) {
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 76
diff changeset
235 if (obj == this)
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 76
diff changeset
236 obj = other;
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 76
diff changeset
237 else if (obj == other)
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 76
diff changeset
238 obj = this;
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 76
diff changeset
239 }
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 76
diff changeset
240 }
c9438ea54ed9 Added move up/down actions.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 76
diff changeset
241
57
6e89589f1fe8 Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 50
diff changeset
242 LDLine::LDLine (vertex v1, vertex v2) {
6e89589f1fe8 Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 50
diff changeset
243 vaCoords[0] = v1;
6e89589f1fe8 Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 50
diff changeset
244 vaCoords[1] = v2;
6e89589f1fe8 Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 50
diff changeset
245 }
6e89589f1fe8 Added polygon bordering function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 50
diff changeset
246
108
351aef26f444 More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
247 LDObject::~LDObject () {
351aef26f444 More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
248 // Remove this object from the selection array if it is there.
351aef26f444 More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
249 for (ulong i = 0; i < g_ForgeWindow->paSelection.size(); ++i)
351aef26f444 More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
250 if (g_ForgeWindow->paSelection[i] == this)
351aef26f444 More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
251 g_ForgeWindow->paSelection.erase (g_ForgeWindow->paSelection.begin() + i);
351aef26f444 More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
252 }
351aef26f444 More selection work - selecting from GUI updates the GL renderer now
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
253
24
d2d4d0154338 added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 22
diff changeset
254 LDComment::~LDComment () {}
d2d4d0154338 added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 22
diff changeset
255 LDCondLine::~LDCondLine () {}
d2d4d0154338 added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 22
diff changeset
256 LDEmpty::~LDEmpty () {}
d2d4d0154338 added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 22
diff changeset
257 LDGibberish::~LDGibberish () {}
d2d4d0154338 added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 22
diff changeset
258 LDLine::~LDLine () {}
d2d4d0154338 added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 22
diff changeset
259 LDQuad::~LDQuad () {}
d2d4d0154338 added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 22
diff changeset
260 LDSubfile::~LDSubfile () {}
d2d4d0154338 added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 22
diff changeset
261 LDTriangle::~LDTriangle () {}
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: 57
diff changeset
262 LDVertex::~LDVertex () {}
73
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
263 LDBFC::~LDBFC () {}
111
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
264 LDRadial::~LDRadial () {}
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: 57
diff changeset
265
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: 65
diff changeset
266 // =============================================================================
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: 65
diff changeset
267 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
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: 65
diff changeset
268 // =============================================================================
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: 65
diff changeset
269 template<class T> static void transformSubObject (LDObject* obj, matrix mMatrix,
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: 65
diff changeset
270 vertex vPos, short dColor)
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: 65
diff changeset
271 {
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: 65
diff changeset
272 T* newobj = static_cast<T*> (obj);
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: 65
diff changeset
273 for (short i = 0; i < (short)(sizeof newobj->vaCoords / sizeof *newobj->vaCoords); ++i)
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: 65
diff changeset
274 newobj->vaCoords[i].transform (mMatrix, vPos);
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: 65
diff changeset
275
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: 65
diff changeset
276 if (newobj->dColor == dMainColor)
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: 65
diff changeset
277 newobj->dColor = dColor;
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: 65
diff changeset
278 }
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: 65
diff changeset
279
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: 65
diff changeset
280 // -----------------------------------------------------------------------------
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: 65
diff changeset
281 static void transformObject (LDObject* obj, matrix mMatrix, vertex vPos,
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: 65
diff changeset
282 short dColor)
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: 65
diff changeset
283 {
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: 65
diff changeset
284 switch (obj->getType()) {
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: 65
diff changeset
285 case OBJ_Line:
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: 65
diff changeset
286 transformSubObject<LDLine> (obj, mMatrix, vPos, dColor);
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: 65
diff changeset
287 break;
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 75
diff changeset
288
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: 65
diff changeset
289 case OBJ_CondLine:
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: 65
diff changeset
290 transformSubObject<LDCondLine> (obj, mMatrix, vPos, dColor);
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: 65
diff changeset
291 break;
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 75
diff changeset
292
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: 65
diff changeset
293 case OBJ_Triangle:
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: 65
diff changeset
294 transformSubObject<LDTriangle> (obj, mMatrix, vPos, dColor);
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: 65
diff changeset
295 break;
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 75
diff changeset
296
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: 65
diff changeset
297 case OBJ_Quad:
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: 65
diff changeset
298 transformSubObject<LDQuad> (obj, mMatrix, vPos, dColor);
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: 65
diff changeset
299 break;
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 75
diff changeset
300
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: 65
diff changeset
301 case OBJ_Subfile:
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: 65
diff changeset
302 {
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: 65
diff changeset
303 LDSubfile* ref = static_cast<LDSubfile*> (obj);
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: 65
diff changeset
304
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: 65
diff changeset
305 matrix mNewMatrix = mMatrix * ref->mMatrix;
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: 65
diff changeset
306 ref->vPosition.transform (mMatrix, vPos);
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: 65
diff changeset
307 ref->mMatrix = mNewMatrix;
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: 65
diff changeset
308 }
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: 65
diff changeset
309
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: 65
diff changeset
310 break;
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 75
diff changeset
311
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: 65
diff changeset
312 default:
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: 65
diff changeset
313 break;
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: 65
diff changeset
314 }
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: 65
diff changeset
315 }
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: 57
diff changeset
316
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: 57
diff changeset
317 // =============================================================================
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: 57
diff changeset
318 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
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: 57
diff changeset
319 // =============================================================================
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: 65
diff changeset
320 vector<LDObject*> LDSubfile::inlineContents (bool bDeepInline, bool bCache) {
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: 65
diff changeset
321 vector<LDObject*> objs, cache;
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: 57
diff changeset
322
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: 65
diff changeset
323 // If we have this cached, just clone that
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: 65
diff changeset
324 if (bDeepInline && pFile->objCache.size ()) {
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: 67
diff changeset
325 for (LDObject* obj : pFile->objCache)
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 75
diff changeset
326 objs.push_back (obj->clone ());
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: 65
diff changeset
327 } else {
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: 65
diff changeset
328 if (!bDeepInline)
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: 65
diff changeset
329 bCache = false;
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: 57
diff changeset
330
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: 67
diff changeset
331 for (LDObject* obj : pFile->objects) {
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: 65
diff changeset
332 // Skip those without schemantic meaning
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: 65
diff changeset
333 switch (obj->getType ()) {
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: 65
diff changeset
334 case OBJ_Comment:
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: 65
diff changeset
335 case OBJ_Empty:
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: 65
diff changeset
336 case OBJ_Gibberish:
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: 65
diff changeset
337 case OBJ_Unidentified:
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: 65
diff changeset
338 case OBJ_Vertex:
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: 65
diff changeset
339 continue;
75
e95a00e34711 Don't include non-INVERTNEXT BFC statements in inlined objects.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 74
diff changeset
340
e95a00e34711 Don't include non-INVERTNEXT BFC statements in inlined objects.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 74
diff changeset
341 case OBJ_BFC:
e95a00e34711 Don't include non-INVERTNEXT BFC statements in inlined objects.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 74
diff changeset
342 // Filter non-INVERTNEXT statements
114
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
343 if (static_cast<LDBFC*> (obj)->eStatement != LDBFC::InvertNext)
75
e95a00e34711 Don't include non-INVERTNEXT BFC statements in inlined objects.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 74
diff changeset
344 continue;
e95a00e34711 Don't include non-INVERTNEXT BFC statements in inlined objects.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 74
diff changeset
345 break;
e95a00e34711 Don't include non-INVERTNEXT BFC statements in inlined objects.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 74
diff changeset
346
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: 65
diff changeset
347 default:
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: 65
diff changeset
348 break;
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: 65
diff changeset
349 }
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: 65
diff changeset
350
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: 65
diff changeset
351 // Got another sub-file reference, inline it if we're deep-inlining. If not,
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: 65
diff changeset
352 // just add it into the objects normally. Also, we only cache immediate
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: 65
diff changeset
353 // subfiles and this is not one. Yay, recursion!
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: 65
diff changeset
354 if (bDeepInline && obj->getType() == OBJ_Subfile) {
63
aa40ce18f869 Implemented the inline action to expose inlining to the user. Also added a `deep inline` action to inline subfile recursively down into polygons and lines only.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 62
diff changeset
355 LDSubfile* ref = static_cast<LDSubfile*> (obj);
aa40ce18f869 Implemented the inline action to expose inlining to the user. Also added a `deep inline` action to inline subfile recursively down into polygons and lines only.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 62
diff changeset
356
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: 65
diff changeset
357 vector<LDObject*> otherobjs = ref->inlineContents (true, false);
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: 65
diff changeset
358
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: 67
diff changeset
359 for (LDObject* otherobj : otherobjs) {
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 75
diff changeset
360 // Cache this object, if desired
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: 65
diff changeset
361 if (bCache)
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 75
diff changeset
362 cache.push_back (otherobj->clone ());
63
aa40ce18f869 Implemented the inline action to expose inlining to the user. Also added a `deep inline` action to inline subfile recursively down into polygons and lines only.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 62
diff changeset
363
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: 65
diff changeset
364 objs.push_back (otherobj);
63
aa40ce18f869 Implemented the inline action to expose inlining to the user. Also added a `deep inline` action to inline subfile recursively down into polygons and lines only.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 62
diff changeset
365 }
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: 65
diff changeset
366 } else {
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: 65
diff changeset
367 if (bCache)
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 75
diff changeset
368 cache.push_back (obj->clone ());
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: 65
diff changeset
369
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 75
diff changeset
370 objs.push_back (obj->clone ());
63
aa40ce18f869 Implemented the inline action to expose inlining to the user. Also added a `deep inline` action to inline subfile recursively down into polygons and lines only.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 62
diff changeset
371 }
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: 57
diff changeset
372 }
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: 65
diff changeset
373
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: 65
diff changeset
374 if (bCache)
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: 65
diff changeset
375 pFile->objCache = cache;
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: 57
diff changeset
376 }
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: 57
diff changeset
377
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: 65
diff changeset
378 // Transform the objects
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
379 for (LDObject* obj : objs) {
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
380 // Set the parent now so we know what inlined this.
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
381 obj->parent = this;
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
382
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: 65
diff changeset
383 transformObject (obj, mMatrix, vPosition, dColor);
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
384 }
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: 57
diff changeset
385
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: 57
diff changeset
386 return objs;
63
aa40ce18f869 Implemented the inline action to expose inlining to the user. Also added a `deep inline` action to inline subfile recursively down into polygons and lines only.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 62
diff changeset
387 }
aa40ce18f869 Implemented the inline action to expose inlining to the user. Also added a `deep inline` action to inline subfile recursively down into polygons and lines only.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 62
diff changeset
388
aa40ce18f869 Implemented the inline action to expose inlining to the user. Also added a `deep inline` action to inline subfile recursively down into polygons and lines only.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 62
diff changeset
389 // =============================================================================
aa40ce18f869 Implemented the inline action to expose inlining to the user. Also added a `deep inline` action to inline subfile recursively down into polygons and lines only.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 62
diff changeset
390 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
aa40ce18f869 Implemented the inline action to expose inlining to the user. Also added a `deep inline` action to inline subfile recursively down into polygons and lines only.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 62
diff changeset
391 // =============================================================================
aa40ce18f869 Implemented the inline action to expose inlining to the user. Also added a `deep inline` action to inline subfile recursively down into polygons and lines only.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 62
diff changeset
392 long LDObject::getIndex (OpenFile* pFile) {
74
1affec15e572 LDObject::getIndex was bogus which would cause inlining to crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 73
diff changeset
393 for (ulong i = 0; i < pFile->objects.size(); ++i)
1affec15e572 LDObject::getIndex was bogus which would cause inlining to crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 73
diff changeset
394 if (pFile->objects[i] == this)
1affec15e572 LDObject::getIndex was bogus which would cause inlining to crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 73
diff changeset
395 return i;
63
aa40ce18f869 Implemented the inline action to expose inlining to the user. Also added a `deep inline` action to inline subfile recursively down into polygons and lines only.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 62
diff changeset
396
aa40ce18f869 Implemented the inline action to expose inlining to the user. Also added a `deep inline` action to inline subfile recursively down into polygons and lines only.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 62
diff changeset
397 return -1;
91
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
398 }
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
399
96
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
400 // =============================================================================
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
401 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
402 // =============================================================================
91
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
403 void LDObject::moveObjects (std::vector<LDObject*> objs, const bool bUp) {
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
404 // If we move down, we need to iterate the array in reverse order.
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
405 const long start = bUp ? 0 : (objs.size() - 1);
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
406 const long end = bUp ? objs.size() : -1;
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
407 const long incr = bUp ? 1 : -1;
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
408
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
409 for (long i = start; i != end; i += incr) {
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
410 LDObject* obj = objs[i];
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
411
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
412 const long lIndex = obj->getIndex (g_CurrentFile),
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
413 lTarget = lIndex + (bUp ? -1 : 1);
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
414
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
415 if ((bUp == true and lIndex == 0) or
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
416 (bUp == false and lIndex == (long)(g_CurrentFile->objects.size() - 1)))
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
417 {
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
418 // One of the objects hit the extrema. If this happens, this should be the first
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
419 // object to be iterated on. Thus, nothing has changed yet and it's safe to just
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
420 // abort the entire operation.
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
421 assert (i == start);
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
422 return;
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
423 }
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
424
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
425 obj->swap (g_CurrentFile->objects[lTarget]);
b4dda6348e7e History handling for list moving
Santeri Piippo <crimsondusk64@gmail.com>
parents: 90
diff changeset
426 }
96
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
427 }
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
428
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
429 // =============================================================================
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
430 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
431 // =============================================================================
117
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
432 str LDObject::objectListContents (const std::vector<LDObject*>& objs) {
96
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
433 bool bFirstDetails = true;
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
434 str zText = "";
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
435
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
436 if (objs.size() == 0)
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
437 return "nothing"; // :)
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
438
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
439 for (long i = 0; i < NUM_ObjectTypes; ++i) {
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
440 LDObjectType_e eType = (LDObjectType_e) i;
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
441 ulong ulCount = 0;
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
442
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
443 for (LDObject* obj : objs)
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
444 if (obj->getType() == eType)
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
445 ulCount++;
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
446
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
447 if (ulCount > 0) {
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
448 if (!bFirstDetails)
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
449 zText += ", ";
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
450
116
4fde8fdf258a Some renaming
Santeri Piippo <crimsondusk64@gmail.com>
parents: 114
diff changeset
451 str zNoun = format ("%s%s", g_saObjTypeNames[eType], PLURAL (ulCount));
103
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
452
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
453 // Plural of "vertex" is "vertices". Stupid English.
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
454 if (eType == OBJ_Vertex && ulCount != 1)
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
455 zNoun = "vertices";
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
456
b0a345196435 Added the ability to add vertices to object corners
Santeri Piippo <crimsondusk64@gmail.com>
parents: 102
diff changeset
457 zText.appendformat ("%lu %s", ulCount, zNoun.chars ());
96
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
458 bFirstDetails = false;
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
459 }
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
460 }
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
461
2f175b3d8211 Added history dialog, cannot display all types yet
Santeri Piippo <crimsondusk64@gmail.com>
parents: 91
diff changeset
462 return zText;
102
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
463 }
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
464
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
465 // =============================================================================
111
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
466 LDObject* LDObject::topLevelParent () {
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
467 if (!parent)
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
468 return null;
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
469
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
470 LDObject* it = this;
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
471
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
472 while (it->parent)
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
473 it = it->parent;
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
474
111
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
475 return it;
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
476 }
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
477
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
478
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
479 // =============================================================================
102
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
480 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
481 // =============================================================================
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
482 void LDObject::move (vertex vVector) { vVector = vVector; /* to shut up GCC */ }
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
483 void LDEmpty::move (vertex vVector) { vVector = vVector; }
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
484 void LDBFC::move (vertex vVector) { vVector = vVector; }
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
485 void LDComment::move (vertex vVector) { vVector = vVector; }
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
486 void LDGibberish::move (vertex vVector) { vVector = vVector; }
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
487
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
488 void LDVertex::move (vertex vVector) {
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
489 vPosition += vVector;
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
490 }
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
491
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
492 void LDSubfile::move (vertex vVector) {
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
493 vPosition += vVector;
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
494 }
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
495
111
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
496 void LDRadial::move (vertex vVector) {
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
497 vPosition += vVector;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
498 }
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
499
102
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
500 void LDLine::move (vertex vVector) {
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
501 for (short i = 0; i < 2; ++i)
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
502 vaCoords[i] += vVector;
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
503 }
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
504
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
505 void LDTriangle::move (vertex vVector) {
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
506 for (short i = 0; i < 3; ++i)
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
507 vaCoords[i] += vVector;
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
508 }
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
509
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
510 void LDQuad::move (vertex vVector) {
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
511 for (short i = 0; i < 4; ++i)
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
512 vaCoords[i] += vVector;
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
513 }
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
514
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
515 void LDCondLine::move (vertex vVector) {
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
516 for (short i = 0; i < 4; ++i)
cacd4681ccb4 Added basic object moving with MLCAD-like controls.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 96
diff changeset
517 vaCoords[i] += vVector;
111
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
518 }
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
519
113
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
520 // =============================================================================
111
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
521 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
522 // =============================================================================
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
523 LDRadial::LDRadial () {
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
524
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
525 }
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
526
113
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
527 static char const* g_saRadialTypeNames[] = {
111
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
528 "Circle",
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
529 "Cylinder",
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
530 "Disc",
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
531 "Disc Negative",
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
532 "Ring",
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
533 "Cone",
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
534 null
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
535 };
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
536
113
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
537 char const* LDRadial::radialTypeName () {
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
538 return g_saRadialTypeNames[eRadialType];
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
539 }
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
540
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
541 char const* LDRadial::radialTypeName (const LDRadial::Type eType) {
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
542 return g_saRadialTypeNames[eType];
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
543 }
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
544
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
545 // =============================================================================
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
546 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
547 // =============================================================================
111
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
548 std::vector<LDObject*> LDRadial::decompose (bool bTransform) {
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
549 std::vector<LDObject*> paObjects;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
550
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
551 for (short i = 0; i < dSegments; ++i) {
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
552 double x0 = cos ((i * 2 * pi) / dDivisions),
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
553 x1 = cos (((i + 1) * 2 * pi) / dDivisions),
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
554 z0 = sin ((i * 2 * pi) / dDivisions),
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
555 z1 = sin (((i + 1) * 2 * pi) / dDivisions);
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
556
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
557 switch (eRadialType) {
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
558 case LDRadial::Circle:
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
559 {
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
560 vertex v0 (x0, 0.0f, z0),
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
561 v1 (x1, 0.0f, z1);
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
562
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
563 if (bTransform) {
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
564 v0.transform (mMatrix, vPosition);
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
565 v1.transform (mMatrix, vPosition);
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
566 }
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
567
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
568 LDLine* pLine = new LDLine;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
569 pLine->vaCoords[0] = v0;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
570 pLine->vaCoords[1] = v1;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
571 pLine->dColor = dEdgeColor;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
572 pLine->parent = this;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
573
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
574 paObjects.push_back (pLine);
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
575 }
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
576 break;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
577
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
578 case LDRadial::Cylinder:
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
579 case LDRadial::Ring:
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
580 case LDRadial::Cone:
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
581 {
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
582 double x2, x3, z2, z3;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
583 double y0, y1, y2, y3;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
584
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
585 if (eRadialType == LDRadial::Cylinder) {
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
586 x2 = x1;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
587 x3 = x0;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
588 z2 = z1;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
589 z3 = z0;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
590
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
591 y0 = y1 = 0.0f;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
592 y2 = y3 = 1.0f;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
593 } else {
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
594 x2 = x1 * (dRingNum + 1);
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
595 x3 = x0 * (dRingNum + 1);
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
596 z2 = z1 * (dRingNum + 1);
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
597 z3 = z0 * (dRingNum + 1);
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
598
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
599 x0 *= dRingNum;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
600 x1 *= dRingNum;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
601 z0 *= dRingNum;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
602 z1 *= dRingNum;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
603
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
604 if (eRadialType == LDRadial::Ring) {
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
605 y0 = y1 = y2 = y3 = 0.0f;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
606 } else {
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
607 y0 = y1 = 1.0f;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
608 y2 = y3 = 0.0f;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
609 }
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
610 }
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
611
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
612 vertex v0 (x0, y0, z0),
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
613 v1 (x1, y1, z1),
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
614 v2 (x2, y2, z2),
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
615 v3 (x3, y3, z3);
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
616
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
617 if (bTransform) {
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
618 v0.transform (mMatrix, vPosition);
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
619 v1.transform (mMatrix, vPosition);
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
620 v2.transform (mMatrix, vPosition);
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
621 v3.transform (mMatrix, vPosition);
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
622 }
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
623
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
624 LDQuad* pQuad = new LDQuad;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
625 pQuad->vaCoords[0] = v0;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
626 pQuad->vaCoords[1] = v1;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
627 pQuad->vaCoords[2] = v2;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
628 pQuad->vaCoords[3] = v3;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
629 pQuad->dColor = dColor;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
630 pQuad->parent = this;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
631
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
632 paObjects.push_back (pQuad);
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
633 }
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
634 break;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
635
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
636 case LDRadial::Disc:
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
637 case LDRadial::DiscNeg:
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
638 {
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
639 double x2, z2;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
640
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
641 if (eRadialType == LDRadial::Disc) {
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
642 x2 = z2 = 0.0f;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
643 } else {
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
644 x2 = (x0 >= 0.0f) ? 1.0f : -1.0f;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
645 z2 = (z0 >= 0.0f) ? 1.0f : -1.0f;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
646 }
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
647
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
648 vertex v0 (x0, 0.0f, z0),
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
649 v1 (x1, 0.0f, z1),
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
650 v2 (x2, 0.0f, z2);
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
651
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
652 if (bTransform) {
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
653 v0.transform (mMatrix, vPosition);
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
654 v1.transform (mMatrix, vPosition);
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
655 v2.transform (mMatrix, vPosition);
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
656 }
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
657
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
658 LDTriangle* pSeg = new LDTriangle;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
659 pSeg->vaCoords[0] = v0;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
660 pSeg->vaCoords[1] = v1;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
661 pSeg->vaCoords[2] = v2;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
662 pSeg->dColor = dColor;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
663 pSeg->parent = this;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
664
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
665 paObjects.push_back (pSeg);
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
666 }
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
667 break;
113
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
668
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
669 default:
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
670 break;
111
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
671 }
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
672 }
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
673
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
674 return paObjects;
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
675 }
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
676
114
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
677 // =============================================================================
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
678 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
679 // =============================================================================
111
125e8031dbf1 Added the radial type, this one sure has been on my wishlist for a while. :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 108
diff changeset
680 str LDRadial::getContents () {
116
4fde8fdf258a Some renaming
Santeri Piippo <crimsondusk64@gmail.com>
parents: 114
diff changeset
681 return format ("0 !LDFORGE RADIAL %s %d %d %d %d %s %s",
113
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
682 str (radialTypeName()).toupper ().strip (' ').chars (),
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
683 dColor, dSegments, dDivisions, dRingNum,
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
684 vPosition.getStringRep (false).chars(), mMatrix.getStringRep().chars());
114
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
685 }
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
686
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
687 char const* g_saRadialNameRoots[] = {
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
688 "edge",
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
689 "cyli",
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
690 "disc",
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
691 "ndis",
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
692 "ring",
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
693 "cone",
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
694 null
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
695 };
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
696
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
697 // =============================================================================
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
698 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
699 // =============================================================================
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
700 str LDRadial::makeFileName () {
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
701 short dNumerator = dSegments,
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
702 dDenominator = dDivisions;
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
703
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
704 // Simplify the fractional part, but the denominator is at least 4.
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
705 simplify (dNumerator, dDenominator);
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
706
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
707 if (dDenominator < 4) {
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
708 const short dFactor = (4 / dDenominator);
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
709
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
710 dNumerator *= dFactor;
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
711 dDenominator *= dFactor;
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
712 }
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
713
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
714 // Compose some general information: prefix, fraction, root, ring number
116
4fde8fdf258a Some renaming
Santeri Piippo <crimsondusk64@gmail.com>
parents: 114
diff changeset
715 str zPrefix = (dDivisions == 16) ? "" : format ("%d/", dDivisions);
4fde8fdf258a Some renaming
Santeri Piippo <crimsondusk64@gmail.com>
parents: 114
diff changeset
716 str zFrac = format ("%d-%d", dNumerator, dDenominator);
114
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
717 str zRoot = g_saRadialNameRoots[eRadialType];
116
4fde8fdf258a Some renaming
Santeri Piippo <crimsondusk64@gmail.com>
parents: 114
diff changeset
718 str zRingNum = (eRadialType == Ring || eRadialType == Cone) ? format ("%d", dRingNum) : "";
114
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
719
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
720 // Truncate the root if necessary (7-16rin4.dat for instance).
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
721 // However, always keep the root at least 2 characters.
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
722 short dExtra = (~zFrac + ~zRingNum + ~zRoot) - 8;
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
723 zRoot -= min<short> (max<short> (dExtra, 0), 2);
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
724
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
725 // Stick them all together and return the result.
116
4fde8fdf258a Some renaming
Santeri Piippo <crimsondusk64@gmail.com>
parents: 114
diff changeset
726 return format ("%s%s%s%s", zPrefix.chars(), zFrac.chars (), zRoot.chars (), zRingNum.chars ());
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: 57
diff changeset
727 }

mercurial