建模 — UV
前置条件:先阅读 unreal-modeling。
库
CDO:/Script/GeometryScriptingCore.Default__GeometryScriptLibrary_MeshUVFunctions
TargetMesh 为 UDynamicMesh* 路径字符串。UVSetIndex(别名 UVChannel)为 int,通常 0。Debug 省略。需要 FGeometryScriptMeshSelection 的函数,用 MeshOperationLibrary 桥接(见 unreal-modeling)。
主要函数
UV 通道管理
| 函数 |
关键参数 |
说明 |
SetNumUVSets |
TargetMesh, NumUVSets |
设置 UV 通道数量 |
ClearUVChannel |
TargetMesh, UVChannel |
清空指定 UV 通道 |
CopyUVSet |
TargetMesh, FromUVSet, ToUVSet |
复制 UV 通道 |
UV 自动生成
| 函数 |
关键参数 |
说明 |
AutoGenerateXAtlasMeshUVs |
TargetMesh, UVSetIndex, Options |
XAtlas 自动展开(推荐通用方案) |
AutoGeneratePatchBuilderMeshUVs |
TargetMesh, UVSetIndex, Options |
PatchBuilder 自动展开(更多控制) |
RecomputeMeshUVs |
TargetMesh, UVSetIndex, Options, Selection |
基于已有岛或 Polygroup 重新计算 UV |
UV 投影
| 函数 |
关键参数 |
说明 |
SetMeshUVsFromPlanarProjection |
TargetMesh, UVSetIndex, PlaneTransform, Selection |
平面投影。PlaneTransform 的 Scale 定义映射到 1 UV 的世界尺寸 |
SetMeshUVsFromBoxProjection |
TargetMesh, UVSetIndex, BoxTransform, Selection, MinIslandTriCount |
盒体投影 |
SetMeshUVsFromCylinderProjection |
TargetMesh, UVSetIndex, CylinderTransform, Selection, SplitAngle |
圆柱投影 |
UV 布局与打包
| 函数 |
关键参数 |
说明 |
RepackMeshUVs |
TargetMesh, UVSetIndex, RepackOptions |
重新打包 UV 岛 |
LayoutMeshUVs |
TargetMesh, UVSetIndex, LayoutOptions, Selection |
布局 UV(支持多种模式) |
ApplyTexelDensityUVScaling |
TargetMesh, UVSetIndex, Options, Selection |
按纹素密度缩放 UV |
UV 变换
| 函数 |
关键参数 |
说明 |
TranslateMeshUVs |
TargetMesh, UVSetIndex, Translation, Selection |
平移 UV |
ScaleMeshUVs |
TargetMesh, UVSetIndex, Scale, ScaleOrigin, Selection |
缩放 UV |
RotateMeshUVs |
TargetMesh, UVSetIndex, RotationAngle, RotationOrigin, Selection |
旋转 UV(角度制) |
UV 查询
| 函数 |
关键参数 |
说明 |
GetMeshUVSizeInfo |
TargetMesh, UVSetIndex, Selection |
返回 3D 面积、UV 面积、3D 包围盒、UV 包围盒等 |
GetMeshPerVertexUVs |
TargetMesh, UVSetIndex |
获取每顶点 UV 列表 |
UV 传输
| 函数 |
关键参数 |
说明 |
TransferMeshUVsByProjection |
TargetMesh, TargetUVChannel, TargetSelection, TargetTransform, SourceMesh, SourceMeshOptionalBVH, SourceUVChannel, SourceSelection, SourceTransform, Settings, ProjectionDirection |
通过投影从源 mesh 传输 UV |
SetUVSeamsAlongSelectedEdges |
TargetMesh, UVChannel, Selection, bInsertSeams |
沿选中边设置/移除 UV 接缝 |
UV 底层操作
| 函数 |
关键参数 |
说明 |
SetMeshTriangleUVs |
TargetMesh, UVSetIndex, TriangleID, UVs |
设置单个三角形的 UV |
AddUVElementToMesh |
TargetMesh, UVSetIndex, NewUVPosition |
添加 UV 元素 |
SetMeshUVElementPosition |
TargetMesh, UVSetIndex, ElementID, NewUVPosition |
设置 UV 元素位置 |
CopyMeshUVLayerToMesh |
CopyFromMesh, UVSetIndex, CopyToUVMesh |
将 UV 通道导出为独立 mesh |
CopyMeshToMeshUVLayer |
CopyFromUVMesh, ToUVSetIndex, CopyToMesh |
将 mesh 写回 UV 通道 |
结构体与枚举
FGeometryScriptRecomputeUVsOptions
| 字段 |
类型 |
默认值 |
说明 |
Method |
EGeometryScriptUVFlattenMethod |
SpectralConformal |
展平算法 |
IslandSource |
EGeometryScriptUVIslandSource |
UVIslands |
岛来源 |
ExpMapOptions |
struct |
— |
ExpMap 专用选项 |
SpectralConformalOptions |
struct |
— |
SpectralConformal 专用选项 |
GroupLayer |
FGeometryScriptGroupLayer |
默认层 |
Polygroup 层(当 IslandSource=PolyGroups 时) |
bAutoAlignIslandsWithAxes |
bool |
true |
自动对齐岛到坐标轴 |
EGeometryScriptUVFlattenMethod
| 值 |
说明 |
ExpMap |
指数映射 |
Conformal |
保角映射 |
SpectralConformal |
谱保角映射(推荐) |
EGeometryScriptUVIslandSource
| 值 |
说明 |
PolyGroups |
按 Polygroup 分岛 |
UVIslands |
按已有 UV 岛分岛 |
FGeometryScriptXAtlasOptions
| 字段 |
类型 |
默认值 |
MaxIterations |
int |
2 |
FGeometryScriptPatchBuilderOptions
| 字段 |
类型 |
默认值 |
说明 |
InitialPatchCount |
int |
100 |
初始 patch 数量 |
MinPatchSize |
int |
2 |
最小 patch 大小 |
PatchCurvatureAlignmentWeight |
float |
1.0 |
曲率对齐权重 |
PatchMergingMetricThresh |
float |
1.5 |
合并度量阈值 |
PatchMergingAngleThresh |
float |
45.0 |
合并角度阈值 |
bRespectInputGroups |
bool |
false |
尊重输入 Polygroup |
bAutoPack |
bool |
true |
自动打包 |
PackingOptions |
FGeometryScriptRepackUVsOptions |
— |
打包选项 |
FGeometryScriptRepackUVsOptions
| 字段 |
类型 |
默认值 |
TargetImageWidth |
int |
512 |
bOptimizeIslandRotation |
bool |
true |
FGeometryScriptLayoutUVsOptions
| 字段 |
类型 |
默认值 |
说明 |
LayoutType |
EGeometryScriptUVLayoutType |
Repack |
布局类型 |
TextureResolution |
int |
1024 |
纹理分辨率 |
Scale |
float |
1 |
打包后缩放 |
Translation |
FVector2D |
(0,0) |
打包后平移 |
bPreserveScale |
bool |
false |
保留岛缩放 |
bPreserveRotation |
bool |
false |
保留岛旋转 |
bAllowFlips |
bool |
false |
允许翻转 |
EGeometryScriptUVLayoutType
| 值 |
说明 |
Transform |
应用 Scale/Translation |
Stack |
每个岛独立缩放到单位正方形 |
Repack |
集体打包到单位正方形(无重叠) |
Normalize |
归一化纹素密度 |
JSON 示例
XAtlas 自动展开:
{"object":"/Script/GeometryScriptingCore.Default__GeometryScriptLibrary_MeshUVFunctions","function":"AutoGenerateXAtlasMeshUVs","params":{"TargetMesh":"/Engine/Transient.DynamicMesh_0","UVSetIndex":0,"Options":{"MaxIterations":2}}}
盒体投影:
{"object":"/Script/GeometryScriptingCore.Default__GeometryScriptLibrary_MeshUVFunctions","function":"SetMeshUVsFromBoxProjection","params":{"TargetMesh":"/Engine/Transient.DynamicMesh_0","UVSetIndex":0,"BoxTransform":{"Rotation":{"X":0,"Y":0,"Z":0,"W":1},"Translation":{"X":0,"Y":0,"Z":0},"Scale3D":{"X":100,"Y":100,"Z":100}},"Selection":{},"MinIslandTriCount":2}}
重新计算 UV(SpectralConformal):
{"object":"/Script/GeometryScriptingCore.Default__GeometryScriptLibrary_MeshUVFunctions","function":"RecomputeMeshUVs","params":{"TargetMesh":"/Engine/Transient.DynamicMesh_0","UVSetIndex":0,"Options":{"Method":"SpectralConformal","IslandSource":"UVIslands","bAutoAlignIslandsWithAxes":true},"Selection":{}}}
发现
对 CDO 路径调用 DescribeObject 可查看完整函数列表和参数签名。
1---2name: unreal-modeling-uv3description: GeometryScript UV 操作。当用户要求生成、投影、布局、变换 UV 或进行 UV 相关处理时使用。4---56# 建模 — UV78前置条件:先阅读 `unreal-modeling`。910## 库1112CDO:`/Script/GeometryScriptingCore.Default__GeometryScriptLibrary_MeshUVFunctions`1314`TargetMesh` 为 `UDynamicMesh*` 路径字符串。`UVSetIndex`(别名 `UVChannel`)为 int,通常 `0`。`Debug` 省略。需要 `FGeometryScriptMeshSelection` 的函数,用 `MeshOperationLibrary` 桥接(见 `unreal-modeling`)。1516## 主要函数1718### UV 通道管理1920| 函数 | 关键参数 | 说明 |21|------|----------|------|22| `SetNumUVSets` | `TargetMesh`, `NumUVSets` | 设置 UV 通道数量 |23| `ClearUVChannel` | `TargetMesh`, `UVChannel` | 清空指定 UV 通道 |24| `CopyUVSet` | `TargetMesh`, `FromUVSet`, `ToUVSet` | 复制 UV 通道 |2526### UV 自动生成2728| 函数 | 关键参数 | 说明 |29|------|----------|------|30| `AutoGenerateXAtlasMeshUVs` | `TargetMesh`, `UVSetIndex`, `Options` | XAtlas 自动展开(推荐通用方案) |31| `AutoGeneratePatchBuilderMeshUVs` | `TargetMesh`, `UVSetIndex`, `Options` | PatchBuilder 自动展开(更多控制) |32| `RecomputeMeshUVs` | `TargetMesh`, `UVSetIndex`, `Options`, `Selection` | 基于已有岛或 Polygroup 重新计算 UV |3334### UV 投影3536| 函数 | 关键参数 | 说明 |37|------|----------|------|38| `SetMeshUVsFromPlanarProjection` | `TargetMesh`, `UVSetIndex`, `PlaneTransform`, `Selection` | 平面投影。PlaneTransform 的 Scale 定义映射到 1 UV 的世界尺寸 |39| `SetMeshUVsFromBoxProjection` | `TargetMesh`, `UVSetIndex`, `BoxTransform`, `Selection`, `MinIslandTriCount` | 盒体投影 |40| `SetMeshUVsFromCylinderProjection` | `TargetMesh`, `UVSetIndex`, `CylinderTransform`, `Selection`, `SplitAngle` | 圆柱投影 |4142### UV 布局与打包4344| 函数 | 关键参数 | 说明 |45|------|----------|------|46| `RepackMeshUVs` | `TargetMesh`, `UVSetIndex`, `RepackOptions` | 重新打包 UV 岛 |47| `LayoutMeshUVs` | `TargetMesh`, `UVSetIndex`, `LayoutOptions`, `Selection` | 布局 UV(支持多种模式) |48| `ApplyTexelDensityUVScaling` | `TargetMesh`, `UVSetIndex`, `Options`, `Selection` | 按纹素密度缩放 UV |4950### UV 变换5152| 函数 | 关键参数 | 说明 |53|------|----------|------|54| `TranslateMeshUVs` | `TargetMesh`, `UVSetIndex`, `Translation`, `Selection` | 平移 UV |55| `ScaleMeshUVs` | `TargetMesh`, `UVSetIndex`, `Scale`, `ScaleOrigin`, `Selection` | 缩放 UV |56| `RotateMeshUVs` | `TargetMesh`, `UVSetIndex`, `RotationAngle`, `RotationOrigin`, `Selection` | 旋转 UV(角度制) |5758### UV 查询5960| 函数 | 关键参数 | 说明 |61|------|----------|------|62| `GetMeshUVSizeInfo` | `TargetMesh`, `UVSetIndex`, `Selection` | 返回 3D 面积、UV 面积、3D 包围盒、UV 包围盒等 |63| `GetMeshPerVertexUVs` | `TargetMesh`, `UVSetIndex` | 获取每顶点 UV 列表 |6465### UV 传输6667| 函数 | 关键参数 | 说明 |68|------|----------|------|69| `TransferMeshUVsByProjection` | `TargetMesh`, `TargetUVChannel`, `TargetSelection`, `TargetTransform`, `SourceMesh`, `SourceMeshOptionalBVH`, `SourceUVChannel`, `SourceSelection`, `SourceTransform`, `Settings`, `ProjectionDirection` | 通过投影从源 mesh 传输 UV |70| `SetUVSeamsAlongSelectedEdges` | `TargetMesh`, `UVChannel`, `Selection`, `bInsertSeams` | 沿选中边设置/移除 UV 接缝 |7172### UV 底层操作7374| 函数 | 关键参数 | 说明 |75|------|----------|------|76| `SetMeshTriangleUVs` | `TargetMesh`, `UVSetIndex`, `TriangleID`, `UVs` | 设置单个三角形的 UV |77| `AddUVElementToMesh` | `TargetMesh`, `UVSetIndex`, `NewUVPosition` | 添加 UV 元素 |78| `SetMeshUVElementPosition` | `TargetMesh`, `UVSetIndex`, `ElementID`, `NewUVPosition` | 设置 UV 元素位置 |79| `CopyMeshUVLayerToMesh` | `CopyFromMesh`, `UVSetIndex`, `CopyToUVMesh` | 将 UV 通道导出为独立 mesh |80| `CopyMeshToMeshUVLayer` | `CopyFromUVMesh`, `ToUVSetIndex`, `CopyToMesh` | 将 mesh 写回 UV 通道 |8182## 结构体与枚举8384### `FGeometryScriptRecomputeUVsOptions`8586| 字段 | 类型 | 默认值 | 说明 |87|------|------|--------|------|88| `Method` | `EGeometryScriptUVFlattenMethod` | `SpectralConformal` | 展平算法 |89| `IslandSource` | `EGeometryScriptUVIslandSource` | `UVIslands` | 岛来源 |90| `ExpMapOptions` | struct | — | ExpMap 专用选项 |91| `SpectralConformalOptions` | struct | — | SpectralConformal 专用选项 |92| `GroupLayer` | `FGeometryScriptGroupLayer` | 默认层 | Polygroup 层(当 IslandSource=PolyGroups 时) |93| `bAutoAlignIslandsWithAxes` | bool | `true` | 自动对齐岛到坐标轴 |9495### `EGeometryScriptUVFlattenMethod`9697| 值 | 说明 |98|----|------|99| `ExpMap` | 指数映射 |100| `Conformal` | 保角映射 |101| `SpectralConformal` | 谱保角映射(推荐) |102103### `EGeometryScriptUVIslandSource`104105| 值 | 说明 |106|----|------|107| `PolyGroups` | 按 Polygroup 分岛 |108| `UVIslands` | 按已有 UV 岛分岛 |109110### `FGeometryScriptXAtlasOptions`111112| 字段 | 类型 | 默认值 |113|------|------|--------|114| `MaxIterations` | int | `2` |115116### `FGeometryScriptPatchBuilderOptions`117118| 字段 | 类型 | 默认值 | 说明 |119|------|------|--------|------|120| `InitialPatchCount` | int | `100` | 初始 patch 数量 |121| `MinPatchSize` | int | `2` | 最小 patch 大小 |122| `PatchCurvatureAlignmentWeight` | float | `1.0` | 曲率对齐权重 |123| `PatchMergingMetricThresh` | float | `1.5` | 合并度量阈值 |124| `PatchMergingAngleThresh` | float | `45.0` | 合并角度阈值 |125| `bRespectInputGroups` | bool | `false` | 尊重输入 Polygroup |126| `bAutoPack` | bool | `true` | 自动打包 |127| `PackingOptions` | `FGeometryScriptRepackUVsOptions` | — | 打包选项 |128129### `FGeometryScriptRepackUVsOptions`130131| 字段 | 类型 | 默认值 |132|------|------|--------|133| `TargetImageWidth` | int | `512` |134| `bOptimizeIslandRotation` | bool | `true` |135136### `FGeometryScriptLayoutUVsOptions`137138| 字段 | 类型 | 默认值 | 说明 |139|------|------|--------|------|140| `LayoutType` | `EGeometryScriptUVLayoutType` | `Repack` | 布局类型 |141| `TextureResolution` | int | `1024` | 纹理分辨率 |142| `Scale` | float | `1` | 打包后缩放 |143| `Translation` | FVector2D | `(0,0)` | 打包后平移 |144| `bPreserveScale` | bool | `false` | 保留岛缩放 |145| `bPreserveRotation` | bool | `false` | 保留岛旋转 |146| `bAllowFlips` | bool | `false` | 允许翻转 |147148### `EGeometryScriptUVLayoutType`149150| 值 | 说明 |151|----|------|152| `Transform` | 应用 Scale/Translation |153| `Stack` | 每个岛独立缩放到单位正方形 |154| `Repack` | 集体打包到单位正方形(无重叠) |155| `Normalize` | 归一化纹素密度 |156157## JSON 示例158159**XAtlas 自动展开**:160161```json162{"object":"/Script/GeometryScriptingCore.Default__GeometryScriptLibrary_MeshUVFunctions","function":"AutoGenerateXAtlasMeshUVs","params":{"TargetMesh":"/Engine/Transient.DynamicMesh_0","UVSetIndex":0,"Options":{"MaxIterations":2}}}163```164165**盒体投影**:166167```json168{"object":"/Script/GeometryScriptingCore.Default__GeometryScriptLibrary_MeshUVFunctions","function":"SetMeshUVsFromBoxProjection","params":{"TargetMesh":"/Engine/Transient.DynamicMesh_0","UVSetIndex":0,"BoxTransform":{"Rotation":{"X":0,"Y":0,"Z":0,"W":1},"Translation":{"X":0,"Y":0,"Z":0},"Scale3D":{"X":100,"Y":100,"Z":100}},"Selection":{},"MinIslandTriCount":2}}169```170171**重新计算 UV(SpectralConformal)**:172173```json174{"object":"/Script/GeometryScriptingCore.Default__GeometryScriptLibrary_MeshUVFunctions","function":"RecomputeMeshUVs","params":{"TargetMesh":"/Engine/Transient.DynamicMesh_0","UVSetIndex":0,"Options":{"Method":"SpectralConformal","IslandSource":"UVIslands","bAutoAlignIslandsWithAxes":true},"Selection":{}}}175```176177## 发现178179对 CDO 路径调用 `DescribeObject` 可查看完整函数列表和参数签名。