Files
DarkflameServer/dUgcServer/UgcFormats.h
Aaron Kimbrell abf1cc1d80 feat: UGC server that makes and serves player models' meshes and icons
A new server (dUgcServer, started by master with enable_ugc_server=1) that
takes unprocessed ugc and ugc_modular_build rows from the database and makes
what the client downloads with UGCUSE3DSERVICES: an optimized NIF (hidden
faces removed, ambient occlusion baked into vertex colors) and a 128px DDS
icon for player models, rendered by a software rasterizer from the client's
LDD brick primitives, and icons for cars and rockets assembled from their
modules per ModularBuildComponent/ModuleComponent. It serves them, with the
models' LXFML, over HTTP in the client's UGCC<dc>/3DOPTIMIZED and
IMAGE128DDS layout with .gz and .checksum files, and keeps its folder under
a size cap.

Processing state lives in ugc.is_optimized plus new processed_at,
process_attempts and process_error columns (and the same on
ugc_modular_build). ServiceType::UGC is appended. NifFile moves to dCommon
and records named node transforms for the modules' attach points.

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

41 lines
1.3 KiB
C++

#pragma once
#include <string>
#include <string_view>
#include <vector>
#include "UgcModel.h"
#include "UgcRender.h"
/**
* The files the UGC server writes: the mesh as a Gamebryo .nif the client loads, icons as .png and .dds, and the
* client's .checksum files for its downloads. Pure (data in, bytes out).
*/
namespace UgcFormats {
struct NifShape {
std::string name;
const UgcModel::Mesh* mesh{};
bool transparent{};
};
/**
* A Gamebryo 20.3.0.9 file (user version 0, as the client's own meshes): a root NiNode named `rootName` with one
* NiTriShape per shape (at most 65535 vertices and triangles each: UgcModel::Split), with vertex colors that are
* the diffuse and ambient color (NiVertexColorProperty), a white NiMaterialProperty, and for transparent shapes an
* NiAlphaProperty blending with the vertex alpha.
*/
std::string WriteNif(const std::string& rootName, const std::vector<NifShape>& shapes);
// PNG (8-bit RGBA)
std::string EncodePng(const UgcRender::Image& image);
// DDS, uncompressed 32-bit BGRA without mipmaps
std::string EncodeDds(const UgcRender::Image& image);
// Lowercase hex MD5 of `data`
std::string Md5Hex(std::string_view data);
// What the client reads from a UGC file's .checksum: the MD5 and size of the file as it is after inflating it
std::string ChecksumXml(std::string_view data);
}