Files
mtgodot-poc/formats/spt.h
T

35 lines
1.7 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// .spt —— SpeedTree RT 私有格式(IDV Inc.)。
//
// W4 调研结论(2026-08-29):**几何无法读**。`.spt` 的解析在闭源 `CSpeedTreeRT::LoadTree()`
// 里(`m2dev-client-src-main/extern/library/SpeedTree/speedtree_static.lib`,实测 COFF x86-64
// IDV 专有,不能链进 macOS/移动端、不可随意分发);`SpeedTreeLib/` 是渲染 wrapper,不含 parser。
// → 运行时使用读取真实 bark/composite atlas 的 proxy;真几何走经授权的 Windows x64 离线 exporter。
// 2026-09-11: hash-matched native exports for 87 local species are now staged in
// assets/TreeGeometry and loaded preferentially by the runtime. This sniffer
// remains only the fallback texture reader, not a geometry decoder.
//
// 这里只做「嗅探」:读文件头 magic + version,抽取内嵌贴图和 composite atlas token。
// 不解析枝干/叶片几何。无 godot 依赖。
#pragma once
#include <string>
#include <vector>
namespace fmt {
struct SptInfo {
bool ok = false;
std::string magic; // "__IdvSpt_02_" 等
uint32_t header_dword = 0; // magic 前的第一个 u32(版本/大小,未定)
std::vector<std::string> texture_refs; // 内嵌的 *.tga / *.dds 路径(原样)
// SpeedTree 2 把这两个 atlas 名写成不一定以 NUL 结尾的 token(例如
// "CompositeMapB1#N"),普通 printable-string 扫描会漏掉。统一转成 .dds,
// 供无几何 reader 的 proxy 渲染使用。
std::string composite_texture;
std::string self_shadow_texture;
};
bool sniff_spt(const std::string& bytes, SptInfo& out);
bool sniff_spt_file(const std::string& path, SptInfo& out);
} // namespace fmt