From 5f7c59e2ebe1160010a4428a3d0e759644bf0330 Mon Sep 17 00:00:00 2001 From: lzwdgc Date: Fri, 8 Dec 2017 14:07:14 +0300 Subject: [PATCH] Extract light, heavy and rocket weapons. --- src/mod_converter/fbx.cpp | 65 ++++++++++++++++++++++++++----------- src/mod_converter/model.cpp | 3 -- 2 files changed, 46 insertions(+), 22 deletions(-) diff --git a/src/mod_converter/fbx.cpp b/src/mod_converter/fbx.cpp index 2365495..2dd1658 100644 --- a/src/mod_converter/fbx.cpp +++ b/src/mod_converter/fbx.cpp @@ -227,34 +227,61 @@ bool CreateScene(model &model, const std::string &name, FbxManager* pSdkManager, static const char* gAmbientElementName = "AmbientUV"; static const char* gSpecularElementName = "SpecularUV"; + auto create_socket_named = [&pScene](const std::string &name) + { + FbxNode *socket = FbxNode::Create(pScene, ("SOCKET_" + name).c_str()); + auto n = FbxNull::Create(socket, ""); + socket->SetNodeAttribute(n); + pScene->GetRootNode()->AddChild(socket); + return socket; + }; + + auto create_socket = [&create_socket_named](const auto &b, const std::string &name, bool mirror_x = false) + { + FbxVector4 c; + for (auto &v : b.vertices) + { + FbxVector4 x; + x.Set(-v.coordinates.x * scale_mult, v.coordinates.y * scale_mult, -v.coordinates.z * scale_mult, v.coordinates.w); + c += x; + } + c /= b.vertices.size(); + + auto s = create_socket_named(name); + if (mirror_x) + c.mData[0] = -c.mData[0]; + s->LclTranslation.Set(c); + }; + //std::mapSetNodeAttribute(n); - pScene->GetRootNode()->AddChild(socket); - - FbxVector4 c; - for (auto &v : b.vertices) - { - FbxVector4 x; - x.Set(-v.coordinates.x * scale_mult, v.coordinates.y * scale_mult, -v.coordinates.z * scale_mult, v.coordinates.w); - c += x; - } - c /= b.vertices.size(); - - socket->LclTranslation.Set(c); - + create_socket(b, "EngineFx_" + std::to_string(socket_id++)); continue; } + else if (b.h.name == "LIGHTGUN") + { + create_socket(b, "WeaponLight_0"); + create_socket(b, "WeaponLight_1", true); + continue; + } + else if (b.h.name == "HEAVYGUN") + { + create_socket(b, "WeaponHeavy"); + continue; + } + else if (b.h.name == "ROCKET") + { + create_socket(b, "WeaponRocket"); + continue; + } + + if (!b.canPrint()) + continue; //auto block_name = name + "/" + b.h.name; const auto block_name = b.h.name; diff --git a/src/mod_converter/model.cpp b/src/mod_converter/model.cpp index 4d73469..e6c988e 100644 --- a/src/mod_converter/model.cpp +++ b/src/mod_converter/model.cpp @@ -472,9 +472,6 @@ bool block::canPrint() const if (h.type == BlockType::VisibleObject) return true; - if (isEngineFx()) - return true; - // particles if (h.type == BlockType::ParticleEmitter) return false;