leocad
leocad copied to clipboard
Model with defined !TEXMAP has no texture shown
Describe the bug I tried to use all possible ways to link raster image texture, but LeoCAD does not show textures for the custom created part in some cases.
Actually LeoCAD supports only texture like !TEXMAP ... <image_name>
, which is placed in <library_folder>/parts/texture/<image_name>
.
But LDraw Specification allows two more options:
- use
<image_name>
file stored in the same folder with LDraw-file, if there is no such image in<library_folder>/parts/texture/
folder; - use
!DATA <image_name>
command to store textures inside LDraw files in Base64, and link it as!TEXMAP ... <image_name>
To Reproduce
Steps to reproduce the behavior:
- Case A:
1.1. Create text as
model.ldr
and open it in text editor 1.2. Copy!TEXMAP
example code (from http://www.leocad.org/docs/texmap.html) intomodel.ldr
file; 1.3. Create and placebottom.png
andside.png
images in the same folder wheremodel.ldr
stored; 1.4. Save it and open in LeoCAD - Case B:
2.1. Create text as
model.ldr
and open it in text editor 2.2. Copy!TEXMAP
example code (from http://www.leocad.org/docs/texmap.html) intomodel.ldr
file; 2.3. Embedbottom.png
andside.png
with a Base64 encoding intomodel.ldr
directly using!DATA bottom.png
and!DATA side.png
commands (seesticker.ldr
sample from!DATA
spec: https://www.ldraw.org/article/47.html); 2.4. Save it and open in LeoCAD
Expected behavior
!TEXMAP
should work as expected, according to LDraw Specification and to the next algorythm:
- If
!TEXMAP
linked toimage.png
check is there!DATA image.png
in the LDraw-file defined with Base64; - If there is no
!DATA image.png
command in the LDraw-file, check is there<library_folder>/parts/texture/image.png
file, where<library_folder>
is a path to LDraw Part Library folder; - If there is no
<library_folder>/parts/texture/image.png
, check is there<my_folder>/image.png
file, where<my_folder>
is a path to folder containing actual LDraw-file (i.e.<my_folder>/model.ldr
, e.g./home/user123/Documents/model.ldr
or just~/Documents/model.ldr
on Linux); - If there is no
<my_folder>/image.png
file, then use a fallback as implemented in https://github.com/leozide/leocad/issues/213; - If fallback used, show also a notification window with the list of missing textures (or at least print a list of missed textures in the LeoCAD's CLI output during model loading).
Screenshots
Version (please complete the following information):
- OS: Debian 12
- LeoCAD Version
continuous
(AppImage)
Crash information: Some versions of LeoCAD will show a message that they saved a minidump file when they crash, if you see this message please attach the file.
Additional context
-
!TEXMAP
spec - https://www.ldraw.org/texmap-spec.html -
!DATA
spec - https://www.ldraw.org/article/47.html
Related issues:
- https://github.com/leozide/leocad/issues/45#issuecomment-393643274
- https://github.com/leozide/leocad/issues/213
- https://github.com/leozide/leocad/issues/391