Skip to content

Commit

Permalink
Release - 1.12
Browse files Browse the repository at this point in the history
  • Loading branch information
simon50keda committed Feb 22, 2019
1 parent 9d9bd0c commit 983ae41
Show file tree
Hide file tree
Showing 36 changed files with 1,128 additions and 370 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ Installation and Usage:
Addon is located in "addon/io_scs_tools" folder.
Use standard Blender addon installation procedure for installing it.
For more information visit wiki at
"https://github.com/SCSSoftware/BlenderTools/wiki".
"http://modding.scssoft.com/wiki/Documentation/Tools/SCS_Blender_Tools".


Notes:
------
- In case of trouble installing SCS Blender Tools make sure you're using
compatible Blender version. SCS Blender Tools for Blender versions
prior 2.75 are not supported.
prior 2.73 are not supported.


Help, questions, troubleshooting:
---------------------------------
If you encounter any problems or have questions regarding SCS Blender Tools,
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")
don't miss wiki ("http://modding.scssoft.com/wiki/Documentation/Tools/SCS_Blender_Tools")
for many useful tips and docs.


Expand Down
2 changes: 1 addition & 1 deletion addon/io_scs_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"name": "SCS Tools",
"description": "Setup models, Import-Export SCS data format",
"author": "Simon Lusenc (50keda), Milos Zajic (4museman)",
"version": (1, 11, "2032583"),
"version": (1, 12, "be00ed8"),
"blender": (2, 78, 0),
"location": "File > Import-Export",
"wiki_url": "http://modding.scssoft.com/wiki/Documentation/Tools/SCS_Blender_Tools",
Expand Down
106 changes: 105 additions & 1 deletion addon/io_scs_tools/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,24 @@ class View3DReport:
(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)
)


class Icons:
Expand Down Expand Up @@ -354,9 +372,12 @@ class PSP:
UNLOAD_HARD_POS = 20
UNLOAD_RIGID_POS = 21
WEIGHT_CAT_POS = 22
COMPANY_UNLOAD_POS = 23
TRAILER_SPAWN = 24
LONG_TRAILER_POS = 25

class TST:
"""Constants representing type of traffic semaphores.
"""Constants representing type of traffic semaphores.
"""
PROFILE = 0
MODEL_ONLY = 1
Expand Down Expand Up @@ -474,6 +495,13 @@ class PaintjobTools:
"""Constants for paintjob tools.
"""

class VehicleTypes:
"""Vehicle types, defining where vehicle will be placed in defs and model paths.
"""
NONE = "none"
TRUCK = "truck"
TRAILER = "trailer_owned"

uvs_name_2nd = "scs_paintjob_2nd"
"""2nd uvs layer name used during unification on export"""
uvs_name_3rd = "scs_paintjob_3rd"
Expand All @@ -483,3 +511,79 @@ class PaintjobTools:
"""Name of the property for saving references paths to models inside a group data-block."""
export_tag_obj_name = ".scs_export_group"
"""Name of the object inside the group which visibility tells us either group should be exported or no."""
model_variant_prop = ".scs_variant"
"""Name of the property for saving variant of the model inside group encapsulating imported paintable model."""

id_mask_colors = (
(51, 0, 0),
(255, 136, 0),
(217, 202, 0),
(134, 179, 140),
(0, 190, 204),
(0, 31, 115),
(117, 70, 140),
(191, 96, 147),
(242, 61, 61),
(127, 68, 0),
(102, 95, 0),
(64, 255, 140),
(0, 204, 255),
(0, 0, 51),
(41, 0, 51),
(204, 0, 82),
(204, 102, 102),
(178, 137, 89),
(173, 179, 89),
(0, 77, 41),
(0, 41, 51),
(108, 108, 217),
(230, 128, 255),
(89, 0, 36),
(230, 172, 172),
(230, 203, 172),
(100, 102, 77),
(48, 191, 124),
(0, 170, 255),
(191, 191, 255),
(83, 0, 89),
(166, 124, 141),
(140, 49, 35),
(128, 113, 96),
(57, 77, 19),
(57, 77, 68),
(64, 106, 128),
(38, 38, 51),
(217, 0, 202),
(127, 0, 34),
(255, 115, 64),
(229, 172, 57),
(234, 255, 191),
(0, 51, 34),
(0, 68, 128),
(34, 0, 255),
(64, 32, 62),
(115, 57, 65),
(76, 34, 19),
(102, 77, 26),
(133, 204, 51),
(0, 255, 238),
(0, 27, 51),
(48, 0, 179),
(255, 191, 251),
(51, 26, 29),
(191, 156, 143),
(51, 38, 13),
(68, 255, 0),
(0, 115, 107),
(153, 180, 204),
(119, 54, 217),
(153, 0, 122),
(204, 112, 51),
(51, 47, 38),
(32, 128, 45),
(143, 191, 188),
(83, 116, 166),
(119, 105, 140),
(255, 64, 166)
)
"""Array of unique colors for building ID mask texture."""
3 changes: 3 additions & 0 deletions addon/io_scs_tools/exp/pim/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ def execute(dirpath, name_suffix, root_object, armature_object, skeleton_filepat
for scale_axis in parent.scale:
scale_sign *= scale_axis

for scale_axis in parent.delta_scale:
scale_sign *= scale_axis

parent = parent.parent

face_flip = scale_sign < 0
Expand Down
8 changes: 5 additions & 3 deletions addon/io_scs_tools/exp/pim_ef/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ def execute(dirpath, name_suffix, root_object, armature_object, skeleton_filepat
for scale_axis in parent.scale:
scale_sign *= scale_axis

for scale_axis in parent.delta_scale:
scale_sign *= scale_axis

parent = parent.parent

winding_order = 1
Expand Down Expand Up @@ -268,16 +271,15 @@ def execute(dirpath, name_suffix, root_object, armature_object, skeleton_filepat
rgbas.append(vcol)
rgbas_names[_MESH_consts.default_vcol] = True

# export rest of the vertex colors too, but do not apply extra multiplies of SCS exporter
# as rest of the layers are just artist layers
# export rest of the vertex colors too (also multiply with 2 and with vcol multiplicator)
for vcol_layer in mesh.vertex_colors:

# we already computed thoose so ignore them
if vcol_layer.name in [_MESH_consts.default_vcol, _MESH_consts.default_vcol + _MESH_consts.vcol_a_suffix]:
continue

color = vcol_layer.data[loop_i].color
vcol = (color[0], color[1], color[2], 1.0)
vcol = (color[0] * 2 * vcol_multi, color[1] * 2 * vcol_multi, color[2] * 2 * vcol_multi)

rgbas.append(vcol)
rgbas_names[vcol_layer.name] = True
Expand Down
14 changes: 10 additions & 4 deletions addon/io_scs_tools/exp/pim_ef/piece_face.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,17 @@ def add_rgbas(self, rgbas, rgbas_names):

for i, rgba in enumerate(rgbas):

rgba_type = Stream.Types.RGBA + str(i)
if rgba_type not in self.__streams:
self.__streams[rgba_type] = Stream(Stream.Types.RGBA, i, rgbas_names[i])
if len(rgba) == 3:
stream_type = Stream.Types.RGB
vcol_type = Stream.Types.RGB + str(i)
else:
stream_type = Stream.Types.RGBA
vcol_type = Stream.Types.RGBA + str(i)

stream = self.__streams[rgba_type]
if vcol_type not in self.__streams:
self.__streams[vcol_type] = Stream(stream_type, i, rgbas_names[i])

stream = self.__streams[vcol_type]
""":type: Stream"""
stream.add_entry(rgba)

Expand Down
5 changes: 4 additions & 1 deletion addon/io_scs_tools/exp/pim_ef/piece_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ def __init__(self, stream_type, index, name=""):
super().__init__(stream_type, index)

# exchange format support multiple vertex color layers
if stream_type == Stream.Types.RGBA:
if stream_type == Stream.Types.RGB:
self.__tag_index = index
self.__format = "FLOAT3"
elif stream_type == Stream.Types.RGBA:
self.__tag_index = index
self.__format = "FLOAT4"

Expand Down
2 changes: 1 addition & 1 deletion addon/io_scs_tools/exp/pip/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def execute(dirpath, filename, name_suffix, prefab_locator_list, offset_matrix,
curve.set_flags(loc1.scs_props, False)

curve.set_semaphore_id(int(loc0_scs_props.locator_prefab_np_traffic_semaphore))
curve.set_traffic_rule(loc1_scs_props.locator_prefab_np_traffic_rule)
curve.set_traffic_rule(loc0_scs_props.locator_prefab_np_traffic_rule)

# set next/prev curves
for next_key in curve_entry.next_curves:
Expand Down
4 changes: 3 additions & 1 deletion addon/io_scs_tools/exp/pit.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,8 @@ def export(root_object, filepath, name_suffix, used_parts, used_materials):
# print(' value: %s' % str(value))
if format_prop == 'FLOAT':
attribute_data.props.append((rec[0], ["&&", (value,)]))
elif format_prop == 'INT':
attribute_data.props.append((rec[0], ["ii", (value,)]))
else:
attribute_data.props.append((rec[0], ["i", tuple(value)]))
attribute_sections.append(attribute_data)
Expand Down Expand Up @@ -542,7 +544,7 @@ def export(root_object, filepath, name_suffix, used_parts, used_materials):
if attr_prop == "Format":
format_value = attribute_dict[attr_prop]

if attr_prop == "Value" and ("FLOAT" in format_value or "STRING" in format_value):
if attr_prop == "Value" and ("FLOAT" in format_value or "STRING" in format_value or "INT" in format_value):

tag_prop = attribute_dict["Tag"].replace("[", "").replace("]", "")
if "aux" in tag_prop:
Expand Down
9 changes: 4 additions & 5 deletions addon/io_scs_tools/imp/pim_ef.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,11 @@ def _create_piece(
context.window_manager.progress_update(0.5)

# VERTEX COLOR
mesh_rgb_final = {}
if mesh_rgba:
mesh_rgb_final = mesh_rgba
elif mesh_rgb:
mesh_rgb_final = mesh_rgb
else:
mesh_rgb_final = []
mesh_rgb_final.update(mesh_rgba)
if mesh_rgb:
mesh_rgb_final.update(mesh_rgb)

for vc_layer_name in mesh_rgb_final:
max_value = mesh_rgb_final[vc_layer_name][0][0][0] / 2
Expand Down
27 changes: 26 additions & 1 deletion addon/io_scs_tools/internals/containers/parsers/sii.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,36 @@ def _parse_unit(tokenizer):
return None


def parse_file(filepath, print_info=False):
def _parse_bare_file(filepath, print_info=False):
if print_info:
print("** SII Parser ...")
unit = _UnitData("", "", is_headless=True)

file = open(filepath, mode="r", encoding="utf8")
lines = file.readlines()
file.close()

tokenizer = _Tokenizer(lines, filepath, [])

while 1:
if tokenizer.consume_token_if_match('eof', '') is not None:
if print_info:
print("** Bare SII Parser END")
return [unit]

if not _parse_unit_property(tokenizer, unit):
print("Unit property parsing failed")
return None


def parse_file(filepath, is_sui=False, print_info=False):
"""
Reads SCS SII definition file from disk, parse it and return its full content in a form of hierarchical structure.
"""

if is_sui:
return _parse_bare_file(filepath, print_info)

if print_info:
print("** SII Parser ...")
sii_container = []
Expand Down
18 changes: 13 additions & 5 deletions addon/io_scs_tools/internals/containers/sii.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,21 @@
from io_scs_tools.internals.containers.writers import sii as _sii_writer


def get_data_from_file(filepath):
"""Returns entire data in data container from specified SII definition file."""
def get_data_from_file(filepath, is_sui=False):
"""Returns entire data in data container from specified SII definition file.
:param filepath: absolute file path where SII should be read from
:type filepath: str
:param is_sui: True if file should be read as SUI, in that case only one unit will be returned
:type is_sui: bool
:return: list of SII Units if parsing succeded; otherwise None
:rtype: list[io_scs_tools.internals.structure.UnitData] | None
"""

container = None
if filepath:
if os.path.isfile(filepath):
container = _sii_reader.parse_file(filepath)
container = _sii_reader.parse_file(filepath, is_sui=is_sui)
if container:
if len(container) < 1:
lprint('D SII file "%s" is empty!', (_path_utils.readable_norm(filepath),))
Expand Down Expand Up @@ -136,7 +144,7 @@ def get_unit_property(container, prop, unit_instance=0):
:param unit_instance: index of unit instance in container list that we are validating
:type unit_instance: int
:return: None if property is not found insde unit instance; otherwise value of the property
:rtype: None|object
:rtype: None|any
"""

value = None
Expand All @@ -157,7 +165,7 @@ def get_direct_unit_property(unit, prop):
:param prop: name of the property we are looking for
:type prop: str
:return: None if property is not found insde unit instance; otherwise value of the property
:rtype: None|object
:rtype: None|any
"""

value = None
Expand Down
Loading

0 comments on commit 983ae41

Please sign in to comment.