COM3D2

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2025 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnmService

type AnmService struct{}

AnmService 专门处理 .anm 文件的读写

func (*AnmService) ReadAnmFile

func (m *AnmService) ReadAnmFile(path string) (*COM3D2.Anm, error)

ReadAnmFile 读取 .anm 文件并返回对应结构体

func (*AnmService) WriteAnmFile

func (m *AnmService) WriteAnmFile(path string, anmData *COM3D2.Anm) error

WriteAnmFile 接收 Anm 数据并写入 .anm 文件

type Base64StdEncoder

type Base64StdEncoder interface {
	EncodeToString([]byte) string
}

Base64StdEncoder 定义一个接口,用于将字节切片编码为 Base64 字符串

type ColService

type ColService struct{}

ColService 专门处理 .col 文件的读写

func (*ColService) ReadColFile

func (m *ColService) ReadColFile(path string) (*COM3D2.Col, error)

ReadColFile 读取 .col 文件并返回对应结构体

func (*ColService) WriteColFile

func (m *ColService) WriteColFile(path string, colData *COM3D2.Col) error

WriteColFile 接收 Col 数据并写入 .col 文件

type CovertTexToImageResult

type CovertTexToImageResult struct {
	Base64EncodedImageData string
	Format                 string
	Rects                  []COM3D2.TexRect
}

CovertTexToImageResult 前端不接受多个返回值,因此使用结构体

type MateService

type MateService struct{}

MateService 专门处理 .mate 文件的读写

func (*MateService) ReadMateFile

func (m *MateService) ReadMateFile(path string) (*COM3D2.Mate, error)

ReadMateFile 读取 .mate 文件并返回对应结构体

func (*MateService) WriteMateFile

func (m *MateService) WriteMateFile(path string, mateData *COM3D2.Mate) error

WriteMateFile 接收 Mate 数据并写入 .mate 文件

type MenuService struct{}

MenuService 专门处理 .menu 文件的读写

func (s *MenuService) ReadMenuFile(path string) (*COM3D2.Menu, error)

ReadMenuFile 读取 .menu 文件并返回对应结构体

func (s *MenuService) WriteMenuFile(path string, menuData *COM3D2.Menu) error

WriteMenuFile 接收 Menu 数据并写入 .menu 文件

type ModelService

type ModelService struct{}

ModelService 专门处理 .model 文件的读写

func (*ModelService) ReadModelFile

func (m *ModelService) ReadModelFile(path string) (*COM3D2.Model, error)

ReadModelFile 读取 .Model 文件并返回对应结构体

func (*ModelService) ReadModelMaterial

func (m *ModelService) ReadModelMaterial(path string) ([]*COM3D2.Material, error)

ReadModelMaterial 读取 .model 文件,但只返回其中的材质数据

func (*ModelService) WriteModelFile

func (m *ModelService) WriteModelFile(path string, modelData *COM3D2.Model) error

WriteModelFile 接收 Model 数据并写入 .model 文件

func (*ModelService) WriteModelMaterial

func (m *ModelService) WriteModelMaterial(inputPath string, outputPath string, materials []*COM3D2.Material) error

WriteModelMaterial 接收 Material 数据并写入.model 文件 因为 Material 数据是在 Model 结构体中,所以需要先读取整个 Model 结构体,然后修改其中的 Material 数据,最后再写入文件 因此这里需要传入输入文件路径和输出文件路径,分别用于读取和写入.model 文件,可以为相同路径

type PMatService

type PMatService struct{}

PMatService 专门处理 .pmat 文件的读写

func (*PMatService) ReadPMatFile

func (s *PMatService) ReadPMatFile(path string) (*COM3D2.PMat, error)

ReadPMatFile 读取 .pmat 文件并返回对应结构体

func (*PMatService) WritePMatFile

func (s *PMatService) WritePMatFile(path string, PMatData *COM3D2.PMat) error

WritePMatFile 接收 PMat 数据并写入 .pmat 文件

type PhyService

type PhyService struct{}

PhyService 专门处理 .phy 文件的读写

func (*PhyService) ReadPhyFile

func (m *PhyService) ReadPhyFile(path string) (*COM3D2.Phy, error)

ReadPhyFile 读取 .phy 文件并返回对应结构体

func (*PhyService) WritePhyFile

func (m *PhyService) WritePhyFile(path string, phyData *COM3D2.Phy) error

WritePhyFile 接收 Phy 数据并写入 .phy 文件

type PskService

type PskService struct{}

PskService 专门处理 .psk 文件的读写

func (*PskService) ReadPskFile

func (m *PskService) ReadPskFile(path string) (*COM3D2.Psk, error)

ReadPskFile 读取 .psk 文件并返回对应结构体

func (*PskService) WritePskFile

func (m *PskService) WritePskFile(path string, pskData *COM3D2.Psk) error

WritePskFile 接收 Psk 数据并写入 .psk 文件

type TexService

type TexService struct {
	// you can choose any encoder you like
	// example:
	// Base64Encoder: emmansun.NewBase64Encoder(), // github.com/emmansun/base64
	// Base64Encoder: base64.StdEncoding, // golang.org/x/encoding/base64
	Base64StdEncoder Base64StdEncoder
}

TexService 专门处理 .tex 文件的读写

func NewTexService

func NewTexService() *TexService

func (*TexService) CheckImageMagick

func (t *TexService) CheckImageMagick() bool

CheckImageMagick 检查是否安装了 ImageMagick

func (*TexService) ConvertAnyToAnyAndWrite

func (t *TexService) ConvertAnyToAnyAndWrite(inputPath string, texName string, compress bool, forcePNG bool, outputPath string) error

ConvertAnyToAnyAndWrite 任意 ImageMagick 支持的格式和 .tex 转换为任意 ImageMagick 支持的格式,并写出 依赖外部库 ImageMagick,且有 Path 环境变量可以直接调用 magick 命令 转换为图片时: 输出格式根据输出路径后缀决定,如果 forcePng 为 true 则强制输出为 PNG,但是如果输出格式为 .tex 则输出为.tex 转换为 .tex 时: 如果 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 压缩,数据位为 DDS 数据,根据有无透明通道选择 DXT1 或 DXT5 如果输入输出都是 .tex,则原样复制,只不过是先读取再写出

func (*TexService) ConvertAnyToPng

func (t *TexService) ConvertAnyToPng(inputPath string) (Base64EncodedPngData string, err error)

ConvertAnyToPng 任意 ImageMagick 支持的格式转换为 PNG,包括 .tex 依赖外部库 ImageMagick,且有 Path 环境变量可以直接调用 magick 命令 输出为 base64 编码的 PNG 数据

func (*TexService) ConvertImageToTex

func (t *TexService) ConvertImageToTex(inputPath string, texName string, compress bool, forcePNG bool) (*COM3D2.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 压缩,数据位为 DDS 数据,根据有无透明通道选择 DXT1 或 DXT5 如果要生成 1011 版本的 tex(纹理图集),需要在图片目录下有一个同名的 .uv.csv 文件(例如 foo.png 对应 foo.png.uv.csv),文件内容为矩形数组 x, y, w, h 一行一组 否则生成 1010 版本的 tex

func (*TexService) ConvertImageToTexAndWrite

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

ConvertImageToTexAndWrite 将任意 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 压缩,数据位为 DDS 数据,根据有无透明通道选择 DXT1 或 DXT5 如果要生成 1011 版本的 tex(纹理图集),需要在图片目录下有一个同名的 .uv.csv 文件(例如 foo.png 对应 foo.png.uv.csv),文件内容为矩形数组 x, y, w, h 一行一组,否则生成 1010 版本的 tex 如果输入输出都是 .tex,则原样复制

func (*TexService) ConvertTexToImageAndWrite

func (t *TexService) ConvertTexToImageAndWrite(tex *COM3D2.Tex, outputPath string, forcePng bool) error

ConvertTexToImageAndWrite 将 .tex 文件转换为图像文件,并写出 依赖外部库 ImageMagick,且有 Path 环境变量可以直接调用 magick 命令 如果 forcePNG 为 false 那么如果图像是有损格式且没有透明通道,则保存为 JPG,否则保存为 PNG 如果 forcePNG 为 true 则强制保存为 PNG,不考虑图像格式和透明通道 如果是 1011 版本的 tex(纹理图集),则还会生成一个 .uv.csv 文件(例如 foo.png 对应 foo.png.uv.csv),文件内容为矩形数组 x, y, w, h 一行一组

func (*TexService) CovertTexToImage

func (t *TexService) CovertTexToImage(inputPath string, forcePng bool) (covertTexToImageResult CovertTexToImageResult, err error)

CovertTexToImage 将 .tex 文件转换为图像文件,但不写出 依赖外部库 ImageMagick,且有 Path 环境变量可以直接调用 magick 命令 如果 forcePNG 为 false 那么如果图像数据位是 JPG 或 PNG 则直接返回数据为,否则根据有没有透明通道保存为 JPG 或 PNG 如果 forcePNG 为 true 则强制保存为 PNG,不考虑图像格式和透明通道 如果是 1011 版本的 tex(纹理图集),则还会返回 rects

func (*TexService) ReadTexFile

func (t *TexService) ReadTexFile(path string) (*COM3D2.Tex, error)

ReadTexFile 读取 .tex 文件并返回对应结构体

func (*TexService) WriteTexFile

func (t *TexService) WriteTexFile(path string, TexData *COM3D2.Tex) error

WriteTexFile 接收 Tex 数据并写入 .tex 文件

Jump to

Keyboard shortcuts

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