mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-08 19:44:55 +00:00
Automatic sharp-edge-marking using Retro's normals for reference
This commit is contained in:
@@ -420,7 +420,10 @@ public:
|
||||
void InitGeomBlenderContext(hecl::BlenderConnection::PyOutStream& os,
|
||||
const hecl::ProjectPath& masterShaderPath)
|
||||
{
|
||||
os << "# Using 'Blender Game'\n"
|
||||
os << "import math\n"
|
||||
"from mathutils import Vector\n"
|
||||
"\n"
|
||||
"# Using 'Blender Game'\n"
|
||||
"bpy.context.scene.render.engine = 'BLENDER_GAME'\n"
|
||||
"\n"
|
||||
"# Clear Scene\n"
|
||||
@@ -434,6 +437,14 @@ void InitGeomBlenderContext(hecl::BlenderConnection::PyOutStream& os,
|
||||
" if loop.vert[bm.verts.layers.int['CMDLOriginalPosIdxs']] == vert_idx:\n"
|
||||
" return loop\n"
|
||||
"\n"
|
||||
"def loops_from_edgevert(bm, edge, vert):\n"
|
||||
" ret = []\n"
|
||||
" for face in edge.link_faces:\n"
|
||||
" for loop in face.loops:\n"
|
||||
" if loop.vert == vert:\n"
|
||||
" ret.append(loop)\n"
|
||||
" return ret\n"
|
||||
"\n"
|
||||
"def add_triangle(bm, vert_seq, vert_indices, norm_seq, norm_indices, mat_nr, od_list):\n"
|
||||
" if len(set(vert_indices)) != 3:\n"
|
||||
" return None, None\n"
|
||||
@@ -516,6 +527,7 @@ void FinishBlenderMesh(hecl::BlenderConnection::PyOutStream& os,
|
||||
"mesh.hecl_material_count = %u\n", meshIdx, matSetCount);
|
||||
|
||||
os << "mesh.use_auto_smooth = True\n"
|
||||
"mesh.auto_smooth_angle = math.pi\n"
|
||||
"\n"
|
||||
"for material in materials:\n"
|
||||
" mesh.materials.append(material)\n"
|
||||
@@ -546,14 +558,26 @@ void FinishBlenderMesh(hecl::BlenderConnection::PyOutStream& os,
|
||||
"\n"
|
||||
" od_entry['bm'].free()\n"
|
||||
"\n"
|
||||
"for edge in bm.edges:\n"
|
||||
" if edge.is_manifold:\n"
|
||||
" pass_count = 0\n"
|
||||
" for vert in edge.verts:\n"
|
||||
" loops = loops_from_edgevert(bm, edge, vert)\n"
|
||||
" norm0 = Vector(norm_list[loops[0][orig_nidx_lay]])\n"
|
||||
" norm1 = Vector(norm_list[loops[1][orig_nidx_lay]])\n"
|
||||
" if norm0.dot(norm1) < 0.9:\n"
|
||||
" pass_count += 1\n"
|
||||
" if pass_count > 0:\n"
|
||||
" edge.smooth = False\n"
|
||||
"\n"
|
||||
"bm.to_mesh(mesh)\n"
|
||||
"\n"
|
||||
"# Load split normal data\n"
|
||||
"split_normals = []\n"
|
||||
"for face in bm.faces:\n"
|
||||
" for loop in face.loops:\n"
|
||||
" split_normals.append(norm_list[loop[orig_nidx_lay]])\n"
|
||||
"mesh.normals_split_custom_set(split_normals)\n"
|
||||
"# Resolve split normal data\n"
|
||||
"#split_normals = []\n"
|
||||
"#for face in bm.faces:\n"
|
||||
"# for loop in face.loops:\n"
|
||||
"# split_normals.append(norm_list[loop[orig_nidx_lay]])\n"
|
||||
"#mesh.normals_split_custom_set(split_normals)\n"
|
||||
"\n"
|
||||
"bm.free()\n"
|
||||
"\n"
|
||||
|
||||
Reference in New Issue
Block a user