Added distinct-normal vertex extraction

This commit is contained in:
Jack Andersen 2015-09-20 15:23:20 -10:00
parent bee7388242
commit 8221caac35
3 changed files with 12 additions and 0 deletions

View File

@ -28,6 +28,11 @@ void InitGeomBlenderContext(HECL::BlenderConnection::PyOutStream& os,
" if loop.vert.index == vert_idx:\n" " if loop.vert.index == vert_idx:\n"
" return loop\n" " return loop\n"
"\n" "\n"
"def eq_normals(n1, n2):\n"
" if n1[0] == n2[0] and n1[1] == n2[1] and n1[2] == n2[2]:\n"
" return True\n"
" return False\n"
"\n"
"def add_triangle(bm, vert_seq, vert_indices, norm_seq, norm_indices, mat_nr, od_list):\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" " if len(set(vert_indices)) != 3:\n"
" return None, None\n" " return None, None\n"
@ -37,6 +42,11 @@ void InitGeomBlenderContext(HECL::BlenderConnection::PyOutStream& os,
" verts = [vert_seq[i] for i in vert_indices]\n" " verts = [vert_seq[i] for i in vert_indices]\n"
" norms = [norm_seq[i] for i in norm_indices]\n" " norms = [norm_seq[i] for i in norm_indices]\n"
"\n" "\n"
" for i in range(3):\n"
" if not eq_normals(verts[i].normal, norms[i]):\n"
" verts[i] = bm.verts.new(verts[i].co, verts[i])\n"
" vert_seq.ensure_lookup_table()\n"
"\n"
" # Make the face\n" " # Make the face\n"
" face = bm.faces.get(verts)\n" " face = bm.faces.get(verts)\n"
"\n" "\n"

View File

@ -181,6 +181,7 @@ bool MREA::Extract(const SpecBase& dataSpec,
mreaDecompOut.seekAlign32(); mreaDecompOut.seekAlign32();
atUint64 decompLen = drs.length(); atUint64 decompLen = drs.length();
mreaDecompOut.writeBytes(drs.readBytes(decompLen).get(), decompLen); mreaDecompOut.writeBytes(drs.readBytes(decompLen).get(), decompLen);
mreaDecompOut.close();
drs.seek(0, Athena::Begin); drs.seek(0, Athena::Begin);
/* Start up blender connection */ /* Start up blender connection */

View File

@ -156,6 +156,7 @@ bool MREA::Extract(const SpecBase& dataSpec,
mreaDecompOut.seekAlign32(); mreaDecompOut.seekAlign32();
atUint64 decompLen = drs.length(); atUint64 decompLen = drs.length();
mreaDecompOut.writeBytes(drs.readBytes(decompLen).get(), decompLen); mreaDecompOut.writeBytes(drs.readBytes(decompLen).get(), decompLen);
mreaDecompOut.close();
drs.seek(0, Athena::Begin); drs.seek(0, Athena::Begin);