COM3D2

package
v2.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 29, 2026 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LocalRotationX int32 = 0
	LocalRotationY       = 1
	LocalRotationZ       = 2
	LocalRotationW       = 3
)

PropertyIndex 表示属性索引,用于标识属性的类型 最高位为 6,含义如下 PropertyIndex identifies the property type The highest index is 6, with the meanings listed below

View Source
const (
	MenuSignature   = "CM3D2_MENU"
	MenuVersion     = 1000
	MateSignature   = "CM3D2_MATERIAL"
	MateVersion     = 2001
	PMatSignature   = "CM3D2_PMATERIAL"
	PMatVersion     = 1000
	ColSignature    = "CM3D21_COL"
	ColVersion      = 24301
	PhySignature    = "CM3D21_PHY"
	PhyVersion      = 24301
	PskSignature    = "CM3D21_PSK"
	PskVersion      = 24301
	TexSignature    = "CM3D2_TEX"
	TexVersion      = 1010
	AnmSignature    = "CM3D2_ANIM"
	AnmVersion      = 1001
	ModelSignature  = "CM3D2_MESH"
	ModelVersion    = 2001
	PresetSignature = "CM3D2_PRESET"
	PresetVersion   = 24301
	SaveSignature   = "COM3D2_SAVE"
	SaveVersion     = 24301
)
View Source
const (
	SkinThicknessSignature = "SkinThickness"
	SkinThicknessVersion   = 100
)
View Source
const (
	PresetPropertyListSignature = "CM3D2_MPROP_LIST"
	PresetPropertyListVersion   = 24301
	PresetPropertySignature     = "CM3D2_MPROP"
	PresetPropertyVersion       = 24301
	MultiColorSignature         = "CM3D2_MULTI_COL"
	MultiColorVersion           = 24301
	BodyPropertySignature       = "CM3D2_MAID_BODY"
	BodyPropertyVersion         = 24301
)
View Source
const (
	// TimelineSignature 是时间线文件头标识
	// TimelineSignature is the timeline file header marker
	TimelineSignature = "BaseData"
	// TimelineFinish 是时间线结束标识
	// TimelineFinish is the timeline end marker
	TimelineFinish   = "Finish"
	TrackTranslation = "Translation"
	TrackRotation    = "Rotation"
	TrackProperty    = "Property"
	TrackEvent       = "Event"
)
View Source
const (
	// 不投射阴影
	// Do not cast shadows
	ShadowCastingModeOff = "Off"
	// 投射阴影
	// Cast shadows
	ShadowCastingModeOn = "On"
	// 双面投射阴影
	// Cast two-sided shadows
	ShadowCastingModeTwoSided = "TwoSided"
	// 只投射阴影
	// Cast shadows only
	ShadowCastingModeShadowsOnly = "ShadowsOnly"
)

阴影投射方式,对应 Unity 的 ShadowCastingMode Shadow-casting modes corresponding to Unity ShadowCastingMode

View Source
const (
	// NeiTextEncodingShiftJIS 是 COM3D2 读取 .nei 时使用的 Shift-JIS(CP932)编码
	// NeiTextEncodingShiftJIS is the Shift-JIS (CP932) encoding COM3D2 uses when reading .nei
	NeiTextEncodingShiftJIS = nei.TextEncodingShiftJIS
	// NeiTextEncodingUTF8 是 KCES 读取 .nei 时使用的 UTF-8 编码,COM3D2 表格不应写出该编码
	// NeiTextEncodingUTF8 is the UTF-8 encoding KCES uses when reading .nei, which COM3D2 tables should not emit
	NeiTextEncodingUTF8 = nei.TextEncodingUTF8
)
View Source
const (
	PartialModeStaticOrCurve int32 = 0 // C# 里的 StaticOrCurve,静态或曲线模式  / StaticOrCurve in C#, the static-or-curve mode
	PartialModePartial       int32 = 1 // C#里的 Partial,按骨骼设置模式 / Partial in C#, the per-bone mode
	PartialModeFromBoneName  int32 = 2 // C#里的 FromBoneName,旧自动按骨骼名设置模式 / FromBoneName in C#, the legacy automatic per-bone-name mode
)

PartialMode 枚举 PartialMode enum

View Source
const (
	FreezeAxisNone int32 = 0
	FreezeAxisX    int32 = 1
	FreezeAxisY    int32 = 2
	FreezeAxisZ    int32 = 3
)

FreezeAxis 枚举 FreezeAxis enum

View Source
const (
	// PresetTypeWear 表示仅应用服装属性
	// PresetTypeWear applies clothing properties only
	PresetTypeWear = 0
	// PresetTypeBody 表示仅应用身体属性
	// PresetTypeBody applies body properties only
	PresetTypeBody = 1
	// PresetTypeAll 表示应用全部属性
	// PresetTypeAll applies all properties
	PresetTypeAll = 2
)

以下常量定义预设应用范围 The following constants define the preset application scope

View Source
const (
	RGB24  int32 = 3
	ARGB32 int32 = 5
	DXT1   int32 = 10
	DXT5   int32 = 12
)

下列值来自 Unity 5.6.4 的 TextureFormat 枚举并仅由 COM3D2 使用 The following values come from the Unity 5.6.4 TextureFormat enum and are used only by COM3D2

View Source
const (
	EndTag = "end"
)

Variables

View Source
var (
	NeiSignature = nei.Signature
)

Functions

func ConvertImageToTexAndWrite

func ConvertImageToTexAndWrite(inputPath string, texName string, compress bool, forcePNG bool, outputPath string) error

ConvertImageToTexAndWrite 将任意 ImageMagick 支持的文件格式转换为 tex 格式并写出 转换规则与 ConvertImageToTex 相同,包括 forcePNG、compress 和同名 .uv.csv 的处理 ConvertImageToTexAndWrite converts any ImageMagick-supported file format to tex and writes it It uses the same forcePNG, compress, and sibling .uv.csv behavior as ConvertImageToTex

func ConvertTexToImageAndWrite

func ConvertTexToImageAndWrite(tex *Tex, outputPath string, forcePNG bool) error

ConvertTexToImageAndWrite 将 .tex 文件转换为图像文件并写出 依赖外部库 ImageMagick,并要求 PATH 环境变量可以直接调用 magick 命令 forcePNG 为 false 时根据输出路径后缀决定格式,没有后缀时有损且无透明通道的数据保存为 JPG,其余保存为 PNG forcePNG 为 true 时不考虑原始格式和透明通道并强制保存为 PNG 版本 1011 的纹理图集还会生成同名 .uv.csv 文件,每行保存一组 x、y、w、h 输出路径使用 .tex 后缀时原样写出 Tex ConvertTexToImageAndWrite converts a .tex file to an image file and writes it It depends on ImageMagick and requires the magick command to be directly available through PATH When forcePNG is false, the output suffix selects the format, while a missing suffix uses JPG for lossy data without alpha and PNG otherwise When forcePNG is true, PNG is forced regardless of the original format and alpha presence Version-1011 texture atlases also produce a sibling .uv.csv file with one x, y, w, h group per row An output path ending in .tex writes the Tex unchanged

func EncodeMultiColorBlock

func EncodeMultiColorBlock(value *MultiColor) ([]byte, error)

EncodeMultiColorBlock 写入一个完整的 CM3D2_MULTI_COL 字节块,并保留 value 中的版本与新旧布局 EncodeMultiColorBlock writes one complete CM3D2_MULTI_COL byte block while retaining the version and current or legacy layout stored in value

func WriteAnimationCurve

func WriteAnimationCurve(writer *stream.BinaryWriter, ac AnimationCurve) error

WriteAnimationCurve 写出 AnimationCurve:先写 int(个数),然后依次写 time,value,inTangent,outTangent WriteAnimationCurve writes the count first, followed by time, value, inTangent, and outTangent for each keyframe

Types

type AnimationCurve

type AnimationCurve struct {
	Keyframes []Keyframe `json:"Keyframes"` // 按时间保存的关键帧 / Keyframes stored in time order
}

AnimationCurve 用于存储 Keyframe 数组 AnimationCurve stores a Keyframe array

func ReadAnimationCurve

func ReadAnimationCurve(reader *stream.BinaryReader) (AnimationCurve, error)

ReadAnimationCurve 读取 AnimationCurve:先读 int(个数),若为 0 则返回空 ReadAnimationCurve reads the keyframe count first and returns an empty curve when it is 0

type Anm

type Anm struct {
	Signature    string          `json:"Signature"`              // CM3D2_ANIM 文件签名 / CM3D2_ANIM file signature
	Version      int32           `json:"Version"`                // 版本 1001 / Version 1001
	BoneCurves   []BoneCurveData `json:"BoneCurves"`             // 所有骨骼的动画曲线数据 / Animation curve data for all bones
	BustKeyLeft  bool            `json:"BustKeyLeft,omitempty"`  // 左胸部动画开关 / Left bust-animation switch
	BustKeyRight bool            `json:"BustKeyRight,omitempty"` // 右胸部动画开关 / Right bust-animation switch
}

Anm 整体描述一个 .anm 文件的结构 Anm describes the overall structure of an .anm file

func ReadAnm

func ReadAnm(r io.Reader) (*Anm, error)

ReadAnm 读取并解析一个 .anm 文件,返回 Anm 结构 ReadAnm reads and parses an .anm file and returns an Anm structure

func (Anm) Dump

func (a Anm) Dump(w io.Writer) error

Dump 将 Anm 结构写到 w 中,生成符合 CM3D2_ANIM 格式的二进制数据 Dump writes an Anm structure to w as CM3D2_ANIM binary data

type BodyProperty

type BodyProperty struct {
	Signature string `json:"Signature"` // 文件签名 CM3D2_MAID_BODY / File signature CM3D2_MAID_BODY
	Version   int32  `json:"Version"`   // 身体块格式版本 / Body-block format version

}

BodyProperty 表示身体属性 BodyProperty represents the body block

type Bone

type Bone struct {
	Name        string     `json:"Name"`            // 骨骼名称 / Bone name
	HasScale    bool       `json:"HasScale"`        // 是否创建名称带 _SCL_ 的缩放辅助节点 / Whether to create a scaling helper node whose name contains _SCL_
	ParentIndex int32      `json:"ParentIndex"`     // 父骨骼索引,负值表示挂在模型根节点 / Parent bone index, with a negative value attaching the bone to the model root
	Position    Vector3    `json:"Position"`        // 骨骼局部位置 / Bone local position
	Rotation    Quaternion `json:"Rotation"`        // 骨骼局部旋转 / Bone local rotation
	Scale       *Vector3   `json:"Scale,omitempty"` // 版本 2001 及以上可选的骨骼局部缩放 / Optional bone local scale for version 2001 and later
}

Bone 表示骨骼数据 Bone represents bone data

type BoneAttachPos

type BoneAttachPos struct {
	Enable      bool                  `json:"Enable"`                // 是否启用 / Whether the position is enabled
	PosRotScale PositionRotationScale `json:"PositionRotationScale"` // 局部位置、旋转和缩放 / Local position, rotation, and scale
}

BoneAttachPos 表示骨骼附着位置 BoneAttachPos represents a bone attachment position

type BoneAttachPosEntry

type BoneAttachPosEntry struct {
	SlotName      string        `json:"SlotName,omitempty"` // v2003 起在线格式中用于解析槽位枚举的名称 / Name used to resolve the slot enum on the wire since v2003
	RID           int32         `json:"RID"`                // 来源菜单文件名哈希,用于确认数据属于当前菜单项 / Source-menu filename hash used to verify that the data belongs to the current menu item
	BoneAttachPos BoneAttachPos `json:"BoneAttachPos"`      // 皮肤位置数据 / Skin-position data
}

BoneAttachPosEntry 保存槽位皮肤位置及其来源菜单哈希 BoneAttachPosEntry stores a slot skin position and its source-menu hash

type BoneCurveData

type BoneCurveData struct {
	BonePath       string          `json:"BonePath"`       // 骨骼路径(如"Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1") / Bone path such as "Bip01/Bip01 Spine/Bip01 Spine0a/Bip01 Spine1"
	PropertyCurves []PropertyCurve `json:"PropertyCurves"` // 该骨骼的所有属性动画曲线 / All property animation curves for this bone
}

BoneCurveData 存储某个骨骼(或节点)对应的一组曲线信息 BoneCurveData stores a group of curves for a bone or node

type BoneLengthEntry

type BoneLengthEntry struct {
	SlotName    string             `json:"SlotName,omitempty"`    // v2003 起在线格式中用于解析槽位枚举的名称 / Name used to resolve the slot enum on the wire since v2003
	RID         int32              `json:"RID"`                   // 来源菜单文件名哈希,用于确认数据属于当前菜单项 / Source-menu filename hash used to verify that the data belongs to the current menu item
	Lengths     map[string]float32 `json:"Lengths"`               // 按骨骼名索引的长度值 / Length values indexed by bone name
	LengthOrder []string           `json:"LengthOrder,omitempty"` // 骨骼名称在线格式中的顺序 / Bone-name order on the wire
}

BoneLengthEntry 保存槽位骨骼长度设置及其来源菜单哈希 BoneLengthEntry stores slot bone-length settings and their source-menu hash

type BoneValue

type BoneValue struct {
	BoneName string  `json:"BoneName"` // 骨骼名称 / Bone name
	Value    float32 `json:"Value"`    // 该骨骼的参数值 / Parameter value for the bone
}

BoneValue 存储一个骨骼名称与对应 float 值 BoneValue stores a bone name and its corresponding float value

type BoneWeight

type BoneWeight struct {
	BoneIndex0 uint16  `json:"BoneIndex0"` // 第一个骨骼索引 / First bone index
	BoneIndex1 uint16  `json:"BoneIndex1"` // 第二个骨骼索引 / Second bone index
	BoneIndex2 uint16  `json:"BoneIndex2"` // 第三个骨骼索引 / Third bone index
	BoneIndex3 uint16  `json:"BoneIndex3"` // 第四个骨骼索引 / Fourth bone index
	Weight0    float32 `json:"Weight0"`    // 第一个骨骼权重 / First bone weight
	Weight1    float32 `json:"Weight1"`    // 第二个骨骼权重 / Second bone weight
	Weight2    float32 `json:"Weight2"`    // 第三个骨骼权重 / Third bone weight
	Weight3    float32 `json:"Weight3"`    // 第四个骨骼权重 / Fourth bone weight
}

BoneWeight 表示骨骼权重 BoneWeight represents bone weights

type Col

type Col struct {
	Signature string      `json:"Signature"` // CM3D21_COL 文件签名 / CM3D21_COL file signature
	Version   int32       `json:"Version"`   // 此版本随每次更新变化,但结构不变 / This version changes with each update without changing the structure
	Colliders []ICollider `json:"Colliders"` // 碰撞器列表 / Collider list
}

Col 表示一个 CM3D21_COL 文件 Col represents a CM3D21_COL file

func ReadCol

func ReadCol(r io.Reader) (*Col, error)

ReadCol 从二进制流里读取一个 Col ReadCol reads a Col from a binary stream

func (*Col) Dump

func (c *Col) Dump(w io.Writer) error

Dump 把 Col 写出到 w 中 Dump writes Col to w

func (*Col) UnmarshalJSON

func (c *Col) UnmarshalJSON(data []byte) error

UnmarshalJSON 为 Col 实现自定义 UnmarshalJSON 因为 Col 的 ICollider 字段是一个接口切片,需要根据 typeName 字段来决定反序列化为哪个具体类型 UnmarshalJSON implements custom JSON unmarshalling for Col Col contains an ICollider interface slice, so typeName determines the concrete type used for deserialization

type ColProperty

type ColProperty struct {
	TypeName string     `json:"TypeName" default:"col"` // JSON 类型判别标识 / JSON type discriminator
	PropName string     `json:"PropName"`               // Unity 材质颜色属性名 / Unity material color-property name
	Color    [4]float32 `json:"Color"`                  // R、G、B、A 分量 / R, G, B, A components
}

ColProperty 表示按 R、G、B、A 顺序保存的材质颜色属性 ColProperty represents a material color property stored in R, G, B, A order

func (*ColProperty) GetTypeName

func (c *ColProperty) GetTypeName() string

GetTypeName 返回颜色属性标识 col GetTypeName returns the col property identifier

func (*ColProperty) Read

func (c *ColProperty) Read(reader *stream.BinaryReader) error

Read 读取颜色属性名和四个 RGBA 浮点分量 Read reads the color property name and four RGBA float components

func (*ColProperty) Write

func (c *ColProperty) Write(writer *stream.BinaryWriter) error

Write 写入 col 类型标识、属性名和四个 RGBA 浮点分量 Write writes the col type identifier, property name, and four RGBA float components

type Color

type Color struct {
	A float32 `json:"A"` // Alpha 分量 / Alpha component
	R float32 `json:"R"` // 红色分量 / Red component
	G float32 `json:"G"` // 绿色分量 / Green component
	B float32 `json:"B"` // 蓝色分量 / Blue component
}

Color 表示颜色(ARGB 顺序,与 Unity 序列化一致) Color represents a color in ARGB order, matching Unity serialization

type Command

type Command struct {
	Command string   `json:"Command"` // 命令名称,即记录中的第一个字符串 / Command name, which is the first string in the record
	Args    []string `json:"Args"`    // 命令名称之后的参数字符串 / Argument strings following the command name
}

Command 对应 .menu 中的命令 Command corresponds to a command in a .menu file

type DanceObjectData

type DanceObjectData struct {
	Entries []DanceObjectEntry `json:"Entries"` // 对象条目列表 / Object entry list
}

DanceObjectData 是舞蹈对象数据,用于描述舞蹈场景中的物体引用关系 DanceObjectData is dance-object data describing object references in a dance scene

func ReadDanceObjectData

func ReadDanceObjectData(r io.Reader) (*DanceObjectData, error)

ReadDanceObjectData 从 r 中读取舞蹈对象数据 ReadDanceObjectData reads dance-object data from r

func (*DanceObjectData) Dump

func (d *DanceObjectData) Dump(w io.Writer) error

Dump 将舞蹈对象数据写出到 w Dump writes dance-object data to w

type DanceObjectEntry

type DanceObjectEntry struct {
	TargetMaidNo               int32   `json:"TargetMaidNo"`               // 目标女仆编号 / Target maid number
	ObjectName                 string  `json:"ObjectName"`                 // 对象名称 / Object name
	TopObjectName              string  `json:"TopObjectName"`              // 顶层对象名称 / Top-level object name
	ResourcesPath              string  `json:"ResourcesPath"`              // 资源路径 / Resource path
	TreePath                   string  `json:"TreePath"`                   // 对象树路径 / Object-tree path
	ObjectReferenceTrackIDList []int32 `json:"ObjectReferenceTrackIDList"` // 引用的轨道 ID 列表 / Referenced track ID list
}

DanceObjectEntry 表示单个舞蹈对象条目 DanceObjectEntry represents one dance-object entry

type DynamicBoneCollider

type DynamicBoneCollider struct {
	TypeName string                   `json:"TypeName" default:"dbc"` // 碰撞器类型,仅标记,不序列化 "dbc" / Collider type marker only, with "dbc" not serialized in the concrete payload
	Base     *DynamicBoneColliderBase `json:"Base"`                   // 基类 / Base class

	Radius float32 `json:"Radius"` // 碰撞器半径 / Collider radius
	Height float32 `json:"Height"` // 碰撞器高度 / Collider height
}

DynamicBoneCollider 对应 "dbc" DynamicBoneCollider corresponds to "dbc"

func (*DynamicBoneCollider) GetTypeName

func (dbc *DynamicBoneCollider) GetTypeName() string

GetTypeName 返回 DynamicBoneCollider 的游戏类型标记 dbc GetTypeName returns the game type marker dbc for DynamicBoneCollider

func (*DynamicBoneCollider) Read

func (dbc *DynamicBoneCollider) Read(reader *stream.BinaryReader, version int32) error

Read 读取 DynamicBoneCollider 数据 Read reads DynamicBoneCollider data

func (*DynamicBoneCollider) Write

func (dbc *DynamicBoneCollider) Write(writer *stream.BinaryWriter, version int32) error

Write 写入 DynamicBoneCollider 数据 Write writes DynamicBoneCollider data

type DynamicBoneColliderBase

type DynamicBoneColliderBase struct {
	TypeName      string     `json:"TypeName"  default:"base"` // 碰撞器类型,仅标记,不序列化 "base" / Collider type marker only, with "base" not serialized
	ParentName    string     `json:"ParentName"`               // 父级 Transform (骨骼)名称 / Parent Transform or bone name
	SelfName      string     `json:"SelfName"`                 // 当前 Transform 名称 / Current Transform name
	LocalPosition [3]float32 `json:"LocalPosition"`            // 局部坐标系中的位置 (x,y,z) / Position in local coordinates (x,y,z)
	LocalRotation [4]float32 `json:"LocalRotation"`            // 局部坐标系中的旋转 (四元数) / Rotation in local coordinates as a quaternion
	LocalScale    [3]float32 `json:"LocalScale"`               // 局部坐标系中的缩放 (x,y,z) / Scale in local coordinates (x,y,z)

	Direction int32      `json:"Direction"` // 碰撞体方向,指定哪一个轴是胶囊碰撞器的高(0=x, 1=y, 2=z) / Collider direction selecting the capsule height axis (0=x, 1=y, 2=z)
	Center    [3]float32 `json:"Center"`    // 碰撞体中心偏移 / Collider center offset
	Bound     int32      `json:"Bound"`     // 碰撞约束边界类型 (0=Outside, 1=Inside) / Collision constraint bound type (0=Outside, 1=Inside)
}

DynamicBoneColliderBase 基类 DynamicBoneColliderBase is the base class

func (*DynamicBoneColliderBase) GetTypeName

func (base *DynamicBoneColliderBase) GetTypeName() string

GetTypeName 返回仅供 JSON 基类表示使用的 base 标记,游戏 C# 基类的 TypeName 实际返回空字符串 GetTypeName returns the base marker used only for the JSON base representation; the game C# base class actually returns an empty TypeName

func (*DynamicBoneColliderBase) Read

func (base *DynamicBoneColliderBase) Read(reader *stream.BinaryReader, version int32) error

Read 按 DynamicBoneColliderBase.Deserialize 的字段顺序读取公共碰撞体数据 Read reads common collider data in the field order of DynamicBoneColliderBase.Deserialize

func (*DynamicBoneColliderBase) Write

func (base *DynamicBoneColliderBase) Write(writer *stream.BinaryWriter, version int32) error

Write 按 DynamicBoneColliderBase.Serialize 的字段顺序写入公共碰撞体数据 Write writes common collider data in the field order of DynamicBoneColliderBase.Serialize

type DynamicBoneMuneCollider

type DynamicBoneMuneCollider struct {
	TypeName string                   `json:"TypeName" default:"dbm"` // 碰撞器类型,仅标记,不序列化 "dbm" / Collider type marker only, with "dbm" not serialized in the concrete payload
	Base     *DynamicBoneColliderBase `json:"Base"`                   // 基类 / Base class

	Radius          float32    `json:"Radius"`          // 碰撞器半径 / Collider radius
	Height          float32    `json:"Height"`          // 碰撞器高度 / Collider height
	ScaleRateMulMax float32    `json:"ScaleRateMulMax"` // 最大缩放倍率 / Maximum scale multiplier
	CenterRateMax   [3]float32 `json:"CenterRateMax"`   // 最大中心偏移(x,y,z) / Maximum center offset (x,y,z)
}

DynamicBoneMuneCollider 对应 "dbm" DynamicBoneMuneCollider corresponds to "dbm"

func (*DynamicBoneMuneCollider) GetTypeName

func (c *DynamicBoneMuneCollider) GetTypeName() string

GetTypeName 返回 DynamicBoneMuneCollider 的游戏类型标记 dbm GetTypeName returns the game type marker dbm for DynamicBoneMuneCollider

func (*DynamicBoneMuneCollider) Read

func (c *DynamicBoneMuneCollider) Read(reader *stream.BinaryReader, version int32) error

Read 读取 DynamicBoneMuneCollider 数据 Read reads DynamicBoneMuneCollider data

func (*DynamicBoneMuneCollider) Write

func (c *DynamicBoneMuneCollider) Write(writer *stream.BinaryWriter, version int32) error

Write 写入 DynamicBoneMuneCollider 数据 Write writes DynamicBoneMuneCollider data

type DynamicBonePlaneCollider

type DynamicBonePlaneCollider struct {
	TypeName string                   `json:"TypeName" default:"dpc"` // 碰撞器类型,仅标记,不序列化 "dpc" / Collider type marker only, with "dpc" not serialized in the concrete payload
	Base     *DynamicBoneColliderBase `json:"Base"`                   // 基类 / Base class
}

DynamicBonePlaneCollider 对应 "dpc" 在 C# 中并无其它独立字段,只继承基类 DynamicBonePlaneCollider corresponds to "dpc" It has no independent fields in C# and only inherits the base class

func (*DynamicBonePlaneCollider) GetTypeName

func (dpc *DynamicBonePlaneCollider) GetTypeName() string

GetTypeName 返回 DynamicBonePlaneCollider 的游戏类型标记 dpc GetTypeName returns the game type marker dpc for DynamicBonePlaneCollider

func (*DynamicBonePlaneCollider) Read

func (dpc *DynamicBonePlaneCollider) Read(reader *stream.BinaryReader, version int32) error

Read 读取 DynamicBonePlaneCollider 数据 Read reads DynamicBonePlaneCollider data

func (*DynamicBonePlaneCollider) Write

func (dpc *DynamicBonePlaneCollider) Write(writer *stream.BinaryWriter, version int32) error

Write 写入 DynamicBonePlaneCollider 数据 Write writes DynamicBonePlaneCollider data

type EventParameter

type EventParameter struct {
	ValueType int32            `json:"ValueType"`           // 值类型枚举 / Value-type enum
	ValBool   bool             `json:"ValBool,omitempty"`   // ValueType=13 的 Boolean 值 / Boolean value for ValueType=13
	ValInt    int32            `json:"ValInt,omitempty"`    // ValueType=0 或 1 的 Integer 或 Long 值 / Integer or Long value for ValueType=0 or 1
	ValFloat  float32          `json:"ValFloat,omitempty"`  // ValueType=2 或 3 的 Float 或 Double 值 / Float or Double value for ValueType=2 or 3
	ValVect2  *Vector2         `json:"ValVect2,omitempty"`  // ValueType=4 的 Vector2 值 / Vector2 value for ValueType=4
	ValVect3  *Vector3         `json:"ValVect3,omitempty"`  // ValueType=5 的 Vector3 值 / Vector3 value for ValueType=5
	ValVect4  *Vector4         `json:"ValVect4,omitempty"`  // ValueType=6 的 Vector4 值 / Vector4 value for ValueType=6
	ValColor  *Color           `json:"ValColor,omitempty"`  // ValueType=7 的 Color 值 / Color value for ValueType=7
	ValRect   *Rect            `json:"ValRect,omitempty"`   // ValueType=8 的 Rect 值 / Rect value for ValueType=8
	ValString string           `json:"ValString,omitempty"` // ValueType=9、10、11 的 String、Char 或 Object 值 / String, Char, or Object value for ValueType=9, 10, or 11
	Array     []EventParameter `json:"Array,omitempty"`     // ValueType=12 的数组值 / Array value for ValueType=12
}

EventParameter 表示支持数组嵌套的递归事件参数 EventParameter represents a recursive event parameter supporting nested arrays

type EventTrack

type EventTrack struct {
	TrackID         int32        `json:"TrackID"`         // 轨道 ID / Track ID
	TotalFrame      int32        `json:"TotalFrame"`      // 总帧数 / Total frame count
	ObjectTreePath  string       `json:"ObjectTreePath"`  // 对象树路径 / Object-tree path
	MethodDataArray []MethodData `json:"MethodDataArray"` // 方法数据数组 / Method data array
}

EventTrack 表示事件轨道 EventTrack represents an event track

func (*EventTrack) GetTypeName

func (t *EventTrack) GetTypeName() string

GetTypeName 返回事件轨道标识 Event GetTypeName returns the Event track identifier

type FProperty

type FProperty struct {
	TypeName string  `json:"TypeName" default:"f"` // JSON 类型判别标识 / JSON type discriminator
	PropName string  `json:"PropName"`             // Unity 材质浮点属性名 / Unity material float-property name
	Number   float32 `json:"Number"`               // 传给 Material.SetFloat 的值 / Value passed to Material.SetFloat
}

FProperty 表示经典 COM3D2 格式中的单浮点材质属性 FProperty represents a single-float material property in the classic COM3D2 format

func (*FProperty) GetTypeName

func (f *FProperty) GetTypeName() string

GetTypeName 返回浮点属性标识 f GetTypeName returns the f property identifier

func (*FProperty) Read

func (f *FProperty) Read(reader *stream.BinaryReader) error

Read 读取浮点属性名和值 Read reads the float property name and value

func (*FProperty) Write

func (f *FProperty) Write(writer *stream.BinaryWriter) error

Write 写入 f 类型标识、属性名和值 Write writes the f type identifier, property name, and value

type ICollider

type ICollider interface {
	// GetTypeName 返回游戏外层记录使用的短类型标记
	// GetTypeName returns the short type marker used by the game's outer record
	GetTypeName() string
	// Read 从当前位置读取该具体类型的载荷
	// Read reads this concrete type's payload from the current position
	Read(reader *stream.BinaryReader, version int32) error
	// Write 将该具体类型的载荷写到当前位置
	// Write writes this concrete type's payload at the current position
	Write(writer *stream.BinaryWriter, version int32) error
}

ICollider 是所有Collider的接口,不同具体类型各自实现 注意在每个 struct 中保存 TypeName 是故意的,否则前端类型推断困难,实际不写入二进制 ICollider is the interface implemented by every collider type TypeName is deliberately retained in each struct because frontend type inference would otherwise be difficult, but it is not written in the concrete binary payload

type KeyValuePairInt

type KeyValuePairInt struct {
	Key   int32 `json:"Key"`   // 键 / Key
	Value int32 `json:"Value"` // 值 / Value
}

KeyValuePairInt 表示 int32 键值对 KeyValuePairInt represents an int32 key-value pair

type Keyframe

type Keyframe struct {
	Time       float32 `json:"Time"`       // 关键帧时间 / Keyframe time
	Value      float32 `json:"Value"`      // 关键帧值 / Keyframe value
	InTangent  float32 `json:"InTangent"`  // 入切线 / Incoming tangent
	OutTangent float32 `json:"OutTangent"` // 出切线 / Outgoing tangent
}

Keyframe 与 UnityEngine.Keyframe 对应 Keyframe corresponds to UnityEngine.Keyframe

type Keyword

type Keyword struct {
	Key   string `json:"Key"`   // 着色器关键字 / Shader keyword
	Value bool   `json:"Value"` // 是否调用 EnableKeyword / Whether EnableKeyword is called
}

Keyword 保存一个着色器关键字及其启用状态 Keyword stores one shader keyword and its enabled state

type KeywordProperty

type KeywordProperty struct {
	TypeName string    `json:"TypeName" default:"keyword"` // JSON 类型判别标识 / JSON type discriminator
	PropName string    `json:"PropName"`                   // 在线格式中保存但游戏关键字分支未使用的属性名 / Property name stored on wire but unused by the game keyword branch
	Count    int32     `json:"Count"`                      // 在线格式记录的关键字数量 / Keyword count recorded on the wire
	Keywords []Keyword `json:"Keywords"`                   // 按文件顺序保存的关键字状态 / Keyword states in file order
}

KeywordProperty 表示 COM3D2_5 读取器用于启用或禁用着色器关键字的属性 KeywordProperty represents the COM3D2_5 property that enables or disables shader keywords

func (*KeywordProperty) GetTypeName

func (f *KeywordProperty) GetTypeName() string

GetTypeName 返回关键字属性标识 keyword GetTypeName returns the keyword property identifier

func (*KeywordProperty) Read

func (f *KeywordProperty) Read(reader *stream.BinaryReader) error

Read 读取属性名、关键字数量和每个启用状态 Read reads the property name, keyword count, and each enabled state

func (*KeywordProperty) Write

func (f *KeywordProperty) Write(writer *stream.BinaryWriter) error

Write 根据 Keywords 更新 Count 并写入 keyword 属性 Write updates Count from Keywords and writes the keyword property

type MatPropSave

type MatPropSave struct {
	MatId    int32  `json:"MatId"`    // 槽位内的材质索引 / Material index within the slot
	PropName string `json:"PropName"` // 着色器属性名称 / Shader property name
	TypeName string `json:"TypeName"` // 游戏用于解释 Value 的属性类型名 / Property type name used by the game to interpret Value
	Value    string `json:"Value"`    // 字符串编码的属性值 / String-encoded property value
}

MatPropSave 表示材质属性保存 MatPropSave represents a saved material-property override

type MatPropSaveEntry

type MatPropSaveEntry struct {
	SlotName    string      `json:"SlotName,omitempty"` // v2003 起在线格式中用于解析槽位枚举的名称 / Name used to resolve the slot enum on the wire since v2003
	RID         int32       `json:"RID"`                // 来源菜单文件名哈希,用于确认数据属于当前菜单项 / Source-menu filename hash used to verify that the data belongs to the current menu item
	MatPropSave MatPropSave `json:"MatPropSave"`        // 材质属性覆盖数据 / Material-property override data
}

MatPropSaveEntry 保存材质属性覆盖及其来源菜单哈希 MatPropSaveEntry stores a material-property override and its source-menu hash

type Mate

type Mate struct {
	Signature string    `json:"Signature"` // 文件签名,固定为 CM3D2_MATERIAL / File signature fixed to CM3D2_MATERIAL
	Version   int32     `json:"Version"`   // 编译器写入但游戏材质读取逻辑未使用的版本值 / Version written by the compiler but unused by the game material reader
	Name      string    `json:"Name"`      // 编译时记录的容器名称,游戏 LoadMaterial 读取后未使用 / Container name recorded at compile time and read but unused by LoadMaterial
	Material  *Material `json:"Material"`  // 内嵌材质记录 / Embedded material record
}

Mate 对应 .mate 文件的整体结构 Mate corresponds to the complete structure of a .mate file

func ReadMate

func ReadMate(r io.Reader) (*Mate, error)

ReadMate 从 r 中读取一个 .mate 文件并返回 Mate 结构 ReadMate reads one .mate file from r and returns its Mate structure

func (*Mate) Dump

func (m *Mate) Dump(w io.Writer) error

Dump 将 Mate 写出到 w 中 Dump writes Mate to w

type Material

type Material struct {
	Name           string     `json:"Name"`           // 赋给 Unity Material.name 的材质名称 / Material name assigned to Unity Material.name
	ShaderName     string     `json:"ShaderName"`     // 用于查找或切换 Unity Shader 的名称 / Name used to find or switch the Unity Shader
	ShaderFilename string     `json:"ShaderFilename"` // 用于从 DefMaterial 加载模板材质的资源名 / Resource name used to load the template material from DefMaterial
	Properties     []Property `json:"Properties"`     // 由 end 字符串终止的材质属性 / Material properties terminated by the end string
}

Material 及其属性解析 Material and its property parsing

func (*Material) Dump

func (m *Material) Dump(writer *stream.BinaryWriter) error

Dump 将 Material 写出到 w 中 Dump writes Material to w

func (*Material) UnmarshalJSON

func (m *Material) UnmarshalJSON(data []byte) error

UnmarshalJSON 为 Material 实现自定义 JSON 反序列化 Material.Properties 是接口切片,需要根据 TypeName 字段决定具体类型 UnmarshalJSON implements custom JSON deserialization for Material Material.Properties is an interface slice whose concrete types are selected by TypeName

type Matrix4x4

type Matrix4x4 [16]float32

Matrix4x4 表示4x4矩阵 Matrix4x4 represents a 4x4 matrix

type Menu struct {
	Signature   string    `json:"Signature"`   // CM3D2_MENU 文件签名 / CM3D2_MENU file signature
	Version     int32     `json:"Version"`     // 菜单格式版本 / Menu format version
	SrcFileName string    `json:"SrcFileName"` // 编译菜单时记录的小写源文件路径 / Lowercase source path recorded when compiling the menu
	ItemName    string    `json:"ItemName"`    // 编译菜单时记录的物品名称 / Item name recorded when compiling the menu
	Category    string    `json:"Category"`    // 编译菜单时记录的类别名称 / Category name recorded when compiling the menu
	InfoText    string    `json:"InfoText"`    // 编译菜单时记录的说明文本 / Description text recorded when compiling the menu
	BodySize    int32     `json:"BodySize"`    // 命令块含终止字节的总字节数 / Total command-block size including the terminator byte
	Commands    []Command `json:"Commands"`    // 菜单命令 / Menu commands
}

Menu 对应 .menu 文件的结构 Menu corresponds to the structure of a .menu file

func ReadMenu

func ReadMenu(r io.Reader) (*Menu, error)

ReadMenu 从 r 中读取一个 .menu 文件结构 ReadMenu reads a .menu file structure from r

func (m *Menu) CalculateBodySize() (int32, error)

CalculateBodySize 返回 Dump 和官方编译器写入的命令块大小 CalculateBodySize returns the command-block size written by Dump and the official compiler

func (m *Menu) Dump(w io.Writer) error

Dump 把 Menu 写出到 w 中 Dump writes Menu to w

func (m *Menu) UpdateBodySize() error

UpdateBodySize 根据当前的 Commands 列表计算 BodySize

  • 每个命令占用 1 字节记录 ArgCount
  • 对于每个字符串参数,先计算其 UTF-8 编码后字节数 encodedLength,然后加上 7BitEncoded 编码 encodedLength 所需的字节数,再加上 encodedLength 本身
  • 最后再加上 1 个字节的结束标志

UpdateBodySize calculates BodySize from the current Commands list

  • Each command uses 1 byte for ArgCount
  • For each string, add its UTF-8 encodedLength, the bytes required to encode encodedLength as 7BitEncoded, and the string bytes themselves
  • Finally add the 1-byte terminator

type MethodData

type MethodData struct {
	StartFrame    int32            `json:"StartFrame"`       // 触发帧 / Trigger frame
	ComponentName string           `json:"ComponentName"`    // 组件名称 / Component name
	MethodName    string           `json:"MethodName"`       // 方法名称 / Method name
	Params        []EventParameter `json:"Params,omitempty"` // 方法参数列表 / Method parameter list
}

MethodData 表示事件方法数据 MethodData represents event method data

type MissingCollider

type MissingCollider struct {
	TypeName string `json:"TypeName" default:"missing"` // 碰撞器类型,仅标记,不序列化 "missing" / Collider type marker only, with "missing" not serialized
}

MissingCollider 对应 "missing" MissingCollider corresponds to "missing"

func (*MissingCollider) GetTypeName

func (m *MissingCollider) GetTypeName() string

GetTypeName 返回无载荷碰撞体的游戏类型标记 missing GetTypeName returns the game type marker missing for a payload-less collider

func (*MissingCollider) Read

func (m *MissingCollider) Read(reader *stream.BinaryReader, version int32) error

Read 读取 MissingCollider 数据 Read reads MissingCollider data

func (*MissingCollider) Write

func (m *MissingCollider) Write(writer *stream.BinaryWriter, version int32) error

Write 写入 MissingCollider 数据 Write writes MissingCollider data

type Model

type Model struct {
	Signature         string         `json:"Signature"`                   // "CM3D2_MESH" 文件签名 / "CM3D2_MESH" file signature
	Version           int32          `json:"Version"`                     // 模型格式版本 / Model format version
	Name              string         `json:"Name"`                        // 模型名称 / Model name
	RootBoneName      string         `json:"RootBoneName"`                // 根骨骼名称 / Root bone name
	ShadowCastingMode *string        `json:"ShadowCastingMode,omitempty"` // Unity ShadowCastingMode 的字符串表示,仅版本 2104 及以上且低于 2200 时存在 / String representation of Unity ShadowCastingMode, present only from version 2104 through versions below 2200
	Bones             []*Bone        `json:"Bones"`                       // 完整骨骼层级数据 / Complete bone hierarchy data
	VertCount         int32          `json:"VertCount"`                   // 线格式顶点数量,写出时由 Vertices 推导 / Wire vertex count, derived from Vertices when writing
	SubMeshCount      int32          `json:"SubMeshCount"`                // 线格式子网格数量,写出时由 SubMeshes 推导 / Wire submesh count, derived from SubMeshes when writing
	BoneCount         int32          `json:"BoneCount"`                   // 网格引用的骨骼数量,写出时由 BoneNames 推导 / Number of bones referenced by the mesh, derived from BoneNames when writing
	BoneNames         []string       `json:"BoneNames"`                   // 网格引用的骨骼名称列表 / Names of bones referenced by the mesh
	BindPoses         []Matrix4x4    `json:"BindPoses"`                   // 与 BoneNames 对应的绑定姿势矩阵 / Bind-pose matrices corresponding to BoneNames
	Vertices          []Vertex       `json:"Vertices"`                    // 顶点数据 / Vertex data
	Tangents          []Quaternion   `json:"Tangents,omitempty"`          // Unity Vector4 顺序的顶点切线数据 / Vertex tangent data in Unity Vector4 order
	BoneWeights       []BoneWeight   `json:"BoneWeights"`                 // 每个顶点的骨骼权重数据 / Bone-weight data for each vertex
	SubMeshes         [][]int32      `json:"SubMeshes"`                   // 各子网格的 UInt16 顶点索引列表 / UInt16 vertex-index lists for each submesh
	Materials         []*Material    `json:"Materials"`                   // 材质数据 / Material data
	MorphData         []*MorphData   `json:"MorphData,omitempty"`         // 以 morph 记录保存的形态数据 / Morph data stored in morph records
	SkinThickness     *SkinThickness `json:"SkinThickness,omitempty"`     // 版本 2100 及以上在 end 标记后保存的皮肤厚度数据 / Skin-thickness data stored after the end marker from version 2100 onward
}

Model 对应 .model 文件 也称作 SkinMesh 皮肤网格 Model corresponds to a .model file It is also known as a SkinMesh skinned mesh

func ReadModel

func ReadModel(r io.Reader) (*Model, error)

ReadModel 从 r 中读取皮肤网格数据 ReadModel reads skinned-mesh data from r

func (*Model) Dump

func (m *Model) Dump(w io.Writer) error

Dump 将 Model 写到 w 中,生成 CM3D2_MESH 二进制数据 Dump writes Model to w as CM3D2_MESH binary data

type ModelMetadata

type ModelMetadata struct {
	Signature         string      `json:"Signature"`                   // "CM3D2_MESH" 文件签名 / "CM3D2_MESH" file signature
	Version           int32       `json:"Version"`                     // 模型格式版本 / Model format version
	Name              string      `json:"Name"`                        // 模型名称 / Model name
	RootBoneName      string      `json:"RootBoneName"`                // 根骨骼名称 / Root bone name
	ShadowCastingMode *string     `json:"ShadowCastingMode,omitempty"` // Unity ShadowCastingMode 的字符串表示,仅版本 2104 及以上且低于 2200 时存在 / String representation of Unity ShadowCastingMode, present only from version 2104 through versions below 2200
	Materials         []*Material `json:"Materials"`                   // 材质数据 / Material data
}

ModelMetadata 表示模型的元数据 不包含模型的 3D 信息,只包含模型的文本信息 例如模型名称、根骨骼名称、材质名称等 用于编辑一些模型的文本属性 修改后需要与原模型文件合并 ModelMetadata represents model metadata It excludes the model's 3D information and contains only textual information Examples include the model name, root bone name, and material names It is used to edit textual model properties After modification it must be merged with the original model file

func ReadModelMetadata

func ReadModelMetadata(r io.Reader) (*ModelMetadata, error)

ReadModelMetadata 仅读取 Model 元数据,返回精简的 ModelMetadata ReadModelMetadata reads only Model metadata and returns a reduced ModelMetadata

type MorphData

type MorphData struct {
	Name     string       `json:"Name"`               // 形态名称 / Morph name
	Indices  []int32      `json:"Indices"`            // 受此形态影响的 UInt16 顶点索引 / UInt16 vertex indices affected by this morph
	Vertex   []Vector3    `json:"Vertex"`             // 顶点位置位移 / Vertex-position deltas
	Normals  []Vector3    `json:"Normals"`            // 顶点法线位移 / Vertex-normal deltas
	Tangents []Quaternion `json:"Tangents,omitempty"` // 版本 2102 及以上可选的切线数据 / Optional tangent data for version 2102 and later
}

MorphData 表示形态数据 MorphData represents morph data

func ReadMorphData

func ReadMorphData(reader *stream.BinaryReader, version int32) (*MorphData, error)

ReadMorphData 从 r 中读取形态数据 ReadMorphData reads morph data from r

type MultiColor

type MultiColor struct {
	Signature   string       `json:"Signature"`   // 文件签名 CM3D2_MULTI_COL / File signature CM3D2_MULTI_COL
	Version     int32        `json:"Version"`     // 多颜色格式版本 / Multi-color format version
	PartCount   int32        `json:"PartCount"`   // wire 头部颜色数量;新布局读取时游戏忽略该值 / Wire header count; ignored by the new-layout reader
	PartNames   []string     `json:"PartNames"`   // 新布局中每项的原始名称及顺序;旧布局无名称 / Raw names/order in the new layout; absent in the legacy layout
	PartsColors []PartsColor `json:"PartsColors"` // wire 上实际存在的颜色,不展开游戏默认值 / Colors physically present on the wire, without game defaults
}

MultiColor 表示多颜色设置 MultiColor represents multi-color settings

func DecodeMultiColorBlock

func DecodeMultiColorBlock(data []byte) (*MultiColor, error)

DecodeMultiColorBlock 解码一个完整的 CM3D2_MULTI_COL 字节块,供顶层预设和 COM3D2.5 的 PartsColorOther 字段共用 DecodeMultiColorBlock decodes one complete CM3D2_MULTI_COL byte block for both top-level presets and COM3D2.5's PartsColorOther field

type NamedPresetProperty

type NamedPresetProperty struct {
	Key      string         `json:"Key"`      // 属性前置键名 / Leading property key
	Property PresetProperty `json:"Property"` // 属性数据 / Property data
}

NamedPresetProperty 保留 MPROP_LIST 中属性的前置键及其顺序 NamedPresetProperty preserves a property's leading key and order in MPROP_LIST

type Nei

type Nei = nei.Table

Nei 表示解密后的 .nei CSV 表格数据 / Nei represents decrypted .nei CSV table data

func NewNei

func NewNei(rows uint32, cols uint32, data [][]string) *Nei

NewNei 创建使用 COM3D2 单元格编码的空表格 NewNei creates an empty table using the COM3D2 cell encoding

func ReadNei

func ReadNei(r io.Reader, neiKey []byte) (*Nei, error)

ReadNei 从 r 中读取一个 .nei 文件,并解析为 Nei 结构 单元格编码按内容探测,COM3D2 自带的表格会得到 Shift-JIS neiKey 传入 nil 则使用默认密钥 ReadNei reads a .nei file from r and parses it into a Nei structure The cell encoding is detected from content and COM3D2's own tables resolve to Shift-JIS Passing nil as neiKey selects the default key

type NeiTextEncoding

type NeiTextEncoding = nei.TextEncoding

NeiTextEncoding 表示 .nei 单元格文本使用的字符编码 / NeiTextEncoding represents the character encoding used by .nei cell text

type PMat

type PMat struct {
	Signature    string  `json:"Signature"`    // CM3D2_PMATERIAL 文件签名 / CM3D2_PMATERIAL file signature
	Version      int32   `json:"Version"`      // 版本 1000 / Version 1000
	Hash         int32   `json:"Hash"`         // 哈希值,用于缓存控制 / Hash value used for cache control
	MaterialName string  `json:"MaterialName"` // 材质名称 / Material name
	RenderQueue  float32 `json:"RenderQueue"`  // 渲染顺序 / Render order
	Shader       string  `json:"Shader"`       // 官方样本中的着色器名称,游戏读取器不消费此字段 / Shader name found in official samples and not consumed by the game reader
}

PMat 对应 .PMat 文件结构 PMat corresponds to the structure of a .PMat file

func ReadPMat

func ReadPMat(r io.Reader) (*PMat, error)

ReadPMat 从 r 中读取一个 .PMat 文件,并解析为 PMat 结构 ReadPMat reads a .PMat file from r and parses it into a PMat structure

func (*PMat) Dump

func (p *PMat) Dump(w io.Writer, calculateHash bool) error

Dump 将 p 写出到 w 中,格式与 .PMat 兼容 Dump writes p to w in a format compatible with .PMat

type PanierRadiusGroup

type PanierRadiusGroup struct {
	BoneName string         `json:"BoneName"` // 骨骼名称 / Bone name
	Radius   float32        `json:"Radius"`   // 该骨骼的裙撑半径 / Panier radius for this bone
	Curve    AnimationCurve `json:"Curve"`    // 半径分布曲线 / Radius distribution curve
}

PanierRadiusGroup 存储骨骼特定的半径信息 PanierRadiusGroup stores bone-specific radius information

type PartsColor

type PartsColor struct {
	IsUse            bool  `json:"IsUse"`            // 是否启用该部件颜色 / Whether this part color is enabled
	MainHue          int32 `json:"MainHue"`          // 主色相 / Main hue
	MainChroma       int32 `json:"MainChroma"`       // 主色度 / Main chroma
	MainBrightness   int32 `json:"MainBrightness"`   // 主亮度 / Main brightness
	MainContrast     int32 `json:"MainContrast"`     // 主对比度 / Main contrast
	ShadowRate       int32 `json:"ShadowRate"`       // 阴影混合比例 / Shadow blend rate
	ShadowHue        int32 `json:"ShadowHue"`        // 阴影色相 / Shadow hue
	ShadowChroma     int32 `json:"ShadowChroma"`     // 阴影色度 / Shadow chroma
	ShadowBrightness int32 `json:"ShadowBrightness"` // 阴影亮度 / Shadow brightness
	ShadowContrast   int32 `json:"ShadowContrast"`   // 阴影对比度 / Shadow contrast
}

PartsColor 表示部件颜色 PartsColor represents one part color

type Phy

type Phy struct {
	// 头部信息
	// Header information
	Signature string `json:"Signature"` // 签名,通常为 "CM3D21_PHY" / 1. Signature, normally "CM3D21_PHY"
	Version   int32  `json:"Version"`   // 版本,例如 24102,此版本随每次更新变化但结构不变 / 2. Version such as 24102, which changes with each update without changing the structure
	RootName  string `json:"RootName"`  // RootBone 名称 / 3. RootBone name

	// 4. Damping 阻尼相关参数
	// 4. Damping parameters
	EnablePartialDamping int32          `json:"EnablePartialDamping"` // PartialMode 枚举,模式 / PartialMode enum selecting the mode
	PartialDamping       []BoneValue    `json:"PartialDamping"`       // 按骨骼设置的阻尼值 / Per-bone damping values
	Damping              float32        `json:"Damping"`              // 静态或曲线模式下的阻尼值 / Damping value in static-or-curve mode
	DampingDistrib       AnimationCurve `json:"DampingDistrib"`       // 曲线 / Curve

	// 5. Elasticity 弹性相关参数
	// 5. Elasticity parameters
	EnablePartialElasticity int32          `json:"EnablePartialElasticity"` // 弹性 PartialMode 枚举 / Elasticity PartialMode enum
	PartialElasticity       []BoneValue    `json:"PartialElasticity"`       // 按骨骼设置的弹性值 / Per-bone elasticity values
	Elasticity              float32        `json:"Elasticity"`              // 静态或曲线模式下的弹性值 / Elasticity value in static-or-curve mode
	ElasticityDistrib       AnimationCurve `json:"ElasticityDistrib"`       // 弹性曲线 / Elasticity curve

	// 6. Stiffness 刚度相关参数
	// 6. Stiffness parameters
	EnablePartialStiffness int32          `json:"EnablePartialStiffness"` // 刚度 PartialMode 枚举 / Stiffness PartialMode enum
	PartialStiffness       []BoneValue    `json:"PartialStiffness"`       // 按骨骼设置的刚度值 / Per-bone stiffness values
	Stiffness              float32        `json:"Stiffness"`              // 静态或曲线模式下的刚度值 / Stiffness value in static-or-curve mode
	StiffnessDistrib       AnimationCurve `json:"StiffnessDistrib"`       // 刚度曲线 / Stiffness curve

	// 7. Inert 惯性相关参数
	// 7. Inert parameters
	EnablePartialInert int32          `json:"EnablePartialInert"` // 惯性 PartialMode 枚举 / Inert PartialMode enum
	PartialInert       []BoneValue    `json:"PartialInert"`       // 按骨骼设置的惯性值 / Per-bone inert values
	Inert              float32        `json:"Inert"`              // 静态或曲线模式下的惯性值 / Inert value in static-or-curve mode
	InertDistrib       AnimationCurve `json:"InertDistrib"`       // 惯性曲线 / Inert curve

	// 8. 碰撞半径相关参数
	// 8. Collision radius parameters
	EnablePartialRadius int32          `json:"EnablePartialRadius"` // 半径 PartialMode 枚举 / Radius PartialMode enum
	PartialRadius       []BoneValue    `json:"PartialRadius"`       // 按骨骼设置的半径值 / Per-bone radius values
	Radius              float32        `json:"Radius"`              // 静态或曲线模式下的碰撞半径 / Collision radius in static-or-curve mode
	RadiusDistrib       AnimationCurve `json:"RadiusDistrib"`       // 半径曲线 / Radius curve

	// 9. 骨骼末端参数
	// 9. Bone-end parameters
	EndLength float32    `json:"EndLength"` // 骨骼末端长度 / Bone end length
	EndOffset [3]float32 `json:"EndOffset"` // 骨骼末端偏移 x、y、z / Bone end offset x, y, z

	// 10. 外力参数
	// 10. External-force parameters
	Gravity [3]float32 `json:"Gravity"` // 外力重力向量 x、y、z / External gravity vector x, y, z
	Force   [3]float32 `json:"Force"`   // 外力向量 x、y、z / External force vector x, y, z

	// 10. 碰撞器相关参数
	// 10. Collider parameters
	ColliderFileName string `json:"ColliderFileName"` // 碰撞器文件名 / Collider filename
	CollidersCount   int32  `json:"CollidersCount"`   // 碰撞器数量,游戏只写入数量而不写后续碰撞器数据 / Collider count written by the game without following collider data

	// 11. 排除骨骼
	// 11. Excluded bones
	ExclusionsCount int32 `json:"ExclusionsCount"` // 排除的骨骼数量,游戏只写入数量而不写后续列表 / Excluded-bone count written by the game without a following list

	// 12. 冻结轴向
	// 12. Freeze axis
	FreezeAxis int32 `json:"FreezeAxis"` // 冻结轴向 FreezeAxis 枚举值 / Freeze axis FreezeAxis enum value
}

Phy 保存一个 CM3D21_PHY 文件的全部字段 Phy stores all fields of a CM3D21_PHY file

func ReadPhy

func ReadPhy(r io.Reader) (*Phy, error)

ReadPhy 读取 "CM3D21_PHY" 格式 ReadPhy reads the "CM3D21_PHY" format

func (*Phy) Dump

func (p *Phy) Dump(w io.Writer) error

Dump 写出 "CM3D21_PHY" 格式 Dump writes the "CM3D21_PHY" format

type PositionRotationScale

type PositionRotationScale struct {
	Position Vector3    `json:"Position"` // 位置 / Position
	Rotation Quaternion `json:"Rotation"` // 旋转 / Rotation
	Scale    Vector3    `json:"Scale"`    // 缩放 / Scale
}

PositionRotationScale 表示组合位置、旋转、缩放信息 PositionRotationScale represents combined position, rotation, and scale information

type Preset

type Preset struct {
	Signature          string              `json:"Signature"`          // 文件签名 CM3D2_PRESET / File signature CM3D2_PRESET
	Version            int32               `json:"Version"`            // 预设格式版本 / Preset format version
	PresetType         int32               `json:"PresetType"`         // 预设类型,0 为服装、1 为身体、2 为全部 / Preset type where 0 is wear, 1 is body, and 2 is all
	ThumbLength        int32               `json:"ThumbLength"`        // 线格式中的 PNG 缩略图字节数 / PNG thumbnail byte count on the wire
	ThumbData          []byte              `json:"ThumbData"`          // PNG 缩略图数据 / PNG thumbnail data
	PresetPropertyList *PresetPropertyList `json:"PresetPropertyList"` // 预设属性列表 / Preset property list
	MultiColor         *MultiColor         `json:"MultiColor"`         // 部件颜色设置 / Part color settings
	BodyProperty       *BodyProperty       `json:"BodyProperty"`       // 身体块数据 / Body-block data
}

Preset 表示角色预设数据 Preset represents character preset data

func ReadPreset

func ReadPreset(r io.Reader) (*Preset, error)

ReadPreset 从 r 中读取 Preset ReadPreset reads a Preset from r

func (*Preset) Dump

func (p *Preset) Dump(w io.Writer) error

Dump 将 Preset 写入 w Dump writes the Preset to w

type PresetMetadata

type PresetMetadata struct {
	Signature   string `json:"Signature"`   // 文件签名 CM3D2_PRESET / File signature CM3D2_PRESET
	Version     int32  `json:"Version"`     // 预设格式版本 / Preset format version
	PresetType  int32  `json:"PresetType"`  // 预设类型,0 为服装、1 为身体、2 为全部 / Preset type where 0 is wear, 1 is body, and 2 is all
	ThumbLength int32  `json:"ThumbLength"` // 线格式中的 PNG 缩略图字节数 / PNG thumbnail byte count on the wire
	ThumbData   []byte `json:"ThumbData"`   // PNG 缩略图数据 / PNG thumbnail data
}

PresetMetadata 表示仅包含略缩图的的角色预设数据,不包含实际数据 PresetMetadata represents character preset header and thumbnail data without the actual property data

func ReadPresetMetadata

func ReadPresetMetadata(reader *stream.BinaryReader) (*PresetMetadata, error)

ReadPresetMetadata 从 r 中读取 PresetMetadata ReadPresetMetadata reads PresetMetadata from r

type PresetProperty

type PresetProperty struct {
	Signature                string                                 `json:"Signature"`                          // 文件签名 CM3D2_MPROP / File signature CM3D2_MPROP
	Version                  int32                                  `json:"Version"`                            // 属性格式版本 / Property format version
	Index                    int32                                  `json:"Index"`                              // 线格式中的 MPN 索引,游戏随后按 Name 重新解析 / MPN index on the wire, subsequently reparsed by the game from Name
	Name                     string                                 `json:"Name"`                               // MPN 枚举名称 / MPN enum name
	Type                     int32                                  `json:"Type"`                               // 属性类别编号 / Property category number
	DefaultValue             int32                                  `json:"DefaultValue"`                       // 默认值 / Default value
	Value                    int32                                  `json:"Value"`                              // 当前值 / Current value
	TempValue                int32                                  `json:"TempValue"`                          // 编辑中的临时值 / Temporary editing value
	LinkMaxValue             int32                                  `json:"LinkMaxValue"`                       // 限制当前值上限的关联属性索引,0 表示无关联 / Linked property index that caps the current value, with 0 meaning none
	FileName                 string                                 `json:"FileName"`                           // 属性所选菜单文件名 / Menu filename selected by the property
	FileNameRID              int32                                  `json:"FileNameRID"`                        // 线格式中的小写文件名哈希,游戏会为非空文件名重新计算 / Lowercase filename hash on the wire, recalculated by the game for a nonempty filename
	IsDut                    bool                                   `json:"IsDut"`                              // 属性待处理标志,游戏反序列化后强制设为 true / Property pending-processing flag, forced to true by the game after deserialization
	Max                      int32                                  `json:"Max"`                                // 最大值 / Maximum value
	Min                      int32                                  `json:"Min"`                                // 最小值 / Minimum value
	SubProps                 []*SubProp                             `json:"SubProps"`                           // 子属性列表,nil 元素对应线格式中的 exists=false / Sub-property list where a nil element represents exists=false on the wire
	SkinPositions            map[int32]BoneAttachPosEntry           `json:"SkinPositions"`                      // 按 slotID 索引的皮肤位置映射 / Skin-position map indexed by slotID
	SkinPositionOrder        []int32                                `json:"SkinPositionOrder,omitempty"`        // 皮肤位置在线格式中的槽位顺序 / Skin-position slot order on the wire
	AttachPositions          map[int32]map[string]VtxAttachPosEntry `json:"AttachPositions"`                    // 按 slotID 和附着点名索引的顶点附着位置 / Vertex attachment positions indexed by slotID and attachment-point name
	AttachPositionOrder      []int32                                `json:"AttachPositionOrder,omitempty"`      // 顶点附着位置在线格式中的槽位顺序 / Vertex-attachment slot order on the wire
	AttachPositionNameOrders map[int32][]string                     `json:"AttachPositionNameOrders,omitempty"` // 各槽位附着点在线格式中的名称顺序 / Attachment-point name order on the wire for each slot
	AttachPositionSlotNames  map[int32]string                       `json:"AttachPositionSlotNames,omitempty"`  // v2003 起每个顶点附着槽位写入的槽位名,包括空映射 / Slot name written for each vertex-attachment slot since v2003, including an empty map
	MaterialProps            map[int32]MatPropSaveEntry             `json:"MaterialProps"`                      // 按 slotID 索引的材质属性覆盖 / Material-property overrides indexed by slotID
	MaterialPropOrder        []int32                                `json:"MaterialPropOrder,omitempty"`        // 材质属性在线格式中的槽位顺序 / Material-property slot order on the wire
	BoneLengths              map[int32]BoneLengthEntry              `json:"BoneLengths"`                        // 按 slotID 索引的骨骼长度设置 / Bone-length settings indexed by slotID
	BoneLengthOrder          []int32                                `json:"BoneLengthOrder,omitempty"`          // 骨骼长度在线格式中的槽位顺序 / Bone-length slot order on the wire
	IsCrcParts               bool                                   `json:"IsCrcParts"`                         // CRC、CRX 或 GP03 部件标志 / CRC, CRX, or GP03 part flag
}

PresetProperty 表示单个属性 PresetProperty represents one property

type PresetPropertyList

type PresetPropertyList struct {
	Signature        string                    `json:"Signature"`                 // 文件签名 CM3D2_MPROP_LIST / File signature CM3D2_MPROP_LIST
	Version          int32                     `json:"Version"`                   // 属性列表格式版本 / Property-list format version
	PropertyCount    int32                     `json:"PropertyCount"`             // 线格式中的主属性数量 / Main-property count on the wire
	PresetProperties map[string]PresetProperty `json:"PresetProperties"`          // 以前置 MPN 键名索引的主属性映射 / Main-property map indexed by the leading MPN key
	PropertyOrder    []string                  `json:"PropertyOrder,omitempty"`   // 主属性在线格式中的顺序 / Main-property order on the wire
	MaidPropOther    []NamedPresetProperty     `json:"MaidPropOther"`             // COM3D2.5 扩展属性及其前置键名 / COM3D2.5 extension properties and their leading keys
	PartsColorOther  *MultiColor               `json:"PartsColorOther,omitempty"` // COM3D2.5 另一身体体系的 CM3D2_MULTI_COL 块 / CM3D2_MULTI_COL block for COM3D2.5's other body system
	CRCPreset        *kces.ExpandedKCESPreset  `json:"CRCPreset,omitempty"`       // COM3D2.5 保存的 KCES VirtualDirectory 预设块 / KCES VirtualDirectory preset block stored by COM3D2.5
}

PresetPropertyList 表示预设属性列表 PresetPropertyList represents a preset property list

type Property

type Property interface {
	// GetTypeName 返回线格式中的属性类型标识
	// GetTypeName returns the property type identifier used on the wire
	GetTypeName() string
	// Read 读取外层类型标识之后的属性载荷
	// Read reads the property payload after its outer type identifier
	Read(reader *stream.BinaryReader) error
	// Write 写入属性类型标识和载荷
	// Write writes the property type identifier and payload
	Write(writer *stream.BinaryWriter) error
}

Property 是对应 C# 抽象 Property 类的接口 Go 使用接口和具体结构体表达这些类型 每个具体结构体故意保存 TypeName,否则前端难以推断接口值的具体类型 Property is the interface corresponding to the abstract C# Property class Go expresses these types through an interface and concrete structs Each concrete struct deliberately stores TypeName because otherwise a frontend cannot easily infer the concrete interface value

type PropertyCreator

type PropertyCreator func() Property

PropertyCreator 定义属性创建器类型 PropertyCreator defines the property-creator type

type PropertyCurve

type PropertyCurve struct {
	PropertyIndex int32      `json:"PropertyIndex"` // 属性索引,b=100 对应 index=0,b=101 对应 index=1,最高位为 6,含义见上方枚举 / Property index where b=100 maps to index=0 and b=101 maps to index=1, with 6 as the highest value as listed above
	Keyframes     []Keyframe `json:"Keyframes"`     // 该属性的所有关键帧数据 / All keyframe data for this property
}

PropertyCurve 存储单一属性(例如 localRotation.x)的一整条 AnimationCurve PropertyCurve stores a complete AnimationCurve for one property such as localRotation.x

type PropertyTrack

type PropertyTrack struct {
	TrackID        int32             `json:"TrackID"`                 // 轨道 ID / Track ID
	TotalFrame     int32             `json:"TotalFrame"`              // 总帧数 / Total frame count
	ObjectTreePath string            `json:"ObjectTreePath"`          // 对象树路径 / Object-tree path
	ValueType      int32             `json:"ValueType"`               // AMPropertyTrack.ValueType 值类型枚举,0=Integer、2=Float、5=Vector3、6=Color / AMPropertyTrack.ValueType enum, 0=Integer, 2=Float, 5=Vector3, 6=Color
	ComponentName  string            `json:"ComponentName"`           // 组件名称 / Component name
	PropertyName   string            `json:"PropertyName"`            // 属性名称 / Property name
	IntValArray    []int32           `json:"IntValArray,omitempty"`   // ValueType=0 的整数值数组 / Integer value array for ValueType=0
	FloatValArray  []float32         `json:"FloatValArray,omitempty"` // ValueType=2 的浮点值数组 / Float value array for ValueType=2
	Vec3ValArray   []Vector3         `json:"Vec3ValArray,omitempty"`  // ValueType=5 的三维向量数组 / Vector3 value array for ValueType=5
	ColorValArray  []Color           `json:"ColorValArray,omitempty"` // ValueType=6 的颜色数组 / Color value array for ValueType=6
	IndexArray     []KeyValuePairInt `json:"IndexArray"`              // 压缩索引数组 / Compression index array
}

PropertyTrack 表示支持 Integer、Float、Vector3、Color 四种值类型的属性轨道 PropertyTrack represents a property track supporting Integer, Float, Vector3, and Color values

func (*PropertyTrack) GetTypeName

func (t *PropertyTrack) GetTypeName() string

GetTypeName 返回属性轨道标识 Property GetTypeName returns the Property track identifier

type Psk

type Psk struct {
	Signature                    string              `json:"Signature"`                    // 文件签名,通常为 CM3D21_PSK / File signature, usually CM3D21_PSK
	Version                      int32               `json:"Version"`                      // 文件版本号,可能随游戏更新变化但结构不一定变化 / File version, may change with game updates without structural changes
	PanierRadius                 float32             `json:"PanierRadius"`                 // 裙撑半径 / Panier radius
	PanierRadiusDistrib          AnimationCurve      `json:"PanierRadiusDistrib"`          // 裙撑半径分布曲线 / Panier radius distribution curve
	PanierRadiusDistribGroups    []PanierRadiusGroup `json:"PanierRadiusDistribGroups"`    // 裙撑半径分布组 / Panier radius distribution groups
	PanierForce                  float32             `json:"PanierForce"`                  // 裙撑力度 / Panier force
	PanierForceDistrib           AnimationCurve      `json:"PanierForceDistrib"`           // 裙撑力度分布曲线 / Panier force distribution curve
	PanierStressForce            float32             `json:"PanierStressForce"`            // 裙撑应力 / Panier stress force
	StressDegreeMin              float32             `json:"StressDegreeMin"`              // 最小应力度 / Minimum stress degree
	StressDegreeMax              float32             `json:"StressDegreeMax"`              // 最大应力度 / Maximum stress degree
	StressMinScale               float32             `json:"StressMinScale"`               // 最小应力缩放 / Minimum stress scale
	ScaleEaseSpeed               float32             `json:"ScaleEaseSpeed"`               // 缩放平滑速度 / Scale easing speed
	PanierForceDistanceThreshold float32             `json:"PanierForceDistanceThreshold"` // 裙撑力度距离阈值 / Panier force distance threshold
	CalcTime                     int32               `json:"CalcTime"`                     // 计算时间 / Calculation time
	VelocityForceRate            float32             `json:"VelocityForceRate"`            // 速度力率 / Velocity force rate
	VelocityForceRateDistrib     AnimationCurve      `json:"VelocityForceRateDistrib"`     // 速度力率分布曲线 / Velocity force rate distribution curve
	Gravity                      Vector3             `json:"Gravity"`                      // 重力向量 / Gravity vector
	GravityDistrib               AnimationCurve      `json:"GravityDistrib"`               // 重力分布曲线 / Gravity distribution curve
	HardValues                   [4]float32          `json:"HardValues"`                   // 硬度值数组 / Hardness value array
}

Psk 整体描述一个 .psk 文件的结构 Psk describes the full structure of a .psk file

func ReadPsk

func ReadPsk(r io.Reader) (*Psk, error)

ReadPsk 读取并解析一个 .psk 文件,返回 Psk 结构 ReadPsk reads and parses a .psk file and returns a Psk structure

func (Psk) Dump

func (p Psk) Dump(w io.Writer) error

Dump 将 Psk 结构写到 w 中,生成符合 CM3D21_PSK 格式的二进制数据 Dump writes a Psk structure to w as CM3D21_PSK binary data

type Quaternion

type Quaternion struct {
	X float32 `json:"X"` // 四元数的 X 分量 / X component of the quaternion
	Y float32 `json:"Y"` // 四元数的 Y 分量 / Y component of the quaternion
	Z float32 `json:"Z"` // 四元数的 Z 分量 / Z component of the quaternion
	W float32 `json:"W"` // 四元数的 W 分量 / W component of the quaternion
}

Quaternion 表示四元数 Quaternion represents a quaternion

type RangeProperty

type RangeProperty struct {
	TypeName string  `json:"TypeName" default:"range"` // JSON 类型判别标识 / JSON type discriminator
	PropName string  `json:"PropName"`                 // Unity 材质浮点属性名 / Unity material float-property name
	Number   float32 `json:"Number"`                   // 传给 Material.SetFloat 的值 / Value passed to Material.SetFloat
}

RangeProperty 表示 COM3D2_5 读取器支持的 range 单浮点材质属性 RangeProperty represents the range single-float material property supported by the COM3D2_5 reader

func (*RangeProperty) GetTypeName

func (ra *RangeProperty) GetTypeName() string

GetTypeName 返回范围属性标识 range GetTypeName returns the range property identifier

func (*RangeProperty) Read

func (ra *RangeProperty) Read(reader *stream.BinaryReader) error

Read 读取范围属性名和值 Read reads the range property name and value

func (*RangeProperty) Write

func (ra *RangeProperty) Write(writer *stream.BinaryWriter) error

Write 写入 range 类型标识、属性名和值 Write writes the range type identifier, property name, and value

type Rect

type Rect struct {
	XMin float32 `json:"XMin"` // X 轴最小边界 / Minimum X bound
	XMax float32 `json:"XMax"` // X 轴最大边界 / Maximum X bound
	YMin float32 `json:"YMin"` // Y 轴最小边界 / Minimum Y bound
	YMax float32 `json:"YMax"` // Y 轴最大边界 / Maximum Y bound
}

Rect 表示矩形区域 Rect represents a rectangular region

type RotationTrack

type RotationTrack struct {
	TrackID         int32        `json:"TrackID"`         // 轨道 ID / Track ID
	TotalFrame      int32        `json:"TotalFrame"`      // 总帧数 / Total frame count
	ObjectTreePath  string       `json:"ObjectTreePath"`  // 对象树路径 / Object-tree path
	QuaternionArray []Quaternion `json:"QuaternionArray"` // 每帧四元数数组 / Per-frame quaternion array
}

RotationTrack 表示旋转轨道 RotationTrack represents a rotation track

func (*RotationTrack) GetTypeName

func (t *RotationTrack) GetTypeName() string

GetTypeName 返回旋转轨道标识 Rotation GetTypeName returns the Rotation track identifier

type SkinThickness

type SkinThickness struct {
	Signature  string                 `json:"Signature"`            // "SkinThickness" 文件签名 / "SkinThickness" file signature
	Version    int32                  `json:"Version"`              // 游戏当前写入 100,读取后不作版本分支 / Currently written as 100 by the game and read without version branches
	Use        bool                   `json:"Use"`                  // 是否使用皮肤厚度 / Whether skin thickness is enabled
	Groups     map[string]*ThickGroup `json:"Groups"`               // 按外层键索引的皮肤厚度组 / Skin-thickness groups indexed by their outer keys
	GroupOrder []string               `json:"GroupOrder,omitempty"` // 线格式中的组顺序 / Group order on the wire
}

SkinThickness 表示皮肤厚度数据 SkinThickness represents skin-thickness data

func ReadSkinThickness

func ReadSkinThickness(reader *stream.BinaryReader) (*SkinThickness, error)

ReadSkinThickness 从 r 中读取皮肤厚度数据 ReadSkinThickness reads skin-thickness data from r

type SubProp

type SubProp struct {
	IsDut       bool    `json:"IsDut"`       // 子属性待处理标志,游戏读取后强制设为 true / Sub-property pending-processing flag, forced to true by the game after reading
	FileName    string  `json:"FileName"`    // 子属性所选菜单文件名 / Menu filename selected by the sub-property
	FileNameRID int32   `json:"FileNameRID"` // 线格式中的小写文件名哈希,游戏读取后重新计算 / Lowercase filename hash on the wire, recalculated by the game after reading
	TexMulAlpha float32 `json:"TexMulAlpha"` // 纹理合成透明度倍率 / Texture-composition alpha multiplier
}

SubProp 表示子属性 SubProp represents a sub-property

type Tex

type Tex struct {
	Signature     string    `json:"Signature"`     // 文件签名,通常为 CM3D2_TEX / File signature, normally CM3D2_TEX
	Version       int32     `json:"Version"`       // 控制尺寸和图集字段的格式版本 / Format version controlling dimension and atlas fields
	TextureName   string    `json:"TextureName"`   // 游戏读取后未使用的编译源纹理名称 / Compiled source texture name read but unused by the game
	Rects         []TexRect `json:"Rects"`         // 版本 1011 及以上的图集矩形 / Atlas rectangles for version 1011 and later
	Width         int32     `json:"Width"`         // 纹理像素宽度 / Texture width in pixels
	Height        int32     `json:"Height"`        // 纹理像素高度 / Texture height in pixels
	TextureFormat int32     `json:"TextureFormat"` // Unity TextureFormat 枚举值 / Unity TextureFormat enum value
	Data          []byte    `json:"Data"`          // 编码图像或原始 DXT 块 / Encoded image or raw DXT blocks
}

Tex 保存 CM3D2_TEX 头部、可选图集矩形和图像载荷 Tex stores the CM3D2_TEX header, optional atlas rectangles, and image payload

func ConvertImageToTex

func ConvertImageToTex(inputPath string, texName string, compress bool, forcePNG bool) (*Tex, error)

ConvertImageToTex 将任意 ImageMagick 支持的文件格式转换为 tex 格式,但不写出 依赖外部库 ImageMagick,并要求 PATH 环境变量可以直接调用 magick 命令 forcePNG 为 true 且 compress 为 false 时,tex 数据是原始 PNG 或转换后的 PNG forcePNG 为 false 且 compress 为 false 时,PNG 或 JPG 输入会直接使用,否则有损且无透明通道的输入转换为 JPG,其余输入转换为 PNG forcePNG 为 true 且 compress 为 true 时忽略 compress,结果与 forcePNG 为 true 且 compress 为 false 相同 forcePNG 为 false 且 compress 为 true 时进行 DXT 压缩,根据有无透明通道选择 DXT1 或 DXT5 生成版本 1011 的纹理图集需要图片目录中存在同名 .uv.csv 文件,例如 foo.png 对应 foo.png.uv.csv,文件内容每行保存一组 x、y、w、h 没有有效纹理图集矩形时生成版本 1010 ConvertImageToTex converts any ImageMagick-supported file format to tex without writing it It depends on ImageMagick and requires the magick command to be directly available through PATH When forcePNG is true and compress is false, the tex data is the original PNG or a converted PNG When forcePNG and compress are both false, PNG or JPG input is used directly, otherwise lossy input without alpha becomes JPG and all other input becomes PNG When forcePNG and compress are both true, compress is ignored and the result matches forcePNG true with compress false When forcePNG is false and compress is true, DXT compression selects DXT1 or DXT5 according to alpha presence Producing a version-1011 texture atlas requires a sibling .uv.csv file such as foo.png.uv.csv for foo.png, with each row storing x, y, w, and h Version 1010 is produced when no valid texture-atlas rectangles are available

func ReadTex

func ReadTex(r io.Reader) (*Tex, error)

ReadTex 从二进制流中读取 Tex 数据,输入数据流需要使用 .tex 格式 ReadTex reads Tex data from a binary stream whose contents must use the .tex format

func (*Tex) Dump

func (t *Tex) Dump(w io.Writer) error

Dump 将 Tex 数据写入 .tex 格式的二进制流,本实现不支持写出版本 1000 Dump writes Tex data to a binary stream in .tex format and does not support writing version 1000

type Tex2DSubProperty

type Tex2DSubProperty struct {
	Name   string     `json:"Name"`   // 用于加载 <Name>.tex 的纹理资源名 / Texture resource name used to load <Name>.tex
	Path   string     `json:"Path"`   // 游戏读取后未使用的第二个字符串 / Second string read but unused by the game
	Offset [2]float32 `json:"Offset"` // 纹理 X、Y 偏移 / Texture X and Y offset
	Scale  [2]float32 `json:"Scale"`  // 纹理 X、Y 缩放 / Texture X and Y scale
}

Tex2DSubProperty 保存纹理资源名、未使用字符串、偏移和缩放 Tex2DSubProperty stores the texture resource name, an unused string, offset, and scale

type TexOffsetProperty

type TexOffsetProperty struct {
	TypeName string  `json:"TypeName" default:"tex_offset"` // JSON 类型判别标识 / JSON type discriminator
	PropName string  `json:"PropName"`                      // Unity 材质纹理属性名 / Unity material texture-property name
	OffsetX  float32 `json:"OffsetX"`                       // 纹理 X 偏移 / Texture X offset
	OffsetY  float32 `json:"OffsetY"`                       // 纹理 Y 偏移 / Texture Y offset
}

TexOffsetProperty 表示 COM3D2_5 读取器支持的独立纹理偏移属性 TexOffsetProperty represents the standalone texture-offset property supported by the COM3D2_5 reader

func (*TexOffsetProperty) GetTypeName

func (to *TexOffsetProperty) GetTypeName() string

GetTypeName 返回纹理偏移属性标识 tex_offset GetTypeName returns the tex_offset property identifier

func (*TexOffsetProperty) Read

func (to *TexOffsetProperty) Read(reader *stream.BinaryReader) error

Read 读取纹理属性名和 X、Y 偏移 Read reads the texture property name and X and Y offsets

func (*TexOffsetProperty) Write

func (to *TexOffsetProperty) Write(writer *stream.BinaryWriter) error

Write 写入 tex_offset 类型标识、属性名和 X、Y 偏移 Write writes the tex_offset type identifier, property name, and X and Y offsets

type TexProperty

type TexProperty struct {
	TypeName string            `json:"TypeName" default:"tex"` // JSON 类型判别标识 / JSON type discriminator
	PropName string            `json:"PropName"`               // Unity 材质纹理属性名 / Unity material texture-property name
	SubTag   string            `json:"SubTag"`                 // 纹理子类型标识 / Texture subtype identifier
	Tex2D    *Tex2DSubProperty `json:"Tex2D"`                  // tex2d 或 cube 子载荷 / tex2d or cube subpayload
	TexRT    *TexRTSubProperty `json:"TexRT"`                  // texRT 子载荷 / texRT subpayload
}

TexProperty 表示 tex 属性及其 tex2d、cube、texRT 或 null 子载荷 TexProperty represents a tex property and its tex2d, cube, texRT, or null subpayload

func (*TexProperty) GetTypeName

func (t *TexProperty) GetTypeName() string

GetTypeName 返回纹理属性标识 tex GetTypeName returns the tex property identifier

func (*TexProperty) Read

func (t *TexProperty) Read(reader *stream.BinaryReader) error

Read 读取纹理属性名、子类型及该子类型对应的载荷 Read reads the texture property name, subtype, and subtype-specific payload

func (*TexProperty) Write

func (t *TexProperty) Write(writer *stream.BinaryWriter) error

Write 写入 tex 类型标识、属性名、子类型及其对应载荷 Write writes the tex type identifier, property name, subtype, and subtype-specific payload

type TexRTSubProperty

type TexRTSubProperty struct {
	DiscardedStr1 string `json:"DiscardedStr1"` // 游戏未使用的第一个字符串 / First string unused by the game
	DiscardedStr2 string `json:"DiscardedStr2"` // 游戏未使用的第二个字符串 / Second string unused by the game
}

TexRTSubProperty 保存 texRT 在线格式中由游戏读取后丢弃的两个字符串 TexRTSubProperty stores the two texRT wire strings that the game reads and discards

type TexRect

type TexRect struct {
	X float32 `json:"X"` // 矩形左下角 X 坐标 / Rectangle lower-left X coordinate
	Y float32 `json:"Y"` // 矩形左下角 Y 坐标 / Rectangle lower-left Y coordinate
	W float32 `json:"W"` // 矩形宽度 / Rectangle width
	H float32 `json:"H"` // 矩形高度 / Rectangle height
}

TexRect 保存版本 1011 纹理图集中的一个 Unity Rect TexRect stores one Unity Rect in a version-1011 texture atlas

func ConvertTexToImage

func ConvertTexToImage(tex *Tex, forcePNG bool) (imgData []byte, format string, rects []TexRect, err error)

ConvertTexToImage 将 Tex 数据转换为图像数据但不写出 依赖外部库 ImageMagick,并要求 PATH 环境变量可以直接调用 magick 命令 forcePNG 为 false 时,PNG 或 JPG 图像载荷可直接返回,否则根据透明通道输出 JPG 或 PNG forcePNG 为 true 时不考虑原始格式和透明通道并强制输出 PNG 版本 1011 的纹理图集还会返回 rects ConvertTexToImage converts Tex data to image data without writing it It depends on ImageMagick and requires the magick command to be directly available through PATH When forcePNG is false, PNG or JPG image payloads may be returned directly, otherwise the output is JPG or PNG according to alpha presence When forcePNG is true, PNG output is forced regardless of the original format and alpha presence Version-1011 texture atlases also return rects

type TexScaleProperty

type TexScaleProperty struct {
	TypeName string  `json:"TypeName" default:"tex_scale"` // JSON 类型判别标识 / JSON type discriminator
	PropName string  `json:"PropName"`                     // Unity 材质纹理属性名 / Unity material texture-property name
	ScaleX   float32 `json:"ScaleX"`                       // 纹理 X 缩放 / Texture X scale
	ScaleY   float32 `json:"ScaleY"`                       // 纹理 Y 缩放 / Texture Y scale
}

TexScaleProperty 表示 COM3D2_5 读取器支持的独立纹理缩放属性 TexScaleProperty represents the standalone texture-scale property supported by the COM3D2_5 reader

func (*TexScaleProperty) GetTypeName

func (ts *TexScaleProperty) GetTypeName() string

GetTypeName 返回纹理缩放属性标识 tex_scale GetTypeName returns the tex_scale property identifier

func (*TexScaleProperty) Read

func (ts *TexScaleProperty) Read(reader *stream.BinaryReader) error

Read 读取纹理属性名和 X、Y 缩放 Read reads the texture property name and X and Y scales

func (*TexScaleProperty) Write

func (ts *TexScaleProperty) Write(writer *stream.BinaryWriter) error

Write 写入 tex_scale 类型标识、属性名和 X、Y 缩放 Write writes the tex_scale type identifier, property name, and X and Y scales

type ThickDefPerAngle

type ThickDefPerAngle struct {
	AngleDegree     int32   `json:"AngleDegree"`     // 角度 / Angle in degrees
	VertexIndex     int32   `json:"VertexIndex"`     // 顶点索引 / Vertex index
	DefaultDistance float32 `json:"DefaultDistance"` // 默认距离 / Default distance
}

ThickDefPerAngle 表示每个角度的皮肤厚度定义 ThickDefPerAngle represents a skin-thickness definition for one angle

type ThickGroup

type ThickGroup struct {
	GroupName       string        `json:"GroupName"`       // 组名称 / Group name
	StartBoneName   string        `json:"StartBoneName"`   // 线段起始骨骼名称 / Segment start-bone name
	EndBoneName     string        `json:"EndBoneName"`     // 线段结束骨骼名称 / Segment end-bone name
	StepAngleDegree int32         `json:"StepAngleDegree"` // 角度步长 / Angle step in degrees
	Points          []*ThickPoint `json:"Points"`          // 皮肤厚度采样点 / Skin-thickness sample points
}

ThickGroup 表示皮肤厚度组 ThickGroup represents a skin-thickness group

type ThickPoint

type ThickPoint struct {
	TargetBoneName         string              `json:"TargetBoneName"`         // 目标骨骼名称 / Target bone name
	RatioSegmentStartToEnd float32             `json:"RatioSegmentStartToEnd"` // 点在线段起点到终点之间的比例 / Point ratio along the segment from start to end
	DistanceParAngle       []*ThickDefPerAngle `json:"DistanceParAngle"`       // 按角度保存的距离定义 / Distance definitions stored per angle
}

ThickPoint 表示皮肤厚度点 ThickPoint represents a skin-thickness point

type TimelineData

type TimelineData struct {
	TotalFrame int32           `json:"TotalFrame"` // 总帧数 / Total frame count
	FrameRate  int32           `json:"FrameRate"`  // 帧率 / Frame rate
	Tracks     []TimelineTrack `json:"Tracks"`     // 轨道列表 / Track list
}

TimelineData 表示舞蹈时间线数据 TimelineData represents dance timeline data

func ReadTimelineData

func ReadTimelineData(r io.Reader) (*TimelineData, error)

ReadTimelineData 从 r 中读取一个 timeline_data.bytes 文件 ReadTimelineData reads one timeline_data.bytes file from r

func (*TimelineData) Dump

func (d *TimelineData) Dump(w io.Writer) error

Dump 将 TimelineData 写出到 w Dump writes TimelineData to w

func (*TimelineData) MarshalJSON

func (d *TimelineData) MarshalJSON() ([]byte, error)

MarshalJSON 序列化 TimelineData 时为每个轨道附加 TypeName 字段 MarshalJSON adds a TypeName field to each track while serializing TimelineData

func (*TimelineData) UnmarshalJSON

func (d *TimelineData) UnmarshalJSON(data []byte) error

UnmarshalJSON 反序列化 TimelineData,并根据 TypeName 字段创建对应的轨道实现 UnmarshalJSON deserializes TimelineData and creates the corresponding track implementation from TypeName

type TimelineTrack

type TimelineTrack interface {
	// GetTypeName 返回游戏轨道类型字符串
	// GetTypeName returns the game track-type string
	GetTypeName() string
	// contains filtered or unexported methods
}

TimelineTrack 表示时间线轨道接口 TimelineTrack represents the timeline-track interface

type TranslationTrack

type TranslationTrack struct {
	TrackID        int32     `json:"TrackID"`        // 轨道 ID / Track ID
	TotalFrame     int32     `json:"TotalFrame"`     // 总帧数 / Total frame count
	ObjectTreePath string    `json:"ObjectTreePath"` // 对象树路径 / Object-tree path
	PosArray       []Vector3 `json:"PosArray"`       // 每帧位置数组 / Per-frame position array
}

TranslationTrack 表示位移轨道 TranslationTrack represents a translation track

func (*TranslationTrack) GetTypeName

func (t *TranslationTrack) GetTypeName() string

GetTypeName 返回位移轨道标识 Translation GetTypeName returns the Translation track identifier

type VecProperty

type VecProperty struct {
	TypeName string     `json:"TypeName" default:"vec"` // JSON 类型判别标识 / JSON type discriminator
	PropName string     `json:"PropName"`               // Unity 材质向量属性名 / Unity material vector-property name
	Vector   [4]float32 `json:"Vector"`                 // X、Y、Z、W 分量 / X, Y, Z, W components
}

VecProperty 表示按 X、Y、Z、W 顺序保存的材质 Vector4 属性 VecProperty represents a material Vector4 property stored in X, Y, Z, W order

func (*VecProperty) GetTypeName

func (v *VecProperty) GetTypeName() string

GetTypeName 返回向量属性标识 vec GetTypeName returns the vec property identifier

func (*VecProperty) Read

func (v *VecProperty) Read(reader *stream.BinaryReader) error

Read 读取向量属性名和四个 Vector4 浮点分量 Read reads the vector property name and four Vector4 float components

func (*VecProperty) Write

func (v *VecProperty) Write(writer *stream.BinaryWriter) error

Write 写入 vec 类型标识、属性名和四个 Vector4 浮点分量 Write writes the vec type identifier, property name, and four Vector4 float components

type Vector2

type Vector2 struct {
	X float32 `json:"X"` // X 轴分量 / X-axis component
	Y float32 `json:"Y"` // Y 轴分量 / Y-axis component
}

Vector2 表示二维向量或UV坐标 Vector2 represents a two-dimensional vector or UV coordinate

type Vector3

type Vector3 struct {
	X float32 `json:"X"` // X 轴分量 / X-axis component
	Y float32 `json:"Y"` // Y 轴分量 / Y-axis component
	Z float32 `json:"Z"` // Z 轴分量 / Z-axis component
}

Vector3 表示三维向量 Vector3 represents a three-dimensional vector

type Vector4

type Vector4 struct {
	X float32 `json:"X"` // X 轴分量 / X-axis component
	Y float32 `json:"Y"` // Y 轴分量 / Y-axis component
	Z float32 `json:"Z"` // Z 轴分量 / Z-axis component
	W float32 `json:"W"` // W 轴分量 / W-axis component
}

Vector4 表示四维向量 Vector4 represents a four-dimensional vector

type Vertex

type Vertex struct {
	Position Vector3  `json:"Position"`           // 顶点位置 / Vertex position
	Normal   Vector3  `json:"Normal"`             // 顶点法线 / Vertex normal
	UV       Vector2  `json:"UV"`                 // 基础顶点 UV 坐标 / Base vertex UV coordinates
	UV2      *Vector2 `json:"UV2,omitempty"`      // 版本 2101 及以上由标志控制的顶点 UV2 坐标 / Vertex UV2 coordinates controlled by a flag from version 2101 onward
	UV3      *Vector2 `json:"UV3,omitempty"`      // 版本 2101 及以上由标志控制的顶点 UV3 坐标 / Vertex UV3 coordinates controlled by a flag from version 2101 onward
	UV4      *Vector2 `json:"UV4,omitempty"`      // 版本 2101 及以上由标志控制的顶点 UV4 坐标 / Vertex UV4 coordinates controlled by a flag from version 2101 onward
	Unknown1 *Vector2 `json:"Unknown1,omitempty"` // 版本 2101 及以上的未知可选 Vector2 通道 1,游戏读取后未使用 / Unknown optional Vector2 channel 1 from version 2101 onward, read but unused by the game
	Unknown2 *Vector2 `json:"Unknown2,omitempty"` // 版本 2101 及以上的未知可选 Vector2 通道 2,游戏读取后未使用 / Unknown optional Vector2 channel 2 from version 2101 onward, read but unused by the game
	Unknown3 *Vector2 `json:"Unknown3,omitempty"` // 版本 2101 及以上的未知可选 Vector2 通道 3,游戏读取后未使用 / Unknown optional Vector2 channel 3 from version 2101 onward, read but unused by the game
	Unknown4 *Vector2 `json:"Unknown4,omitempty"` // 版本 2101 及以上的未知可选 Vector2 通道 4,游戏读取后未使用 / Unknown optional Vector2 channel 4 from version 2101 onward, read but unused by the game
}

Vertex 表示顶点数据 Vertex represents vertex data

type VtxAttachPos

type VtxAttachPos struct {
	Enable      bool                  `json:"Enable"`                // 是否启用 / Whether the attachment is enabled
	VtxCount    int32                 `json:"VtxCount"`              // 创建附着数据时的网格顶点数,用于拒绝不匹配的网格 / Mesh vertex count when the attachment was created, used to reject a mismatched mesh
	VtxIdx      int32                 `json:"VtxIdx"`                // 目标顶点索引 / Target vertex index
	PosRotScale PositionRotationScale `json:"PositionRotationScale"` // 相对于目标顶点的位置、旋转和缩放 / Position, rotation, and scale relative to the target vertex
}

VtxAttachPos 表示顶点附着位置 VtxAttachPos represents a vertex attachment position

type VtxAttachPosEntry

type VtxAttachPosEntry struct {
	RID          int32        `json:"RID"`          // 来源菜单文件名哈希,用于确认数据属于当前菜单项 / Source-menu filename hash used to verify that the data belongs to the current menu item
	VtxAttachPos VtxAttachPos `json:"VtxAttachPos"` // 顶点附着位置数据 / Vertex attachment-position data
}

VtxAttachPosEntry 保存顶点附着位置及其来源菜单哈希 VtxAttachPosEntry stores a vertex attachment position and its source-menu hash

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL