Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
TextureValidation.c
Go to the documentation of this file.
1
class
TextureValidationRequest :
JsonApiStruct
2
{
3
ref array<string> mats =
new
array<string>;
4
string
fbxPath;
5
6
void
TextureValidationRequest()
7
{
8
RegV(
"mats"
);
9
RegV(
"fbxPath"
);
10
}
11
}
12
13
class
TextureValidationResponse
:
JsonApiStruct
14
{
15
ref array<string>
invalidTextures
=
new
array<string>;
16
bool
xob
=
true
;
17
ref array<string>
xobMats
=
new
array<string>;
18
19
void
TextureValidationResponse
()
20
{
21
RegV(
"invalidTextures"
);
22
RegV(
"xob"
);
23
RegV(
"xobMats"
);
24
}
25
}
26
27
class
TextureValidationUtils
28
{
29
// Getting assigned materials from XOB
30
map<string, ResourceName>
GetMaterialAssigns(
string
xobPath,
TextureValidationResponse
response)
31
{
32
map<string,ResourceName>
materials =
new
map<string,ResourceName>
();
33
EBTEmatUtils ematUtils =
new
EBTEmatUtils();
34
bool
meta = ematUtils.GetMaterials(xobPath, materials);
35
if
(!meta)
36
{
37
return
materials;
38
}
39
40
for
(
int
i = 0; i < materials.Count(); i++)
41
{
42
response.xobMats.Insert(materials.GetKey(i));
43
}
44
return
materials;
45
}
46
47
array<string> GetInvalidTextures(
ResourceName
emat)
48
{
49
ResourceName
temp;
50
array<string> invalidText = {};
51
ResourceName
ematGuid = emat.Substring(0, emat.IndexOf(
"}"
)+ 1);
52
53
// check if the Resource in the xob meta corresponds to the GUID of the material
54
if
(ematGuid.Length() == 18)
55
{
56
string
resName = Workbench.GetResourceName(ematGuid);
57
if
(ematGuid == resName)
58
{
59
invalidText.Insert(
"Emat does not have valid GUID in XOB file"
);
60
return
invalidText;
61
}
62
}
63
// load the emat
64
Resource
resource =
Resource
.Load(emat);
65
BaseContainer
ematCont = resource.GetResource().ToBaseContainer();
66
67
for
(
int
i = 0; i < ematCont.GetNumVars(); i++)
68
{
69
ematCont.Get(ematCont.GetVarName(i), temp);
70
if
(ematCont.IsVariableSet(ematCont.GetVarName(i)))
71
{
72
// get textures
73
if
(temp.Contains(
".edds"
))
74
{
75
// check texture GUID the same way as the material one
76
ResourceName
texGuid = temp.Substring(0, temp.IndexOf(
"}"
)+ 1);
77
if
(texGuid.Length() == 18)
78
{
79
string
resName = Workbench.GetResourceName(texGuid);
80
if
(texGuid == resName)
81
{
82
// if the resource name is equal to the GUID that means workbench couldn't find the resource
83
invalidText.Insert(temp.Substring(0, temp.Length() - 2));
84
}
85
}
86
}
87
}
88
}
89
return
invalidText;
90
}
91
}
92
93
class
TextureValidation : NetApiHandler
94
{
95
override
JsonApiStruct
GetRequest
()
96
{
97
return
new
TextureValidationRequest
();
98
}
99
100
override
JsonApiStruct
GetResponse
(
JsonApiStruct
request)
101
{
102
TextureValidationRequest
req =
TextureValidationRequest
.Cast(request);
103
TextureValidationResponse
response =
new
TextureValidationResponse
();
104
TextureValidationUtils
utils =
new
TextureValidationUtils
();
105
array<string> invalidTextArr = {};
106
107
// get the material assigns from fbx
108
req.fbxPath.Replace(
".fbx"
,
".xob"
);
109
map<string, ResourceName>
matAssigns = utils.GetMaterialAssigns(req.fbxPath, response);
110
111
// return if no material was assigned
112
if
(matAssigns.IsEmpty())
113
{
114
response.xob =
false
;
115
return
response;
116
}
117
118
// checking all textures per material in the fbx
119
foreach
(
string
mat : req.mats)
120
{
121
string
invalidTextStr =
string
.Empty;
122
ResourceName emat = matAssigns.Get(mat);
123
// if mat in fbx exists but emat in matAssigns is empty
124
if
(emat ==
string
.Empty)
125
{
126
response.invalidTextures.Insert(
"Material is in FBX but not found in XOB"
);
127
continue
;
128
}
129
130
// list of all invalid textures for that material
131
invalidTextArr = utils.GetInvalidTextures(emat);
132
133
// add all invalid texture errors to the output
134
for
(
int
i = 0; i < invalidTextArr.Count(); i++)
135
{
136
invalidTextStr += invalidTextArr[i];
137
if
(i != invalidTextArr.Count() - 1)
138
{
139
invalidTextStr +=
", "
;
140
}
141
}
142
// insert the error messages of the invalid texture for that material
143
response.invalidTextures.Insert(invalidTextStr);
144
}
145
return
response;
146
}
147
}
GetResponse
override JsonApiStruct GetResponse(JsonApiStruct request)
Definition
AnimExportProfiles.c:97
GetRequest
SCR_AICombatMoveRequestBase GetRequest()
Definition
SCR_AICombatMoveState.c:137
invalidTextures
TextureValidationRequest invalidTextures
TextureValidationResponse
void TextureValidationResponse()
Definition
TextureValidation.c:19
xob
bool xob
Definition
TextureValidation.c:16
xobMats
ref array< string > xobMats
Definition
TextureValidation.c:17
BaseContainer
Definition
BaseContainer.c:13
JsonApiStruct
base classes for filtering in server browser
Definition
SCR_FeedbackDialogUI.c:3
Resource
Object holding reference to resource. In destructor release the resource.
Definition
Resource.c:25
ResourceName
Definition
ResourceName.c:13
TextureValidationRequest
Definition
TextureValidation.c:2
TextureValidationUtils
Definition
TextureValidation.c:28
map
Definition
Types.c:486
scripts
WorkbenchGameCommon
EnfusionBlenderTools
TextureValidation.c
Generated by
1.17.0