leocad icon indicating copy to clipboard operation
leocad copied to clipboard

Model with defined !TEXMAP has no texture shown

Open app4soft opened this issue 4 months ago • 0 comments

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:

  1. 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) into model.ldr file; 1.3. Create and place bottom.png and side.png images in the same folder where model.ldr stored; 1.4. Save it and open in LeoCAD
  2. 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) into model.ldr file; 2.3. Embed bottom.png and side.png with a Base64 encoding into model.ldr directly using !DATA bottom.png and !DATA side.png commands (see sticker.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:

  1. If !TEXMAP linked to image.png check is there !DATA image.png in the LDraw-file defined with Base64;
  2. 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;
  3. 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);
  4. If there is no <my_folder>/image.png file, then use a fallback as implemented in https://github.com/leozide/leocad/issues/213;
  5. 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

Screenshot_2024-10-08_03-07-28

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

app4soft avatar Oct 08 '24 00:10 app4soft