[OpenSCAD] Semantics CSG ops with respect to color, materials

bobc bobcousins42 at googlemail.com
Tue May 19 14:36:03 EDT 2015


Hmm, no takers. Never mind, I will press on. :)

Just a reminder, the scope here is to look at semantics and what sort of
language extensions might be required, to guide future implementation.

I've been looking at how color is handled on difference() and intersect().
The main issue is how the "cut" face of the result should be colored.
Conventionally, the color is that of the contributing surface. Illustrated
here
http://en.wikipedia.org/wiki/Constructive_solid_geometry#Workings_of_CSG

In various cases, it would be useful to have different behaviour
https://github.com/openscad/openscad/issues/501

After playing around with a version of csg.js (csg.cs), I would like to
propose a simple extension to difference() and union() to allow colors of
the result to be defined in a more flexible way. The method is to add an
"alpha" parameter, which works in the same way as alpha color blending.

For an operation such difference() {a(); b();}, then the color of the cut
surface is color(A).alpha + color(B).(1-alpha), where alpha = [0:1].

The default value would be zero, which corresponds to standard behaviour,
with alpha=1, the color of the original objects is preserved.

If an object has no defined color, then the object with a defined color
takes precedence.

Adding color preservation to csg.cs was quite easy, as there is a property
which can be attached to polygons. With that type of feature, I think it
should be relatively easy to create boolean ops which allow the user to
express a full range of color properties to the result.



--
View this message in context: http://forum.openscad.org/Semantics-CSG-ops-with-respect-to-color-materials-tp12667p12705.html
Sent from the OpenSCAD mailing list archive at Nabble.com.




More information about the Discuss mailing list