Documentation
¶
Index ¶
- Constants
- func BaseMaterialMarshal(wt io.Writer, mtl *BaseMaterial)
- func BuildGltf[T float64 | float32](doc *gltf.Document, mh *Mesh[T], exportOutline, gpu_instance bool) error
- func CompressImage(buf []byte) []byte
- func CreateDoc() *gltf.Document
- func DecompressImage(src []byte) ([]byte, error)
- func GetGltfBinary(doc *gltf.Document, paddingUnit int) ([]byte, error)
- func LambertMaterialMarshal(wt io.Writer, mtl *LambertMaterial)
- func LoadTexture(tex *Texture, flipY bool) (image.Image, error)
- func MaterialMarshal[T float64 | float32](wt io.Writer, mt MeshMaterial, v uint32)
- func MeshInstanceNodeMarshal[T float64 | float32](wt io.Writer, instNd *InstanceMesh[T], v uint32)
- func MeshInstanceNodesMarshal[T float64 | float32](wt io.Writer, instNd []*InstanceMesh[T], v uint32)
- func MeshMarshal[T float64 | float32](wt io.Writer, ms *Mesh[T])
- func MeshNodeMarshal[T float64 | float32](wt io.Writer, nd *MeshNode[T])
- func MeshNodesMarshal[T float64 | float32](wt io.Writer, nds []*MeshNode[T])
- func MeshOutlineMarshal(wt io.Writer, nd *MeshOutline)
- func MeshTriangleMarshal(wt io.Writer, nd *MeshTriangle)
- func MeshWriteTo[T float64 | float32](path string, ms *Mesh[T]) error
- func MstToGltf[T float64 | float32](msts []*Mesh[T]) (*gltf.Document, error)
- func MstToGltfWithOutline[T float64 | float32](msts []*Mesh[T]) (*gltf.Document, error)
- func MtlsMarshal(wt io.Writer, mtls []MeshMaterial, v uint32)
- func PbrMaterialMarshal[T float64 | float32](wt io.Writer, mtl *PbrMaterial[T], v uint32)
- func PhongMaterialMarshal(wt io.Writer, mtl *PhongMaterial)
- func TextureMarshal(wt io.Writer, tex *Texture)
- func TextureMaterialMarshal(wt io.Writer, mtl *TextureMaterial)
- type BaseMaterial
- type BaseMesh
- type Face
- type InstanceMesh
- type LambertMaterial
- type Mesh
- type MeshMaterial
- type MeshNode
- type MeshOutline
- type MeshTriangle
- type PbrMaterial
- type PhongMaterial
- type Texture
- type TextureMaterial
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 CompressImage ¶
func DecompressImage ¶
func LambertMaterialMarshal ¶
func LambertMaterialMarshal(wt io.Writer, mtl *LambertMaterial)
func MaterialMarshal ¶
func MeshInstanceNodeMarshal ¶
func MeshNodesMarshal ¶
func MeshOutlineMarshal ¶
func MeshOutlineMarshal(wt io.Writer, nd *MeshOutline)
func MeshTriangleMarshal ¶
func MeshTriangleMarshal(wt io.Writer, nd *MeshTriangle)
func MstToGltfWithOutline ¶
func MtlsMarshal ¶
func MtlsMarshal(wt io.Writer, mtls []MeshMaterial, v uint32)
func PbrMaterialMarshal ¶
func PhongMaterialMarshal ¶
func PhongMaterialMarshal(wt io.Writer, mtl *PhongMaterial)
func TextureMarshal ¶
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 InstanceMesh ¶
type InstanceMesh[T float64 | float32] struct { Transfors []*mat4.Mat[T] Features []uint64 BBox *[6]float64 Mesh *BaseMesh[T] Hash uint64 }
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 (*Mesh[T]) MaterialCount ¶
type MeshMaterial ¶
type MeshMaterial interface {
HasTexture() bool
GetTexture() *Texture
GetColor() [3]byte
GetEmissive() [3]byte
}
func MaterialUnMarshal ¶
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 (*MeshNode[T]) GetBoundbox ¶
func (*MeshNode[T]) ReComputeNormal ¶
func (n *MeshNode[T]) ReComputeNormal()
func (*MeshNode[T]) ResortVtVn ¶
type MeshOutline ¶
func MeshOutlineUnMarshal ¶
func MeshOutlineUnMarshal(rd io.Reader) *MeshOutline
type MeshTriangle ¶
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 (*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 TextureUnMarshal ¶
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
Click to show internal directories.
Click to hide internal directories.