-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathactor.go
More file actions
81 lines (63 loc) · 1.76 KB
/
actor.go
File metadata and controls
81 lines (63 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package main
import "github.com/beevik/etree"
type Actor etree.Element
func LoadActor(path string) (*Actor, error) {
file, err := ActiveMod.Open(Actors+path)
if err != nil {
return nil, err
}
defer file.Close()
tree := etree.NewDocument()
if _, err := tree.ReadFrom(file); err != nil {
return nil, err
}
return (*Actor)(tree.Root()), nil
}
func (a *Actor) Mesh() string {
mesh := (*etree.Element)(a).FindElement("./group/variant/mesh")
if mesh == nil {
return ""
}
return Meshes+mesh.Text()
}
func (a *Actor) Props() map[string]string {
props := (*etree.Element)(a).FindElement("./group/variant/props")
if props == nil {
return nil
}
result := make(map[string]string)
for _, child := range props.ChildElements() {
if child.SelectAttr("attachpoint") != nil {
result[child.SelectAttr("actor").Value] = child.SelectAttr("attachpoint").Value
}
}
return result
}
func (a *Actor) Texture() string {
texture := (*etree.Element)(a).FindElement("./group/variant/textures/texture[@name='baseTex']")
if texture == nil {
return ""
}
return Textures+texture.SelectAttr("file").Value
}
func (a *Actor) Normal() string {
texture := (*etree.Element)(a).FindElement("./group/variant/textures/texture[@name='normTex']")
if texture == nil {
return ""
}
return Textures+texture.SelectAttr("file").Value
}
func (a *Actor) Specular() string {
texture := (*etree.Element)(a).FindElement("./group/variant/textures/texture[@name='specTex']")
if texture == nil {
return ""
}
return Textures+texture.SelectAttr("file").Value
}
func (a *Actor) AmbientOcclusion() string {
texture := (*etree.Element)(a).FindElement("./group/variant/textures/texture[@name='aoTex']")
if texture == nil {
return ""
}
return Textures+texture.SelectAttr("file").Value
}