Skip to content

Commit

Permalink
Release - 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
simon50keda committed Dec 17, 2019
1 parent 983ae41 commit 7ca2c43
Show file tree
Hide file tree
Showing 269 changed files with 17,203 additions and 10,653 deletions.
364 changes: 201 additions & 163 deletions addon/io_scs_tools/__init__.py

Large diffs are not rendered by default.

103 changes: 47 additions & 56 deletions addon/io_scs_tools/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#
# ##### END GPL LICENSE BLOCK #####

# Copyright (C) 2013-2017: SCS Software
# Copyright (C) 2013-2019: SCS Software

"""
Constants for data group of map and navigation curves
Expand All @@ -31,8 +31,8 @@ class ConnectionsStorage:
"""Constants related for storage of connections used in custom drawing
"""

group_name = ".scs_connection_storage"
"""Name of bpy.data.group which will be used for storing Custom Property for connections dictionary"""
collection_name = ".scs_connection_storage"
"""Name of bpy.data.collection which will be used for storing Custom Property for connections dictionary"""
custom_prop_name = "scs_locator_connections"
"""Name of the Blender Custom Property where dictionary for connections will be stored"""

Expand Down Expand Up @@ -67,51 +67,35 @@ class TerrainPoints:
class View3DReport:
"""Constants related to 3D view report operator.
"""
# constants defining BT logo image and texts/positions of close/hide controls
BT_LOGO_IMG_NAME = ".scs_bt_logo.png"
BT_LOGO_AREA = (20, 217, 30, 50)
CLOSE_BTN_AREA = (230, 370, 26, 54)
CLOSE_BTN_TEXT = (
"[Click] Close", # used when report text is shown
"[Click/ESC] Close" # used when report text is hidden (aka condensed mode)
)
CLOSE_BTN_TEXT_POS = (
(260, 45), # used when report text is shown
(240, 45) # used when report text is hidden (aka condensed mode)
)
HIDE_BTN_AREA = (385, 530, 26, 54)
HIDE_BTN_TEXT = (
"[Click/ESC] Hide", # used when report text is shown
"[Click] Show" # used when report text is hidden (aka condensed mode)
)
HIDE_BTN_TEXT_POS = (
(400, 45), # used when report text is shown
(415, 45) # used when report text is hidden (aka condensed mode)
)
SCROLLUP_BTN_AREA = (545, 585, 26, 54)
SCROLLUP_BTN_TEXT = (
"↑", # used when report text is shown
"" # used when report text is hidden (aka condensed mode)
)
SCROLLUP_BTN_TEXT_POS = (
(560, 45), # used when report text is shown
(560, 45) # used when report text is hidden (aka condensed mode)
)
SCROLLDOWN_BTN_AREA = (585, 625, 26, 54)
SCROLLDOWN_BTN_TEXT = (
"↓", # used when report text is shown
"" # used when report text is hidden (aka condensed mode)
)
SCROLLDOWN_BTN_TEXT_POS = (
(600, 45), # used when report text is shown
(600, 45) # used when report text is hidden (aka condensed mode)
)
# constants defining BT banner image and texts/positions of close/hide controls
BT_BANNER_IMG_NAME = ".scs_bt_banner.png"
BT_BANNER_WITH_CTRLS_IMG_NAME = ".scs_bt_banner_with_ctrls.png"
CLOSE_BTN_AREA = (270, 290, -25, -5)
CLOSE_BTN_TEXT_POS = (272, -9)
CLOSE_BTN_TEXT = "×"
HIDE_BTN_AREA = (245, 265, -25, -5)
HIDE_BTN_TEXT_POS = (250, -5)
HIDE_BTN_TEXT = "–"
SCROLLUP_BTN_AREA = (225, 240, -25, -5)
SCROLLUP_BTN_TEXT_POS = (226, -9)
SCROLLUP_BTN_TEXT = "↑"
SCROLLDOWN_BTN_AREA = (205, 220, -25, -5)
SCROLLDOWN_BTN_TEXT_POS = (206, -9)
SCROLLDOWN_BTN_TEXT = "↓"

class InventoryMoveType:
"""Constants related to moving type in operators for inventories items moving.
"""
move_down = "down"
move_up = "up"


class Icons:
"""Constants related to loading of custom icons.
"""

default_icon_theme = "white"

class Types:
"""This class saves names of all custom icons for Blender Tools.
"""
Expand All @@ -136,8 +120,8 @@ class Types:
loc_collider_cylinder = ".19_collider_cylinder.png"
loc_collider_convex = ".20_collider_convex.png"
scs_root = ".21_scs_root_object.png"
scs_object_menu = ".22_scs_object_menu.png"
scs_logo = ".icon_scs_bt_logo.png"
scs_logo_orange = ".icon_scs_bt_logo_orange.png"

@staticmethod
def as_list():
Expand All @@ -151,7 +135,7 @@ def as_list():
Icons.Types.loc_prefab_navigation, Icons.Types.loc_prefab_map, Icons.Types.loc_prefab_trigger,
Icons.Types.loc_collider_box, Icons.Types.loc_collider_sphere, Icons.Types.loc_collider_capsule,
Icons.Types.loc_collider_cylinder, Icons.Types.loc_collider_convex, Icons.Types.scs_root,
Icons.Types.scs_logo_orange, Icons.Types.scs_logo]
Icons.Types.scs_object_menu, Icons.Types.scs_logo]


class Part:
Expand Down Expand Up @@ -186,15 +170,17 @@ class Material:
"""Unset value of material substance (used for identifying if this value in material was set)"""
node_group_prefix = ".SCS_NG_"
"""Prefix for naming node groups used by SCS materials"""
prevm_material_name = ".scs_prevm"
"""Name of the material used on SCS preview models."""


class Colors:
"""Constants related to colors in Blender
"""
gamma = 2.2
"""Gamma value used by Blender for correcting display colors."""
saturation = 1.15
"""Amount of saturation for vertex colors in nodes."""
prevm_color = (0.36, 0.29, 0.57, 1)
"""Color array used for preview models."""


class LampTools:
Expand Down Expand Up @@ -474,21 +460,19 @@ class ConvHlpr:


class SCSLigthing:
"""Constants for scs lighting scene. Lighting scene is created from sun profile loaded from SII file.
"""Constants for scs lighting.
"""
scene_name = ".scs_lighting"
"""Name of lighting scene. It should be prefixed with dot to be partially hidden in scene selection theme."""

ambient_lamps = (
(".scs_ambient_z+", (pi, 0, 0), 0.5),
(".scs_ambient_z-", (0, 0, 0), 1.1)
)
"""Ambient lamps definitions. Each lamp is defined as (name, direction, energy_factor).
There has to be 6 hemi lamps to point in each direction, which should reassemble ambient lights.
Energy factor in each of lamps tells percent of given light by that ambient lamp."""
sun_lamp_name = ".scs_sun"
"""Name of scs sun object in the lighting scene."""

diffuse_lamp_name = ".scs_diffuse"
specular_lamp_name = ".scs_specular"
default_ambient = (0.3,) * 3
default_diffuse = (0.9,) * 3
default_specular = (0.5,) * 3
default_env = 1.0
"""Default lighting values used when scs lighting is disabled, gotten from effect/eut/defaults.sii"""


class PaintjobTools:
Expand Down Expand Up @@ -587,3 +571,10 @@ class VehicleTypes:
(255, 64, 166)
)
"""Array of unique colors for building ID mask texture."""


class Cache:
dir_name = "blender_scs_blender_tools"
"""Name of the directory inside tmp directory, that will be used for cache storage."""
max_size = 40 * 1024 * 1024 # 40MB
"""Maximum size of tmp directory cache."""
9 changes: 1 addition & 8 deletions addon/io_scs_tools/exp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,6 @@ def batch_export(operator_instance, init_obj_list, name_suffix="", menu_filepath
scs_game_objects_rejected.append("> \"" + root_object.name + "\"")
continue

# update root object location to invoke update tagging on it and
# then update scene to make sure all children objects will have all transforms up to date
# NOTE: needed because Blender doesn't update objects on invisible layers on it's own
root_object.location = root_object.location
for scene in bpy.data.scenes:
scene.update()

# GET CUSTOM FILE PATH
custom_filepath = _path_utils.get_custom_scs_root_export_path(root_object)

Expand Down Expand Up @@ -122,7 +115,7 @@ def batch_export(operator_instance, init_obj_list, name_suffix="", menu_filepath

if not lprint("\nI Export procces completed, summaries are printed below!", report_errors=True, report_warnings=True):
operator_instance.report({'INFO'}, "Export successfully completed, exported %s game object(s)!" % len(scs_game_objects_exported))
bpy.ops.wm.show_3dview_report('INVOKE_DEFAULT', abort=True) # abort 3d view reporting operator
bpy.ops.wm.scs_tools_show_3dview_report('INVOKE_DEFAULT', abort=True) # abort 3d view reporting operator

if len(scs_game_objects_exported) > 0:
message = "EXPORTED GAME OBJECTS (" + str(len(scs_game_objects_exported)) + "):\n\t " + "=" * 26 + "\n\t "
Expand Down
20 changes: 13 additions & 7 deletions addon/io_scs_tools/exp/pia.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def _get_bone_channels(scs_root_obj, armature, scs_animation, action, export_sca

# armature matrix stores transformation of armature object against scs root
# and has to be added to all bones as they only armature space transformations
armature_mat = scs_root_obj.matrix_world.inverted() * armature.matrix_world
armature_mat = scs_root_obj.matrix_world.inverted() @ armature.matrix_world

invalid_data = False # flag to indicate invalid data state
curves_per_bone = OrderedDict() # store all the curves we are interested in per bone names
Expand Down Expand Up @@ -143,10 +143,12 @@ def _get_bone_channels(scs_root_obj, armature, scs_animation, action, export_sca
quat_rot_curves = bone_curves["quat_rotation"]
sca_curves = bone_curves["scale"]

bone_rest_mat = armature_mat * bone.matrix_local
bone_rest_mat = armature_mat @ bone.matrix_local
if bone.parent:
parent_bone_rest_mat = (Matrix.Scale(export_scale, 4) * _convert_utils.scs_to_blend_matrix().inverted() *
armature_mat * bone.parent.matrix_local)
parent_bone_rest_mat = (Matrix.Scale(export_scale, 4) @
_convert_utils.scs_to_blend_matrix().inverted() @
armature_mat @
bone.parent.matrix_local)
else:
parent_bone_rest_mat = Matrix()

Expand Down Expand Up @@ -202,7 +204,7 @@ def _get_bone_channels(scs_root_obj, armature, scs_animation, action, export_sca
mat_sca[3] = (0, 0, 0, 1)

# BLENDER FRAME MATRIX
mat = mat_loc * mat_rot * mat_sca
mat = mat_loc @ mat_rot @ mat_sca

# SCALE REMOVAL MATRIX
rest_location, rest_rotation, rest_scale = bone_rest_mat.decompose()
Expand All @@ -218,8 +220,12 @@ def _get_bone_channels(scs_root_obj, armature, scs_animation, action, export_sca
scale_matrix = Matrix.Scale(export_scale, 4)

# COMPUTE SCS FRAME MATRIX
frame_matrix = (parent_bone_rest_mat.inverted() * _convert_utils.scs_to_blend_matrix().inverted() *
scale_matrix.inverted() * bone_rest_mat * mat * scale_removal_matrix.inverted())
frame_matrix = (parent_bone_rest_mat.inverted() @
_convert_utils.scs_to_blend_matrix().inverted() @
scale_matrix.inverted() @
bone_rest_mat @
mat @
scale_removal_matrix.inverted())

# print(' actual_frame: %s - value: %s' % (actual_frame, frame_matrix))
timings_stream.append(("__time__", scs_animation.length / total_frames), )
Expand Down
22 changes: 11 additions & 11 deletions addon/io_scs_tools/exp/pic.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def _fill_piece_sections(convex_coll_locators, export_scale):
for vert in verts:
# scs_position = Matrix.Scale(scs_globals.export_scale, 4) * io_utils.scs_to_blend_matrix().inverted() * mat_world * position ##
# POSITION
scs_position = Matrix.Scale(export_scale, 4) * _convert_utils.scs_to_blend_matrix().inverted() * Vector(vert) # POSITION
scs_position = Matrix.Scale(export_scale, 4) @ _convert_utils.scs_to_blend_matrix().inverted() @ Vector(vert) # POSITION
vector_verts.append(Vector(scs_position))
section.sections.append(_pix_container.make_stream_section(vector_verts, "_POSITION", ()))

Expand Down Expand Up @@ -166,25 +166,25 @@ def _make_common_part(item, index, col_type):

if not item.scs_props.locator_collider_centered:
if item.scs_props.locator_collider_type == 'Box':
offset_matrix = (item.matrix_world *
Matrix.Translation((0.0, -item.scs_props.locator_collider_box_y / 2, 0.0)) *
(Matrix.Scale(item.scs_props.locator_collider_box_x, 4, (1.0, 0.0, 0.0)) *
Matrix.Scale(item.scs_props.locator_collider_box_y, 4, (0.0, 1.0, 0.0)) *
offset_matrix = (item.matrix_world @
Matrix.Translation((0.0, -item.scs_props.locator_collider_box_y / 2, 0.0)) @
(Matrix.Scale(item.scs_props.locator_collider_box_x, 4, (1.0, 0.0, 0.0)) @
Matrix.Scale(item.scs_props.locator_collider_box_y, 4, (0.0, 1.0, 0.0)) @
Matrix.Scale(item.scs_props.locator_collider_box_z, 4, (0.0, 0.0, 1.0))))
elif item.scs_props.locator_collider_type == 'Sphere':
offset_matrix = (item.matrix_world *
Matrix.Translation((0.0, -item.scs_props.locator_collider_dia / 2, 0.0)) *
offset_matrix = (item.matrix_world @
Matrix.Translation((0.0, -item.scs_props.locator_collider_dia / 2, 0.0)) @
Matrix.Scale(item.scs_props.locator_collider_dia, 4))
elif item.scs_props.locator_collider_type in ('Capsule', 'Cylinder'):
offset_matrix = (item.matrix_world *
Matrix.Translation((0.0, -item.scs_props.locator_collider_len / 2, 0.0)) *
offset_matrix = (item.matrix_world @
Matrix.Translation((0.0, -item.scs_props.locator_collider_len / 2, 0.0)) @
Matrix.Scale(item.scs_props.locator_collider_dia, 4))
else:
offset_matrix = item.matrix_world

loc, qua, sca = _convert_utils.get_scs_transformation_components(scs_root.matrix_world.inverted() * offset_matrix)
loc, qua, sca = _convert_utils.get_scs_transformation_components(scs_root.matrix_world.inverted() @ offset_matrix)
else:
loc, qua, sca = _convert_utils.get_scs_transformation_components(scs_root.matrix_world.inverted() * item.matrix_world)
loc, qua, sca = _convert_utils.get_scs_transformation_components(scs_root.matrix_world.inverted() @ item.matrix_world)

section = _SectionData("Locator")
section.props.append(("Name", _name_utils.tokenize_name(item.name)))
Expand Down
Loading

0 comments on commit 7ca2c43

Please sign in to comment.