[Blender] Implemented tesselation for CAD-model, retopology and optimisation tesselation's result, assigning physical properties with assigned material
This commit is contained in:
parent
9fa936cfba
commit
839ce36c70
19 changed files with 891 additions and 351 deletions
|
@ -10,6 +10,7 @@
|
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
__version__ = '0.2'
|
||||
import logging
|
||||
import sys
|
||||
import bpy
|
||||
|
@ -20,11 +21,12 @@ logger = logging.getLogger(__name__)
|
|||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
|
||||
def import_materials(bobj, fem_mat):
|
||||
""" Build Blender Shader from FreeCAD's FEM material """
|
||||
def assign_materials(bobj, fem_mat):
|
||||
''' Build Blender shader from FreeCAD's FEM material '''
|
||||
fem_mat_name = fem_mat.Material['Name']
|
||||
|
||||
if fem_mat_name in bpy.data.materials:
|
||||
# prepare for reimport
|
||||
if len(bobj.material_slots) < 1:
|
||||
bobj.data.materials.append(bpy.data.materials[fem_mat_name])
|
||||
else:
|
||||
|
@ -73,6 +75,43 @@ def import_materials(bobj, fem_mat):
|
|||
principled.roughness = rg
|
||||
principled.emission_color = e_col
|
||||
principled.alpha = alpha
|
||||
bobj.data.materials.append(bmat)
|
||||
# prepare for reimport
|
||||
if len(bobj.material_slots) < 1:
|
||||
bobj.data.materials.append(bmat)
|
||||
else:
|
||||
bobj.material_slots[0].material = bmat
|
||||
|
||||
logger.debug('Assign %s to object %s', fem_mat_name, bobj.name)
|
||||
return bobj
|
||||
|
||||
|
||||
def assign_black(bobj):
|
||||
''' Set absolute black Blender shader '''
|
||||
fem_mat_name = 'black_mat'
|
||||
|
||||
if fem_mat_name in bpy.data.materials:
|
||||
# prepare for reimport
|
||||
if len(bobj.material_slots) < 1:
|
||||
bobj.data.materials.append(bpy.data.materials[fem_mat_name])
|
||||
else:
|
||||
bobj.material_slots[0].material = bpy.data.materials[fem_mat_name]
|
||||
else:
|
||||
bmat = bpy.data.materials.new(name=fem_mat_name)
|
||||
bmat.use_nodes = True
|
||||
bmat.diffuse_color = (0, 0, 0, 1)
|
||||
bmat.node_tree.nodes.remove(bmat.node_tree.nodes['Principled BSDF'])
|
||||
emission = bmat.node_tree.nodes.new(type='ShaderNodeEmission')
|
||||
emission.location = 0, 300
|
||||
emission.inputs['Color'].default_value = (0, 0, 0, 1)
|
||||
emission.inputs['Strength'].default_value = 0
|
||||
bmat.node_tree.links.new(
|
||||
emission.outputs['Emission'],
|
||||
bmat.node_tree.nodes['Material Output'].inputs['Surface'])
|
||||
# prepare for reimport
|
||||
if len(bobj.material_slots) < 1:
|
||||
bobj.data.materials.append(bmat)
|
||||
else:
|
||||
bobj.material_slots[0].material = bmat
|
||||
|
||||
logger.debug('Assign %s to object %s', fem_mat_name, bobj.name)
|
||||
return bobj
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue