mst

package
v0.0.0-...-0aee600 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: MIT Imports: 22 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(doc *gltf.Document, mh *Mesh, 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(wt io.Writer, mt MeshMaterial, v uint32)

func MeshInstanceNodeMarshal

func MeshInstanceNodeMarshal(wt io.Writer, instNd *InstanceMesh, v uint32)

func MeshInstanceNodesMarshal

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

func MeshMarshal

func MeshMarshal(wt io.Writer, ms *Mesh)

func MeshNodeMarshal

func MeshNodeMarshal(wt io.Writer, nd *MeshNode)

func MeshNodesMarshal

func MeshNodesMarshal(wt io.Writer, nds []*MeshNode)

func MeshOutlineMarshal

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

func MeshTriangleMarshal

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

func MeshWriteTo

func MeshWriteTo(path string, ms *Mesh) error

func MstToGltf

func MstToGltf(msts []*Mesh) (*gltf.Document, error)

func MstToGltfWithOutline

func MstToGltfWithOutline(msts []*Mesh) (*gltf.Document, error)

func MtlsMarshal

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

func PbrMaterialMarshal

func PbrMaterialMarshal(wt io.Writer, mtl *PbrMaterial, 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 struct {
	Materials []MeshMaterial `json:"materials,omitempty"`
	Nodes     []*MeshNode    `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 struct {
	Transfors []*dmat.T
	Features  []uint64
	BBox      *[6]float64
	Mesh      *BaseMesh
	Hash      uint64
}

func MeshInstanceNodeUnMarshal

func MeshInstanceNodeUnMarshal(rd io.Reader, v uint32) *InstanceMesh

func MeshInstanceNodesUnMarshal

func MeshInstanceNodesUnMarshal(rd io.Reader, v uint32) []*InstanceMesh

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 struct {
	BaseMesh
	Version      uint32 `json:"version"`
	InstanceNode []*InstanceMesh
}

func MeshReadFrom

func MeshReadFrom(path string) (*Mesh, error)

func MeshUnMarshal

func MeshUnMarshal(rd io.Reader) *Mesh

func NewMesh

func NewMesh() *Mesh

func (*Mesh) ComputeBBox

func (m *Mesh) ComputeBBox() dvec3.Box

func (*Mesh) MaterialCount

func (m *Mesh) MaterialCount() int

func (*Mesh) NodeCount

func (m *Mesh) NodeCount() int

type MeshMaterial

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

func MaterialUnMarshal

func MaterialUnMarshal(rd io.Reader, v uint32) MeshMaterial

func MtlsUnMarshal

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

type MeshNode

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

func MeshNodeUnMarshal

func MeshNodeUnMarshal(rd io.Reader) *MeshNode

func MeshNodesUnMarshal

func MeshNodesUnMarshal(rd io.Reader) []*MeshNode

func (*MeshNode) GetBoundbox

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

func (*MeshNode) ReComputeNormal

func (n *MeshNode) ReComputeNormal()

func (*MeshNode) ResortVtVn

func (n *MeshNode) ResortVtVn(m *Mesh)

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 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.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(rd io.Reader, v uint32) *PbrMaterial

func (*PbrMaterial) GetEmissive

func (m *PbrMaterial) 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