mmd

package
v0.2.13 Latest Latest
Warning

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

Go to latest
Published: May 11, 2021 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	MaterialFlagDoubleSided uint8 = 1
	MaterialFlagCastShadow  uint8 = 2
)
View Source
const (
	BoneFlagTailIndex    uint16 = 1
	BoneFlagRotatable    uint16 = 2
	BoneFlagTranslatable uint16 = 4
	BoneFlagVisible      uint16 = 8
	BoneFlagEnabled      uint16 = 16
	BoneFlagEnableIK     uint16 = 32

	BoneFlagInheritRotation    uint16 = 256
	BoneFlagInheritTranslation uint16 = 512
	BoneFlagFixedAxis          uint16 = 1024
	BoneFlagLocalAxis          uint16 = 2048
	BoneFlagPhysicsMode        uint16 = 4096
	BoneFlagExternalParent     uint16 = 8192

	BoneFlagAll uint16 = (31 | 32 | 256 | 512 | 1024 | 2048 | 4096 | 8192)
)
View Source
const (
	AttrStringEncoding int = iota
	AttrExtUV
	AttrVertIndexSz
	AttrTexIndexSz
	AttrMatIndexSz
	AttrBoneIndexSz
	AttrMorphIndexSz
	AttrRBIndexSz
)

Variables

This section is empty.

Functions

func WritePMX

func WritePMX(doc *Document, w io.Writer) error

WritePMX writes .pmx data

Types

type Bone

type Bone struct {
	Name     string
	NameEn   string
	Pos      Vector3
	ParentID int
	Layer    int
	Flags    uint16
	TailID   int
	TailPos  Vector3

	InheritParentID        int
	InheritParentInfluence float32

	FixedAxis Vector3

	IK struct {
		TargetID int
		Loop     int
		LimitRad float32
		Links    []*Link
	}
}

type Document added in v0.2.0

type Document struct {
	Header    *Header
	Name      string
	NameEn    string
	Comment   string
	CommentEn string
	Vertexes  []*Vertex
	Faces     []*Face
	Textures  []string
	Materials []*Material
	Bones     []*Bone
	Morphs    []*Morph
}

func NewDocument added in v0.2.0

func NewDocument() *Document

func Parse

func Parse(r io.Reader) (*Document, error)

Parse pmx/pmd file.

type Face

type Face struct {
	Verts [3]int
}
type Header struct {
	Format  []byte
	Version float32
	Info    []byte
}
type Link struct {
	TargetID int
	HasLimit bool
	LimitMax Vector3
	LimitMin Vector3
}

type Material

type Material struct {
	Name        string
	NameEn      string
	Color       Vector4
	Specular    Vector3
	Specularity float32
	AColor      Vector3
	Flags       byte
	EdgeColor   Vector4
	EdgeScale   float32
	TextureID   int
	EnvID       int
	EnvMode     byte
	ToonType    byte
	Toon        int
	Memo        string
	Count       int
}

type Morph

type Morph struct {
	Name      string
	NameEn    string
	PanelType byte
	MorphType byte

	// oneof
	Group    []*MorphGroup
	Vertex   []*MorphVertex
	UV       []*MorphUV
	Material []*MorphMaterial
}

type MorphGroup

type MorphGroup struct {
	Target int
	Weight float32
}

type 0

type MorphMaterial

type MorphMaterial struct {
	Target int

	Flags           byte
	Diffuse         Vector4
	Specular        Vector3
	Specularity     float32
	Ambient         Vector3
	EdgeColor       Vector4
	EdgeSize        float32
	TextureTint     Vector4
	EnvironmentTint Vector4
	ToonTint        Vector4
}

type 8

type MorphUV

type MorphUV struct {
	Target int
	Value  Vector4
}

type 3

type MorphVertex

type MorphVertex struct {
	Target int
	Offset Vector3
}

type 1

type PMDParser

type PMDParser struct {
	// contains filtered or unexported fields
}

PMDParser is parser for .pmd model.

func NewPMDParser

func NewPMDParser(r io.Reader) *PMDParser

NewPMDParser returns new parser.

func (*PMDParser) Parse

func (p *PMDParser) Parse() (*Document, error)

Parse model data.

type PMXParser

type PMXParser struct {
	// contains filtered or unexported fields
}

PMXParser is parser for .pmx model.

func NewPMXParser

func NewPMXParser(r io.Reader) *PMXParser

NewPMXParser returns new parser.

func (*PMXParser) Parse

func (p *PMXParser) Parse() (*Document, error)

Parse model data.

type PMXWriter

type PMXWriter struct {
	// contains filtered or unexported fields
}

PMXWriter is writer for .pmx data

func (*PMXWriter) Write

func (w *PMXWriter) Write(doc *Document) error

type Vector2

type Vector2 struct {
	X float32
	Y float32
}

type Vector3

type Vector3 struct {
	X float32
	Y float32
	Z float32
}

type Vector4

type Vector4 struct {
	X float32
	Y float32
	Z float32
	W float32
}

type Vertex

type Vertex struct {
	Pos       Vector3
	Normal    Vector3
	UV        Vector2
	ExtUVs    []Vector4
	EdgeScale float32

	// TODO Matrix
	Bones       []int
	BoneWeights []float32
}

Jump to

Keyboard shortcuts

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