Skip to content

Instantly share code, notes, and snippets.

@joar
Created September 28, 2011 23:54
Show Gist options
  • Save joar/1249622 to your computer and use it in GitHub Desktop.
Save joar/1249622 to your computer and use it in GitHub Desktop.
mc2obj turn off antialiasing (batch script)
import bpy
import re
materials = {
'Bedrock': {},
'Chest_Front': {},
'Chest_Left_Back': {},
'Chest_Left_Front': {},
'Chest_Right_Back': {},
'Chest_Right_Front': {},
'Chest_Side': {},
'Chest_Top': {},
'Cobblestone': {},
'Dirt': {},
'Dirt_Grass': {},
'Flower_Red': {},
'Flower_Yellow': {},
'Grass_Top': {},
'Gravel': {},
'Ladder': {},
'Lava': {},
'Leaves_Oak': {},
'Lever': {},
'Log_Birch': {},
'Log_Oak': {},
'Log_Top': {},
'Material': {},
'Obsidian': {},
'Ore_Coal': {},
'Ore_Iron': {},
'Ore_Redstone': {},
'Piston': {},
'Piston_Bottom': {},
'Piston_Side': {},
'Piston_Top': {},
'Pumpkin_Lit': {},
'Pumpkin_Side': {},
'Pumpkin_Top': {},
'Rails': {},
'Rails_Bend': {},
'Rails_Detector': {},
'Rails_Powered_On': {},
'Redstone_Cross': {},
'Redstone_Torch_On': {},
'Repeater_On': {},
'Sand': {},
'Slab_Side': {},
'Slab_Top': {},
'Stone': {},
'Tall_Grass': {},
'Torch': {},
'Water': {},
'Wood': {}}
count = 0
for name, texture in bpy.data.textures.items():
if re.search(r'^(Kd|D)\.', name):
texture.use_interpolation = False
texture.filter_type = 'BOX'
count += 1
if re.search(r'^D\.', name):
texture.use_calculate_alpha = True
print(texture.users_material)
# texture.use_stencil = True
for name, material in bpy.data.materials.items():
'''
print(' \'{key}\': {val},'.format(
key=name,
val={}))
'''
if name in materials:
material.specular_intensity = 0
for slot in material.texture_slots:
if slot:
if re.search(r'^Kd', slot.name):
if name in ['Torch']:
slot.emit_factor = 1
print('Matched torch!')
elif re.search(r'^D', slot.name):
slot.use_stencil = True
else:
print('{0} did not match anything (name: {1}'.format(slot, slot.name))
print('Converted {0} textures.'.format(
count))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment