mqo

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: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UpdateBoneRef

func UpdateBoneRef(bones []*BoneOld)

func WriteMQO

func WriteMQO(mqo *Document, ww io.Writer, path string) error

func WriteMQX

func WriteMQX(mqo *Document, w io.Writer, mqoName string) error

Types

type Bone

type Bone struct {
	ID       int      `xml:"id,attr"`
	Name     string   `xml:"name,attr"`
	Group    int      `xml:"group,attr,omitempty"`
	Parent   int      `xml:"parent,attr,omitempty"`
	Pos      Vector3  `xml:"pos,attr,omitempty"`
	Movable  int      `xml:"movable,attr,omitempty"`
	Hide     int      `xml:"hide,attr,omitempty"`
	Dummy    int      `xml:"dummy,attr,omitempty"`
	Color    string   `xml:"color,attr,omitempty"`
	UpVector *Vector3 `xml:"upVector,attr,omitempty"`
	Rotate   *Vector3 `xml:"rotate,attr,omitempty"`

	IK *BoneIK `xml:"IK,omitempty"`

	Weights []*BoneWeight2 `xml:"W"`
	// contains filtered or unexported fields
}

func (*Bone) SetVertexWeight

func (b *Bone) SetVertexWeight(objectID, vertID int, weight float32) *VertexWeight

type BoneIK

type BoneIK struct {
	ChainCount int `xml:"chain,attr"`
}

type BoneObj

type BoneObj struct {
	ID int `xml:"id,attr"`
}

type BoneOld

type BoneOld struct {
	ID      int    `xml:"id,attr"`
	Name    string `xml:"name,attr"`
	Group   int    `xml:"group,attr"`
	IsDummy int    `xml:"isDummy,attr"`

	RtX float32 `xml:"rtX,attr"`
	RtY float32 `xml:"rtY,attr"`
	RtZ float32 `xml:"rtZ,attr"`
	TpX float32 `xml:"tpX,attr"`
	TpY float32 `xml:"tpY,attr"`
	TpZ float32 `xml:"tpZ,attr"`

	MvX float32 `xml:"mvX,attr"`
	MvY float32 `xml:"mvY,attr"`
	MvZ float32 `xml:"mvZ,attr"`

	RotB float32 `xml:"rotB,attr"`
	RotH float32 `xml:"rotH,attr"`
	RotP float32 `xml:"rotP,attr"`

	Sc float32 `xml:"sc,attr"`

	MaxAngB float32 `xml:"maxAngB,attr"`
	MaxAngH float32 `xml:"maxAngH,attr"`
	MaxAngP float32 `xml:"maxAngP,attr"`

	MinAngB float32 `xml:"minAngB,attr"`
	MinAngH float32 `xml:"minAngH,attr"`
	MinAngP float32 `xml:"minAngP,attr"`

	Parent   BoneRef    `xml:"P"`
	Children []*BoneRef `xml:"C"`

	Weights []*BoneWeight `xml:"W"`
}

type BonePlugin

type BonePlugin struct {
	XMLName xml.Name `xml:"Plugin.56A31D20.71F282AB"`

	Name     string `xml:"name,attr"`
	BoneSet  BoneSet
	BoneSet2 BoneSet2
	PoseSet  PoseSet `xml:"Poses"`
	Obj      []BoneObj
}

func GetBonePlugin

func GetBonePlugin(mqo *Document) *BonePlugin

func (*BonePlugin) AddBone

func (p *BonePlugin) AddBone(b *Bone)

func (*BonePlugin) Bones

func (p *BonePlugin) Bones() []*Bone

func (*BonePlugin) PostDeserialize

func (p *BonePlugin) PostDeserialize(mqo *Document)

func (*BonePlugin) PreSerialize

func (p *BonePlugin) PreSerialize(mqo *Document)

func (*BonePlugin) SetBones

func (p *BonePlugin) SetBones(bones []*Bone)

func (*BonePlugin) Transform

func (p *BonePlugin) Transform(transform func(v *Vector3))

type BonePose

type BonePose struct {
	// oneof
	ID   int    `xml:"id,attr"`
	Name string `xml:"name,attr"`

	// Translation
	MvX float32 `xml:"mvX,attr"`
	MvY float32 `xml:"mvY,attr"`
	MvZ float32 `xml:"mvZ,attr"`

	// Rotation
	RotB float32 `xml:"rotB,attr"`
	RotH float32 `xml:"rotH,attr"`
	RotP float32 `xml:"rotP,attr"`

	// Scale
	ScB float32 `xml:"scB,attr"`
	ScH float32 `xml:"scH,attr"`
	ScP float32 `xml:"scP,attr"`
}

type BoneRef

type BoneRef struct {
	ID int `xml:"id,attr"`
}

type BoneSet

type BoneSet struct {
	Bone []*BoneOld
}

type BoneSet2

type BoneSet2 struct {
	Limit int     `xml:"limit,attr"`
	Bones []*Bone `xml:"Bone"`
}

type BoneWeight

type BoneWeight struct {
	ObjectID int     `xml:"oi,attr"`
	VertexID int     `xml:"vi,attr"`
	Weight   float32 `xml:"w,attr"`
}

type BoneWeight2

type BoneWeight2 struct {
	ObjectID int             `xml:"obj,attr"`
	Vertexes []*VertexWeight `xml:"V"`
}

type Document added in v0.2.1

type Document struct {
	Scene     *Scene
	Materials []*Material
	Objects   []*Object

	Plugins []Plugin
}

func NewDocument

func NewDocument() *Document

func Parse

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

Parse mqo file.

func (*Document) BoneAdjustX added in v0.2.2

func (doc *Document) BoneAdjustX(baseBone *Bone)

for T-Pose adjustment TODO: more generic function.

func (*Document) BoneTransform added in v0.2.3

func (doc *Document) BoneTransform(baseBone *Bone, transform func(v *Vector3))

func (*Document) FixObjectID added in v0.2.1

func (doc *Document) FixObjectID()

func (*Document) GetObjectByID added in v0.2.2

func (doc *Document) GetObjectByID(id int) *Object

func (*Document) GetPlugins added in v0.2.1

func (doc *Document) GetPlugins() []Plugin

func (*Document) Transform added in v0.2.1

func (doc *Document) Transform(transform func(v *Vector3))

Transform all objects and plugins

type Face

type Face struct {
	UID      int
	Verts    []int
	Material int
	UVs      []Vector2
}

type MQXDoc

type MQXDoc struct {
	XMLName    xml.Name `xml:"MetasequoiaDocument"`
	IncludedBy string

	Plugins []Plugin
}

func ReadMQX

func ReadMQX(r io.Reader) (*MQXDoc, error)

type Material

type Material struct {
	Name  string
	UID   int
	Color Vector4

	Diffuse  float32
	Ambient  float32
	Emission float32
	Specular float32
	Power    float32
	Texture  string

	EmissionColor *Vector3

	DoubleSided bool

	Shader int
	Ex2    *MaterialEx2
}

type MaterialEx2

type MaterialEx2 struct {
	ShaderType   string
	ShaderName   string
	ShaderParams map[string]interface{}
}

func (*MaterialEx2) FloatParam added in v0.2.1

func (m *MaterialEx2) FloatParam(name string) float64

func (*MaterialEx2) IntParam added in v0.2.1

func (m *MaterialEx2) IntParam(name string) int

func (*MaterialEx2) StringParam added in v0.2.1

func (m *MaterialEx2) StringParam(name string) string

type MorphPlugin

type MorphPlugin struct {
	XMLName xml.Name `xml:"Plugin.56A31D20.C452C6DB"`

	Name     string `xml:"name,attr"`
	MorphSet MorphSet
}

func GetMorphPlugin

func GetMorphPlugin(mqo *Document) *MorphPlugin

func (*MorphPlugin) Morphs added in v0.2.0

func (p *MorphPlugin) Morphs() []*MorphTargetList

func (*MorphPlugin) PostDeserialize

func (p *MorphPlugin) PostDeserialize(mqo *Document)

func (*MorphPlugin) PreSerialize

func (p *MorphPlugin) PreSerialize(mqo *Document)

type MorphSet

type MorphSet struct {
	Targets []*MorphTargetList `xml:"TargetList"`
}

type MorphTarget

type MorphTarget struct {
	Name  string `xml:"name,attr"`
	Param int    `xml:"param,attr"`
}

type MorphTargetList

type MorphTargetList struct {
	Base   string `xml:"base,attr"`
	Target []*MorphTarget
}

type Object

type Object struct {
	UID       int
	Name      string
	Vertexes  []*Vector3
	Faces     []*Face
	Visible   bool
	Locked    bool
	Depth     int
	Shading   int
	Facet     float32
	Patch     int
	Segment   int
	Mirror    int
	MirrorDis float32

	VertexByUID map[int]int
}

func NewObject

func NewObject(name string) *Object

func (*Object) Clone

func (o *Object) Clone() *Object

func (*Object) GetSmoothNormals added in v0.2.3

func (obj *Object) GetSmoothNormals() []Vector3

func (*Object) GetVertexIndexByID added in v0.2.1

func (o *Object) GetVertexIndexByID(uid int) int

func (*Object) Transform

func (o *Object) Transform(transform func(v *Vector3))

Transform object

type Parser

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

Parser for mqo file.

func NewParser

func NewParser(r io.Reader, fname string) *Parser

NewParser returns new parser.

func (*Parser) Parse

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

type Plugin

type Plugin interface {
	PreSerialize(mqo *Document)
	PostDeserialize(mqo *Document)
}

type PoseSet

type PoseSet struct {
	BonePoses []*BonePose `xml:"Pose"`
}

type Scene

type Scene struct {
	CameraPos    Vector3
	CameraLookAt Vector3
	CameraRot    Vector3
}

type Vector2

type Vector2 struct {
	X float32
	Y float32
}

type Vector3

type Vector3 struct {
	X float32
	Y float32
	Z float32
}

func (*Vector3) Add added in v0.2.3

func (v *Vector3) Add(v2 *Vector3) *Vector3

func (*Vector3) Len added in v0.2.2

func (v *Vector3) Len() float32

func (*Vector3) MarshalXMLAttr

func (v *Vector3) MarshalXMLAttr(name xml.Name) (xml.Attr, error)

func (*Vector3) Normalize added in v0.2.2

func (v *Vector3) Normalize()

func (*Vector3) Sub added in v0.2.2

func (v *Vector3) Sub(v2 *Vector3) *Vector3

func (*Vector3) ToArray added in v0.2.2

func (v *Vector3) ToArray(array []float32)

func (*Vector3) UnmarshalXMLAttr

func (v *Vector3) UnmarshalXMLAttr(attr xml.Attr) error

type Vector4

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

type VertexWeight

type VertexWeight struct {
	VertexID int     `xml:"v,attr"`
	Weight   float32 `xml:"w,attr"`
}

Jump to

Keyboard shortcuts

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