diff --git a/DataSpec/DNAMP1/DeafBabe.hpp b/DataSpec/DNAMP1/DeafBabe.hpp index 6aa038f87..95f0334f4 100644 --- a/DataSpec/DNAMP1/DeafBabe.hpp +++ b/DataSpec/DNAMP1/DeafBabe.hpp @@ -23,9 +23,6 @@ void DeafBabeSendToBlender(HECL::BlenderConnection::PyOutStream& os, const DEAFB os << "col_bm.verts.ensure_lookup_table()\n"; int triIdx = 0; - -#define TEST 0 -#if TEST == 0 for (const typename DEAFBABE::Triangle& tri : db.triangleEdgeConnections) { const typename DEAFBABE::Material& triMat = db.materials[db.triMats[triIdx++]]; @@ -52,68 +49,8 @@ void DeafBabeSendToBlender(HECL::BlenderConnection::PyOutStream& os, const DEAFB "\n", triMat.material); } -#elif TEST == 1 - for (const typename DEAFBABE::Triangle& tri : db.triangleEdgeConnections2) - { - - if (tri.edges[0] != 65535) - { - const typename DEAFBABE::Edge& edge0 = db.edgeVertConnections[tri.edges[0]]; - - os.format("edge_verts = [col_bm.verts[%u], col_bm.verts[%u]]\n", - edge0.verts[0], edge0.verts[1]); - - os << "edge = col_bm.edges.get(edge_verts)\n" - "if edge is None:\n" - " edge = col_bm.edges.new(edge_verts)\n" - "\n"; - } - - if (tri.edges[1] != 65535) - { - const typename DEAFBABE::Edge& edge1 = db.edgeVertConnections[tri.edges[1]]; - - os.format("edge_verts = [col_bm.verts[%u], col_bm.verts[%u]]\n", - edge1.verts[0], edge1.verts[1]); - - os << "edge = col_bm.edges.get(edge_verts)\n" - "if edge is None:\n" - " edge = col_bm.edges.new(edge_verts)\n" - "\n"; - } - - if (tri.edges[2] != 65535) - { - const typename DEAFBABE::Edge& edge2 = db.edgeVertConnections[tri.edges[2]]; - - os.format("edge_verts = [col_bm.verts[%u], col_bm.verts[%u]]\n", - edge2.verts[0], edge2.verts[1]); - - os << "edge = col_bm.edges.get(edge_verts)\n" - "if edge is None:\n" - " edge = col_bm.edges.new(edge_verts)\n" - "\n"; - } - } - -#elif TEST == 2 - int max = 0; - for (const typename DEAFBABE::Triangle& tri : db.triangleEdgeConnections2) - { - for (int e=0 ; e<3 ; ++e) - { - if (tri.edges[e] == 65535) - continue; - const typename DEAFBABE::Edge& edge = db.edgeVertConnections.at(tri.edges[e]); - if (edge.verts[0] > max) - max = edge.verts[0]; - if (edge.verts[1] > max) - max = edge.verts[1]; - } - } - printf("MAX: %d\n", max); -#endif + db.insertNoClimb(os); os << "col_mesh = bpy.data.meshes.new('CMESH')\n" "col_bm.to_mesh(col_mesh)\n" @@ -209,7 +146,7 @@ struct DeafBabe : BigDNA Vector verts; /* Dummy MP2 member */ - std::vector triangleEdgeConnections2; + void insertNoClimb(HECL::BlenderConnection::PyOutStream&) const {} static void BlenderInit(HECL::BlenderConnection::PyOutStream& os); void sendToBlender(HECL::BlenderConnection::PyOutStream& os) const diff --git a/DataSpec/DNAMP2/DeafBabe.hpp b/DataSpec/DNAMP2/DeafBabe.hpp index 150190c19..f00d93109 100644 --- a/DataSpec/DNAMP2/DeafBabe.hpp +++ b/DataSpec/DNAMP2/DeafBabe.hpp @@ -62,8 +62,8 @@ struct DeafBabe : BigDNA Vector edgeVertConnections; Value triangleEdgesCount; Vector triangleEdgeConnections; - Value triangleEdges2Count; - Vector triangleEdgeConnections2; + Value noClimbEdgeCount; + Vector noClimbEdges; Value vertCount; Vector verts; @@ -71,6 +71,19 @@ struct DeafBabe : BigDNA { DNAMP1::DeafBabe::BlenderInit(os); } + void insertNoClimb(HECL::BlenderConnection::PyOutStream& os) const + { + for (atInt16 edgeIdx : noClimbEdges) + { + if (edgeIdx == -1) + continue; + const Edge& edge = edgeVertConnections[edgeIdx]; + os.format("edge = col_bm.edges.get((col_bm.verts[%u], col_bm.verts[%u]))\n" + "if edge:\n" + " edge.seam = True\n", + edge.verts[0], edge.verts[1]); + } + } void sendToBlender(HECL::BlenderConnection::PyOutStream& os) const { DNAMP1::DeafBabeSendToBlender(os, *this); diff --git a/DataSpec/DNAMP3/MREA.cpp b/DataSpec/DNAMP3/MREA.cpp index 63490a21b..75925a9e7 100644 --- a/DataSpec/DNAMP3/MREA.cpp +++ b/DataSpec/DNAMP3/MREA.cpp @@ -60,14 +60,13 @@ void MREA::ReadBabeDeadToBlender_3(HECL::BlenderConnection::PyOutStream& os, { BabeDeadLight light; light.read(rs); -#if 0 switch (light.lightType) { case BabeDeadLight::LightLocalAmbient: os.format("bg_node.inputs[0].default_value = (%f,%f,%f,1.0)\n" "bg_node.inputs[1].default_value = %f\n", light.color.vec[0], light.color.vec[1], light.color.vec[2], - light.q / 8.0); + light.unk6 / 8.0); continue; case BabeDeadLight::LightDirectional: os.format("lamp = bpy.data.lamps.new('LAMP_%01u_%03u', 'SUN')\n" @@ -89,7 +88,7 @@ void MREA::ReadBabeDeadToBlender_3(HECL::BlenderConnection::PyOutStream& os, "lamp_obj.rotation_mode = 'QUATERNION'\n" "lamp_obj.rotation_quaternion = Vector((0,0,-1)).rotation_difference(Vector((%f,%f,%f)))\n" "\n", s, l, - light.spotCutoff * M_PI / 180.f, + light.spotCutoff / 2.f, light.direction.vec[0], light.direction.vec[1], light.direction.vec[2]); break; default: continue; @@ -97,34 +96,36 @@ void MREA::ReadBabeDeadToBlender_3(HECL::BlenderConnection::PyOutStream& os, os.format("lamp.retro_layer = %u\n" "lamp.use_nodes = True\n" - "falloff_node = lamp.node_tree.nodes.new('ShaderNodeLightFalloff')\n" + "quadratic_node = lamp.node_tree.nodes.new('ShaderNodeLightFalloff')\n" + "quadratic_node.inputs[0].default_value = %f\n" + "quadratic_node.location = (-600, 0)\n" + "linear_node = lamp.node_tree.nodes.new('ShaderNodeLightFalloff')\n" + "linear_node.inputs[0].default_value = %f\n" + "linear_node.location = (-400, 0)\n" + "constant_node = lamp.node_tree.nodes.new('ShaderNodeLightFalloff')\n" + "constant_node.inputs[0].default_value = %f\n" + "constant_node.location = (-200, 0)\n" + "add1 = lamp.node_tree.nodes.new('ShaderNodeMath')\n" + "add1.operation = 'ADD'\n" + "add1.location = (-400, -300)\n" + "add2 = lamp.node_tree.nodes.new('ShaderNodeMath')\n" + "add2.operation = 'ADD'\n" + "add2.location = (-200, -300)\n" + "lamp.node_tree.links.new(quadratic_node.outputs[0], add1.inputs[0])\n" + "lamp.node_tree.links.new(linear_node.outputs[1], add1.inputs[1])\n" + "lamp.node_tree.links.new(add1.outputs[0], add2.inputs[0])\n" + "lamp.node_tree.links.new(constant_node.outputs[2], add2.inputs[1])\n" + "lamp.node_tree.links.new(add2.outputs[0], lamp.node_tree.nodes['Emission'].inputs[1])\n" "lamp.energy = 0.0\n" - "falloff_node.inputs[0].default_value = %f\n" "hue_sat_node = lamp.node_tree.nodes.new('ShaderNodeHueSaturation')\n" "hue_sat_node.inputs[1].default_value = 1.25\n" "hue_sat_node.inputs[4].default_value = (%f,%f,%f,1.0)\n" "lamp.node_tree.links.new(hue_sat_node.outputs[0], lamp.node_tree.nodes['Emission'].inputs[0])\n" "lamp_obj.location = (%f,%f,%f)\n" "bpy.context.scene.objects.link(lamp_obj)\n" - "\n", s, light.q / 8.0, + "\n", s, light.unk5, light.unk6, light.unk7, light.color.vec[0], light.color.vec[1], light.color.vec[2], light.position.vec[0], light.position.vec[1], light.position.vec[2]); - - switch (light.falloff) - { - case BabeDeadLight::FalloffConstant: - os << "falloff_node.inputs[0].default_value *= 75.0\n" - "lamp.node_tree.links.new(falloff_node.outputs[2], lamp.node_tree.nodes['Emission'].inputs[1])\n"; - break; - case BabeDeadLight::FalloffLinear: - os << "lamp.node_tree.links.new(falloff_node.outputs[1], lamp.node_tree.nodes['Emission'].inputs[1])\n"; - break; - case BabeDeadLight::FalloffQuadratic: - os << "lamp.node_tree.links.new(falloff_node.outputs[0], lamp.node_tree.nodes['Emission'].inputs[1])\n"; - break; - default: break; - } -#endif } } } @@ -197,31 +198,31 @@ bool MREA::Extract(const SpecBase& dataSpec, /* Read mesh info */ atUint32 curSec = 1; - auto secIdxIt = drs.beginSecIdxs(); std::vector surfaceCounts; surfaceCounts.reserve(head.meshCount); for (int m=0 ; mfirst == FOURCC('WOBJ')) - { - /* Mesh header */ - MeshHeader mHeader; - secStart = drs.position(); - mHeader.read(drs); - drs.seek(secStart + head.secSizes[curSec++], Athena::Begin); + /* Mesh header */ + MeshHeader mHeader; + secStart = drs.position(); + mHeader.read(drs); + drs.seek(secStart + head.secSizes[curSec++], Athena::Begin); - /* Surface count from here */ - secStart = drs.position(); - surfaceCounts.push_back(drs.readUint32Big()); - drs.seek(secStart + head.secSizes[curSec++], Athena::Begin); + /* Surface count from here */ + secStart = drs.position(); + surfaceCounts.push_back(drs.readUint32Big()); + drs.seek(secStart + head.secSizes[curSec++], Athena::Begin); - /* Seek through AROT-relation sections */ - drs.seek(head.secSizes[curSec++], Athena::Current); - drs.seek(head.secSizes[curSec++], Athena::Current); - ++secIdxIt; - } + /* Seek through AROT-relation sections */ + drs.seek(head.secSizes[curSec++], Athena::Current); + drs.seek(head.secSizes[curSec++], Athena::Current); } + /* Skip though WOBJs */ + auto secIdxIt = drs.beginSecIdxs(); + while (secIdxIt->first == FOURCC('WOBJ')) + ++secIdxIt; + /* Skip AROT */ if (secIdxIt->first == FOURCC('ROCT')) { @@ -248,41 +249,48 @@ bool MREA::Extract(const SpecBase& dataSpec, ++secIdxIt; } -#if 0 - - - /* Skip AROT */ - drs.seek(head.secSizes[curSec++], Athena::Current); - - /* Skip BVH */ - drs.seek(head.secSizes[curSec++], Athena::Current); - - /* Skip Bitmap */ - drs.seek(head.secSizes[curSec++], Athena::Current); - - /* Skip SCLY (for now) */ - for (atUint32 l=0 ; lfirst == FOURCC('DEPS')) + { drs.seek(head.secSizes[curSec++], Athena::Current); + ++secIdxIt; + } - /* Skip SCGN (for now) */ - drs.seek(head.secSizes[curSec++], Athena::Current); + /* Skip SOBJ (SCLY) */ + if (secIdxIt->first == FOURCC('SOBJ')) + { + for (int l=0 ; lfirst == FOURCC('SGEN')) + { + drs.seek(head.secSizes[curSec++], Athena::Current); + ++secIdxIt; + } - /* Skip unknown section */ - drs.seek(head.secSizes[curSec++], Athena::Current); + /* Read Collision Meshes */ + if (secIdxIt->first == FOURCC('COLI')) + { + DNAMP2::DeafBabe collision; + secStart = drs.position(); + collision.read(drs); + DNAMP2::DeafBabe::BlenderInit(os); + collision.sendToBlender(os); + drs.seek(secStart + head.secSizes[curSec++], Athena::Begin); + ++secIdxIt; + } /* Read BABEDEAD Lights as Cycles emissives */ - secStart = drs.position(); - ReadBabeDeadToBlender_3(os, drs); - drs.seek(secStart + head.secSizes[curSec++], Athena::Begin); -#endif + if (secIdxIt->first == FOURCC('LITE')) + { + secStart = drs.position(); + ReadBabeDeadToBlender_3(os, drs); + drs.seek(secStart + head.secSizes[curSec++], Athena::Begin); + ++secIdxIt; + } /* Origins to center of mass */ os << "bpy.context.scene.layers[1] = True\n" diff --git a/DataSpec/DNAMP3/MREA.hpp b/DataSpec/DNAMP3/MREA.hpp index 8d8726a7e..e507ef6f8 100644 --- a/DataSpec/DNAMP3/MREA.hpp +++ b/DataSpec/DNAMP3/MREA.hpp @@ -66,16 +66,15 @@ struct MREA Value lightType; Value color; Value position; - Value unk3; - Value power; - Value unk4; + Value direction; + Value codirection; Value unk5; Value unk6; - Value unk7; - Value unk8; + Value unk7; + Value unk8; Value unk9; - Value unk10; - Value unk11; + Value unk10; + Value spotCutoff; Value unk12; Value unk13; };