Blender Plugin 1.6.0
This commit is contained in:
40
Blender/_Source/L1960_Tools_1_5_0/PrepareLods.py
Normal file
40
Blender/_Source/L1960_Tools_1_5_0/PrepareLods.py
Normal file
@@ -0,0 +1,40 @@
|
||||
import bpy
|
||||
|
||||
class MESH_OT_prepare_lods_decimate(bpy.types.Operator):
|
||||
"""Copy current Mesh and apply decimate Modifier"""
|
||||
|
||||
bl_idname = "mesh.prepare_lods_decimate"
|
||||
bl_label = "Copy current Mesh and apply decimate Modifier"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
def execute(self, context):
|
||||
|
||||
#Selected Mesh
|
||||
obj = bpy.context.active_object
|
||||
|
||||
if obj not in bpy.context.selected_objects or obj.type != "MESH":
|
||||
self.report({'WARNING'}, 'Select a Mesh to continue')
|
||||
return {"CANCELLED"}
|
||||
|
||||
if not obj.name[:-1].endswith('LOD'):
|
||||
obj.name = obj.name + '_LOD0'
|
||||
|
||||
LODnumber = context.scene.lod_slider #Get from Slider
|
||||
startLODcount = int(obj.name[-1])
|
||||
endLODcount = startLODcount + LODnumber
|
||||
|
||||
for i in range (startLODcount + 1, endLODcount):
|
||||
new_obj = obj.copy()
|
||||
new_obj.data = obj.data.copy()
|
||||
new_obj.name = obj.name[:-1] + str(i)
|
||||
bpy.context.collection.objects.link(new_obj)
|
||||
|
||||
for t in range (startLODcount, i):
|
||||
newModifierName = 'LOD_Decimate_' + str(t)
|
||||
new_obj.modifiers.new(type='DECIMATE', name=newModifierName)
|
||||
mod = new_obj.modifiers[newModifierName]
|
||||
mod.ratio = 0.49
|
||||
mod.use_collapse_triangulate = True
|
||||
|
||||
self.report({'INFO'}, 'LOD´s created')
|
||||
return {"FINISHED"}
|
||||
Reference in New Issue
Block a user