forked from miho/JCSG
-
Notifications
You must be signed in to change notification settings - Fork 7
Closed
Description
I don't know if I have the wrong expectation, but I would like to have the polygons to inherit their colors from the original CSG. I can look into it if this is something that should work.
Right now the colors seems to be random, and they become different every time:
@Test
public void polygonsShouldGetColorFromCSG() {
CSG cube = new Cube()
.toCSG()
.setColor(Color.BLUE);
assertEquals(Color.BLUE, cube.getColor());
String colorAsString = Color.BLUE.getRed() + " " + Color.BLUE.getGreen() + " " + Color.BLUE.getBlue();
cube.getPolygons().forEach(polygon -> {
assertTrue(polygon.getStorage().getValue("material:color").isPresent());
assertEquals("Expected the polygon to get the same color as the CSG", colorAsString, polygon.getStorage().getValue("material:color").get());
});
}The result from the test gives different results every run, here is one example:
Expected the polygon to get the same color as the CSG expected:<[0.0 0.0 1].0> but was:<[1.0 0.6470588445663452 0].0>
Expected :0.0 0.0 1.0
Actual :1.0 0.6470588445663452 0.0
<Click to see difference>
In the long run I would like to be able to colorize the output like in this example:
CSG cube = new Cube(0.5).toCSG();
CSG sphere = new Sphere(0.36, 64, 32).toCSG();
CSG corners = cube.difference(sphere);
CSG result = cube.difference(corners)
.setColor(Color.GRAY);
CSG text = CSG.text("Z-", 2)
.setColor(Color.BLUE)
.transformed(new Transform().scale(0.01).scale(1, 1, 1).rot(180, 0, 0).translate(-14, -10, 28));
result = result.dumbUnion(text);
text = CSG.text("Z+", 2)
.setColor(Color.BLUE)
.transformed(new Transform().scale(0.01).scale(1, 1, 1).translate(-14, -10, 28));
result = result.dumbUnion(text);
text = CSG.text("Y+", 2)
.setColor(Color.GREEN)
.transformed(new Transform().scale(0.01).scale(1, 1, 1).rot(90, 0, 180).translate(-14, -10, 28));
result = result.dumbUnion(text);
text = CSG.text("Y-", 2)
.setColor(Color.GREEN)
.transformed(new Transform().scale(0.01).scale(1, 1, 1).rot(270, 0, 0).translate(-14, -10, 28));
result = result.dumbUnion(text);
text = CSG.text("X-", 2)
.setColor(Color.RED)
.transformed(new Transform().scale(0.01).scale(1, 1, 1).rot(270, 90, 0).translate(-14, -10, 28));
result = result.dumbUnion(text);
text = CSG.text("X+", 2)
.setColor(Color.RED)
.transformed(new Transform().scale(0.01).scale(1, 1, 1).rot(270, 270, 0).translate(-14, -10, 28));
result = result.dumbUnion(text);Metadata
Metadata
Assignees
Labels
No labels