Skip to content

Commit

Permalink
some small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarcontar committed Apr 13, 2020
1 parent f17b241 commit 835fd05
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 38 deletions.
7 changes: 2 additions & 5 deletions io_mesh_w3d/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from io_mesh_w3d.export_utils import save
from io_mesh_w3d.custom_properties import *


bl_info = {
'name': 'Import/Export Westwood W3D Format (.w3d/.w3x)',
'author': 'OpenSage Developers',
Expand Down Expand Up @@ -299,12 +300,8 @@ def register_node_groups():
continue
NodeGroupCreator().create(directory, file)

from io_mesh_w3d.common.node_groups.vertex_material import VertexMaterialGroup, PrelitUnlitGroup, PrelitVertexGroup, PrelitLightmapMultiPassGroup, PrelitLightmapMultiTextureGroup
from io_mesh_w3d.common.node_groups.vertex_material import VertexMaterialGroup
VertexMaterialGroup.register(VertexMaterialGroup.name)
PrelitUnlitGroup.register(PrelitUnlitGroup.name)
PrelitVertexGroup.register(PrelitVertexGroup.name)
PrelitLightmapMultiPassGroup.register(PrelitLightmapMultiPassGroup.name)
PrelitLightmapMultiTextureGroup.register(PrelitLightmapMultiTextureGroup.name)

def register():
for class_ in CLASSES:
Expand Down
53 changes: 23 additions & 30 deletions io_mesh_w3d/common/node_groups/vertex_material.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Written by Stephan Vedder and Michael Schnabel

import bpy
from io_mesh_w3d.common.node_groups.helpers import *


class VertexMaterialGroup():
Expand All @@ -13,7 +12,7 @@ def create(node_tree, name, vm_info, shader):
instance = node_tree.nodes.new(type='ShaderNodeGroup')
instance.location = (0, 300)
instance.width = 300
# TODO: depending on prelit type

instance.node_tree = bpy.data.node_groups['VertexMaterial']
instance.label = name

Expand Down Expand Up @@ -42,6 +41,13 @@ def create(node_tree, name, vm_info, shader):

return instance

@staticmethod
def addInputInt(group, name, default=0, min=0, max=255):
group.inputs.new('NodeSocketInt', name)
group.inputs[name].default_value = default
group.inputs[name].min_value = min
group.inputs[name].max_value = max

@staticmethod
def register(name):
group = bpy.data.node_groups.new(name, 'ShaderNodeTree')
Expand All @@ -57,7 +63,7 @@ def register(name):
group.inputs.new('NodeSocketColor', 'DiffuseTexture')
group.inputs.new('NodeSocketFloat', 'DiffuseTextureAlpha')
group.inputs['DiffuseTextureAlpha'].default_value = 0.0
addInputInt(group, 'DestBlend', max=1)
VertexMaterialGroup.addInputInt(group, 'DestBlend', max=1)
group.inputs.new('NodeSocketColor', 'Ambient')
group.inputs['Ambient'].default_value = (0.8, 0.8, 0.8, 1.0)
group.inputs.new('NodeSocketColor', 'Specular')
Expand All @@ -68,20 +74,20 @@ def register(name):
group.inputs.new('NodeSocketFloat', 'Opacity')
group.inputs.new('NodeSocketFloat', 'Translucency')

addInputInt(group, 'DepthCompare')
addInputInt(group, 'DepthMask')
addInputInt(group, 'ColorMask')
addInputInt(group, 'FogFunc')
addInputInt(group, 'PriGradient')
addInputInt(group, 'SecGradient')
addInputInt(group, 'SrcBlend')
addInputInt(group, 'Texturing')
addInputInt(group, 'DetailColorFunc')
addInputInt(group, 'DetailAlphaFunc')
addInputInt(group, 'Preset')
addInputInt(group, 'AlphaTest')
addInputInt(group, 'PostDetailColorFunc')
addInputInt(group, 'PostDetailAlphaFunc')
VertexMaterialGroup.addInputInt(group, 'DepthCompare')
VertexMaterialGroup.addInputInt(group, 'DepthMask')
VertexMaterialGroup.addInputInt(group, 'ColorMask')
VertexMaterialGroup.addInputInt(group, 'FogFunc')
VertexMaterialGroup.addInputInt(group, 'PriGradient')
VertexMaterialGroup.addInputInt(group, 'SecGradient')
VertexMaterialGroup.addInputInt(group, 'SrcBlend')
VertexMaterialGroup.addInputInt(group, 'Texturing')
VertexMaterialGroup.addInputInt(group, 'DetailColorFunc')
VertexMaterialGroup.addInputInt(group, 'DetailAlphaFunc')
VertexMaterialGroup.addInputInt(group, 'Preset')
VertexMaterialGroup.addInputInt(group, 'AlphaTest')
VertexMaterialGroup.addInputInt(group, 'PostDetailColorFunc')
VertexMaterialGroup.addInputInt(group, 'PostDetailAlphaFunc')

# create group outputs
group_outputs = group.nodes.new('NodeGroupOutput')
Expand All @@ -107,16 +113,3 @@ def register(name):
links.new(group_inputs.outputs['Emissive'], shader.inputs['Emissive Color'])
links.new(alpha_pipeline.outputs['Alpha'], shader.inputs['Transparency'])
links.new(shader.outputs['BSDF'], group_outputs.inputs['BSDF'])


class PrelitUnlitGroup(VertexMaterialGroup):
name = 'PrelitUnlit'

class PrelitVertexGroup(VertexMaterialGroup):
name = 'PrelitVertex'

class PrelitLightmapMultiPassGroup(VertexMaterialGroup):
name = 'PrelitLightmapMultiPass'

class PrelitLightmapMultiTextureGroup(VertexMaterialGroup):
name = 'PrelitLightmapMultiTextue'
3 changes: 0 additions & 3 deletions io_mesh_w3d/common/utils/material_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from bpy_extras import node_shader_utils

from io_mesh_w3d.common.node_groups.vertex_material import *
from io_mesh_w3d.common.node_groups.helpers import *
from io_mesh_w3d.common.utils.helpers import *
from io_mesh_w3d.w3d.structs.mesh_structs.vertex_material import *
from io_mesh_w3d.common.structs.mesh_structs.shader_material import *
Expand Down Expand Up @@ -132,8 +131,6 @@ def create_shader_material(context, mesh, b_mesh, triangles, shader_mat, tx_coor
material.show_transparent_back = False

node_tree = material.node_tree
links = node_tree.links

node_tree.nodes.remove(node_tree.nodes.get('Principled BSDF'))

instance = node_tree.nodes.new(type='ShaderNodeGroup')
Expand Down
1 change: 1 addition & 0 deletions tests/w3x/cases/test_roundtrip.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def test_roundtrip_HAM(self):
self.assertTrue('TRUNK' in bpy.data.objects)

def test_roundtrip_texture_name_with_dots(self):
self.info = print
hierarchy_name = 'testname_skl'
hierarchy = get_hierarchy(hierarchy_name)
mesh = get_mesh(name='sword', skin=True)
Expand Down

0 comments on commit 835fd05

Please sign in to comment.