Hi
There is nice addon for importing MagicaVoxel project files into blender. Sadly I couldn’t find it ported to 2.8. Could anyone do this for me? Maybe it’s not a big deal, but I’m not familiar with coding at all.
Thanks
io_scene_vox.py (11.0 KB)
Hi
There is nice addon for importing MagicaVoxel project files into blender. Sadly I couldn’t find it ported to 2.8. Could anyone do this for me? Maybe it’s not a big deal, but I’m not familiar with coding at all.
Thanks
io_scene_vox.py (11.0 KB)
Try this and let me know please: io_scene_vox.py (11.6 KB)
Btw, I started using both Python and Blender last week, so… maybe it is totally wrong
Hear u soon!
ps. this is the original GitHub repository of the project by Richard Spencer
Just a tip to set “shadeless” materials, removed in 2.80; use nodes and set Emission:
#material.use_shadeless = use_shadeless
if use_shadeless:
material.use_nodes = True
material_diffuse_to_emission(material)
Add the following helpers:
import bpy
def replace_with_emission(node, node_tree):
new_node = node_tree.nodes.new('ShaderNodeEmission')
connected_sockets_out = []
sock = node.inputs[0]
if len(sock.links)>0:
color_link = sock.links[0].from_socket
else:
color_link=None
defaults_in = sock.default_value[:]
for sock in node.outputs:
if len(sock.links)>0:
connected_sockets_out.append( sock.links[0].to_socket)
else:
connected_sockets_out.append(None)
#print( defaults_in )
new_node.location = (node.location.x, node.location.y)
if color_link is not None:
node_tree.links.new(new_node.inputs[0], color_link)
new_node.inputs[0].default_value = defaults_in
if connected_sockets_out[0] is not None:
node_tree.links.new(connected_sockets_out[0], new_node.outputs[0])
def material_diffuse_to_emission(mat):
doomed=[]
for node in mat.node_tree.nodes:
if node.type=='BSDF_DIFFUSE' or node.type=='BSDF_PRINCIPLED':
replace_with_emission(node, mat.node_tree)
doomed.append(node)
else:
print(node.type)
# wait until we are done iterating and adding before we start wrecking things
for node in doomed:
mat.node_tree.nodes.remove(node)
def replace_on_selected_objects():
mats = set()
for obj in bpy.context.scene.objects:
if obj.select_set:
for slot in obj.material_slots:
mats.add(slot.material)
for mat in mats:
material_diffuse_to_emission(mat)
def replace_in_all_materials():
for mat in bpy.data.materials:
material_diffuse_to_emission(mat)
References:
http://web.purplefrog.com/~thoth/blender/python-cookbook/change-diffuse-to-emission-node.html
The option appears under “import”, but after chosing .vox file and clicking “import” nothing is happening
Thanks for your feedback.
Please, try using the updated script by the author: he released my pull request it right few hours ago!
We added “collection” handling also: when imported, you’ll have a new collection to group every voxel object.
Btw, upload your VOX file to further investigate… latest file format is not supported yet. Add this to the downloaded python script to bypass/skip new chunks:
elif name == 'nTRN':
vox.read(s_self)
elif name == 'nGRP':
vox.read(s_self)
elif name == 'nGRP':
vox.read(s_self)
elif name == 'MATL':
vox.read(s_self)
elif name == 'LAYR':
vox.read(s_self)
elif name == 'rOBJ':
vox.read(s_self)
Right before the “throw an error if unknown chunk” part:
else:
# Any other chunk, we don't know how to handle
# This puts us out-of-step
print('Unknown Chunk id {}'.format(name))
return {'CANCELLED'}
See also:
It works! Thank you very much!
Np, we are working on frame-base animations and MATT/MATL chunks support (just for “basic” glass/metal/plastic/emit shaders).
If you need them, please see
Frame-based animations #11
MagicaVoxel-VOX-importer/io_scene_vox.py from wizardgsz MATT_MATL branch
I have an issue with importing .vox file in blender. https://github.com/RichysHub/MagicaVoxel-VOX-importer/issues/12
Solved. Please use GitHub to open issues, not here. Thanks.