Skip to content

Commit

Permalink
Merge pull request #14 from StandingPadAnimations/obj-metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
StandingPadAnimations committed Feb 12, 2023
2 parents 7e710cc + d79ae9b commit acad35c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
1 change: 0 additions & 1 deletion MCprep_addon/materials/prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ def draw_mats_common(self, context):

if util.isTextureSwapCompatible(context):
col.prop(self, "animateTextures")

col.prop(self, "autoFindMissingTextures")

row = self.layout.row()
Expand Down
8 changes: 2 additions & 6 deletions MCprep_addon/mcprep_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,12 +789,8 @@ def draw(self, context):
col.label(text="MCprep tools")
col.operator("mcprep.prep_materials", text="Prep Materials")

if len(context.selected_objects):
for obj in context.selected_objects:
if obj["MCPREP_OBJ_HEADER"] == 1:
if obj["MCPREP_OBJ_FILE_TYPE"] == "ATLAS":
col.label(text="OBJ not exported with the correct settings for textureswap")
break
if not util.isTextureSwapCompatible(context):
col.label(text="OBJ not exported with the correct settings for textureswap")
p = col.operator("mcprep.swap_texture_pack")
p.filepath = context.scene.mcprep_texturepack_path
if context.mode == "OBJECT":
Expand Down
4 changes: 2 additions & 2 deletions MCprep_addon/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def isTextureSwapCompatible(context):
}
for obj in context.selected_objects:
# If the header exists then we should be fine
if obj["MCPREP_OBJ_HEADER"] is not None:
if "MCPREP_OBJ_HEADER" in obj:
if obj["MCPREP_OBJ_FILE_TYPE"] == "ATLAS":
file_types["ATLAS"] += 1
else:
Expand All @@ -239,7 +239,7 @@ def isTextureSwapCompatible(context):
return True
if file_types["ATLAS"] == 0:
return True
return False
return False

def face_on_edge(faceLoc):
"""Check if a face is on the boundary between two blocks (local coordinates)."""
Expand Down
20 changes: 13 additions & 7 deletions MCprep_addon/world_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import os
import math
import re

import bpy
from bpy_extras.io_utils import ExportHelper, ImportHelper
Expand Down Expand Up @@ -104,18 +103,25 @@ def detect_world_exporter(filepath):
try:
header = obj_fd.readline()
if 'mineways' in header.lower():
conf.obj_header.set_mineways()
obj_header.set_mineways()
# form of: # Wavefront OBJ file made by Mineways version 5.10...
for line in obj_fd:
if line.startswith("# File type:"):
header = line
header = line.rstrip() # Remove trailing newline

# The issue here is that Mineways has changed how the header is generated. As such, we're limited with only a couple of OBJs, some from 2020 and some from 2023, so we'll assume people are using an up to date version.
atlas = re.compile(r'\btextures to three large images|full color texture patterns\b')
tiles = re.compile(r'\bexport individual textures|tiles for textures\b')
if re.search(atlas, header.lower()) is not None: # If a texture atlas is used
atlas = (
"# File type: Export all textures to three large images",
"# File type: Export full color texture patterns"
)
tiles = (
"# File type: Export tiles for textures to directory textures",
"# File type: Export individual textures to directory tex"
)
print(f"\"{header}\"")
if header in atlas: # If a texture atlas is used
obj_header.set_atlas()
elif re.search(tiles, header.lower()) is not None: # If the OBJ uses individual textures
elif header in tiles: # If the OBJ uses individual textures
obj_header.set_seperated()
return
except UnicodeDecodeError:
Expand Down

0 comments on commit acad35c

Please sign in to comment.