mmd

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2022 License: MIT Imports: 13 Imported by: 0

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 Save added in v0.3.1

func Save(doc *Document, path string) error

func WritePMX

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

WritePMX writes .pmx data

Types

type Animation added in v0.2.4

type Animation struct {
	Name   string
	Bone   []*AnimationBoneSample
	Morph  []*AnimationMorphSample
	Camera []*AnimationCameraSample
	Light  []*AnimationLightSample
}

func (*Animation) GetBoneChannels added in v0.3.0

func (a *Animation) GetBoneChannels() map[string]*BoneChannel

func (*Animation) GetMorphChannels added in v0.3.0

func (a *Animation) GetMorphChannels() map[string]*MorphChannel

type AnimationBoneSample added in v0.2.4

type AnimationBoneSample struct {
	Target   string
	Frame    int
	Position Vector3
	Rotation Quaternion
	Params   [64]byte
}

type AnimationCameraSample added in v0.2.4

type AnimationCameraSample struct {
	Frame      int
	Distance   float32
	Position   Vector3
	Rotation   Vector3 // 4?
	Params     [24]byte
	FoV        float32
	Projection byte
}

type AnimationLightSample added in v0.2.4

type AnimationLightSample struct {
	Frame    int
	Color    Vector3
	Position Vector3
}

type AnimationMorphSample added in v0.2.4

type AnimationMorphSample struct {
	Target string
	Frame  int
	Value  float32
}

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 BoneChannel added in v0.3.0

type BoneChannel struct {
	Target    string
	Keyframes []*AnimationBoneSample
	Frames    []uint32
	Rotations []*Quaternion
	Positions []*Vector3
}

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
	Bodies    []*RigidBody
	Joints    []*Joint
}

func Load added in v0.3.1

func Load(path string) (*Document, error)

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 Joint added in v0.3.5

type Joint struct {
	Name   string
	NameEn string
	Type   uint8
	Body1  int
	Body2  int

	Position geom.Vector3
	Rotation geom.Vector3

	// Constrains
	PositionMin geom.Vector3
	PositionMax geom.Vector3
	RotationMin geom.Vector3
	RotationMax geom.Vector3

	LinerSpring   geom.Vector3
	AngulerSpring geom.Vector3
}
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 MorphChannel added in v0.3.0

type MorphChannel struct {
	Target    string
	Keyframes []*AnimationMorphSample
	Frames    []uint32
	Weights   []float32
}

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 Quaternion added in v0.3.0

type Quaternion = geom.Vector4

type RigidBody added in v0.3.5

type RigidBody struct {
	Name        string
	NameEn      string
	Bone        int
	Group       int
	GroupTarget int
	Shape       uint8

	Size     geom.Vector3
	Position geom.Vector3
	Rotation geom.Vector3

	Mass float32

	LinearDamping  float32
	AngularDamping float32
	Restitution    float32
	Friction       float32

	Mode uint8 // kinematic?
}

type VMDParser added in v0.2.4

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

VMDParser is parser for .vmd animation.

func NewVMDParser added in v0.2.4

func NewVMDParser(r io.Reader) *VMDParser

NewVMDParser returns new parser.

func (*VMDParser) Parse added in v0.2.4

func (p *VMDParser) Parse() (*Animation, error)

Parse animation data.

type Vector2

type Vector2 = geom.Vector2

type Vector3

type Vector3 = geom.Vector3

type Vector4

type Vector4 = geom.Vector4

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