Files
DarkflameServer/dUgcServer/Model/UgcModular.h
Aaron Kimbrell 7c32779e89 fix(ugc): transparent bricks drawn see-through in mixed models; dUgcServer in folders by role
- The client puts a shape in its sorted, blended pass only when its
  NiMaterialProperty alpha is under 0.99999 (ShaderCommon::GetAlphaFlags
  0x0109f5a0; the NiAlphaProperty blend flag isn't read); at 1.0 it's drawn
  solid with blending off. Transparent (and transparent glitter) shapes now
  get a material with alpha 0.9999, as the S01_Alpha shapes of the game's own
  brick models (res/BrickModels/ndmade) do; opaque shapes keep 1.0. Models
  with a transparent brick change; the others are byte for byte the same.
- dUgcServer's files move into Bricks/, Model/, Render/, Formats/ and
  Processing/ (the CMakeLists says what each holds); includes are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 22:31:26 -05:00

58 lines
2.0 KiB
C++

#pragma once
#include <cstdint>
#include <map>
#include <optional>
#include <string>
#include <string_view>
#include <vector>
#include <glm/glm.hpp>
#include "NifFile.h"
#include "UgcModel.h"
/**
* Modular builds (cars, rockets) put together from their modules the way the CDClient describes it:
* ModularBuildComponent.xml has the topology (a root part and which part connects to which named location of which
* other part), ModuleComponent.xml each module's connection offsets, and each module's render asset has the named
* attach-point nodes. Pure.
*/
namespace UgcModular {
struct Connection {
uint32_t part{}; // the part the location is on
std::string location; // node name on that part
uint32_t connectingPart{}; // the part placed there
};
struct BuildInfo {
uint32_t rootPart{};
uint32_t parts{};
std::vector<Connection> connections;
glm::mat4 additionalRotation{ 1.0f }; // Placement/AdditionalModelRotation
};
// ModularBuildComponent.xml; nullopt when it has no topology
std::optional<BuildInfo> ParseBuild(std::string_view xml);
// ModuleComponent.xml's connection offsets, by location name
std::map<std::string, glm::vec3> ParseModuleConnections(std::string_view xml);
// The LOTs in a ugc_modular_build.ldf_config ("1:4713+1:4714+1:4715", also with ';' or ',' between)
std::vector<uint32_t> ParseModuleLots(std::string_view ldf);
struct Module {
uint32_t partCode{};
NifFile::Model nif;
std::map<std::string, glm::vec3> connections; // from ParseModuleConnections
};
/**
* The modules placed per the build's topology, starting at the root part: a connection puts the connecting part
* where the parent's node of the location's name is (or the parent module's connection offset of that name when
* its mesh has no such node), less where the connecting part's own node of that name is, if it has one.
* Parts without a module are skipped; `warnings` says what was.
*/
UgcModel::Model Assemble(const BuildInfo& build, const std::vector<Module>& modules, std::string& warnings);
}