Skip to content

Commit

Permalink
Beta - 0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
simon50keda committed Feb 19, 2015
1 parent 1aa5fa2 commit 4ba0069
Show file tree
Hide file tree
Showing 25 changed files with 124 additions and 11,061 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,22 @@ Notes:
Help, questions, troubleshooting:
---------------------------------
If you encounter any problems or have questions regarding SCS Blender Tools,
please visit "Blender Tools" forum at "http://forum.scssoft.com" and
please visit forum at "http://forum.scssoft.com/viewforum.php?f=159" and
don't hesitate to ask if your problem wasn't addressed already. Also
don't miss the wiki ("https://github.com/SCSSoftware/BlenderTools/wiki")
for many useful tips and docs.


Bugs:
-----
For reporting bugs please visit our forum at "http://forum.scssoft.com" and
go to "Blender Tools > Bugs" sub-forums.
For reporting bugs please visit forum at
"http://forum.scssoft.com/viewforum.php?f=163".


License:
--------
SCS Blender Tools are developed and distributed under GNU GPL v2.
http://www.gnu.org/licenses/gpl-2.0.html
SCS Blender Tools are developed and distributed under GNU GPL v2
("http://www.gnu.org/licenses/gpl-2.0.html").


SCS Blender Tools Team
Expand Down
40 changes: 20 additions & 20 deletions addon/io_scs_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,31 +120,31 @@ def draw(self, context):
box2 = layout.box()

row = box2.row()
row.prop(scs_globals, "import_pim_file", toggle=True)
if scs_globals.import_pim_file:
row = box2.row()
row.prop(scs_globals, "auto_welding")
row.prop(scs_globals, "import_pim_file", toggle=True)
if scs_globals.import_pim_file:
row = box2.row()
row.prop(scs_globals, "import_pit_file", toggle=True)
if scs_globals.import_pit_file:
row = box2.row()
row.prop(scs_globals, "load_textures")
row.prop(scs_globals, "auto_welding")
row = box2.row()
row.prop(scs_globals, "import_pit_file", toggle=True)
if scs_globals.import_pit_file:
row = box2.row()
row.prop(scs_globals, "import_pic_file", toggle=True)
row.prop(scs_globals, "load_textures")
row = box2.row()
row.prop(scs_globals, "import_pic_file", toggle=True)
row = box2.row()
row.prop(scs_globals, "import_pip_file", toggle=True)
row = box2.row()
row.prop(scs_globals, "import_pis_file", toggle=True)
if scs_globals.import_pis_file:
# row = box2.row()
# row.prop(_get_scs_globals(), "connected_bones")
row = box2.row()
row.prop(scs_globals, "import_pip_file", toggle=True)
row.prop(scs_globals, "bone_import_scale")
row = box2.row()
row.prop(scs_globals, "import_pis_file", toggle=True)
if scs_globals.import_pis_file:
# row = box2.row()
# row.prop(_get_scs_globals(), "connected_bones")
row = box2.row()
row.prop(scs_globals, "bone_import_scale")
row.prop(scs_globals, "import_pia_file", toggle=True)
if scs_globals.import_pia_file:
row = box2.row()
row.prop(scs_globals, "import_pia_file", toggle=True)
if scs_globals.import_pia_file:
row = box2.row()
row.prop(scs_globals, "include_subdirs_for_pia")
row.prop(scs_globals, "include_subdirs_for_pia")

ui.shared.draw_debug_settings(layout)

Expand Down
19 changes: 14 additions & 5 deletions addon/io_scs_tools/exp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,27 @@ def batch_export(operator_instance, init_obj_list, exclude_switched_off=True, me
filepath = global_filepath

# print(' filepath (%r):\n%r' % (root_object.name, str(filepath)))

if filepath:
scs_project_path = _get_scs_globals().scs_project_path
if filepath and filepath.startswith(scs_project_path) and scs_project_path != "":
pix.export(filepath, root_object, game_object_list)
scs_game_objects_exported += 1
# if result != {'FINISHED'}: return {'CANCELLED'}
else:
message = "No valid export path found! Please check the export path."
if filepath:
message = (
"No valid export inside SCS Project Base Path found!\n\t "
"Make sure that SCS Project Base Path is properly set and\n\t " +
"that you are exporting somewhere inside that path!\n\t " +
"SCS Project Base Path:\n\t \"" + scs_project_path + "\"\n\t " +
"SCS Game Object export path:\n\t \"" + filepath + "\""
)
else:
message = "No valid export path found! Please check the export path."
lprint('E ' + message)
operator_instance.report({'ERROR'}, message)
operator_instance.report({'ERROR'}, message.replace("\t", "").replace(" ", ""))
return {'CANCELLED'}

if scs_game_objects_exported:
if scs_game_objects_exported > 0:
if scs_game_objects_exported == 1:
message = "Single 'SCS Game Object' exported."
else:
Expand Down
52 changes: 42 additions & 10 deletions addon/io_scs_tools/exp/pit.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import bpy
import os
import shutil
from io_scs_tools.consts import Variant as _VARIANT_consts
from io_scs_tools.exp import tobj as _tobj
from io_scs_tools.internals.structure import SectionData as _SectionData
Expand Down Expand Up @@ -123,7 +124,7 @@ def _default_material(alias):
return material_export_data


def _get_texture_path_from_material(material, texture_type):
def _get_texture_path_from_material(material, texture_type, export_path):
"""Get's relative path for Texture section of tobj from given texture_type.
If tobj is not yet created it also creates tobj for it.
Expand All @@ -148,22 +149,52 @@ def _get_texture_path_from_material(material, texture_type):
return tex_entry["Value"]

# TEXTURE PATH
texture_path = getattr(material.scs_props, "shader_" + texture_type, "NO PATH")
texture_abs_filepath = _path_utils.get_abs_path(texture_path)
texture_raw_path = getattr(material.scs_props, "shader_" + texture_type, "NO PATH")
texture_abs_filepath = _path_utils.get_abs_path(texture_raw_path)

# TOBJ PATH
tobj_rel_filepath = os.path.splitext(texture_path)[0][1:]
tobj_abs_filepath = str(os.path.splitext(texture_abs_filepath)[0] + ".tobj")
scs_project_path = _get_scs_globals().scs_project_path
if os.path.isfile(scs_project_path + os.sep + texture_raw_path): # relative within base

tobj_rel_filepath = os.path.splitext(texture_raw_path)[0][1:]
tobj_abs_filepath = str(os.path.splitext(texture_abs_filepath)[0] + ".tobj")

elif os.path.isfile(texture_raw_path): # absolute

# if we are exporting somewhere into SCS Project Base Path texture still can be saved
if scs_project_path != "" and export_path.startswith(scs_project_path):

tex_dir, tex_filename = os.path.split(texture_raw_path)

# copy texture beside exported files
shutil.copy2(texture_raw_path, os.path.join(export_path, tex_filename))

tobj_filename = tex_filename.split(".")[0]
export_rel_path = os.path.relpath(export_path, scs_project_path)
tobj_rel_filepath = os.sep + export_rel_path + os.sep + tobj_filename
tobj_abs_filepath = os.path.join(export_path, tobj_filename + ".tobj")

else:
lprint("E Can not properly export texture %r from material %r!\n\t " +
"Make sure you are exporting somewhere into Project Base Path and texture is properly set!",
(texture_raw_path, material.name))
return ""

else:
lprint("E Texture file %r from material %r doesn't exists inside current Project Base Path, TOBJ can not be exported!",
(texture_raw_path, material.name))
return ""

# CREATE TOBJ FILE
if not os.path.isfile(tobj_abs_filepath) or getattr(material.scs_props, "shader_" + texture_type + "_export_tobj", False):

# export tobj only if file of texture exists
if os.path.isfile(texture_abs_filepath):
settings = getattr(material.scs_props, "shader_" + texture_type + "_settings", set())
_tobj.export(tobj_abs_filepath, os.path.split(texture_path)[1], settings)
_tobj.export(tobj_abs_filepath, os.path.split(texture_raw_path)[1], settings)
else:
lprint("W Texture file '%s' specified in material '%s' doesn't exists, TOBJ can not be exported!", (texture_path, material.name))
lprint("E Texture file %r from material %r doesn't exists, TOBJ can not be exported!",
(texture_raw_path, material.name))

# make sure that Windows users will export proper paths
tobj_rel_filepath = tobj_rel_filepath.replace("\\", "/")
Expand Down Expand Up @@ -302,7 +333,7 @@ def export(root_object, used_parts, used_materials, scene, filepath):

# SUBSTANCE
if material.scs_props.substance != 'None':
print('material.name: %r\tmat.scs_props.substance: "%s"' % (material.name, str(material.scs_props.substance)))
lprint('D material.name: %r\tmat.scs_props.substance: "%s"', (material.name, str(material.scs_props.substance)))
# TODO: Substance Export...

# MATERIAL EFFECT
Expand Down Expand Up @@ -433,7 +464,8 @@ def export(root_object, used_parts, used_materials, scene, filepath):
# print(' tag_prop: %r' % str(tag_prop))

# create and get path to tobj
tobj_rel_path = _get_texture_path_from_material(material, tag_prop)
tobj_rel_path = _get_texture_path_from_material(material, tag_prop,
os.path.dirname(filepath))

texture_data.props.append((rec[0], tobj_rel_path))

Expand Down Expand Up @@ -508,7 +540,7 @@ def export(root_object, used_parts, used_materials, scene, filepath):

if tex_prop == "Value" and tag_id_string != "":

tobj_rel_path = _get_texture_path_from_material(material, tag_id_string)
tobj_rel_path = _get_texture_path_from_material(material, tag_id_string, os.path.dirname(filepath))
texture_section.props.append((tex_prop, tobj_rel_path))

else:
Expand Down
8 changes: 4 additions & 4 deletions addon/io_scs_tools/imp/pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ def load(filepath):
# print(' tsem_position: %s' % tsem_position)
# print(' tsem_rotation: %s' % str(tsem_rotation))
# print(' tsem_type: %s' % tsem_type)
print(' tsem_id: %s' % tsem_id)
# print(' tsem_id: %s' % tsem_id)
# print(' tsem_intervals: %s' % tsem_intervals)
# print(' tsem_cycle: %s' % tsem_cycle)
# print(' tsem_model: %s' % tsem_model)
Expand Down Expand Up @@ -1293,7 +1293,7 @@ def load(filepath):
start_node = mp_locs[connection[0]]
end_node = mp_locs[connection[1]]
else:
print(' Err - map connection out of range: %s' % str(connection))
lprint('E Map connection out of range: %s', (str(connection),))
continue

_group_connections_wrapper.create_connection(start_node, end_node)
Expand All @@ -1303,7 +1303,7 @@ def load(filepath):
for loc_index, tr_point in enumerate(trigger_points_data):
# print(' name: %s' % tr_point[0])
if len(tr_point[9]) != 2:
print('WARNING - Unexpected number of connections (%i) for Trigger Point "%s"!' % (len(tr_point[9]), tr_point[0]))
lprint('W Unexpected number of connections (%i) for Trigger Point "%s"!', (len(tr_point[9]), tr_point[0]))

for loc_neighbour_index in tr_point[9]:
connections.append((loc_index, loc_neighbour_index))
Expand Down Expand Up @@ -1342,7 +1342,7 @@ def load(filepath):
start_node = tp_locs[connection[0]]
end_node = tp_locs[connection[1]]
else:
print(' Err - trigger connection: %s' % str(connection))
print('E Trigger connection: %s', (str(connection),))
continue

_group_connections_wrapper.create_connection(start_node, end_node)
Expand Down
2 changes: 1 addition & 1 deletion addon/io_scs_tools/imp/pit.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def _get_variant(section):
if var_part_value[0] == 1:
variantparts.append(_name_utils.tokenize_name(part_name))
else:
print('---var_part_value: %s' % str(var_part_value))
lprint('D ---var_part_value: %s', (str(var_part_value),))
return variant_name, variantparts


Expand Down
3 changes: 2 additions & 1 deletion addon/io_scs_tools/internals/callbacks/persistent.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@ def disable():
if _persistent_init.initialise_scs_dict in bpy.app.handlers.load_post:
bpy.app.handlers.load_post.remove(_persistent_init.initialise_scs_dict)
if _persistent_loop.object_data_check in bpy.app.handlers.scene_update_post:
bpy.app.handlers.scene_update_post.remove(_persistent_loop.object_data_check) if _persistent_file_save.pre_save in bpy.app.handlers.save_pre:
bpy.app.handlers.scene_update_post.remove(_persistent_loop.object_data_check)
if _persistent_file_save.pre_save in bpy.app.handlers.save_pre:
bpy.app.handlers.save_pre.remove(_persistent_file_save.pre_save)
11 changes: 3 additions & 8 deletions addon/io_scs_tools/internals/containers/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ def update_tsem_library_rel_path(scs_tsem_profile_inventory, tsem_library_rel_pa

else:
print(' tsem_library_rel_path: "%s"' % str(tsem_library_rel_path))
# print(' tsem_library_filepath:\n%s' % str(tsem_library_filepath))

update_item_in_file('Paths.TSemProfileRelFilePath', tsem_library_rel_path)

Expand Down Expand Up @@ -237,7 +236,6 @@ def update_traffic_rules_library_rel_path(scs_traffic_rules_inventory, traffic_r

else:
print(' traffic_rules_library_rel_path: "%s"' % str(traffic_rules_library_rel_path))
# print(' traffic_rules_library_filepath:\n%s' % str(traffic_rules_library_filepath))

update_item_in_file('Paths.TrafficRulesRelFilePath', traffic_rules_library_rel_path)

Expand Down Expand Up @@ -331,7 +329,6 @@ def update_matsubs_inventory(scs_matsubs_inventory, matsubs_library_rel_path):

else:
print(' matsubs_library_rel_path: "%s"' % str(matsubs_library_rel_path))
# print(' matsubs_library_filepath:\n%s' % str(matsubs_library_filepath))

update_item_in_file('Paths.MatSubsRelFilePath', matsubs_library_rel_path)

Expand Down Expand Up @@ -476,8 +473,6 @@ def get_config_filepath():
# SEARCH FOR CONFIG...
scs_config_file = ''
for i, location in enumerate(scs_installation_dirs):
if len(scs_installation_dirs) > 1:
print('\tSCS Blender Tools Installation %i:\n\t "%s"\n\n' % (i + 1, location))
test_path = os.path.join(location, 'config.txt')
if os.path.isfile(test_path):
scs_config_file = test_path
Expand Down Expand Up @@ -525,7 +520,7 @@ def apply_settings():
elif prop[0] == "MatSubsRelFilePath":
_get_scs_globals().matsubs_library_rel_path = prop[1]
else:
print('WARNING - Unrecognised item "%s" has been found in setting file! Skipping...' % str(prop[0]))
lprint('W Unrecognised item "%s" has been found in setting file! Skipping...', (str(prop[0]),))
elif section.type == "Import":
for prop in section.props:
if prop[0] in ("", "#"):
Expand Down Expand Up @@ -614,7 +609,7 @@ def apply_settings():
elif prop[0] == "DisplayTextInfo":
bpy.context.scene.scs_props.display_info = prop[1]
else:
print('WARNING - Unrecognised item "%s" has been found in setting file! Skipping...' % str(prop[0]))
lprint('W Unrecognised item "%s" has been found in setting file! Skipping...', (str(prop[0]),))
elif section.type == "GlobalColors":
for prop in section.props:
if prop[0] in ("", "#"):
Expand All @@ -636,7 +631,7 @@ def apply_settings():
elif prop[0] == "InfoText":
bpy.context.scene.scs_props.info_text_color = prop[1]
else:
print('WARNING - Unrecognised item "%s" has been found in setting file! Skipping...' % str(prop[0]))
lprint('W Unrecognised item "%s" has been found in setting file! Skipping...', (str(prop[0]),))
elif section.type == "Various":
for prop in section.props:
# if prop[0] == "#":
Expand Down
3 changes: 1 addition & 2 deletions addon/io_scs_tools/internals/persistent/file_save.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,4 @@ def pre_save(scene):
img.use_fake_user = False
img.user_clear()

bpy.data.images.remove(img)
print("Removing image:", icon)
bpy.data.images.remove(img)
1 change: 0 additions & 1 deletion addon/io_scs_tools/internals/persistent/loop_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ def __object_rename__(old_name, new_name):
"""

# send rename notify into connections storage
print(old_name, new_name)
if _connections_group_wrapper.rename_locator(old_name, new_name):
_view3d_utils.tag_redraw_all_view3d()

Expand Down
2 changes: 1 addition & 1 deletion addon/io_scs_tools/operators/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def execute_export(self, context, disable_local_view):
:return: succes of batch export
:rtype: {'FINISHED'} | {'CANCELLED'}
"""
_get_scs_globals().content_type = 'selection' # NOTE: I'm not sure if this is still necessary.
_get_scs_globals().content_type = 'selection' # NOTE: I'm not sure if this is still necessary.

try:
result = _export.batch_export(self, tuple(bpy.context.selected_objects), exclude_switched_off=False)
Expand Down
2 changes: 1 addition & 1 deletion addon/io_scs_tools/properties/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def active_scs_animation_update(self, context):
('anim', "Animated Model", ""),
('rigid', "Rigid Model", ""),
),
default='anim',
default='rigid',
)
scs_root_object_allow_custom_path = BoolProperty(
name="Allow Custom Export File Path",
Expand Down
3 changes: 0 additions & 3 deletions addon/io_scs_tools/properties/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -1149,9 +1149,6 @@ def has(self, preset_name):
else:
return False

def println(self):
print(' ShaderPresetContainer.preset: %s' % self.preset)

@staticmethod
def get_shader_icon_str(preset_name):
"""
Expand Down
4 changes: 2 additions & 2 deletions addon/io_scs_tools/shader_presets.txt
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ Shader {
Tag: "shadow_bias"
Value: ( 0.0 )
}
}
}
Shader {
PresetName: "shadowonly"
Alias: "shadow_caster"
Expand All @@ -323,4 +323,4 @@ Shader {
Tag: "shadow_bias"
Value: ( 0.0 )
}
}
}
Loading

0 comments on commit 4ba0069

Please sign in to comment.