It is a very small code change actually, everything was there already. When you use the "set colors" tool to set individual colors for selected faces, the DiffuseColor property is filled with a list of colors with the same length as the number of faces. These colors already had an alpha value, but it was simply not used.
There is one catch: colors are written as (red, green, blue, alpha). The alpha value, normally, is understood as: 0 = fully transparent and 1 = fully opaque. In FreeCAD however, all colors until now have always been saved with their alpha value at 0. This actually makes some sense, because FreeCAD doesn't use the concept of alpha, but the concept of transparency (inherited from coin), where 0 = opaque and 1 (or 100%) = transparent.
So in order to not make existing objects suddenly become fully transparent, this implementation respects the FreeCAD idea and the alpha value of colors should therefore be understood not as alpha, but as transparency (0 = opaque -> 1 = fully transparent).
At the moment, the color editor of FreeCAD cannot set transparency, so the only way to set per-face transparency is from python. For example, if you have an object with 4 faces, you can do this:
Code: Select all
myObject.ViewObject.DiffuseColor = [ (0.0,0.0,1.0,0.0) , (0.0,1.0,1.0,0.25) , (1.0,1.0,1.0,0.5) , (1.0,1.0,0.0,0.75) ]