Skip to content

Commit

Permalink
Release - 1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
simon50keda committed May 5, 2016
1 parent a587cfb commit d7732f0
Show file tree
Hide file tree
Showing 21 changed files with 467 additions and 132 deletions.
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, 3, "588c66f"),
"version": (1, 4, "4ae6843"),
"blender": (2, 75, 0),
"location": "File > Import-Export",
"wiki_url": "https://github.com/SCSSoftware/BlenderTools/wiki",
Expand Down
3 changes: 2 additions & 1 deletion addon/io_scs_tools/exp/pim/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def execute(dirpath, root_object, armature_object, skeleton_filepath, mesh_objec
is_skin_used = (armature_object and root_object.scs_props.scs_root_animated == "anim")

pim_header = Header(format_type, format_version, root_object.name)
pim_global = Globall(skeleton_filepath)
pim_global = Globall(used_parts.count(), skeleton_filepath)

pim_materials = collections.OrderedDict() # dict of Material class instances representing used materials
""":type: dict[str, Material]"""
Expand Down Expand Up @@ -382,6 +382,7 @@ def execute(dirpath, root_object, armature_object, skeleton_filepath, mesh_objec
# create part if it doesn't exists yet
part_name = loc_obj.scs_props.scs_part
if part_name not in pim_parts:
assert used_parts.is_present(part_name)
pim_parts[part_name] = Part(part_name)

# add locator to part
Expand Down
11 changes: 6 additions & 5 deletions addon/io_scs_tools/exp/pim/globall.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

from io_scs_tools.exp.pim.piece import Piece
from io_scs_tools.exp.pim.material import Material
from io_scs_tools.exp.pim.part import Part
from io_scs_tools.exp.pim.locator import Locator
from io_scs_tools.exp.pim.bones import Bones
from io_scs_tools.internals.structure import SectionData as _SectionData
Expand All @@ -29,18 +28,20 @@
class Globall:
__skeleton = ""

def __init__(self, skeleton):
def __init__(self, part_count, skeleton):
"""Constructs global for PIM
:param part_count: parts counter for current game object (including any parts from PIC and PIT
:type part_count: int
:param skeleton: file name of the skeleton file
:type skeleton: str
"""

Piece.reset_counters()
Material.reset_counter()
Part.reset_counter()
Locator.reset_counter()
Bones.reset_counter()

self.__part_count = part_count
self.__skeleton = skeleton.replace("\\", "/") # make sure to replace backslashes for windows paths

def get_as_section(self):
Expand All @@ -52,9 +53,9 @@ def get_as_section(self):
section = _SectionData("Global")
section.props.append(("VertexCount", Piece.get_global_vertex_count()))
section.props.append(("TriangleCount", Piece.get_global_triangle_count()))
section.props.append(("MaterialCount", Material.get_global_part_count()))
section.props.append(("MaterialCount", Material.get_global_material_count()))
section.props.append(("PieceCount", Piece.get_global_piece_count()))
section.props.append(("PartCount", Part.get_global_material_count()))
section.props.append(("PartCount", self.__part_count))
section.props.append(("BoneCount", Bones.get_global_bones_count()))
section.props.append(("LocatorCount", Locator.get_global_locator_count()))
section.props.append(("Skeleton", self.__skeleton))
Expand Down
2 changes: 1 addition & 1 deletion addon/io_scs_tools/exp/pim/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def reset_counter():
Material.__global_material_counter = 0

@staticmethod
def get_global_part_count():
def get_global_material_count():
return Material.__global_material_counter

def __init__(self, index, alias, effect, blend_mat):
Expand Down
11 changes: 0 additions & 11 deletions addon/io_scs_tools/exp/pim/part.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,6 @@ class Part:
__pieces = {} # references to Piece classes used in this part
__locators = {} # references to Locator classes used in this part

__global_part_counter = 0

@staticmethod
def reset_counter():
Part.__global_part_counter = 0

@staticmethod
def get_global_material_count():
return Part.__global_part_counter

def __init__(self, name):
"""Constructor for part with it's name.
NOTE: all of the pieces and locators are added later with methods.
Expand All @@ -49,7 +39,6 @@ def __init__(self, name):
self.__locators = {}

self.__name = name
Part.__global_part_counter += 1

def add_piece(self, piece):
"""Adds piece to part.
Expand Down
8 changes: 8 additions & 0 deletions addon/io_scs_tools/exp/transition_structs/parts.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ def add(self, part_name):
"""
self.__storage[part_name] = 1

def count(self):
"""Number of currently stored parts in transitional structure.
:return: number of currently stored parts
:rtype: int
"""
return len(self.__storage)

def is_present(self, part_name):
"""Tells if given part is present in storage.
Expand Down
3 changes: 3 additions & 0 deletions addon/io_scs_tools/internals/containers/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ def fill_global_colors_section():
section.props.append(("MapLineBase", tuple(_property_utils.get_by_type(bpy.types.GlobalSCSProps.mp_connection_base_color))))
section.props.append(("TriggerLineBase", tuple(_property_utils.get_by_type(bpy.types.GlobalSCSProps.tp_connection_base_color))))
section.props.append(("InfoText", tuple(_property_utils.get_by_type(bpy.types.GlobalSCSProps.info_text_color))))
section.props.append(("BasePaint", tuple(_property_utils.get_by_type(bpy.types.GlobalSCSProps.base_paint_color))))
return section

'''
Expand Down Expand Up @@ -788,6 +789,8 @@ def apply_settings():
scs_globals.tp_connection_base_color = prop[1]
elif prop[0] == "InfoText":
scs_globals.info_text_color = prop[1]
elif prop[0] == "BasePaint":
scs_globals.base_paint_color = prop[1]
else:
lprint('W Unrecognised item "%s" has been found in setting file! Skipping...', (str(prop[0]),))
elif section.type == "Header":
Expand Down
19 changes: 19 additions & 0 deletions addon/io_scs_tools/internals/shaders/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@


from io_scs_tools.internals.shaders.eut2.dif_anim import anim_blend_factor_ng
from io_scs_tools.internals.shaders.eut2.truckpaint import Truckpaint
from io_scs_tools.internals.shaders.flavors import paint


def update_shaders():
Expand All @@ -28,3 +30,20 @@ def update_shaders():

# update animation blend factor group node
anim_blend_factor_ng.update_time()


def set_base_paint_color(node_tree, color):
"""Sets base paint color from global settings to given node tree of material
:param node_tree: node tree to which paint color should be applied
:type node_tree: bpy.types.NodeTree
:param color: new color value
:type color: bpy.utils.Color
:return:
:rtype:
"""
# update paint flavor based shaders
paint.set_color(node_tree, color)

# update eut2 truckpaint shaders
Truckpaint.set_base_paint_color(node_tree, color)
22 changes: 22 additions & 0 deletions addon/io_scs_tools/internals/shaders/eut2/dif/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from io_scs_tools.internals.shaders.flavors import blend_over
from io_scs_tools.internals.shaders.flavors import blend_add
from io_scs_tools.internals.shaders.flavors import nmap
from io_scs_tools.internals.shaders.flavors import paint
from io_scs_tools.internals.shaders.flavors import tg0
from io_scs_tools.utils import convert as _convert_utils

Expand Down Expand Up @@ -486,3 +487,24 @@ def set_flat_flavor(node_tree, switch_on):
node_tree.nodes.remove(node_tree.nodes[_FLAT_FAC_MULT_NODE])

node_tree.links.new(out_mat_n.inputs['Color'], diff_mult_n.outputs['Color'])

@staticmethod
def set_paint_flavor(node_tree, switch_on):
"""Set paint flavor to this shader.
:param node_tree: node tree of current shader
:type node_tree: bpy.types.NodeTree
:param switch_on: flag indication if flavor should be switched on or off
:type switch_on: bool
"""

diff_col_n = node_tree.nodes[Dif.DIFF_COL_NODE]
diff_mult_n = node_tree.nodes[Dif.DIFF_MULT_NODE]

if switch_on:

location = (diff_mult_n.location.x - 185, diff_mult_n.location.y + 50)
paint.init(node_tree, location, diff_col_n.outputs["Color"], diff_mult_n.inputs["Color1"])

else:
paint.delete(node_tree)
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ def add(node_tree, geom_n_name, spec_col_n_name, base_tex_n_name, out_mat_n_name
node_tree.links.new(add_env_gn.inputs['View Vector'], geometry_n.outputs['View'])
node_tree.links.new(refl_tex_n.inputs['Vector'], geometry_n.outputs['Normal'])

# if out material node is really material node and has normal output,
# use it as this normal might include normal maps
if "Normal" in out_mat_n.outputs:
node_tree.links.new(refl_tex_n.inputs['Vector'], out_mat_n.outputs['Normal'])

node_tree.links.new(add_env_gn.inputs['Env Factor Color'], env_col_n.outputs['Color'])
node_tree.links.new(add_env_gn.inputs['Reflection Texture Color'], refl_tex_n.outputs['Color'])

Expand Down
Loading

0 comments on commit d7732f0

Please sign in to comment.