forked from reyhard/o2scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RemoveRedundantUV.bio2s
188 lines (172 loc) · 6.06 KB
/
RemoveRedundantUV.bio2s
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
//#include "std\paramFile.inc"
#include "std\lodNames.inc"
lastLodShow=-1;
inLodShow={
private "_res";
bugreported=true;
if (lastLodShow!=_this) then
{
_res=eoln+"In level "+(_this call lodNameGetName)+":"+eoln;
lastLodShow=_this;
}
else
{
_res="";
};
_res
};
#define ERROR(x) {console<<(_resol call inLodShow)<<" "<<x<<eoln;}
console = openStandardIO;
_log = "p:\log.txt";
_wrnlog = "p:\wrn.txt";
shellCmd ("CMD /C DEL /Q "+_log+" 2>nul");
shellCmd ("CMD /C DEL /Q "+_wrnlog+" 2>nul");
//SSLogIn ["\\core1\vssdatap\cfg\srcsafe.ini","$/ca","p:\ca"];
f_toSSFormat = {
private ["_path","_index"];
_path = _this @ 0;
for "_index" from 0 to (count(_path) - 1) step 1 do {
if ((_path @ _index) == "\") then {
_path = _path @ [0,_index] + "/" + _path @ [_index + 1];
};
};
_path
};
f_toSVNFormat = {
private ["_path","_SVNPath","_exist","_folder","_folders"];
_path = (_this @ 0);
_folders = [];
_SVNPath = _this@1;
_exist = true;
while {_path != "p:"} do {
_folder = ((splitPath _path) select 2)+((splitPath _path) select 3);
_folders = [_folder] + _folders;
_path = _path @ [0, ((_path findI _folder) - 1)];
};
{
if (_exist) then {
_folderList = shellCmdOpenPipe ("c:\tools\subversion\bin\svn.exe list "+ _SVNPath);
_exist = false;
while {!eof _folderList && !_exist} do {
_line =getLine _folderList;
_name =_x;
if (_line@[(count _line)-1]=="/") then {_name=_name+"/"};
if (toLower (_name) == toLower (_line)) then {
_SVNPath = _SVNPath + _line;
_exist = true;
};
};
};
} forEach _folders;
if (!_exist) then {_SVNPath = ""};
_SVNPath
};
f_main =
{
// _mat = "P:\Ca\structures\Wall\Data\wall_cbrk.rvmat";
// _svn = "c:\tools\subversion\bin\svn.exe";
// _path = ((splitPath _mat) select 0)+((splitPath _mat) select 1);
// _path = _path@[0,count _path-1];
_fail =false;
_changed = false;
if (typename _this=="STRING") then
{
p3d=newLODObject;
p3dname=_this;
_fail = !(p3d loadP3d p3dname);
if (_fail) then { console<<"Unable to open:"<<p3dname<<eoln;};
runFromO2=false;
texpath=((splitPath p3dname) @ 0);
}
else
{
p3dname=nameof _this;
p3dname=splitPath p3dname;
p3dname=p3dname @ 2 + p3dname @ 3;
runFromO2=true;
p3d=_this;
};
if (!_fail) then
{
console<<"----------------------------------------------------------------------"<<eoln;
console<<"Checking file: "<<p3dname<<eoln;
objects=getObjects p3d;
resols=getResolutions p3d;
for "_i" from 0 to (count p3d-1) do
{
private ["_obj","_resol","_isol","_numsect","_degen"];
_resol=resols @ _i;
_obj=objects @ _i;
if (_resol<LOD_EDIT_MIN || _resol>=LOD_EDIT_MAX) then
{
//check 3. UV in visible LODS
if (IS_LOD_RESOLUTION(_resol)) then
{
_UV = getUVSetList _obj;
_count = count _UV;
if (_count>2) then
{
if (true) then ERROR("3rd UV not supported");
if ((0 in _UV)and (1 in _UV)) then
{
_obj setActiveUVSet 0;
_UV = _UV- [0,1];
{
_obj deleteUVSet _x;
}foreach _UV;
_changed=true;
} else ERROR("no 0 and 1 UV SET");
};
};
//check 2. UV in not visible LODS
if (NOT IS_LOD_RESOLUTION(_resol)) then
{
_UV = getUVSetList _obj;
_count = count _UV;
if (_count>1) then
{
if (true) then ERROR("2nd UV in special lod ");
if (0 in _UV) then
{
_obj setActiveUVSet 0;
_UV = _UV- [0];
{
_obj deleteUVSet _x;
}foreach _UV;
_changed=true;
} else ERROR("no 0 and 1 UV SET");
};
//mesh deleteUVSet UVSet_id
//mesh isUVSet UVSet_id
//mesh setActiveUVSet UVSet_id
};
};
};
if (_changed and !runFromO2) then
{
if (!save p3d)then {console <<"unable to SAVE "<<p3dname<<eoln;};
};
};
};
if (typename this=="STRING") then
{
_filename= this;
if (_filename@((count _filename) - 1)=="\") then
{
_stream = shellCmdOpenPipe ("CMD /C for /r "+_filename+" %i in (*.p3d)do @ECHO %i");
while {! eof _stream} do
{
(getline _stream) call f_main;
};
shellCmd("CMD /C pause");
console << "konec" << eoln;
}
else
{
_filename call f_main;
}
}
else
{
this call f_main;
};