mst

package
v0.0.0-...-52be630 Latest Latest
Warning

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

Go to latest
Published: May 4, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MESH_TRIANGLE_MATERIAL_TYPE_COLOR   = 0
	MESH_TRIANGLE_MATERIAL_TYPE_TEXTURE = 1
	MESH_TRIANGLE_MATERIAL_TYPE_PBR     = 2
	MESH_TRIANGLE_MATERIAL_TYPE_LAMBERT = 3
	MESH_TRIANGLE_MATERIAL_TYPE_PHONG   = 4
)
View Source
const (
	PBR_MATERIAL_TYPE_LIT        = 0
	PBR_MATERIAL_TYPE_SUBSURFACE = 1
	PBR_MATERIAL_TYPE_CLOTH      = 2
)
View Source
const (
	TEXTURE_PIXEL_TYPE_UBYTE  = 0
	TEXTURE_PIXEL_TYPE_BYTE   = 1
	TEXTURE_PIXEL_TYPE_USHORT = 2
	TEXTURE_PIXEL_TYPE_SHORT  = 3
	TEXTURE_PIXEL_TYPE_UINT   = 4
	TEXTURE_PIXEL_TYPE_INT    = 5
	TEXTURE_PIXEL_TYPE_HALF   = 6
	TEXTURE_PIXEL_TYPE_FLOAT  = 7
)
View Source
const (
	TEXTURE_FORMAT_R               = 0
	TEXTURE_FORMAT_R_INTEGER       = 1
	TEXTURE_FORMAT_RG              = 2
	TEXTURE_FORMAT_RG_INTEGER      = 3
	TEXTURE_FORMAT_RGB             = 4
	TEXTURE_FORMAT_RGB_INTEGER     = 5
	TEXTURE_FORMAT_RGBA            = 6
	TEXTURE_FORMAT_RGBA_INTEGER    = 7
	TEXTURE_FORMAT_RGBM            = 8
	TEXTURE_FORMAT_DEPTH_COMPONENT = 9
	TEXTURE_FORMAT_DEPTH_STENCIL   = 10
	TEXTURE_FORMAT_ALPHA           = 11
)
View Source
const GLTF_VERSION = "2.0"
View Source
const MESH_SIGNATURE string = "fwtm"
View Source
const MSTEXT string = ".mst"
View Source
const (
	TEXTURE_COMPRESSED_ZLIB = 1
)
View Source
const V1 uint32 = 1
View Source
const V2 uint32 = 2
View Source
const V3 uint32 = 3
View Source
const V4 uint32 = 4

Variables

This section is empty.

Functions

func BaseMaterialMarshal

func BaseMaterialMarshal(wt io.Writer, mtl *BaseMaterial)

func BuildGltf

func BuildGltf[T float64 | float32](doc *gltf.Document, mh *Mesh[T], exportOutline, gpu_instance bool) error

func CompressImage

func CompressImage(buf []byte) []byte

func CreateDoc

func CreateDoc() *gltf.Document

func DecompressImage

func DecompressImage(src []byte) ([]byte, error)

func GetGltfBinary

func GetGltfBinary(doc *gltf.Document, paddingUnit int) ([]byte, error)

func LambertMaterialMarshal

func LambertMaterialMarshal(wt io.Writer, mtl *LambertMaterial)

func LoadTexture

func LoadTexture(tex *Texture, flipY bool) (image.Image, error)

func MaterialMarshal

func MaterialMarshal[T float64 | float32](wt io.Writer, mt MeshMaterial, v uint32)

func MeshInstanceNodeMarshal

func MeshInstanceNodeMarshal[T float64 | float32](wt io.Writer, instNd *InstanceMesh[T], v uint32)

func MeshInstanceNodesMarshal

func MeshInstanceNodesMarshal[T float64 | float32](wt io.Writer, instNd []*InstanceMesh[T], v uint32)

func MeshMarshal

func MeshMarshal[T float64 | float32](wt io.Writer, ms *Mesh[T])

func MeshNodeMarshal

func MeshNodeMarshal[T float64 | float32](wt io.Writer, nd *MeshNode[T])

func MeshNodesMarshal

func MeshNodesMarshal[T float64 | float32](wt io.Writer, nds []*MeshNode[T])

func MeshOutlineMarshal

func MeshOutlineMarshal(wt io.Writer, nd *MeshOutline)

func MeshTriangleMarshal

func MeshTriangleMarshal(wt io.Writer, nd *MeshTriangle)

func MeshWriteTo

func MeshWriteTo[T float64 | float32](path string, ms *Mesh[T]) error

func MstToGltf

func MstToGltf[T float64 | float32](msts []*Mesh[T]) (*gltf.Document, error)

func MstToGltfWithOutline

func MstToGltfWithOutline[T float64 | float32](msts []*Mesh[T]) (*gltf.Document, error)

func MtlsMarshal

func MtlsMarshal(wt io.Writer, mtls []MeshMaterial, v uint32)

func PbrMaterialMarshal

func PbrMaterialMarshal[T float64 | float32](wt io.Writer, mtl *PbrMaterial[T], v uint32)

func PhongMaterialMarshal

func PhongMaterialMarshal(wt io.Writer, mtl *PhongMaterial)

func TextureMarshal

func TextureMarshal(wt io.Writer, tex *Texture)

func TextureMaterialMarshal

func TextureMaterialMarshal(wt io.Writer, mtl *TextureMaterial)

Types

type BaseMaterial

type BaseMaterial struct {
	Color        [3]byte `json:"color"`
	Transparency float32 `json:"transparency"`
}

func BaseMaterialUnMarshal

func BaseMaterialUnMarshal(rd io.Reader) *BaseMaterial

func (*BaseMaterial) GetColor

func (m *BaseMaterial) GetColor() [3]byte

func (*BaseMaterial) GetEmissive

func (m *BaseMaterial) GetEmissive() [3]byte

func (*BaseMaterial) GetTexture

func (m *BaseMaterial) GetTexture() *Texture

func (*BaseMaterial) HasTexture

func (m *BaseMaterial) HasTexture() bool

type BaseMesh

type BaseMesh[T float64 | float32] struct {
	Materials []MeshMaterial `json:"materials,omitempty"`
	Nodes     []*MeshNode[T] `json:"nodes,omitempty"`
	Code      uint32         `json:"code,omitempty"`
}

type Face

type Face struct {
	Vertex [3]uint32
	Normal *[3]uint32
	Uv     *[3]uint32
}

type InstanceMesh

type InstanceMesh[T float64 | float32] struct {
	Transfors []*mat4.Mat[T]
	Features  []uint64
	BBox      *[6]float64
	Mesh      *BaseMesh[T]
	Hash      uint64
}

func MeshInstanceNodeUnMarshal

func MeshInstanceNodeUnMarshal[T float64 | float32](rd io.Reader, v uint32) *InstanceMesh[T]

func MeshInstanceNodesUnMarshal

func MeshInstanceNodesUnMarshal[T float64 | float32](rd io.Reader, v uint32) []*InstanceMesh[T]

type LambertMaterial

type LambertMaterial struct {
	TextureMaterial
	Ambient  [3]byte `json:"ambient"`
	Diffuse  [3]byte `json:"diffuse"`
	Emissive [3]byte `json:"emissive"`
}

func LambertMaterialUnMarshal

func LambertMaterialUnMarshal(rd io.Reader) *LambertMaterial

func (*LambertMaterial) GetEmissive

func (m *LambertMaterial) GetEmissive() [3]byte

type Mesh

type Mesh[T float64 | float32] struct {
	BaseMesh[T]
	Version      uint32 `json:"version"`
	InstanceNode []*InstanceMesh[T]
}

func MeshReadFrom

func MeshReadFrom[T float64 | float32](path string) (*Mesh[T], error)

func MeshUnMarshal

func MeshUnMarshal[T float64 | float32](rd io.Reader) *Mesh[T]

func NewMesh

func NewMesh[T float64 | float32]() *Mesh[T]

func (*Mesh[T]) ComputeBBox

func (m *Mesh[T]) ComputeBBox() vec3.Box[float64]

func (*Mesh[T]) MaterialCount

func (m *Mesh[T]) MaterialCount() int

func (*Mesh[T]) NodeCount

func (m *Mesh[T]) NodeCount() int

type MeshMaterial

type MeshMaterial interface {
	HasTexture() bool
	GetTexture() *Texture
	GetColor() [3]byte
	GetEmissive() [3]byte
}

func MaterialUnMarshal

func MaterialUnMarshal[T float64 | float32](rd io.Reader, v uint32) MeshMaterial

func MtlsUnMarshal

func MtlsUnMarshal(rd io.Reader, v uint32) []MeshMaterial

type MeshNode

type MeshNode[T float64 | float32] struct {
	Vertices  []vec3.Vec[T]   `json:"vertices"`
	Normals   []vec3.Vec[T]   `json:"normals,omitempty"`
	Colors    [][3]byte       `json:"colors,omitempty"`
	TexCoords []vec2.Vec[T]   `json:"texCoords,omitempty"`
	Mat       *mat4.Mat[T]    `json:"mat,omitempty"`
	FaceGroup []*MeshTriangle `json:"faceGroup,omitempty"`
	EdgeGroup []*MeshOutline  `json:"edgeGroup,omitempty"`
}

func MeshNodeUnMarshal

func MeshNodeUnMarshal[T float64 | float32](rd io.Reader) *MeshNode[T]

func MeshNodesUnMarshal

func MeshNodesUnMarshal[T float64 | float32](rd io.Reader) []*MeshNode[T]

func (*MeshNode[T]) GetBoundbox

func (nd *MeshNode[T]) GetBoundbox() *[6]float64

func (*MeshNode[T]) ReComputeNormal

func (n *MeshNode[T]) ReComputeNormal()

func (*MeshNode[T]) ResortVtVn

func (n *MeshNode[T]) ResortVtVn(m *Mesh[T])

type MeshOutline

type MeshOutline struct {
	Batchid int      `json:"batchid"`
	Edges   [][2]int `json:"edges"`
}

func MeshOutlineUnMarshal

func MeshOutlineUnMarshal(rd io.Reader) *MeshOutline

type MeshTriangle

type MeshTriangle struct {
	Batchid int     `json:"batchid"`
	Faces   []*Face `json:"faces"`
}

func MeshTriangleUnMarshal

func MeshTriangleUnMarshal(rd io.Reader) *MeshTriangle

type PbrMaterial

type PbrMaterial[T float64 | float32] struct {
	TextureMaterial
	Emissive            [3]byte     `json:"emissive"`
	Metallic            float32     `json:"metallic"`
	Roughness           float32     `json:"roughness"`
	Reflectance         float32     `json:"reflectance"`
	AmbientOcclusion    float32     `json:"ambientOcclusion"`
	ClearCoat           float32     `json:"clearCoat"`
	ClearCoatRoughness  float32     `json:"clearCoatRoughness"`
	ClearCoatNormal     [3]byte     `json:"clearCoatNormal"`
	Anisotropy          float32     `json:"anisotropy"`
	AnisotropyDirection vec3.Vec[T] `json:"anisotropyDirection"`
	Thickness           float32     `json:"thickness"`       // subsurface only
	SubSurfacePower     float32     `json:"subSurfacePower"` // subsurface only
	SheenColor          [3]byte     `json:"sheenColor"`      // cloth only
	SubSurfaceColor     [3]byte     `json:"subSurfaceColor"` // subsurface or cloth
}

func PbrMaterialUnMarshal

func PbrMaterialUnMarshal[T float64 | float32](rd io.Reader, v uint32) *PbrMaterial[T]

func (*PbrMaterial[T]) GetEmissive

func (m *PbrMaterial[T]) GetEmissive() [3]byte

type PhongMaterial

type PhongMaterial struct {
	LambertMaterial
	Specular    [3]byte `json:"specular"`
	Shininess   float64 `json:"shininess"`
	Specularity float64 `json:"specularity"`
}

func PhongMaterialUnMarshal

func PhongMaterialUnMarshal(rd io.Reader) *PhongMaterial

type Texture

type Texture struct {
	Id         int       `json:"id"`
	Name       string    `json:"name"`
	Size       [2]uint64 `json:"size"`
	Format     uint16    `json:"format"`
	Type       uint16    `json:"type"`
	Compressed uint16    `json:"compressed"`
	Data       []byte    `json:"-"`
	Repeated   bool      `json:"repeated"`
}

func CreateTexture

func CreateTexture(name string, repet bool) (*Texture, error)

func TextureUnMarshal

func TextureUnMarshal(rd io.Reader) *Texture

type TextureMaterial

type TextureMaterial struct {
	BaseMaterial
	Texture *Texture `json:"texture,omitempty"`
	Normal  *Texture `json:"normal,omitempty"`
}

func TextureMaterialUnMarshal

func TextureMaterialUnMarshal(rd io.Reader) *TextureMaterial

func (*TextureMaterial) GetNormalTexture

func (m *TextureMaterial) GetNormalTexture() *Texture

func (*TextureMaterial) GetTexture

func (m *TextureMaterial) GetTexture() *Texture

func (*TextureMaterial) HasNormalTexture

func (m *TextureMaterial) HasNormalTexture() bool

func (*TextureMaterial) HasTexture

func (m *TextureMaterial) HasTexture() bool

Jump to

Keyboard shortcuts

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