@@ -59,8 +59,8 @@ public RoundedCube(Vector3d center, Vector3d dimensions) {
59
59
}
60
60
61
61
/**
62
- * Constructor. Creates a new rounded cuboid with center {@code [0,0,0]}
63
- * and with the specified dimensions.
62
+ * Constructor. Creates a new rounded cuboid with center {@code [0,0,0]} and
63
+ * with the specified dimensions.
64
64
*
65
65
* @param w width
66
66
* @param h height
@@ -70,11 +70,10 @@ public RoundedCube(double w, double h, double d) {
70
70
this (Vector3d .ZERO , new Vector3d (w , h , d ));
71
71
}
72
72
73
-
74
73
@ Override
75
74
public List <Polygon > toPolygons () {
76
- CSG spherePrototype =
77
- new Sphere (getCornerRadius (), getResolution ()* 2 , getResolution ()).toCSG ();
75
+ CSG spherePrototype
76
+ = new Sphere (getCornerRadius (), getResolution () * 2 , getResolution ()).toCSG ();
78
77
79
78
double x = dimensions .x / 2.0 - getCornerRadius ();
80
79
double y = dimensions .y / 2.0 - getCornerRadius ();
@@ -94,6 +93,12 @@ public List<Polygon> toPolygons() {
94
93
sphere2 , sphere3 , sphere4 ,
95
94
sphere5 , sphere6 , sphere7 , sphere8 ).hull ().getPolygons ();
96
95
96
+ Transform locTransform = Transform .unity ().translate (center );
97
+
98
+ for (Polygon p : result ) {
99
+ p .transform (locTransform );
100
+ }
101
+
97
102
if (!centered ) {
98
103
99
104
Transform centerTransform = Transform .unity ().translate (dimensions .x / 2.0 , dimensions .y / 2.0 , dimensions .z / 2.0 );
@@ -141,6 +146,7 @@ public void setDimensions(Vector3d dimensions) {
141
146
142
147
/**
143
148
* Defines that this cube will not be centered.
149
+ *
144
150
* @return this cube
145
151
*/
146
152
public RoundedCube noCenter () {
@@ -161,8 +167,8 @@ public int getResolution() {
161
167
public void setResolution (int resolution ) {
162
168
this .resolution = resolution ;
163
169
}
164
-
165
- /**
170
+
171
+ /**
166
172
* @param resolution the resolution to set
167
173
* @return this cube
168
174
*/
@@ -184,7 +190,7 @@ public double getCornerRadius() {
184
190
public void setCornerRadius (double cornerRadius ) {
185
191
this .cornerRadius = cornerRadius ;
186
192
}
187
-
193
+
188
194
/**
189
195
* @param cornerRadius the corner radius to set
190
196
* @return this cube
0 commit comments