@@ -3,33 +3,34 @@ package axe
3
3
import (
4
4
"regexp"
5
5
6
+ "github.com/axe/axe-go/pkg/asset"
6
7
"github.com/udhos/gwob"
7
8
)
8
9
9
- var _ AssetFormat = & MtlFormat {}
10
+ var _ asset. Format = & MtlFormat {}
10
11
var mtlFormatRegex , _ = regexp .Compile (`\.mtl$` )
11
12
12
13
type MtlFormat struct {
13
14
}
14
15
15
- func (format * MtlFormat ) Handles (ref AssetRef ) bool {
16
+ func (format * MtlFormat ) Handles (ref asset. Ref ) bool {
16
17
return mtlFormatRegex .MatchString (ref .URI )
17
18
}
18
19
19
- func (format * MtlFormat ) Types () []AssetType {
20
- return []AssetType { AssetTypeModel }
20
+ func (format * MtlFormat ) Types () []asset. Type {
21
+ return []asset. Type { asset . TypeModel }
21
22
}
22
23
23
- func (format * MtlFormat ) Load (asset * Asset ) error {
24
- lib , err := gwob .ReadMaterialLibFromReader (asset .SourceReader , & gwob.ObjParserOptions {})
24
+ func (format * MtlFormat ) Load (a * asset. Asset ) error {
25
+ lib , err := gwob .ReadMaterialLibFromReader (a .SourceReader , & gwob.ObjParserOptions {})
25
26
26
27
if err != nil {
27
- asset .LoadStatus .Fail (err )
28
+ a .LoadStatus .Fail (err )
28
29
return err
29
30
}
30
31
31
32
materials := Materials {}
32
- asset .Dependent = make ([]AssetRef , 0 )
33
+ a .Dependent = make ([]asset. Ref , 0 )
33
34
34
35
for materialName , material := range lib .Lib {
35
36
mat := Material {
@@ -57,39 +58,39 @@ func (format *MtlFormat) Load(asset *Asset) error {
57
58
}
58
59
59
60
if mat .Ambient .Texture != "" {
60
- asset .AddNext (mat .Ambient .Texture , true )
61
+ a .AddNext (mat .Ambient .Texture , true )
61
62
}
62
63
if mat .Specular .Texture != "" {
63
- asset .AddNext (mat .Specular .Texture , true )
64
+ a .AddNext (mat .Specular .Texture , true )
64
65
}
65
66
if mat .Diffuse .Texture != "" {
66
- asset .AddNext (mat .Diffuse .Texture , true )
67
+ a .AddNext (mat .Diffuse .Texture , true )
67
68
}
68
69
if mat .Emissive .Texture != "" {
69
- asset .AddNext (mat .Emissive .Texture , true )
70
+ a .AddNext (mat .Emissive .Texture , true )
70
71
}
71
72
if mat .TextureBump != "" {
72
- asset .AddNext (mat .TextureBump , true )
73
+ a .AddNext (mat .TextureBump , true )
73
74
}
74
75
75
76
materials [materialName ] = mat
76
77
}
77
78
78
- asset .Data = materials
79
- asset .LoadStatus .Success ()
79
+ a .Data = materials
80
+ a .LoadStatus .Success ()
80
81
81
82
return nil
82
83
}
83
84
84
- func (format * MtlFormat ) Unload (asset * Asset ) error {
85
+ func (format * MtlFormat ) Unload (asset * asset. Asset ) error {
85
86
asset .LoadStatus .Reset ()
86
87
return nil
87
88
}
88
- func (format * MtlFormat ) Activate (asset * Asset ) error {
89
+ func (format * MtlFormat ) Activate (asset * asset. Asset ) error {
89
90
asset .ActivateStatus .Success ()
90
91
return nil
91
92
}
92
- func (format * MtlFormat ) Deactivate (asset * Asset ) error {
93
+ func (format * MtlFormat ) Deactivate (asset * asset. Asset ) error {
93
94
asset .ActivateStatus .Reset ()
94
95
return nil
95
96
}
0 commit comments