support external texture

This commit is contained in:
yyc12345 2020-07-14 14:55:12 +08:00
parent c27505b1a5
commit fa1c5c8a30
3 changed files with 98 additions and 4 deletions

View File

@ -19,7 +19,9 @@ if "bpy" in locals():
importlib.reload(floor_rail_uv)
if "utils" in locals():
importlib.reload(utils)
from . import utils, bm_import_export, floor_rail_uv
if "config" in locals():
importlib.reload(config)
from . import config, utils, bm_import_export, floor_rail_uv
# ============================================= func block

View File

@ -2,6 +2,7 @@ import bpy,bmesh,bpy_extras,mathutils
import pathlib,zipfile,time,os,tempfile,math
import struct,shutil
from bpy_extras import io_utils,node_shader_utils
from . import utils, config
bm_current_version = 10
@ -230,6 +231,7 @@ def export_bm(context,filepath,export_mode, export_target, no_component_suffix):
# ====================== export texture
ftexture = open(os.path.join(tempFolder, "texture.bm"), "wb")
source_dir = os.path.dirname(bpy.data.filepath)
existed_texture = set()
for texture in textureList:
# write finfo first
@ -245,9 +247,11 @@ def export_bm(context,filepath,export_mode, export_target, no_component_suffix):
if (is_external_texture(filename)):
write_int(ftexture, 1)
else:
# copy internal texture
# copy internal texture, if this file is copied, do not copy it again
write_int(ftexture, 0)
shutil.copy(texture_filepath, os.path.join(tempTextureFolder, filename))
if filename not in existed_texture:
shutil.copy(texture_filepath, os.path.join(tempTextureFolder, filename))
existed_texture.add(filename)
ftexture.close()
@ -280,7 +284,10 @@ def get_component_id(name):
return -1 # todo: finish this, -1 mean not a component
def is_external_texture(name):
return False # todo: finish this. external mean no copy file
if name in config.external_texture_list:
return True
else:
return False
def mesh_triangulate(me):
bm = bmesh.new()

View File

@ -0,0 +1,85 @@
external_texture_list = set([
'Ball_LightningSphere1.bmp',
'Ball_LightningSphere2.bmp',
'Ball_LightningSphere3.bmp',
'Ball_Paper.bmp',
'Ball_Stone.bmp',
'Ball_Wood.bmp',
'Brick.bmp',
'Button01_deselect.tga',
'Button01_select.tga',
'Button01_special.tga',
'Column_beige.bmp',
'Column_beige_fade.tga',
'Column_blue.bmp',
'Cursor.tga',
'Dome.bmp',
'DomeEnvironment.bmp',
'DomeShadow.tga',
'ExtraBall.bmp',
'ExtraParticle.bmp',
'E_Holzbeschlag.bmp',
'FloorGlow.bmp',
'Floor_Side.bmp',
'Floor_Top_Border.bmp',
'Floor_Top_Borderless.bmp',
'Floor_Top_Checkpoint.bmp',
'Floor_Top_Flat.bmp',
'Floor_Top_Profil.bmp',
'Floor_Top_ProfilFlat.bmp',
'Font_1.tga',
'Gravitylogo_intro.bmp',
'HardShadow.bmp',
'Laterne_Glas.bmp',
'Laterne_Schatten.tga',
'Laterne_Verlauf.tga',
'Logo.bmp',
'Metal_stained.bmp',
'Misc_Ufo.bmp',
'Misc_UFO_Flash.bmp',
'Modul03_Floor.bmp',
'Modul03_Wall.bmp',
'Modul11_13_Wood.bmp',
'Modul11_Wood.bmp',
'Modul15.bmp',
'Modul16.bmp',
'Modul18.bmp',
'Modul18_Gitter.tga',
'Modul30_d_Seiten.bmp',
'Particle_Flames.bmp',
'Particle_Smoke.bmp',
'PE_Bal_balloons.bmp',
'PE_Bal_platform.bmp',
'PE_Ufo_env.bmp',
'Pfeil.tga',
'P_Extra_Life_Oil.bmp',
'P_Extra_Life_Particle.bmp',
'P_Extra_Life_Shadow.bmp',
'Rail_Environment.bmp',
'sandsack.bmp',
'SkyLayer.bmp',
'Sky_Vortex.bmp',
'Stick_Bottom.tga',
'Stick_Stripes.bmp',
'Target.bmp',
'Tower_Roof.bmp',
'Trafo_Environment.bmp',
'Trafo_FlashField.bmp',
'Trafo_Shadow_Big.tga',
'Tut_Pfeil01.tga',
'Tut_Pfeil_Hoch.tga',
'Wolken_intro.tga',
'Wood_Metal.bmp',
'Wood_MetalStripes.bmp',
'Wood_Misc.bmp',
'Wood_Nailed.bmp',
'Wood_Old.bmp',
'Wood_Panel.bmp',
'Wood_Plain.bmp',
'Wood_Plain2.bmp',
'Wood_Raft.bmp'
])
component_list = [
]