|
17 | 17 | logger, |
18 | 18 | resolveBlenderPath, |
19 | 19 | ) |
20 | | -from ..xplane_image_composer import ( |
21 | | - combineSpecularAndNormal, |
22 | | - getImageByFilepath, |
23 | | - normalWithoutAlpha, |
24 | | - specularToGrayscale, |
25 | | -) |
26 | 20 | from .xplane_attribute import XPlaneAttribute |
27 | 21 | from .xplane_attributes import XPlaneAttributes |
28 | 22 |
|
@@ -508,88 +502,6 @@ def _init(self): |
508 | 502 | for attr in self.xplaneFile.options.customAttributes: |
509 | 503 | self.attributes.add(XPlaneAttribute(attr.name, attr.value)) |
510 | 504 |
|
511 | | - def _compositeNormalTextureNeedsRecompile(self, compositePath, sourcePaths): |
512 | | - compositePath = resolveBlenderPath(compositePath) |
513 | | - |
514 | | - if not os.path.exists(compositePath): |
515 | | - return True |
516 | | - else: |
517 | | - compositeTime = os.path.getmtime(compositePath) |
518 | | - |
519 | | - for sourcePath in sourcePaths: |
520 | | - sourcePath = resolveBlenderPath(sourcePath) |
521 | | - |
522 | | - if os.path.exists(sourcePath): |
523 | | - sourceTime = os.path.getmtime(sourcePath) |
524 | | - |
525 | | - if sourceTime > compositeTime: |
526 | | - return True |
527 | | - |
528 | | - return False |
529 | | - |
530 | | - def _getCompositeNormalTexture(self, textureNormal, textureSpecular): |
531 | | - normalImage = None |
532 | | - specularImage = None |
533 | | - texture = None |
534 | | - image = None |
535 | | - filepath = None |
536 | | - channels = 4 |
537 | | - |
538 | | - if textureNormal: |
539 | | - normalImage = getImageByFilepath(textureNormal) |
540 | | - |
541 | | - if textureSpecular: |
542 | | - specularImage = getImageByFilepath(textureSpecular) |
543 | | - |
544 | | - # only normals, no specular |
545 | | - if normalImage and not specularImage: |
546 | | - filename, extension = os.path.splitext(textureNormal) |
547 | | - filepath = texture = filename + "_nm" + extension |
548 | | - channels = 3 |
549 | | - |
550 | | - if self._compositeNormalTextureNeedsRecompile(filepath, (textureNormal)): |
551 | | - image = normalWithoutAlpha(normalImage, normalImage.name + "_nm") |
552 | | - |
553 | | - # normal + specular |
554 | | - elif normalImage and specularImage: |
555 | | - filename, extension = os.path.splitext(textureNormal) |
556 | | - filepath = texture = filename + "_nm_spec" + extension |
557 | | - channels = 4 |
558 | | - |
559 | | - if self._compositeNormalTextureNeedsRecompile( |
560 | | - filepath, (textureNormal, textureSpecular) |
561 | | - ): |
562 | | - image = combineSpecularAndNormal( |
563 | | - specularImage, normalImage, normalImage.name + "_nm_spec" |
564 | | - ) |
565 | | - |
566 | | - # specular only |
567 | | - elif not normalImage and specularImage: |
568 | | - filename, extension = os.path.splitext(textureSpecular) |
569 | | - filepath = texture = filename + "_spec" + extension |
570 | | - channels = 1 |
571 | | - |
572 | | - if self._compositeNormalTextureNeedsRecompile(filepath, (textureSpecular)): |
573 | | - image = specularToGrayscale(specularImage, specularImage.name + "_spec") |
574 | | - |
575 | | - if image: |
576 | | - savepath = resolveBlenderPath(filepath) |
577 | | - |
578 | | - color_mode = bpy.context.scene.render.image_settings.color_mode |
579 | | - if channels == 4: |
580 | | - bpy.context.scene.render.image_settings.color_mode = "RGBA" |
581 | | - elif channels == 3: |
582 | | - bpy.context.scene.render.image_settings.color_mode = "RGB" |
583 | | - elif channels == 1: |
584 | | - bpy.context.scene.render.image_settings.color_mode = "BW" |
585 | | - image.save_render(savepath, bpy.context.scene) |
586 | | - image.filepath = filepath |
587 | | - |
588 | | - # restore color_mode |
589 | | - bpy.context.scene.render.image_settings.color_mode = color_mode |
590 | | - |
591 | | - return texture |
592 | | - |
593 | 505 | def get_path_relative_to_dir(self, res_path: str, export_dir: str) -> str: |
594 | 506 | """ |
595 | 507 | Returns the resource path relative to the exported OBJ |
|
0 commit comments