Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make colors of polygons reflect the color of the source object. #56

Open
madhephaestus opened this issue Aug 11, 2024 · 1 comment
Open

Comments

@madhephaestus
Copy link
Member

It would be nice to have the color of a polygon withing a CSG object preserve the color of its source object through difference and union operations.

The storage of the Color needs to be moved from the storage object that is synced at the end of an op, and therefor obliterates one of the colors and replaces it with a single color.

@breiler attempted to fix the polygon color issue here: #54 but some operations still sync the storage and break the color.

To so this we need to make a Color object in the CSG, and pass a reference to it to the polygons when the color is set, but not when the CSG operations is called.

@breiler
Copy link

breiler commented Aug 12, 2024

It is getting there, I did a local build of #58 and it will now retain the colors of the polygons on unions 🥳:

image

There is still some work to be done on difference operations, for instance in this case I would expect the cube to still be blue with one red face (as the cube used for cutting one side of the cube was red):

CSG cube1 = new Cube(1)
        .toCSG()
        .move(-0.5, 0, 0)
        .setColor(Color.BLUE);

CSG cube2 = new Cube(1)
        .toCSG()
        .move(0.49, 0, 0)
        .setColor(Color.RED);

model = cube1.difference(cube2).scale(0.4);

But instead I got this:

Screencast.from.2024-08-12.18-57-00.webm

I'll see if I can figure this out tomorrow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants