Skip to content

Commit

Permalink
added some prints
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarcontar committed Feb 10, 2020
1 parent aaab5f3 commit 87b3b29
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions io_mesh_w3d/common/utils/material_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ def create_vertex_material(context, principleds, materials, struct, mesh, name,
context, name, vertMat)
mesh.materials.append(material)
principleds.append(principled)

if prelit_type is not None:
material.material_type = 'PRELIT_MATERIAL'
material.prelit_type = prelit_type

materials.append(material)

if struct.material_passes:
Expand Down
7 changes: 7 additions & 0 deletions io_mesh_w3d/common/utils/mesh_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ def retrieve_meshes(context, hierarchy, rig, container_name, force_vertex_materi
file=filepath,
texture_info=info)

#print('material type: ' + material.material_type)
if material.material_type == 'VERTEX_MATERIAL':
mat_pass.shader_ids = [i]
mat_pass.vertex_material_ids = [i]
Expand All @@ -224,6 +225,7 @@ def retrieve_meshes(context, hierarchy, rig, container_name, force_vertex_materi
if tex is not None:
mesh_struct.textures.append(tex)
else:
#print('prelit type: ' + material.prelit_type)
if material.prelit_type == 'PRELIT_UNLIT':
if mesh_struct.prelit_unlit is None:
mesh_struct.prelit_unlit = PrelitBase(
Expand Down Expand Up @@ -299,6 +301,7 @@ def retrieve_meshes(context, hierarchy, rig, container_name, force_vertex_materi
mesh_struct.bitangents = []

if mesh_struct.prelit_unlit is not None:
# print('prelit unlit')
mesh_struct.header.attrs |= PRELIT_UNLIT
prelit = mesh_struct.prelit_unlit
prelit.mat_info = MaterialInfo(
Expand All @@ -308,6 +311,7 @@ def retrieve_meshes(context, hierarchy, rig, container_name, force_vertex_materi
texture_count=len(prelit.textures))

if mesh_struct.prelit_vertex is not None:
# print('prelit vertex')
mesh_struct.header.attrs |= PRELIT_VERTEX
prelit = mesh_struct.prelit_vertex
prelit.mat_info = MaterialInfo(
Expand All @@ -317,6 +321,7 @@ def retrieve_meshes(context, hierarchy, rig, container_name, force_vertex_materi
texture_count=len(prelit.textures))

if mesh_struct.prelit_lightmap_multi_pass is not None:
# print('prelit lightmap multi pass')
mesh_struct.header.attrs |= PRELIT_LIGHTMAP_MULTI_PASS
prelit = mesh_struct.prelit_lightmap_multi_pass
prelit.mat_info = MaterialInfo(
Expand All @@ -326,6 +331,7 @@ def retrieve_meshes(context, hierarchy, rig, container_name, force_vertex_materi
texture_count=len(prelit.textures))

if mesh_struct.prelit_lightmap_multi_texture is not None:
# print('prelit lightmap multi texture')
mesh_struct.header.attrs |= PRELIT_LIGHTMAP_MULTI_TEXTURE
prelit = mesh_struct.prelit_lightmap_multi_texture
prelit.mat_info = MaterialInfo(
Expand All @@ -337,6 +343,7 @@ def retrieve_meshes(context, hierarchy, rig, container_name, force_vertex_materi

if mesh_struct.prelit_unlit is None and mesh_struct.prelit_vertex is None \
and mesh_struct.prelit_lightmap_multi_pass is None and mesh_struct.prelit_lightmap_multi_texture is None:
# print('NO PRELIT')
mesh_struct.mat_info = MaterialInfo(
pass_count=len(mesh_struct.material_passes),
vert_matl_count=len(mesh_struct.vert_materials),
Expand Down
4 changes: 4 additions & 0 deletions io_mesh_w3d/common/utils/mesh_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,31 @@ def create_mesh(context, mesh_struct, hierarchy, coll):
set_shader_properties(materials[i], shader)

if mesh_struct.prelit_unlit is not None:
print('create prelit unlit')
materials = []
prelit = mesh_struct.prelit_unlit
create_vertex_material(context, principleds, materials, prelit, mesh, name, triangles, prelit_type='PRELIT_UNLIT')
for i, shader in enumerate(prelit.shaders):
set_shader_properties(materials[i], shader)

if mesh_struct.prelit_vertex is not None:
print('create prelit vertex')
materials = []
prelit = mesh_struct.prelit_vertex
create_vertex_material(context, principleds, materials, prelit, mesh, name, triangles, prelit_type='PRELIT_VERTEX')
for i, shader in enumerate(prelit.shaders):
set_shader_properties(materials[i], shader)

if mesh_struct.prelit_lightmap_multi_pass is not None:
print('create prelit lightmap multi pass')
materials = []
prelit = mesh_struct.prelit_lightmap_multi_pass
create_vertex_material(context, principleds, materials, prelit, mesh, name, triangles, prelit_type='PRELIT_LIGHTMAP_MULTI_PASS')
for i, shader in enumerate(prelit.shaders):
set_shader_properties(materials[i], shader)

if mesh_struct.prelit_lightmap_multi_texture is not None:
print('create prelit lightmap multi texture')
materials = []
prelit = mesh_struct.prelit_lightmap_multi_texture
create_vertex_material(context, principleds, materials, prelit, mesh, name, triangles, prelit_type='PRELIT_LIGHTMAP_MULTI_TEXTURE')
Expand Down
3 changes: 2 additions & 1 deletion tests/common/cases/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Written by Stephan Vedder and Michael Schnabel

from shutil import copyfile
from os.path import dirname as up

from io_mesh_w3d.export_utils import *
from io_mesh_w3d.import_utils import *
Expand All @@ -16,7 +17,6 @@
from tests.w3d.helpers.dazzle import *
from tests.w3d.helpers.mesh_structs.shader import *
from tests.w3d.helpers.mesh_structs.vertex_material import *
from os.path import dirname as up


class TestUtils(TestCase):
Expand Down Expand Up @@ -582,6 +582,7 @@ def test_prelit_meshes_roundtrip(self):
print('################# Prelit test')
create_data(self, meshes)

print('##### created data')
self.compare_data(meshes)

def test_animation_roundtrip(self):
Expand Down

0 comments on commit 87b3b29

Please sign in to comment.