leozide / leocad

A CAD application for creating virtual LEGO models
https://www.leocad.org
2.48k stars 212 forks source link

Color of edge lines of mixed-color pieces incorrect #691

Open j6t opened 3 years ago

j6t commented 3 years ago

Look at this screenshot:

image

These are two pieces 122c03.dat (Plate 2 x 2 with Red Wheels and Tyres...).

The version with opaque orange color has dark gray or black edge lines everywhere. This is correct.

The version with transparent orange color, however, has orange edge lines everywhere, even in the opaque sub-parts. This is incorrect. These sub-parts should also have dark gray or black edge lines.

leozide commented 3 years ago

I think the way I draw is technically correct according to the spec:

Colour 24 is referred to as the "complement colour" or "edge colour". Colour 24 is most commonly used for line types 2 (line) and 5 (optional line). When a sub-file is referenced by another file all the colour 24 command lines are displayed using the complement colour of the line that referenced it. The complement colour of a given colour is defined in the Colour Definition for that colour.

Example: 1 4 0 0 0 1 0 0 0 1 0 0 0 1 part.dat

All the colour 24 command lines in part.dat will be displayed using the complement colour of colour 4

The other apps I checked don't follow it, and I think they look better, I'll take a look.

j6t commented 3 years ago

Ah, I see. I thought that the transparency has something to do with it, but that is not the case: if you pick an opaque color with a light edge line color, such as Dark Brown, the same happens: image

I don't think that the spec is ambiguous, or that other renderers (mis-)interpret it is just to get an aesthetically better result. In the case of 122c03.dat, we have

1 16 0 0 0 1 0 0 0 1 0 0 0 1 122c01.dat
1 256 -31 6 0 0 0 -1 0 1 0 1 0 0 3641.dat
1 256 31 6 0 0 0 1 0 1 0 -1 0 0 3641.dat

Clearly, the two 3641.dat lines reference sub-files, and then the 24 lines within 3641.dat must use the complement color of the line that referenced the sub-file, which is 256 in this case.