├── prefs
├── icons
│ ├── bem.png
│ ├── dc.png
│ ├── dh.png
│ ├── ef.png
│ ├── exp.png
│ ├── eye.png
│ ├── ft.png
│ ├── hs.png
│ ├── imp.png
│ ├── mr.png
│ ├── psf.png
│ ├── psw.png
│ ├── qna.png
│ ├── qnd.png
│ ├── sq1.png
│ ├── sq2.png
│ ├── sq3.png
│ ├── sq4.png
│ ├── uv.png
│ ├── bakec.png
│ ├── baron.png
│ ├── bush.png
│ ├── expsl.png
│ ├── four.png
│ ├── frot.png
│ ├── group.png
│ ├── gtbp.png
│ ├── layer.png
│ ├── lmuv.png
│ ├── lmuvd.png
│ ├── mirror.png
│ ├── pref.png
│ ├── rebind.png
│ ├── sepmat.png
│ ├── setbp.png
│ ├── conform.png
│ ├── frotsel.png
│ ├── hsdelete.png
│ ├── reverse.png
│ └── texture.png
└── shelves
│ ├── shelf_LoLMaya.mel
│ └── shelf_LoLMaya_MAPGEO.mel
├── scripts
├── MAPGEOTranslatorOpts.mel
├── ANMTranslatorOpts.mel
└── SKNTranslatorOpts.mel
├── .gitignore
├── README.md
└── LICENSE
/prefs/icons/bem.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/bem.png
--------------------------------------------------------------------------------
/prefs/icons/dc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/dc.png
--------------------------------------------------------------------------------
/prefs/icons/dh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/dh.png
--------------------------------------------------------------------------------
/prefs/icons/ef.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/ef.png
--------------------------------------------------------------------------------
/prefs/icons/exp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/exp.png
--------------------------------------------------------------------------------
/prefs/icons/eye.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/eye.png
--------------------------------------------------------------------------------
/prefs/icons/ft.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/ft.png
--------------------------------------------------------------------------------
/prefs/icons/hs.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/hs.png
--------------------------------------------------------------------------------
/prefs/icons/imp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/imp.png
--------------------------------------------------------------------------------
/prefs/icons/mr.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/mr.png
--------------------------------------------------------------------------------
/prefs/icons/psf.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/psf.png
--------------------------------------------------------------------------------
/prefs/icons/psw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/psw.png
--------------------------------------------------------------------------------
/prefs/icons/qna.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/qna.png
--------------------------------------------------------------------------------
/prefs/icons/qnd.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/qnd.png
--------------------------------------------------------------------------------
/prefs/icons/sq1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/sq1.png
--------------------------------------------------------------------------------
/prefs/icons/sq2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/sq2.png
--------------------------------------------------------------------------------
/prefs/icons/sq3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/sq3.png
--------------------------------------------------------------------------------
/prefs/icons/sq4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/sq4.png
--------------------------------------------------------------------------------
/prefs/icons/uv.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/uv.png
--------------------------------------------------------------------------------
/prefs/icons/bakec.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/bakec.png
--------------------------------------------------------------------------------
/prefs/icons/baron.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/baron.png
--------------------------------------------------------------------------------
/prefs/icons/bush.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/bush.png
--------------------------------------------------------------------------------
/prefs/icons/expsl.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/expsl.png
--------------------------------------------------------------------------------
/prefs/icons/four.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/four.png
--------------------------------------------------------------------------------
/prefs/icons/frot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/frot.png
--------------------------------------------------------------------------------
/prefs/icons/group.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/group.png
--------------------------------------------------------------------------------
/prefs/icons/gtbp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/gtbp.png
--------------------------------------------------------------------------------
/prefs/icons/layer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/layer.png
--------------------------------------------------------------------------------
/prefs/icons/lmuv.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/lmuv.png
--------------------------------------------------------------------------------
/prefs/icons/lmuvd.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/lmuvd.png
--------------------------------------------------------------------------------
/prefs/icons/mirror.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/mirror.png
--------------------------------------------------------------------------------
/prefs/icons/pref.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/pref.png
--------------------------------------------------------------------------------
/prefs/icons/rebind.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/rebind.png
--------------------------------------------------------------------------------
/prefs/icons/sepmat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/sepmat.png
--------------------------------------------------------------------------------
/prefs/icons/setbp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/setbp.png
--------------------------------------------------------------------------------
/prefs/icons/conform.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/conform.png
--------------------------------------------------------------------------------
/prefs/icons/frotsel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/frotsel.png
--------------------------------------------------------------------------------
/prefs/icons/hsdelete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/hsdelete.png
--------------------------------------------------------------------------------
/prefs/icons/reverse.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/reverse.png
--------------------------------------------------------------------------------
/prefs/icons/texture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tarngaina/lol_maya/HEAD/prefs/icons/texture.png
--------------------------------------------------------------------------------
/scripts/MAPGEOTranslatorOpts.mel:
--------------------------------------------------------------------------------
1 | global proc int MAPGEOTranslatorOpts (string $parent, string $action, string $initialSettings, string $resultCallback)
2 | {
3 | if ($action == "post") {
4 | setParent $parent;
5 | formLayout form;
6 | checkBox -label "Use Standard Surface material" ssmat;
7 | formLayout -e -attachPosition ssmat left 0 0 -attachPosition ssmat right 0 0 -attachPosition ssmat top 0 0 form;
8 |
9 | string $temp[];
10 | tokenize($initialSettings, "=", $temp);
11 | if ($temp[1] == "0")
12 | checkBox -edit -value 0 ssmat;
13 | else
14 | checkBox -edit -value 1 ssmat;
15 | return 1;
16 | }
17 | else if ($action == "query") {
18 | string $temp2;
19 | if (`checkBox -q -value ssmat` == 0)
20 | $temp2 = "ssmat=0";
21 | else
22 | $temp2 = "ssmat=1";
23 | eval($resultCallback+" \""+$temp2+"\"");
24 | return 1;
25 | }
26 | return 0;
27 | }
--------------------------------------------------------------------------------
/scripts/ANMTranslatorOpts.mel:
--------------------------------------------------------------------------------
1 | global proc int ANMTranslatorOpts (string $parent, string $action, string $initialSettings, string $resultCallback)
2 | {
3 | if ($action == "post") {
4 | setParent $parent;
5 | formLayout form;
6 | checkBox -label "Delete existing scene animation before import." delchannel;
7 | formLayout -e -attachPosition delchannel left 0 0 -attachPosition delchannel right 0 0 -attachPosition delchannel top 0 0 form;
8 |
9 | string $temp[];
10 | tokenize($initialSettings, "=", $temp);
11 | if ($temp[1] == "0")
12 | checkBox -edit -value 0 delchannel;
13 | else
14 | checkBox -edit -value 1 delchannel;
15 | return 1;
16 | }
17 | else if ($action == "query") {
18 | string $temp2;
19 | if (`checkBox -q -value delchannel` == 0)
20 | $temp2 = "delchannel=0";
21 | else
22 | $temp2 = "delchannel=1";
23 | eval($resultCallback+" \""+$temp2+"\"");
24 | return 1;
25 | }
26 | return 0;
27 | }
--------------------------------------------------------------------------------
/scripts/SKNTranslatorOpts.mel:
--------------------------------------------------------------------------------
1 | global proc int SKNTranslatorOpts (string $parent, string $action, string $initialSettings, string $resultCallback)
2 | {
3 | if ($action == "post") {
4 | setParent $parent;
5 | formLayout form;
6 | checkBox -label "Import skeleton: load SKL in same directory and bind with SKN as skin cluster." skl;
7 | formLayout -e -attachPosition skl left 0 0 -attachPosition skl right 0 0 -attachPosition skl top 0 0 form;
8 | checkBox -label "Import mesh separated by material." sepmat;
9 | formLayout -e -attachPosition sepmat left 0 0 -attachPosition sepmat right 0 0 -attachPosition sepmat top 0 60 form;
10 |
11 | string $options[];
12 | string $option[];
13 | tokenize($initialSettings, ";", $options);
14 | for ($index = 0; $index < size($options); $index++) {
15 | tokenize($options[$index], "=", $option);
16 | if ($option[0] == "skl") {
17 | if ($option[1] == "0")
18 | checkBox -edit -value 0 skl;
19 | else
20 | checkBox -edit -value 1 skl;
21 | }
22 | else if ($option[0] == "sepmat") {
23 | if ($option[1] == "0")
24 | checkBox -edit -value 0 sepmat;
25 | else
26 | checkBox -edit -value 1 sepmat;
27 | }
28 | }
29 | return 1;
30 | }
31 | else if ($action == "query") {
32 | string $options;
33 | if (`checkBox -q -value skl` == 0)
34 | $options = "skl=0";
35 | else
36 | $options = "skl=1";
37 |
38 | if (`checkBox -q -value sepmat` == 0)
39 | $options = $options + ";sepmat=0";
40 | else
41 | $options = $options + ";sepmat=1";
42 | eval($resultCallback+" \""+$options+"\"");
43 | return 1;
44 | }
45 | return 0;
46 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | build/
12 | develop-eggs/
13 | dist/
14 | downloads/
15 | eggs/
16 | .eggs/
17 | lib/
18 | lib64/
19 | parts/
20 | sdist/
21 | var/
22 | wheels/
23 | pip-wheel-metadata/
24 | share/python-wheels/
25 | *.egg-info/
26 | .installed.cfg
27 | *.egg
28 | MANIFEST
29 |
30 | # PyInstaller
31 | # Usually these files are written by a python script from a template
32 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
33 | *.manifest
34 | *.spec
35 |
36 | # Installer logs
37 | pip-log.txt
38 | pip-delete-this-directory.txt
39 |
40 | # Unit test / coverage reports
41 | htmlcov/
42 | .tox/
43 | .nox/
44 | .coverage
45 | .coverage.*
46 | .cache
47 | nosetests.xml
48 | coverage.xml
49 | *.cover
50 | *.py,cover
51 | .hypothesis/
52 | .pytest_cache/
53 |
54 | # Translations
55 | *.mo
56 | *.pot
57 |
58 | # Django stuff:
59 | *.log
60 | local_settings.py
61 | db.sqlite3
62 | db.sqlite3-journal
63 |
64 | # Flask stuff:
65 | instance/
66 | .webassets-cache
67 |
68 | # Scrapy stuff:
69 | .scrapy
70 |
71 | # Sphinx documentation
72 | docs/_build/
73 |
74 | # PyBuilder
75 | target/
76 |
77 | # Jupyter Notebook
78 | .ipynb_checkpoints
79 |
80 | # IPython
81 | profile_default/
82 | ipython_config.py
83 |
84 | # pyenv
85 | .python-version
86 |
87 | # pipenv
88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
91 | # install all needed dependencies.
92 | #Pipfile.lock
93 |
94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow
95 | __pypackages__/
96 |
97 | # Celery stuff
98 | celerybeat-schedule
99 | celerybeat.pid
100 |
101 | # SageMath parsed files
102 | *.sage.py
103 |
104 | # Environments
105 | .env
106 | .venv
107 | env/
108 | venv/
109 | ENV/
110 | env.bak/
111 | venv.bak/
112 |
113 | # Spyder project settings
114 | .spyderproject
115 | .spyproject
116 |
117 | # Rope project settings
118 | .ropeproject
119 |
120 | # mkdocs documentation
121 | /site
122 |
123 | # mypy
124 | .mypy_cache/
125 | .dmypy.json
126 | dmypy.json
127 |
128 | # Pyre type checker
129 | .pyre/
130 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | This plugin is moved into [LtMAO.lemon3d](https://github.com/tarngaina/LtMAO?tab=readme-ov-file#lemon3d), this repo no longer get updates.
2 |
3 | # LoL Maya 2023
4 | An attempt to update RiotFileTranslator to Maya 2023.
5 |
6 | 
7 |
8 | ### Installation:
9 | 1. [Click here and download latest release.](https://github.com/tarngaina/lol_maya/releases)
10 |
11 |
12 | 2. Extract all `plug-ins`, `prefs` and `scripts` folder to `Documents` \ `maya` \ `2023`.
13 |
14 | 
15 |
16 | 3. In Maya toolbar, select `Windows` > `Settings/Preferences` > `Plug-in Manager`.
17 |
18 | 
19 |
20 | 4. Tick `Load` / `Auto Load` on the plug-in `lol_maya.py`.
21 |
22 | 
23 |
24 |
25 | ### File translators:
26 | 1. Misc:
27 | - Add fix for read/write file with suffix in name.
28 | - Export base on original file:
29 | - How to: have at least 1 of 2 files below in export location:
30 | - `riot_{name of export file}.EXT` (take priority first)
31 | - `riot.EXT`
32 | - File type support (EXT):
33 | - SKN: For fixing incorrect transparent faces on champions.
34 | - SKL: For fixing bad animation blending of champions that have animation layers.
35 | - SCO, SCB: For fixing incorrect pivot and central point.
36 | - MAPGEO: For fixing map crashed while casting a skill has ground indicator.
37 | - Example: If you want to export modified `yone_base.skl` base on original file, you must have either `riot_yone_base.skl` or `riot.skl` in export location; if you have both of them, `riot_yone_base.skl` will take priority.
38 | 2. SKN:
39 | - SKN data in Maya scene:
40 | - Combined mesh : A single mesh that:
41 | - Materials and UVs assigned on all faces.
42 | - All face normals point inward.
43 | - Bound with joints as a skin cluster and have weight painted on all vertices.
44 |
45 | 
46 | - Group meshes: A group of combined mesh.
47 |
48 | 
49 | - Read:
50 | - `33 22 11 00`: V0, V1, V2, V4
51 | - SKN import options:
52 | - Import skeleton: load with SKL as skin cluster.
53 | - Material that has duplicated name with another joint will be renamed to full lowercase letters.
54 | - Example: If there is a joint `Fish`, material `Fish` will be renamed to `fish` in scene.
55 | - Import mesh separated by material: load SKN as group meshes separated by materials.
56 |
57 | 
58 |
59 | - Write:
60 | - To export:
61 | - Combined mesh: select the bound mesh -> use export selection.
62 | - Group meshes: select the group of bound meshes -> use export selection.
63 | - `33 22 11 00`: V1
64 | - Limit vertices: 65535.
65 | - Show/select component on error:
66 | - Vertex: 4+ influences vertex, material shared vertex, non UVs assigned vertex.
67 | - Face: invalid triangulation face, non material assigned face, non UVs assigned face.
68 | 3. SKL:
69 | - SKL data in Maya scene: all joints in scene, it does not matter if ther are bound or not.
70 | - Read:
71 | - `r3d2sklt`: V1, V2
72 | - `C3 4F FD 22`: V0
73 | - Write:
74 | - To export: will be exported with SKN.
75 | - `C3 4F FD 22`: V0
76 | - Limit joints: 256
77 | - New SKL data, no need to update/convert.
78 | 4. ANM:
79 | - ANM data in Maya scene:
80 | - Translate + Rotate + Scale keyframes of all joints in scene from animation start time + 1 to animation end time on Time Slider.
81 |
82 | **Example**: If the animation time range is -5 to 14 like in the below picture, keyframes will be exported from time -4 (-5+1) to 14.
83 | 
84 | - FPS support: 30/60.
85 | - Read:
86 | - `r3d2canm`
87 | - `r3d2anmd`: V3, V4, V5
88 | - To delete existing scene animations before load ANM, change ANM import options to:
89 |
90 | 
91 |
92 | - To ensure importing FPS and animation range from ANM file, change ANM import options to:
93 |
94 | 
95 | - Write:
96 | - To export: use export all.
97 | - `r3d2anmd`: V4
98 | - Uncompressed, scaling support.
99 | - No need to convert with lol2dae or edit 1E hex.
100 | 5. Static object:
101 | - Static object in Maya scene:
102 | - A single mesh that:
103 | - UVs assigned on all faces.
104 | - All face normals point inward.
105 | - Central point: is translation of mesh's transform.
106 | - Pivot point (SCO only, optional): is translation of an additional joint that bound with mesh.
107 |
108 | 
109 | - Read:
110 | - SCO
111 | - SCB: `r3d2Mesh`: V1, V2, V3
112 | - Write:
113 | - To export: select the mesh -> use export selection.
114 | - SCO
115 | - SCB: `r3d2Mesh`: V3
116 | - Show/select component on error:
117 | - Face: invalid triangulation face, non UVs assigned face.
118 | - No need to convert with Wooxy.
119 |
120 |
121 | ### Shelf buttons
122 | 
123 | 1. Hover mouse on shelf buttons to read tooltip.
124 | 2. Explain some buttons:
125 | - Namespace buttons: Quickly add/remove a temporary namespace on selected objects.
126 | - Separated mesh button: Separate selected mesh by materials.
127 | - Fix shared vertices button.
128 | - Martin UV helper: move selected UVs to specific corner.
129 | - Update bind pose button: set current pose as bind pose for skin cluster, require: select single joint of the skin cluster.
130 | - Freeze joints buttons: Freeze/bake selected/all joints rotation.
131 | - Mirror joint buttons: work great if joints rotations have been frozen.
132 | - L<->R: mirror rotation of a selected joint startswith `L_` or `R_` to the opposite joint.
133 | - A<->B: mirror rotation of first selected joint to second selected joint.
134 | - 4 influences fix button: prune and force max 4 influences on selected skin cluster.
135 | - Rebind button: Quickly unbind, delete history, rebind selected skin cluster.
136 |
137 | ### MAPGEO
138 | 1. MAPGEO data in Maya scene:
139 | - A group of meshes that:
140 | - Materials and UVs assigned on all faces.
141 | - All face normals point inward.
142 |
143 | 
144 |
145 | - Material:
146 | - Material names in MAPGEO files or in BIN files are used with `/`, this character can't be used in Maya, so all `/` will be converted to `__` when import, and will be converted back to `/` when export.
147 | - Example:
148 | - In mapgeo or bin: `Maps/KitPieces/Howling_Abyss/Materials/Keep_inst`
149 | - In Maya: `Maps__KitPieces__Howling_Abyss__Materials__Keep_inst`
150 | - Material type that used in Maya for MAPGEO by default is Lambert, however, Standard Surface / Arnold's Standard Surface is more advanced to use when export/import materials data through shelf buttons.
151 | - To import MAPGEO using Standard Surface materials, change MAPGEO import options to:
152 |
153 | 
154 | - Layer:
155 | - A map must have 8 layers, equal to 8 `set` in Maya.
156 |
157 | 
158 | - If an object is assigned to a layer, it will appear on that layer in game.
159 | - An object can be assigned to multiple layers, if it is assigned on all 8 layers, it will appear on all 8 layers.
160 | - Layer in Summoner Rift (SR):
161 | - Layer 1: Base
162 | - Layer 2: Inferno
163 | - Layer 3: Mountain
164 | - Layer 4: Ocean
165 | - Layer 5: Cloud
166 | - Layer 6: Hextech
167 | - Layer 7: Chemtech
168 | - Layer 8: Unknown
169 | - Example in SR: if mesh assigned to `set2` -> that object will appear in layer 2 - Inferno map.
170 | - Layer in Aram / other maps: objects are always assigned to all 8 layers.
171 |
172 | - Bushes:
173 | - Similar to `set` for Layers, a map also must have `setBushes` to indicate which mesh is bush.
174 |
175 | 
176 |
177 | - If an object is assigned to `setBushes`, it is bush. (yep)
178 |
179 | - Baron (only SR):
180 | - When importing mapgeo, there is `setBaron` to indicate which mesh belong to Baron area. This `setBaron` is just for better organizing in Maya and do not require when exporting mapgeo.
181 | - However, those meshes must have an extra attribute called `Bucket Hash` and this `Bucket Hash` is the thing that will get imported/exported.
182 |
183 | 
184 |
185 | - `Bucket Hash`: is a FNV1a hash value that can be found in `materials.bin`. When exporting, if your entered value is not a correct hash, the mesh will be exported with default value: 0.
186 | - There is also a shelf button for assign/remove meshes to/from `setBaron` and create `Bucket Hash` attribute on them.
187 |
188 | - Bucket Grid (Important):
189 | - Bucket Grid can only be achieved by exporting base on original MAPGEO file. (aka `riot.mapgeo` method)
190 | - If you export without Bucket Grid, the modified map will crash League or event worse, freeze you computer.
191 |
192 | - Lightmap (Optional):
193 | - 2nd texture & UVs to store light data in, will blend with main texture (diffuse texture) in game.
194 | - Lightmap contains two things: Name and UVs data
195 |
196 | 
197 | - Name:
198 | - If there is no lightmap: The group name can be whatever it is.
199 | - If there is lightmap: The group name must be lightmap folder path and have `riot_` before it. Example: In Aram, keep this name if you want original lightmap work.
200 |
201 | 
202 |
203 | - Example Lightmap name in Aram: `ASSETS/Maps/Lightmaps/Maps/MapGeometry/Map12/Base/2.dds`
204 | - UVs data: 2nd UV set of mesh, can be generated by a button on shelf.
205 | - You don't need to have Lightmap if you can bake light straight into main texture, like Riot did with SR.
206 | 2. Read:
207 | - `OEGM`: V5, V6, V7, V9, V11, V12, V13, V14, V15
208 | 3. Write:
209 | - To export: select the group of meshes -> use export selection.
210 | - `OEGM`: V15
211 | - Limit vertices for each mesh: 65535.
212 | - Show/select component on error:
213 | - Vertex: material shared vertex, non UVs assigned vertex.
214 | - Face: invalid triangulation face, non material assigned face, non UVs assigned face.
215 | - Diffuse UVs must be in 1st UV set; if model uses Lightmap, Lightmap UVs must be in 2nd UV set.
216 | - Freeze all meshes's transform before you export for better organized.
217 |
218 | 
219 | 4. Shelf buttons:
220 |
221 | 
222 |
223 | Explain buttons from left to right:
224 | - Rename path of selected objects with input prefix.
225 | - Rename selected objects with input prefix.
226 | - Toggle on/off all layers on selected mesh.
227 | - Toggle on/off layer 1 - 8 on selected mesh.
228 | - Assigned to / remove from `setBushes` on selected mesh.
229 | - Assigned to / remove from `setBaron` on selected mesh, also create `Bucket Hash` attribute if not existed.
230 | - Select all faces of all meshes that have same assigned material as selected face.
231 | - Set all black emissions weight to 0.
232 | - Fix shared vertices on all meshes in scene.
233 | - Import `materials.py`:
234 | - Read `materials.py` file to import textures.
235 | - `assets` folder must be in same location as `materials.py`.
236 | - Export `materials.json`: export all materials of selected meshes to a json file; all textures will be copied to same export location; if nothing get selected, this button export all materials in scene instead; `materials.json` can be read by `Avatar (made by Killery)` to convert back to `materials.py`.
237 | - Export `materials.py`: export all materials of selected meshes to a py file; all textures will be copied to same export location; if nothing get selected, this button export all materials in scene instead; only diffuse textures will be exported and only export into `default_env` shader.
238 | - Check if materials of selected meshes are not defined in `materials.py`, if nothing get selected, this button will check all materials in scene instead.
239 | - Extra: League shader <-> Maya shader:
240 | - Lambert / Other materials:
241 | - Diffuse Texture -> Color / Transparency
242 | - Standard Surface / Arnold's Standard Surface:
243 | - Diffuse Texture <-> Base
244 | - Glow Texture <-> Base, Glow Color <-> Glow
245 | - Mask Color <-> Coat, Mask Texture <-> Coat Normal
246 | - Emissive Texture <-> Emissive Color <-> Emission
247 | - Generate Lightmap UVs on 2nd UV set of selected objects.
248 | - Delete Lightmap UVs and 2nd UV set of selected objects.
249 | - Bake texture: bake textures with [Arnold](https://arnoldrenderer.com/download/) on selected objects.
250 |
251 | 
252 |
253 | - Output: Location of output baked textures.
254 | - No diffuse:
255 | - On: Bake only light - use 2nd UV set of selected objects and default material `standardSurface1` to bake.
256 | - Off: Bake with diffuse - use 1st UV set of selected objects and their own materials to bake.
257 | - Quality: You will want High quality bake for diffuse and Low quality bake for lightmap.
258 | - Resolution: Resolution of baked textures; integer input, should be 256, 512, 1024,...
259 |
260 | ### External Links:
261 |
262 | - [LeagueFileTranlastor](https://github.com/LoL-Fantome/LeagueFileTranslator)
263 |
264 | - [LeagueToolKit](https://github.com/LoL-Fantome/LeagueToolkit)
265 |
266 | - [LoL2Blender](https://github.com/WorldSEnder/LoL2Blender)
267 |
268 | - [Maya SDK Reference](https://help.autodesk.com/view/MAYAUL/2024/ENU/?guid=MAYA_API_REF_cpp_ref_index_html)
269 |
270 | - [Arnold](https://docs.arnoldrenderer.com/display/A5AFMUG/Arnold+for+Maya+User+Guide)
271 |
272 | - [Avatar](https://github.com/TheKillerey/Avatar)
273 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/prefs/shelves/shelf_LoLMaya.mel:
--------------------------------------------------------------------------------
1 | global proc shelf_LoLMaya () {
2 | global string $gBuffStr;
3 | global string $gBuffStr0;
4 | global string $gBuffStr1;
5 |
6 |
7 | shelfButton
8 | -enableCommandRepeat 1
9 | -flexibleWidthType 3
10 | -flexibleWidthValue 32
11 | -enable 1
12 | -width 35
13 | -height 34
14 | -manage 1
15 | -visible 1
16 | -preventOverride 0
17 | -annotation "Add the file to the current scene"
18 | -enableBackground 0
19 | -backgroundColor 0 0 0
20 | -highlightColor 0.321569 0.521569 0.65098
21 | -align "center"
22 | -label "Import..."
23 | -labelOffset 0
24 | -rotation 0
25 | -flipX 0
26 | -flipY 0
27 | -useAlpha 1
28 | -font "plainLabelFont"
29 | -overlayLabelColor 0.8 0.8 0.8
30 | -overlayLabelBackColor 0 0 0 0.5
31 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/imp.png"
32 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/imp.png"
33 | -style "iconOnly"
34 | -marginWidth 0
35 | -marginHeight 1
36 | -command "Import"
37 | -sourceType "mel"
38 | -commandRepeatable 1
39 | -flat 1
40 | ;
41 | shelfButton
42 | -enableCommandRepeat 1
43 | -flexibleWidthType 3
44 | -flexibleWidthValue 32
45 | -enable 1
46 | -width 35
47 | -height 34
48 | -manage 1
49 | -visible 1
50 | -preventOverride 0
51 | -annotation "Export entire scene (including contents of all references) into one file"
52 | -enableBackground 0
53 | -backgroundColor 0 0 0
54 | -highlightColor 0.321569 0.521569 0.65098
55 | -align "center"
56 | -label "Export All..."
57 | -labelOffset 0
58 | -rotation 0
59 | -flipX 0
60 | -flipY 0
61 | -useAlpha 1
62 | -font "plainLabelFont"
63 | -overlayLabelColor 0.8 0.8 0.8
64 | -overlayLabelBackColor 0 0 0 0.5
65 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/exp.png"
66 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/exp.png"
67 | -style "iconOnly"
68 | -marginWidth 0
69 | -marginHeight 1
70 | -command "Export"
71 | -sourceType "mel"
72 | -commandRepeatable 1
73 | -flat 1
74 | ;
75 | shelfButton
76 | -enableCommandRepeat 1
77 | -flexibleWidthType 3
78 | -flexibleWidthValue 32
79 | -enable 1
80 | -width 35
81 | -height 34
82 | -manage 1
83 | -visible 1
84 | -preventOverride 0
85 | -annotation "Export selected objects (and related info) to a new file"
86 | -enableBackground 0
87 | -backgroundColor 0 0 0
88 | -highlightColor 0.321569 0.521569 0.65098
89 | -align "center"
90 | -label "Export Selection..."
91 | -labelOffset 0
92 | -rotation 0
93 | -flipX 0
94 | -flipY 0
95 | -useAlpha 1
96 | -font "plainLabelFont"
97 | -overlayLabelColor 0.8 0.8 0.8
98 | -overlayLabelBackColor 0 0 0 0.5
99 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/expsl.png"
100 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/expsl.png"
101 | -style "iconOnly"
102 | -marginWidth 0
103 | -marginHeight 1
104 | -command "ExportSelection"
105 | -sourceType "mel"
106 | -commandRepeatable 1
107 | -flat 1
108 | ;
109 | separator
110 | -enable 1
111 | -width 34
112 | -height 35
113 | -manage 1
114 | -visible 1
115 | -preventOverride 0
116 | -enableBackground 0
117 | -backgroundColor 0 0 0
118 | -highlightColor 0.321569 0.521569 0.65098
119 | -style "shelf"
120 | -horizontal 0
121 | ;
122 | shelfButton
123 | -enableCommandRepeat 1
124 | -flexibleWidthType 3
125 | -flexibleWidthValue 32
126 | -enable 1
127 | -width 35
128 | -height 34
129 | -manage 1
130 | -visible 1
131 | -preventOverride 0
132 | -annotation "Delete all history."
133 | -enableBackground 0
134 | -backgroundColor 0 0 0
135 | -highlightColor 0.321569 0.521569 0.65098
136 | -align "center"
137 | -label "Delete all history"
138 | -labelOffset 0
139 | -rotation 0
140 | -flipX 0
141 | -flipY 0
142 | -useAlpha 1
143 | -font "plainLabelFont"
144 | -overlayLabelColor 0.8 0.8 0.8
145 | -overlayLabelBackColor 0 0 0 0.5
146 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/dh.png"
147 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/dh.png"
148 | -style "iconOnly"
149 | -marginWidth 0
150 | -marginHeight 1
151 | -command "DeleteAllHistory;\nprint \"Deleted all history.\""
152 | -sourceType "mel"
153 | -commandRepeatable 1
154 | -flat 1
155 | ;
156 | shelfButton
157 | -enableCommandRepeat 1
158 | -flexibleWidthType 3
159 | -flexibleWidthValue 32
160 | -enable 1
161 | -width 35
162 | -height 34
163 | -manage 1
164 | -visible 1
165 | -preventOverride 0
166 | -annotation "Delete all channels"
167 | -enableBackground 0
168 | -backgroundColor 0 0 0
169 | -highlightColor 0.321569 0.521569 0.65098
170 | -align "center"
171 | -label "Delete all channels"
172 | -labelOffset 0
173 | -rotation 0
174 | -flipX 0
175 | -flipY 0
176 | -useAlpha 1
177 | -font "plainLabelFont"
178 | -imageOverlayLabel "Chan"
179 | -overlayLabelColor 0.8 0.8 0.8
180 | -overlayLabelBackColor 0 0 0 1
181 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/dc.png"
182 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/dc.png"
183 | -style "iconOnly"
184 | -marginWidth 0
185 | -marginHeight 1
186 | -command "DeleteAllChannels;\nprint \"Deleted all channels.\""
187 | -sourceType "mel"
188 | -commandRepeatable 1
189 | -flat 1
190 | ;
191 | separator
192 | -enable 1
193 | -width 34
194 | -height 35
195 | -manage 1
196 | -visible 1
197 | -preventOverride 0
198 | -enableBackground 0
199 | -backgroundColor 0 0 0
200 | -highlightColor 0.321569 0.521569 0.65098
201 | -style "shelf"
202 | -horizontal 0
203 | ;
204 | shelfButton
205 | -enableCommandRepeat 1
206 | -flexibleWidthType 3
207 | -flexibleWidthValue 32
208 | -enable 1
209 | -width 35
210 | -height 34
211 | -manage 1
212 | -visible 1
213 | -preventOverride 0
214 | -annotation "Add a temporary namespace to selected objects."
215 | -enableBackground 0
216 | -backgroundColor 0 0 0
217 | -highlightColor 0.321569 0.521569 0.65098
218 | -align "center"
219 | -label "Add namespace"
220 | -labelOffset 0
221 | -rotation 0
222 | -flipX 0
223 | -flipY 0
224 | -useAlpha 1
225 | -font "plainLabelFont"
226 | -overlayLabelColor 0.8 0.8 0.8
227 | -overlayLabelBackColor 0 0 0 0.5
228 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/qna.png"
229 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/qna.png"
230 | -style "iconOnly"
231 | -marginWidth 0
232 | -marginHeight 1
233 | -command "from maya import cmds\nfrom maya.OpenMaya import MGlobal\n\nselected = cmds.ls(sl = True)\nnodes = []\nfor item in selected:\n nodes.append(item)\n des = cmds.listRelatives(item, ad=True)\n if des:\n nodes += des\nfor node in nodes:\n old = node\n if 'Fake_namespace_' not in old:\n new = 'Fake_namespace_' + old\n try:\n cmds.rename(old, new)\n except:\n pass\n\nMGlobal.displayInfo('Added fake namespace.')"
234 | -sourceType "python"
235 | -commandRepeatable 1
236 | -flat 1
237 | ;
238 | shelfButton
239 | -enableCommandRepeat 1
240 | -flexibleWidthType 3
241 | -flexibleWidthValue 32
242 | -enable 1
243 | -width 35
244 | -height 34
245 | -manage 1
246 | -visible 1
247 | -preventOverride 0
248 | -annotation "Remove temporary namespace on selected objects."
249 | -enableBackground 0
250 | -backgroundColor 0 0 0
251 | -highlightColor 0.321569 0.521569 0.65098
252 | -align "center"
253 | -label "Remove namespace"
254 | -labelOffset 0
255 | -rotation 0
256 | -flipX 0
257 | -flipY 0
258 | -useAlpha 1
259 | -font "plainLabelFont"
260 | -overlayLabelColor 0.8 0.8 0.8
261 | -overlayLabelBackColor 0 0 0 0.5
262 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/qnd.png"
263 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/qnd.png"
264 | -style "iconOnly"
265 | -marginWidth 0
266 | -marginHeight 1
267 | -command "from maya import cmds\nfrom maya.OpenMaya import MGlobal\n\nselected = cmds.ls(sl = True)\nnodes = []\nfor item in selected:\n nodes.append(item)\n des = cmds.listRelatives(item, ad=True)\n if des:\n nodes += des\nfor node in nodes:\n old = node\n if 'Fake_namespace_' in old:\n new = old.replace('Fake_namespace_', '')\n try:\n cmds.rename(old, new)\n except:\n pass\n elif ':' in old:\n new = old.split(':')[1]\n try:\n cmds.rename(old, new)\n except:\n pass\n\nMGlobal.displayInfo('Removed fake namespace.')"
268 | -sourceType "python"
269 | -commandRepeatable 1
270 | -flat 1
271 | ;
272 | shelfButton
273 | -enableCommandRepeat 1
274 | -flexibleWidthType 3
275 | -flexibleWidthValue 32
276 | -enable 1
277 | -width 35
278 | -height 34
279 | -manage 1
280 | -visible 1
281 | -preventOverride 0
282 | -annotation "Group the selected object(s)."
283 | -enableBackground 0
284 | -backgroundColor 0 0 0
285 | -highlightColor 0.321569 0.521569 0.65098
286 | -align "center"
287 | -label "Group"
288 | -labelOffset 0
289 | -rotation 0
290 | -flipX 0
291 | -flipY 0
292 | -useAlpha 1
293 | -font "plainLabelFont"
294 | -imageOverlayLabel "Grp"
295 | -overlayLabelColor 0.8 0.8 0.8
296 | -overlayLabelBackColor 0 0 0 1
297 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/group.png"
298 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/group.png"
299 | -style "iconOnly"
300 | -marginWidth 0
301 | -marginHeight 1
302 | -command "doGroup 0 1 1"
303 | -sourceType "mel"
304 | -commandRepeatable 1
305 | -flat 1
306 | ;
307 | shelfButton
308 | -enableCommandRepeat 1
309 | -flexibleWidthType 3
310 | -flexibleWidthValue 32
311 | -enable 1
312 | -width 35
313 | -height 34
314 | -manage 1
315 | -visible 1
316 | -preventOverride 0
317 | -annotation "Ungroup the selected object(s)."
318 | -enableBackground 0
319 | -backgroundColor 0 0 0
320 | -highlightColor 0.321569 0.521569 0.65098
321 | -align "center"
322 | -label "Ungroup"
323 | -labelOffset 0
324 | -rotation 0
325 | -flipX 0
326 | -flipY 0
327 | -useAlpha 1
328 | -font "plainLabelFont"
329 | -imageOverlayLabel "UnGrp"
330 | -overlayLabelColor 0.8 0.8 0.8
331 | -overlayLabelBackColor 0 0 0 1
332 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/group.png"
333 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/group.png"
334 | -style "iconOnly"
335 | -marginWidth 0
336 | -marginHeight 1
337 | -command "ungroup"
338 | -sourceType "mel"
339 | -commandRepeatable 1
340 | -flat 1
341 | ;
342 | separator
343 | -enable 1
344 | -width 34
345 | -height 35
346 | -manage 1
347 | -visible 1
348 | -preventOverride 0
349 | -enableBackground 0
350 | -backgroundColor 0 0 0
351 | -highlightColor 0.321569 0.521569 0.65098
352 | -style "shelf"
353 | -horizontal 0
354 | ;
355 | shelfButton
356 | -enableCommandRepeat 1
357 | -flexibleWidthType 3
358 | -flexibleWidthValue 32
359 | -enable 1
360 | -width 35
361 | -height 34
362 | -manage 1
363 | -visible 1
364 | -preventOverride 0
365 | -annotation "Display and edit connections in shading networks"
366 | -enableBackground 0
367 | -backgroundColor 0 0 0
368 | -highlightColor 0.321569 0.521569 0.65098
369 | -align "center"
370 | -label "Hypershade"
371 | -labelOffset 0
372 | -rotation 0
373 | -flipX 0
374 | -flipY 0
375 | -useAlpha 1
376 | -font "plainLabelFont"
377 | -overlayLabelColor 0.8 0.8 0.8
378 | -overlayLabelBackColor 0 0 0 0.5
379 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/hs.png"
380 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/hs.png"
381 | -style "iconOnly"
382 | -marginWidth 0
383 | -marginHeight 1
384 | -command "HypershadeWindow"
385 | -sourceType "mel"
386 | -commandRepeatable 1
387 | -flat 1
388 | ;
389 | shelfButton
390 | -enableCommandRepeat 1
391 | -flexibleWidthType 3
392 | -flexibleWidthValue 32
393 | -enable 1
394 | -width 35
395 | -height 34
396 | -manage 1
397 | -visible 1
398 | -preventOverride 0
399 | -annotation "Delete unused node in Hypershade."
400 | -enableBackground 0
401 | -backgroundColor 0 0 0
402 | -highlightColor 0.321569 0.521569 0.65098
403 | -align "center"
404 | -label "Hypershade Delete unused node"
405 | -labelOffset 0
406 | -rotation 0
407 | -flipX 0
408 | -flipY 0
409 | -useAlpha 1
410 | -font "plainLabelFont"
411 | -overlayLabelColor 0.8 0.8 0.8
412 | -overlayLabelBackColor 0 0 0 0.5
413 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/hsdelete.png"
414 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/hsdelete.png"
415 | -style "iconOnly"
416 | -marginWidth 0
417 | -marginHeight 1
418 | -command "MLdeleteUnused;\nprint \"Deleted unused nodeds in hypershade.\""
419 | -sourceType "mel"
420 | -commandRepeatable 1
421 | -flat 1
422 | ;
423 | shelfButton
424 | -enableCommandRepeat 1
425 | -flexibleWidthType 3
426 | -flexibleWidthValue 32
427 | -enable 1
428 | -width 35
429 | -height 34
430 | -manage 1
431 | -visible 1
432 | -preventOverride 0
433 | -annotation "Separate selected mesh by materials."
434 | -enableBackground 0
435 | -backgroundColor 0 0 0
436 | -highlightColor 0.321569 0.521569 0.65098
437 | -align "center"
438 | -label "Seperate mesh by materials"
439 | -labelOffset 0
440 | -rotation 0
441 | -flipX 0
442 | -flipY 0
443 | -useAlpha 1
444 | -font "plainLabelFont"
445 | -imageOverlayLabel "sepMat"
446 | -overlayLabelColor 0.8 0.8 0.8
447 | -overlayLabelBackColor 0 0 0 1
448 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/sepmat.png"
449 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/sepmat.png"
450 | -style "iconOnly"
451 | -marginWidth 0
452 | -marginHeight 1
453 | -command "from maya import cmds\nfrom maya.OpenMaya import MGlobal\n\ndef getSGsFromShape(shape):\n myShapeNode=cmds.listRelatives(shape, shapes=1, children=1)\n shadingEngines = []\n if cmds.objExists(shape):\n dest=cmds.listConnections(myShapeNode[0], \n source=False, \n plugs=False, \n destination=True, \n type=\"shadingEngine\")\n if len(dest):\n select=cmds.ls(sl=1)\n cmds.select(dest, r=1, ne=1)\n shadingEngines=cmds.ls(sl=1)\n cmds.select(select, r=1)\n return shadingEngines\n\ndef sepMat(object):\n shadingGroups=getSGsFromShape(object)\n ParentName=(\"group_\"+object)\n cmds.group(empty=1, n=ParentName)\n i=0\n while 1:\n if not ( i Top Left\""
687 | -sourceType "mel"
688 | -commandRepeatable 1
689 | -flat 1
690 | ;
691 | shelfButton
692 | -enableCommandRepeat 1
693 | -flexibleWidthType 3
694 | -flexibleWidthValue 32
695 | -enable 1
696 | -width 35
697 | -height 34
698 | -manage 1
699 | -visible 1
700 | -preventOverride 0
701 | -annotation "Moves selected uv to top right corner and makes it half the size."
702 | -enableBackground 0
703 | -backgroundColor 0 0 0
704 | -highlightColor 0.321569 0.521569 0.65098
705 | -align "center"
706 | -label "UV Top Right"
707 | -labelOffset 0
708 | -rotation 0
709 | -flipX 0
710 | -flipY 0
711 | -useAlpha 1
712 | -font "plainLabelFont"
713 | -overlayLabelColor 0.8 0.8 0.8
714 | -overlayLabelBackColor 0 0 0 0.5
715 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/sq2.png"
716 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/sq2.png"
717 | -style "iconOnly"
718 | -marginWidth 0
719 | -marginHeight 1
720 | -command "polyEditUV -pu 0.5 -pv 0.5 -su 0.5 -sv 0.5;\npolyEditUV -u 0.25 -v 0.25 ;\nprint \"Moved UV -> Top Right\""
721 | -sourceType "mel"
722 | -commandRepeatable 1
723 | -flat 1
724 | ;
725 | shelfButton
726 | -enableCommandRepeat 1
727 | -flexibleWidthType 3
728 | -flexibleWidthValue 32
729 | -enable 1
730 | -width 35
731 | -height 34
732 | -manage 1
733 | -visible 1
734 | -preventOverride 0
735 | -annotation "Moves selected uv to bottom left corner and makes it half the size."
736 | -enableBackground 0
737 | -backgroundColor 0 0 0
738 | -highlightColor 0.321569 0.521569 0.65098
739 | -align "center"
740 | -label "UV Bottom Left"
741 | -labelOffset 0
742 | -rotation 0
743 | -flipX 0
744 | -flipY 0
745 | -useAlpha 1
746 | -font "plainLabelFont"
747 | -overlayLabelColor 0.8 0.8 0.8
748 | -overlayLabelBackColor 0 0 0 0.5
749 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/sq3.png"
750 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/sq3.png"
751 | -style "iconOnly"
752 | -marginWidth 0
753 | -marginHeight 1
754 | -command "polyEditUV -pu 0.5 -pv 0.5 -su 0.5 -sv 0.5;\npolyEditUV -u -0.25 -v -0.25 ;\nprint \"Moved UV -> Bottom Left\""
755 | -sourceType "mel"
756 | -commandRepeatable 1
757 | -flat 1
758 | ;
759 | shelfButton
760 | -enableCommandRepeat 1
761 | -flexibleWidthType 3
762 | -flexibleWidthValue 32
763 | -enable 1
764 | -width 35
765 | -height 34
766 | -manage 1
767 | -visible 1
768 | -preventOverride 0
769 | -annotation "Moves selected uv to bottom right corner and makes it half the size."
770 | -enableBackground 0
771 | -backgroundColor 0 0 0
772 | -highlightColor 0.321569 0.521569 0.65098
773 | -align "center"
774 | -label "UV Bottom Right"
775 | -labelOffset 0
776 | -rotation 0
777 | -flipX 0
778 | -flipY 0
779 | -useAlpha 1
780 | -font "plainLabelFont"
781 | -overlayLabelColor 0.8 0.8 0.8
782 | -overlayLabelBackColor 0 0 0 0.5
783 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/sq4.png"
784 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/sq4.png"
785 | -style "iconOnly"
786 | -marginWidth 0
787 | -marginHeight 1
788 | -command "polyEditUV -pu 0.5 -pv 0.5 -su 0.5 -sv 0.5;\npolyEditUV -u 0.25 -v -0.25 ;\nprint \"Moved UV -> Bottom Right\""
789 | -sourceType "mel"
790 | -commandRepeatable 1
791 | -flat 1
792 | ;
793 | separator
794 | -enable 1
795 | -width 34
796 | -height 35
797 | -manage 1
798 | -visible 1
799 | -preventOverride 0
800 | -enableBackground 0
801 | -backgroundColor 0 0 0
802 | -highlightColor 0.321569 0.521569 0.65098
803 | -style "shelf"
804 | -horizontal 0
805 | ;
806 | shelfButton
807 | -enableCommandRepeat 1
808 | -flexibleWidthType 3
809 | -flexibleWidthValue 32
810 | -enable 1
811 | -width 35
812 | -height 34
813 | -manage 1
814 | -visible 1
815 | -preventOverride 0
816 | -annotation "Go to bind pose."
817 | -enableBackground 0
818 | -backgroundColor 0 0 0
819 | -highlightColor 0.321569 0.521569 0.65098
820 | -align "center"
821 | -label "Go to bindPose"
822 | -labelOffset 0
823 | -rotation 0
824 | -flipX 0
825 | -flipY 0
826 | -useAlpha 1
827 | -font "plainLabelFont"
828 | -overlayLabelColor 0.8 0.8 0.8
829 | -overlayLabelBackColor 0 0 0 0.5
830 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/gtbp.png"
831 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/gtbp.png"
832 | -style "iconOnly"
833 | -marginWidth 0
834 | -marginHeight 1
835 | -command "GoToBindPose;"
836 | -sourceType "mel"
837 | -commandRepeatable 1
838 | -flat 1
839 | ;
840 | shelfButton
841 | -enableCommandRepeat 1
842 | -flexibleWidthType 3
843 | -flexibleWidthValue 32
844 | -enable 1
845 | -width 35
846 | -height 34
847 | -manage 1
848 | -visible 1
849 | -preventOverride 0
850 | -annotation "Set current pose as bind pose."
851 | -enableBackground 0
852 | -backgroundColor 0 0 0
853 | -highlightColor 0.321569 0.521569 0.65098
854 | -align "center"
855 | -label "Set bindPose"
856 | -labelOffset 0
857 | -rotation 0
858 | -flipX 0
859 | -flipY 0
860 | -useAlpha 1
861 | -font "plainLabelFont"
862 | -overlayLabelColor 0.8 0.8 0.8
863 | -overlayLabelBackColor 0 0 0 0.5
864 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/setbp.png"
865 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/setbp.png"
866 | -style "iconOnly"
867 | -marginWidth 0
868 | -marginHeight 1
869 | -command "from maya import cmds\nfrom maya.OpenMaya import MGlobal\n\nbps = cmds.dagPose(q=True, bp=True)\nif bps and len(bps) > 0:\n joints = cmds.dagPose(bps[0], q=True, m=True)\n for j in joints:\n cmds.dagPose(j, rs=True, name=bps[0])\n \nMGlobal.displayInfo('Updated bindpose.')"
870 | -sourceType "python"
871 | -commandRepeatable 1
872 | -flat 1
873 | ;
874 | shelfButton
875 | -enableCommandRepeat 1
876 | -flexibleWidthType 3
877 | -flexibleWidthValue 32
878 | -enable 1
879 | -width 35
880 | -height 34
881 | -manage 1
882 | -visible 1
883 | -preventOverride 0
884 | -annotation "Freeze selected joints rotation."
885 | -enableBackground 0
886 | -backgroundColor 0 0 0
887 | -highlightColor 0.321569 0.521569 0.65098
888 | -align "center"
889 | -label "Freeze selected joints rotation"
890 | -labelOffset 0
891 | -rotation 0
892 | -flipX 0
893 | -flipY 0
894 | -useAlpha 1
895 | -font "plainLabelFont"
896 | -overlayLabelColor 0.8 0.8 0.8
897 | -overlayLabelBackColor 0 0 0 0.5
898 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/frotsel.png"
899 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/frotsel.png"
900 | -style "iconOnly"
901 | -marginWidth 0
902 | -marginHeight 1
903 | -command "from maya.OpenMaya import *\nfrom maya.OpenMayaAnim import *\n\nselections = MSelectionList()\nMGlobal.getActiveSelectionList(selections)\niterator = MItSelectionList(selections, MFn.kJoint)\nwhile not iterator.isDone():\n dagpath = MDagPath()\n iterator.getDagPath(dagpath)\n ik_joint = MFnIkJoint(dagpath)\n rotation = MQuaternion()\n orient = MQuaternion()\n ik_joint.getOrientation(orient)\n ik_joint.getRotation(rotation, MSpace.kTransform)\n orient = rotation * orient\n ik_joint.setOrientation(orient)\n ik_joint.setRotation(orient.identity)\n iterator.next()\n\nMGlobal.displayInfo('Froze selected joints.')"
904 | -sourceType "python"
905 | -commandRepeatable 1
906 | -flat 1
907 | ;
908 | shelfButton
909 | -enableCommandRepeat 1
910 | -flexibleWidthType 3
911 | -flexibleWidthValue 32
912 | -enable 1
913 | -width 35
914 | -height 34
915 | -manage 1
916 | -visible 1
917 | -preventOverride 0
918 | -annotation "Freeze all joint rotations."
919 | -enableBackground 0
920 | -backgroundColor 0 0 0
921 | -highlightColor 0.321569 0.521569 0.65098
922 | -align "center"
923 | -label "Freeze all joints rotation"
924 | -labelOffset 0
925 | -rotation 0
926 | -flipX 0
927 | -flipY 0
928 | -useAlpha 1
929 | -font "plainLabelFont"
930 | -overlayLabelColor 0.8 0.8 0.8
931 | -overlayLabelBackColor 0 0 0 1
932 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/frot.png"
933 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/frot.png"
934 | -style "iconOnly"
935 | -marginWidth 0
936 | -marginHeight 1
937 | -command "from maya.OpenMaya import *\nfrom maya.OpenMayaAnim import *\n\niterator = MItDag(MItDag.kDepthFirst, MFn.kJoint)\nwhile not iterator.isDone():\n dagpath = MDagPath()\n iterator.getPath(dagpath)\n ik_joint = MFnIkJoint(dagpath)\n rotation = MQuaternion()\n orient = MQuaternion()\n ik_joint.getOrientation(orient)\n ik_joint.getRotation(rotation, MSpace.kTransform)\n orient = rotation * orient\n ik_joint.setOrientation(orient)\n ik_joint.setRotation(orient.identity)\n iterator.next()\n\nMGlobal.displayInfo('Froze all joints.')"
938 | -sourceType "python"
939 | -commandRepeatable 1
940 | -flat 1
941 | ;
942 | shelfButton
943 | -enableCommandRepeat 1
944 | -flexibleWidthType 3
945 | -flexibleWidthValue 32
946 | -enable 1
947 | -width 35
948 | -height 34
949 | -manage 1
950 | -visible 1
951 | -preventOverride 0
952 | -annotation "Mirror selected L_ joint rotation to same name R_ joint, or opposite way. (Work better if joints has been frozen)"
953 | -enableBackground 0
954 | -backgroundColor 0 0 0
955 | -highlightColor 0.321569 0.521569 0.65098
956 | -align "center"
957 | -label "Mirror joint"
958 | -labelOffset 0
959 | -rotation 0
960 | -flipX 0
961 | -flipY 0
962 | -useAlpha 1
963 | -font "plainLabelFont"
964 | -imageOverlayLabel "L<->R"
965 | -overlayLabelColor 0.8 0.8 0.8
966 | -overlayLabelBackColor 0 0 0 1
967 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/mirror.png"
968 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/mirror.png"
969 | -style "iconOnly"
970 | -marginWidth 0
971 | -marginHeight 1
972 | -command "\nfrom maya import cmds\nfrom maya.OpenMaya import MGlobal\n\nobjects = cmds.ls(sl = True)\nif not objects:\n raise Exception('No joint selected.')\nprefixs = (('l_', 'r_'), ('L_', 'R_'), ('r_', 'l_'), ('R_', 'L_'))\nfor object in objects:\n l_joint = None\n r_joint = None\n \n for prefix in prefixs:\n if object.startswith(prefix[0]):\n l_joint = object\n r_joint = prefix[1] + object[2:]\n break\n \n lrx = cmds.getAttr(f'{l_joint}.rotateX')\n lry = cmds.getAttr(f'{l_joint}.rotateY')\n lrz = cmds.getAttr(f'{l_joint}.rotateZ')\n cmds.setAttr(f'{r_joint}.rotateX', lrx)\n cmds.setAttr(f'{r_joint}.rotateY', lry)\n cmds.setAttr(f'{r_joint}.rotateZ', lrz)\n\nMGlobal.displayInfo('Mirrored selected joints.')"
973 | -sourceType "python"
974 | -commandRepeatable 1
975 | -flat 1
976 | ;
977 | shelfButton
978 | -enableCommandRepeat 1
979 | -flexibleWidthType 3
980 | -flexibleWidthValue 32
981 | -enable 1
982 | -width 35
983 | -height 34
984 | -manage 1
985 | -visible 1
986 | -preventOverride 0
987 | -annotation "Mirror selected joint A rotation to selected joint B. (Work better if joints has been frozen)"
988 | -enableBackground 0
989 | -backgroundColor 0 0 0
990 | -highlightColor 0.321569 0.521569 0.65098
991 | -align "center"
992 | -label "Mirror joint select"
993 | -labelOffset 0
994 | -rotation 0
995 | -flipX 0
996 | -flipY 0
997 | -useAlpha 1
998 | -font "plainLabelFont"
999 | -imageOverlayLabel "A<->B"
1000 | -overlayLabelColor 0.8 0.8 0.8
1001 | -overlayLabelBackColor 0 0 0 1
1002 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/mirror.png"
1003 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/mirror.png"
1004 | -style "iconOnly"
1005 | -marginWidth 0
1006 | -marginHeight 1
1007 | -command "\nfrom maya import cmds\nfrom maya.OpenMaya import MGlobal\n\nobjects = cmds.ls(sl = True)\nif not objects:\n raise Exception('No joints selected.')\nif len(objects) > 2:\n raise Exception('More than 2 joints selected.')\n\nl_joint = objects[0]\nr_joint = objects[1]\n \nlrx = cmds.getAttr(f'{l_joint}.rotateX')\nlry = cmds.getAttr(f'{l_joint}.rotateY')\nlrz = cmds.getAttr(f'{l_joint}.rotateZ')\ncmds.setAttr(f'{r_joint}.rotateX', lrx)\ncmds.setAttr(f'{r_joint}.rotateY', lry)\ncmds.setAttr(f'{r_joint}.rotateZ', lrz)\n\nMGlobal.displayInfo('Mirrored selected joints.')"
1008 | -sourceType "python"
1009 | -commandRepeatable 1
1010 | -flat 1
1011 | ;
1012 | separator
1013 | -enable 1
1014 | -width 34
1015 | -height 35
1016 | -manage 1
1017 | -visible 1
1018 | -preventOverride 0
1019 | -enableBackground 0
1020 | -backgroundColor 0 0 0
1021 | -highlightColor 0.321569 0.521569 0.65098
1022 | -style "shelf"
1023 | -horizontal 0
1024 | ;
1025 | shelfButton
1026 | -enableCommandRepeat 1
1027 | -flexibleWidthType 3
1028 | -flexibleWidthValue 32
1029 | -enable 1
1030 | -width 35
1031 | -height 34
1032 | -manage 1
1033 | -visible 1
1034 | -preventOverride 0
1035 | -annotation "Open Tool settings + enter paint weight mode."
1036 | -enableBackground 0
1037 | -backgroundColor 0 0 0
1038 | -highlightColor 0.321569 0.521569 0.65098
1039 | -align "center"
1040 | -label "Paint skin weights"
1041 | -labelOffset 0
1042 | -rotation 0
1043 | -flipX 0
1044 | -flipY 0
1045 | -useAlpha 1
1046 | -font "plainLabelFont"
1047 | -overlayLabelColor 0.8 0.8 0.8
1048 | -overlayLabelBackColor 0 0 0 0.5
1049 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/psw.png"
1050 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/psw.png"
1051 | -style "iconOnly"
1052 | -marginWidth 0
1053 | -marginHeight 1
1054 | -command "ToolSettingsWindow;\nArtPaintSkinWeightsTool;"
1055 | -sourceType "mel"
1056 | -commandRepeatable 1
1057 | -flat 1
1058 | ;
1059 | shelfButton
1060 | -enableCommandRepeat 1
1061 | -flexibleWidthType 3
1062 | -flexibleWidthValue 32
1063 | -enable 1
1064 | -width 35
1065 | -height 34
1066 | -manage 1
1067 | -visible 1
1068 | -preventOverride 0
1069 | -annotation "Prune weights to fit max 4 influences on vertices on selected skin cluster."
1070 | -enableBackground 0
1071 | -backgroundColor 0 0 0
1072 | -highlightColor 0.321569 0.521569 0.65098
1073 | -align "center"
1074 | -label "4 Influence fix"
1075 | -labelOffset 0
1076 | -rotation 0
1077 | -flipX 0
1078 | -flipY 0
1079 | -useAlpha 1
1080 | -font "plainLabelFont"
1081 | -overlayLabelColor 0 0 0
1082 | -overlayLabelBackColor 0 0 0 0
1083 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/four.png"
1084 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/four.png"
1085 | -style "iconOnly"
1086 | -marginWidth 0
1087 | -marginHeight 1
1088 | -command "from maya.OpenMaya import *\nfrom maya.OpenMayaAnim import *\n\ncmd = MGlobal.executeCommandStringResult(\n 'confirmDialog -title \"Force max 4 influences\" -message \"Please backup/save scene first because this function might not work as expect. Continue?\" -button \"Yes\" -button \"No\" -defaultButton \"Yes\" -cancelButton \"No\"'\n)\nif cmd == 'Yes':\n # get mesh in selections\n selections = MSelectionList()\n MGlobal.getActiveSelectionList(selections)\n iterator = MItSelectionList(selections, MFn.kMesh)\n if iterator.isDone():\n raise Exception(f'Please select a mesh.')\n mesh_dagpath = MDagPath()\n iterator.getDagPath(mesh_dagpath) # get first mesh\n iterator.next()\n if not iterator.isDone():\n raise Exception(\n f'More than 1 mesh selected., combine all meshes if you have mutiple meshes.')\n mesh = MFnMesh(mesh_dagpath)\n mesh_name = mesh.name()\n vertices_num = mesh.numVertices()\n\n # find skin cluster node upstream - bypass history node\n iterator = MItDependencyGraph(\n mesh.object(), MFn.kSkinClusterFilter, MItDependencyGraph.kUpstream)\n if iterator.isDone():\n raise Exception('Failed to find created skin cluster.')\n skin_cluster = MFnSkinCluster(iterator.currentItem())\n skin_cluster_name = skin_cluster.name()\n\n # get weights\n component = MFnSingleIndexedComponent()\n vertex_component = component.create(MFn.kMeshVertComponent)\n weights = MDoubleArray()\n util = MScriptUtil()\n ptr = util.asUintPtr()\n skin_cluster.getWeights(mesh_dagpath, vertex_component, weights, ptr)\n weight_influence_count = util.getUint(ptr)\n\n # fix 4 influence weights\n for i in range(0, vertices_num):\n found_weights = []\n inf_count = 0\n\n for j in range(0, weight_influence_count):\n weight = weights[i * weight_influence_count + j]\n if weight > 0:\n inf_count += 1\n found_weights.append((weight, j))\n\n if inf_count > 4:\n # get sorted weights + influence\n found_weights = sorted(\n found_weights, key=lambda f: f[0], reverse=True)\n\n # 4 highest weights\n high_weights = found_weights[:4]\n # the rest small weights\n low_weights = found_weights[4:]\n\n # sum all low weights and remove them\n low_sum = 0.0\n for weight, influence in low_weights:\n low_sum += weight\n weights[i * weight_influence_count + influence] = 0.0\n\n # distributed low weights to high weights + re calculate weight sum for normalize\n low_sum /= 4\n weight_sum = 0.0\n for weight, influence in high_weights:\n weights[i * weight_influence_count + influence] += low_sum\n\n # set weights back\n MGlobal.executeCommand(f'setAttr {skin_cluster_name}.normalizeWeights 0')\n mask_influence = MIntArray()\n MScriptUtil.createIntArrayFromList(\n list(range(0, weight_influence_count)), mask_influence)\n skin_cluster.setWeights(mesh_dagpath, vertex_component,\n mask_influence, weights, False)\n MGlobal.executeCommand(f'setAttr {skin_cluster_name}.normalizeWeights 1')\n MGlobal.executeCommand(\n f'skinPercent -normalize true {skin_cluster_name} {mesh_name}')\n\n MGlobal.displayInfo('Forced max 4 influences.')\n"
1089 | -sourceType "python"
1090 | -commandRepeatable 1
1091 | -flat 1
1092 | ;
1093 | shelfButton
1094 | -enableCommandRepeat 1
1095 | -flexibleWidthType 3
1096 | -flexibleWidthValue 32
1097 | -enable 1
1098 | -width 35
1099 | -height 34
1100 | -manage 1
1101 | -visible 1
1102 | -preventOverride 0
1103 | -annotation "Unbind, delete history, rebind on a selected skin cluster."
1104 | -enableBackground 0
1105 | -backgroundColor 0 0 0
1106 | -highlightColor 0.321569 0.521569 0.65098
1107 | -align "center"
1108 | -label "Rebind"
1109 | -labelOffset 0
1110 | -rotation 0
1111 | -flipX 0
1112 | -flipY 0
1113 | -useAlpha 1
1114 | -font "plainLabelFont"
1115 | -overlayLabelColor 0.725962 0.725962 0.725962
1116 | -overlayLabelBackColor 0 0 0 0
1117 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/rebind.png"
1118 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/rebind.png"
1119 | -style "iconOnly"
1120 | -marginWidth 0
1121 | -marginHeight 1
1122 | -command "from maya.OpenMaya import *\nfrom maya.OpenMayaAnim import *\n\ncmd = MGlobal.executeCommandStringResult(\n 'confirmDialog -title \"Rebind skinned mesh with same vertex id\" -message \"Please backup/save scene first because this function might not work as expect. Continue?\" -button \"Yes\" -button \"No\" -defaultButton \"Yes\" -cancelButton \"No\"'\n)\nif cmd == 'Yes':\n # get mesh in selections\n selections = MSelectionList()\n MGlobal.getActiveSelectionList(selections)\n iterator = MItSelectionList(selections, MFn.kMesh)\n if iterator.isDone():\n raise Exception(f'Please select a mesh.')\n mesh_dagpath = MDagPath()\n iterator.getDagPath(mesh_dagpath) # get first mesh\n iterator.next()\n if not iterator.isDone():\n raise Exception(\n f'More than 1 mesh selected., combine all meshes if you have mutiple meshes.')\n mesh = MFnMesh(mesh_dagpath)\n mesh_name = mesh.name()\n\n # find skin cluster\n iterator = MItDependencyGraph(\n mesh.object(), MFn.kSkinClusterFilter, MItDependencyGraph.kUpstream)\n if iterator.isDone():\n raise Exception('Failed to find skin cluster.')\n skin_cluster = MFnSkinCluster(iterator.currentItem())\n\n # get weights\n component = MFnSingleIndexedComponent()\n vertex_component = component.create(MFn.kMeshVertComponent)\n weights = MDoubleArray()\n util = MScriptUtil()\n ptr = util.asUintPtr()\n skin_cluster.getWeights(mesh_dagpath, vertex_component, weights, ptr)\n\n # get influence\n influences_dagpath = MDagPathArray()\n skin_cluster.influenceObjects(influences_dagpath)\n influence_count = influences_dagpath.length()\n\n # unbind\n MGlobal.executeCommand(f'skinCluster -e -ubk {mesh_name}')\n MGlobal.executeCommand('DeleteHistory')\n\n # rebind\n selections = MSelectionList()\n selections.add(mesh_dagpath)\n for i in range(0, influence_count):\n selections.add(influences_dagpath[i])\n MGlobal.selectCommand(selections)\n MGlobal.executeCommand(f'skinCluster -mi 4 -tsb -n {mesh_name}_skinCluster')\n\n # get created skincluster\n iterator = MItDependencyGraph(\n mesh.object(), MFn.kSkinClusterFilter, MItDependencyGraph.kUpstream)\n if iterator.isDone():\n raise Exception('Failed to find created skin cluster.')\n skin_cluster = MFnSkinCluster(iterator.currentItem())\n\n # get influences mask (influences indices)\n new_influences_dagpath = MDagPathArray()\n skin_cluster.influenceObjects(new_influences_dagpath)\n mask_influence = MIntArray(influence_count)\n for i in range(0, influence_count):\n for j in range(0, influence_count):\n if new_influences_dagpath[i] == influences_dagpath[j]:\n mask_influence[i] = j\n break\n\n # set weights\n MGlobal.executeCommand(f'setAttr {mesh_name}_skinCluster.normalizeWeights 0')\n skin_cluster.setWeights(mesh_dagpath, vertex_component,\n mask_influence, weights, False)\n MGlobal.executeCommand(f'setAttr {mesh_name}_skinCluster.normalizeWeights 1')\n MGlobal.executeCommand(\n f'skinPercent -normalize true {mesh_name}_skinCluster {mesh_name}')\n\n MGlobal.displayInfo('Rebound.')\n"
1123 | -sourceType "python"
1124 | -commandRepeatable 1
1125 | -flat 1
1126 | ;
1127 |
1128 | }
1129 |
--------------------------------------------------------------------------------
/prefs/shelves/shelf_LoLMaya_MAPGEO.mel:
--------------------------------------------------------------------------------
1 | global proc shelf_LoLMaya_MAPGEO () {
2 | global string $gBuffStr;
3 | global string $gBuffStr0;
4 | global string $gBuffStr1;
5 |
6 |
7 | shelfButton
8 | -enableCommandRepeat 1
9 | -flexibleWidthType 3
10 | -flexibleWidthValue 32
11 | -enable 1
12 | -width 35
13 | -height 34
14 | -manage 1
15 | -visible 1
16 | -preventOverride 0
17 | -annotation "Add the file to the current scene"
18 | -enableBackground 0
19 | -backgroundColor 0 0 0
20 | -highlightColor 0.321569 0.521569 0.65098
21 | -align "center"
22 | -label "Import..."
23 | -labelOffset 0
24 | -rotation 0
25 | -flipX 0
26 | -flipY 0
27 | -useAlpha 1
28 | -font "plainLabelFont"
29 | -overlayLabelColor 0.8 0.8 0.8
30 | -overlayLabelBackColor 0 0 0 0.5
31 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/imp.png"
32 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/imp.png"
33 | -style "iconOnly"
34 | -marginWidth 0
35 | -marginHeight 1
36 | -command "Import"
37 | -sourceType "mel"
38 | -commandRepeatable 1
39 | -flat 1
40 | ;
41 | shelfButton
42 | -enableCommandRepeat 1
43 | -flexibleWidthType 3
44 | -flexibleWidthValue 32
45 | -enable 1
46 | -width 35
47 | -height 34
48 | -manage 1
49 | -visible 1
50 | -preventOverride 0
51 | -annotation "Export selected objects (and related info) to a new file"
52 | -enableBackground 0
53 | -backgroundColor 0 0 0
54 | -highlightColor 0.321569 0.521569 0.65098
55 | -align "center"
56 | -label "Export Selection..."
57 | -labelOffset 0
58 | -rotation 0
59 | -flipX 0
60 | -flipY 0
61 | -useAlpha 1
62 | -font "plainLabelFont"
63 | -overlayLabelColor 0.8 0.8 0.8
64 | -overlayLabelBackColor 0 0 0 0.5
65 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/expsl.png"
66 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/expsl.png"
67 | -style "iconOnly"
68 | -marginWidth 0
69 | -marginHeight 1
70 | -command "ExportSelection"
71 | -sourceType "mel"
72 | -commandRepeatable 1
73 | -flat 1
74 | ;
75 | separator
76 | -enable 1
77 | -width 12
78 | -height 35
79 | -manage 1
80 | -visible 1
81 | -preventOverride 0
82 | -enableBackground 0
83 | -backgroundColor 0 0 0
84 | -highlightColor 0.321569 0.521569 0.65098
85 | -style "shelf"
86 | -horizontal 0
87 | ;
88 | shelfButton
89 | -enableCommandRepeat 1
90 | -flexibleWidthType 3
91 | -flexibleWidthValue 32
92 | -enable 1
93 | -width 35
94 | -height 34
95 | -manage 1
96 | -visible 1
97 | -preventOverride 0
98 | -annotation "Delete history on all objects"
99 | -enableBackground 0
100 | -backgroundColor 0 0 0
101 | -highlightColor 0.321569 0.521569 0.65098
102 | -align "center"
103 | -label "History"
104 | -labelOffset 0
105 | -rotation 0
106 | -flipX 0
107 | -flipY 0
108 | -useAlpha 1
109 | -font "plainLabelFont"
110 | -overlayLabelColor 0.8 0.8 0.8
111 | -overlayLabelBackColor 0 0 0 0.5
112 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/dh.png"
113 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/dh.png"
114 | -style "iconOnly"
115 | -marginWidth 0
116 | -marginHeight 1
117 | -command "DeleteAllHistory"
118 | -sourceType "mel"
119 | -commandRepeatable 1
120 | -flat 1
121 | ;
122 | shelfButton
123 | -enableCommandRepeat 1
124 | -flexibleWidthType 3
125 | -flexibleWidthValue 32
126 | -enable 1
127 | -width 35
128 | -height 34
129 | -manage 1
130 | -visible 1
131 | -preventOverride 0
132 | -annotation "Rename selected objects."
133 | -enableBackground 0
134 | -backgroundColor 0 0 0
135 | -highlightColor 0.321569 0.521569 0.65098
136 | -align "center"
137 | -label "Rename Objects"
138 | -labelOffset 0
139 | -rotation 0
140 | -flipX 0
141 | -flipY 0
142 | -useAlpha 1
143 | -font "plainLabelFont"
144 | -overlayLabelColor 0.8 0.8 0.8
145 | -overlayLabelBackColor 0 0 0 0.5
146 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/pref.png"
147 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/pref.png"
148 | -style "iconOnly"
149 | -marginWidth 0
150 | -marginHeight 1
151 | -command "from maya import cmds\nfrom maya.OpenMaya import MGlobal\n\ndef on_textfield(textfield):\n cmds.optionVar(sv=('lolmaya_prefixrename', cmds.textField(textfield, q=True, tx=True)))\n\n\nif cmds.window('PREFIXRENAME', ex=True):\n cmds.deleteUI('PREFIXRENAME')\n\nwindow = cmds.window(\n \"PREFIXRENAME\", \n title = 'Enter prefix:', \n sizeable = False\n)\n\nlayout = cmds.rowLayout (p = window, nc = 2)\ntextfield = cmds.textField(p = layout, w = 500, h = 30)\nold_str = cmds.optionVar(q='lolmaya_prefixrename')\nif old_str:\n cmds.textField(textfield, e=True, it = old_str)\ncmds.textField(textfield, e = True, cc = lambda c: on_textfield(textfield))\ndef apply(*args):\n prefix = cmds.textField(textfield, q = True, tx=True)\n if prefix: \n selected = cmds.ls(sl = True)\n i = 0\n for obj in selected: \n try: \n cmds.rename(obj, f'{prefix}_{i}')\n i += 1\n except:\n pass\n\n MGlobal.displayInfo('Renamed selected objects.')\n\ncmds.textField(textfield, edit = True, ec = apply)\ncmds.button('Apply', p = layout, w = 100, h = 30, c = apply)\n\ncmds.showWindow(window)"
152 | -sourceType "python"
153 | -commandRepeatable 1
154 | -flat 1
155 | ;
156 | shelfButton
157 | -enableCommandRepeat 1
158 | -flexibleWidthType 3
159 | -flexibleWidthValue 32
160 | -enable 1
161 | -width 35
162 | -height 34
163 | -manage 1
164 | -visible 1
165 | -preventOverride 0
166 | -annotation "Rename path of selected objects."
167 | -enableBackground 0
168 | -backgroundColor 0 0 0
169 | -highlightColor 0.321569 0.521569 0.65098
170 | -align "center"
171 | -label "Rename Paths"
172 | -labelOffset 0
173 | -rotation 0
174 | -flipX 0
175 | -flipY 0
176 | -useAlpha 1
177 | -font "plainLabelFont"
178 | -overlayLabelColor 0.8 0.8 0.8
179 | -overlayLabelBackColor 0 0 0 0.5
180 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/mr.png"
181 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/mr.png"
182 | -style "iconOnly"
183 | -marginWidth 0
184 | -marginHeight 1
185 | -command "from maya import cmds\nfrom maya.OpenMaya import MGlobal\n\nif cmds.window('MATRenameWin', ex=True):\n cmds.deleteUI('MATRenameWin')\n\nwindow = cmds.window(\n 'MATRenameWin', \n title = 'Enter prefix:', \n sizeable = False\n)\n\nlayout = cmds.rowLayout (p = window, nc = 2)\ntextfield = cmds.textField(p = layout, w = 500, h = 30)\nold_str = cmds.optionVar(q='lolmaya_matrename')\nif old_str:\n cmds.textField(textfield, e=True, it = old_str)\n\ndef apply(*args):\n path = cmds.textField(textfield, q = True, tx=True)\n if path:\n cmds.optionVar(sv=('lolmaya_matrename', path))\n path = path.replace('\\\\', '/')\n path = path.replace('/', '__')\n if not path.endswith('__'):\n path += '__'\n selected = cmds.ls(sl = True)\n for obj in selected: \n try: \n old = obj\n new = path + old.split('__')[-1]\n cmds.rename(old, new)\n except:\n pass\n\n MGlobal.displayInfo('Renamed selected objects.')\n\ncmds.textField(textfield, edit = True, ec = apply)\ncmds.button('Apply', p = layout, w = 100, h = 30, c = apply)\n\ncmds.showWindow(window)"
186 | -sourceType "python"
187 | -commandRepeatable 1
188 | -flat 1
189 | ;
190 | separator
191 | -enable 1
192 | -width 12
193 | -height 35
194 | -manage 1
195 | -visible 1
196 | -preventOverride 0
197 | -enableBackground 0
198 | -backgroundColor 0 0 0
199 | -highlightColor 0.321569 0.521569 0.65098
200 | -style "shelf"
201 | -horizontal 0
202 | ;
203 | shelfButton
204 | -enableCommandRepeat 1
205 | -flexibleWidthType 3
206 | -flexibleWidthValue 32
207 | -enable 1
208 | -width 35
209 | -height 34
210 | -manage 1
211 | -visible 1
212 | -preventOverride 0
213 | -annotation "Create 8 layers and assign selected object to all layers."
214 | -enableBackground 0
215 | -backgroundColor 0 0 0
216 | -highlightColor 0.321569 0.521569 0.65098
217 | -align "center"
218 | -label "Create 8 layers"
219 | -labelOffset 0
220 | -rotation 0
221 | -flipX 0
222 | -flipY 0
223 | -useAlpha 1
224 | -font "plainLabelFont"
225 | -imageOverlayLabel "ALL"
226 | -overlayLabelColor 0 1 0.2039
227 | -overlayLabelBackColor 0 0 0 1
228 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/layer.png"
229 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/layer.png"
230 | -style "iconOnly"
231 | -marginWidth 0
232 | -marginHeight 1
233 | -command "from maya import cmds\nfrom maya.OpenMaya import MGlobal\n\nfor i in range(1, 9):\n if not cmds.objExists(f'set{i}'):\n cmds.sets(name=f'set{i}')\n else:\n cmds.sets(addElement=f'set{i}')\n\nMGlobal.displayInfo('Created 8 sets.')"
234 | -sourceType "python"
235 | -commandRepeatable 1
236 | -flat 1
237 | ;
238 | shelfButton
239 | -enableCommandRepeat 1
240 | -flexibleWidthType 3
241 | -flexibleWidthValue 32
242 | -enable 1
243 | -width 35
244 | -height 34
245 | -manage 1
246 | -visible 1
247 | -preventOverride 0
248 | -annotation "Remove selected objects from all layers."
249 | -enableBackground 0
250 | -backgroundColor 0 0 0
251 | -highlightColor 0.321569 0.521569 0.65098
252 | -align "center"
253 | -label "Remove from all layers"
254 | -labelOffset 0
255 | -rotation 0
256 | -flipX 0
257 | -flipY 0
258 | -useAlpha 1
259 | -font "plainLabelFont"
260 | -imageOverlayLabel "X"
261 | -overlayLabelColor 1 0 0
262 | -overlayLabelBackColor 0 0 0 1
263 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/layer.png"
264 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/layer.png"
265 | -style "iconOnly"
266 | -marginWidth 0
267 | -marginHeight 1
268 | -command "from maya import cmds\nfrom maya.OpenMaya import MGlobal\n\nfor i in range(1, 9):\n if cmds.objExists(f'set{i}'):\n cmds.sets(remove=f'set{i}')\n\nMGlobal.displayInfo('Removed selected from all sets.')"
269 | -sourceType "python"
270 | -commandRepeatable 1
271 | -flat 1
272 | ;
273 | shelfButton
274 | -enableCommandRepeat 1
275 | -flexibleWidthType 3
276 | -flexibleWidthValue 32
277 | -enable 1
278 | -width 35
279 | -height 34
280 | -manage 1
281 | -visible 1
282 | -preventOverride 0
283 | -annotation "Assign/remove selected objects to layer 1."
284 | -enableBackground 0
285 | -backgroundColor 0 0 0
286 | -highlightColor 0.321569 0.521569 0.65098
287 | -align "center"
288 | -label "Layer1"
289 | -labelOffset 0
290 | -rotation 0
291 | -flipX 0
292 | -flipY 0
293 | -useAlpha 1
294 | -font "plainLabelFont"
295 | -imageOverlayLabel "1"
296 | -overlayLabelColor 1 1 1
297 | -overlayLabelBackColor 0 0 0 0.8
298 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/layer.png"
299 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/layer.png"
300 | -style "iconOnly"
301 | -marginWidth 0
302 | -marginHeight 1
303 | -command "from maya import cmds\nfrom maya.OpenMaya import MGlobal\n\ni = 1\nif not cmds.objExists(f'set{i}'):\n cmds.sets(name=f'set{i}')\nelse:\n if cmds.sets(im=f'set{i}'):\n cmds.sets(remove=f'set{i}')\n MGlobal.displayInfo('Removed selected from set{i}.')\n else:\n cmds.sets(addElement=f'set{i}')\n MGlobal.displayInfo('Assigned selected to set{i}.')"
304 | -sourceType "python"
305 | -commandRepeatable 1
306 | -flat 1
307 | ;
308 | shelfButton
309 | -enableCommandRepeat 1
310 | -flexibleWidthType 3
311 | -flexibleWidthValue 32
312 | -enable 1
313 | -width 35
314 | -height 34
315 | -manage 1
316 | -visible 1
317 | -preventOverride 0
318 | -annotation "Assign/remove selected objects to layer 2."
319 | -enableBackground 0
320 | -backgroundColor 0 0 0
321 | -highlightColor 0.321569 0.521569 0.65098
322 | -align "center"
323 | -label "Layer2"
324 | -labelOffset 0
325 | -rotation 0
326 | -flipX 0
327 | -flipY 0
328 | -useAlpha 1
329 | -font "plainLabelFont"
330 | -imageOverlayLabel "2"
331 | -overlayLabelColor 1 0.145 0
332 | -overlayLabelBackColor 0 0 0 0.8
333 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/layer.png"
334 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/layer.png"
335 | -style "iconOnly"
336 | -marginWidth 0
337 | -marginHeight 1
338 | -command "from maya import cmds\nfrom maya.OpenMaya import MGlobal\n\ni = 2\nif not cmds.objExists(f'set{i}'):\n cmds.sets(name=f'set{i}')\nelse:\n if cmds.sets(im=f'set{i}'):\n cmds.sets(remove=f'set{i}')\n MGlobal.displayInfo('Removed selected from set{i}.')\n else:\n cmds.sets(addElement=f'set{i}')\n MGlobal.displayInfo('Assigned selected to set{i}.')"
339 | -sourceType "python"
340 | -commandRepeatable 1
341 | -flat 1
342 | ;
343 | shelfButton
344 | -enableCommandRepeat 1
345 | -flexibleWidthType 3
346 | -flexibleWidthValue 32
347 | -enable 1
348 | -width 35
349 | -height 34
350 | -manage 1
351 | -visible 1
352 | -preventOverride 0
353 | -annotation "Assign/remove selected objects to layer 3."
354 | -enableBackground 0
355 | -backgroundColor 0 0 0
356 | -highlightColor 0.321569 0.521569 0.65098
357 | -align "center"
358 | -label "Layer3"
359 | -labelOffset 0
360 | -rotation 0
361 | -flipX 0
362 | -flipY 0
363 | -useAlpha 1
364 | -font "plainLabelFont"
365 | -imageOverlayLabel "3"
366 | -overlayLabelColor 1 0.6313 0
367 | -overlayLabelBackColor 0 0 0 0.8
368 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/layer.png"
369 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/layer.png"
370 | -style "iconOnly"
371 | -marginWidth 0
372 | -marginHeight 1
373 | -command "from maya import cmds\nfrom maya.OpenMaya import MGlobal\n\ni = 3\nif not cmds.objExists(f'set{i}'):\n cmds.sets(name=f'set{i}')\nelse:\n if cmds.sets(im=f'set{i}'):\n cmds.sets(remove=f'set{i}')\n MGlobal.displayInfo('Removed selected from set{i}.')\n else:\n cmds.sets(addElement=f'set{i}')\n MGlobal.displayInfo('Assigned selected to set{i}.')"
374 | -sourceType "python"
375 | -commandRepeatable 1
376 | -flat 1
377 | ;
378 | shelfButton
379 | -enableCommandRepeat 1
380 | -flexibleWidthType 3
381 | -flexibleWidthValue 32
382 | -enable 1
383 | -width 35
384 | -height 34
385 | -manage 1
386 | -visible 1
387 | -preventOverride 0
388 | -annotation "Assign/remove selected objects to layer 4."
389 | -enableBackground 0
390 | -backgroundColor 0 0 0
391 | -highlightColor 0.321569 0.521569 0.65098
392 | -align "center"
393 | -label "Layer4"
394 | -labelOffset 0
395 | -rotation 0
396 | -flipX 0
397 | -flipY 0
398 | -useAlpha 1
399 | -font "plainLabelFont"
400 | -imageOverlayLabel "4"
401 | -overlayLabelColor 0.0509 0 1
402 | -overlayLabelBackColor 0 0 0 0.8
403 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/layer.png"
404 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/layer.png"
405 | -style "iconOnly"
406 | -marginWidth 0
407 | -marginHeight 1
408 | -command "from maya import cmds\nfrom maya.OpenMaya import MGlobal\n\ni = 4\nif not cmds.objExists(f'set{i}'):\n cmds.sets(name=f'set{i}')\nelse:\n if cmds.sets(im=f'set{i}'):\n cmds.sets(remove=f'set{i}')\n MGlobal.displayInfo('Removed selected from set{i}.')\n else:\n cmds.sets(addElement=f'set{i}')\n MGlobal.displayInfo('Assigned selected to set{i}.')"
409 | -sourceType "python"
410 | -commandRepeatable 1
411 | -flat 1
412 | ;
413 | shelfButton
414 | -enableCommandRepeat 1
415 | -flexibleWidthType 3
416 | -flexibleWidthValue 32
417 | -enable 1
418 | -width 35
419 | -height 34
420 | -manage 1
421 | -visible 1
422 | -preventOverride 0
423 | -annotation "Assign/remove selected objects to layer 5."
424 | -enableBackground 0
425 | -backgroundColor 0 0 0
426 | -highlightColor 0.321569 0.521569 0.65098
427 | -align "center"
428 | -label "Layer5"
429 | -labelOffset 0
430 | -rotation 0
431 | -flipX 0
432 | -flipY 0
433 | -useAlpha 1
434 | -font "plainLabelFont"
435 | -imageOverlayLabel "5"
436 | -overlayLabelColor 0.6078 1 0.8941
437 | -overlayLabelBackColor 0 0 0 0.8
438 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/layer.png"
439 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/layer.png"
440 | -style "iconOnly"
441 | -marginWidth 0
442 | -marginHeight 1
443 | -command "from maya import cmds\nfrom maya.OpenMaya import MGlobal\n\ni = 5\nif not cmds.objExists(f'set{i}'):\n cmds.sets(name=f'set{i}')\nelse:\n if cmds.sets(im=f'set{i}'):\n cmds.sets(remove=f'set{i}')\n MGlobal.displayInfo('Removed selected from set{i}.')\n else:\n cmds.sets(addElement=f'set{i}')\n MGlobal.displayInfo('Assigned selected to set{i}.')"
444 | -sourceType "python"
445 | -commandRepeatable 1
446 | -flat 1
447 | ;
448 | shelfButton
449 | -enableCommandRepeat 1
450 | -flexibleWidthType 3
451 | -flexibleWidthValue 32
452 | -enable 1
453 | -width 35
454 | -height 34
455 | -manage 1
456 | -visible 1
457 | -preventOverride 0
458 | -annotation "Assign/remove selected objects to layer 6."
459 | -enableBackground 0
460 | -backgroundColor 0 0 0
461 | -highlightColor 0.321569 0.521569 0.65098
462 | -align "center"
463 | -label "Layer6"
464 | -labelOffset 0
465 | -rotation 0
466 | -flipX 0
467 | -flipY 0
468 | -useAlpha 1
469 | -font "plainLabelFont"
470 | -imageOverlayLabel "6"
471 | -overlayLabelColor 0 0.7647 1
472 | -overlayLabelBackColor 0 0 0 0.8
473 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/layer.png"
474 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/layer.png"
475 | -style "iconOnly"
476 | -marginWidth 0
477 | -marginHeight 1
478 | -command "from maya import cmds\nfrom maya.OpenMaya import MGlobal\n\ni = 6\nif not cmds.objExists(f'set{i}'):\n cmds.sets(name=f'set{i}')\nelse:\n if cmds.sets(im=f'set{i}'):\n cmds.sets(remove=f'set{i}')\n MGlobal.displayInfo('Removed selected from set{i}.')\n else:\n cmds.sets(addElement=f'set{i}')\n MGlobal.displayInfo('Assigned selected to set{i}.')"
479 | -sourceType "python"
480 | -commandRepeatable 1
481 | -flat 1
482 | ;
483 | shelfButton
484 | -enableCommandRepeat 1
485 | -flexibleWidthType 3
486 | -flexibleWidthValue 32
487 | -enable 1
488 | -width 35
489 | -height 34
490 | -manage 1
491 | -visible 1
492 | -preventOverride 0
493 | -annotation "Assign/remove selected objects to layer 7."
494 | -enableBackground 0
495 | -backgroundColor 0 0 0
496 | -highlightColor 0.321569 0.521569 0.65098
497 | -align "center"
498 | -label "Layer7"
499 | -labelOffset 0
500 | -rotation 0
501 | -flipX 0
502 | -flipY 0
503 | -useAlpha 1
504 | -font "plainLabelFont"
505 | -imageOverlayLabel "7"
506 | -overlayLabelColor 0.3686 1 0
507 | -overlayLabelBackColor 0 0 0 0.8
508 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/layer.png"
509 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/layer.png"
510 | -style "iconOnly"
511 | -marginWidth 0
512 | -marginHeight 1
513 | -command "from maya import cmds\nfrom maya.OpenMaya import MGlobal\n\ni = 7\nif not cmds.objExists(f'set{i}'):\n cmds.sets(name=f'set{i}')\nelse:\n if cmds.sets(im=f'set{i}'):\n cmds.sets(remove=f'set{i}')\n MGlobal.displayInfo('Removed selected from set{i}.')\n else:\n cmds.sets(addElement=f'set{i}')\n MGlobal.displayInfo('Assigned selected to set{i}.')"
514 | -sourceType "python"
515 | -commandRepeatable 1
516 | -flat 1
517 | ;
518 | shelfButton
519 | -enableCommandRepeat 1
520 | -flexibleWidthType 3
521 | -flexibleWidthValue 32
522 | -enable 1
523 | -width 35
524 | -height 34
525 | -manage 1
526 | -visible 1
527 | -preventOverride 0
528 | -annotation "Assign/remove selected objects to layer 8."
529 | -enableBackground 0
530 | -backgroundColor 0 0 0
531 | -highlightColor 0.321569 0.521569 0.65098
532 | -align "center"
533 | -label "Layer8"
534 | -labelOffset 0
535 | -rotation 0
536 | -flipX 0
537 | -flipY 0
538 | -useAlpha 1
539 | -font "plainLabelFont"
540 | -imageOverlayLabel "8"
541 | -overlayLabelColor 0.441006 0.441006 0.441006
542 | -overlayLabelBackColor 0 0 0 1
543 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/layer.png"
544 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/layer.png"
545 | -style "iconOnly"
546 | -marginWidth 0
547 | -marginHeight 1
548 | -command "from maya import cmds\nfrom maya.OpenMaya import MGlobal\n\ni = 8\nif not cmds.objExists(f'set{i}'):\n cmds.sets(name=f'set{i}')\nelse:\n if cmds.sets(im=f'set{i}'):\n cmds.sets(remove=f'set{i}')\n MGlobal.displayInfo('Removed selected from set{i}.')\n else:\n cmds.sets(addElement=f'set{i}')\n MGlobal.displayInfo('Assigned selected to set{i}.')"
549 | -sourceType "python"
550 | -commandRepeatable 1
551 | -flat 1
552 | ;
553 | separator
554 | -enable 1
555 | -width 12
556 | -height 35
557 | -manage 1
558 | -visible 1
559 | -preventOverride 0
560 | -enableBackground 0
561 | -backgroundColor 0 0 0
562 | -highlightColor 0.321569 0.521569 0.65098
563 | -style "shelf"
564 | -horizontal 0
565 | ;
566 | shelfButton
567 | -enableCommandRepeat 1
568 | -flexibleWidthType 3
569 | -flexibleWidthValue 32
570 | -enable 1
571 | -width 35
572 | -height 34
573 | -manage 1
574 | -visible 1
575 | -preventOverride 0
576 | -annotation "Assign/remove selected objects to setBushes."
577 | -enableBackground 0
578 | -backgroundColor 0 0 0
579 | -highlightColor 0.321569 0.521569 0.65098
580 | -align "center"
581 | -label "setBushes"
582 | -labelOffset 0
583 | -rotation 0
584 | -flipX 0
585 | -flipY 0
586 | -useAlpha 1
587 | -font "plainLabelFont"
588 | -overlayLabelColor 0.8 0.8 0.8
589 | -overlayLabelBackColor 0 0 0 0.5
590 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/bush.png"
591 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/bush.png"
592 | -style "iconOnly"
593 | -marginWidth 0
594 | -marginHeight 1
595 | -command "from maya import cmds\nfrom maya.OpenMaya import MGlobal\n\nif not cmds.objExists(f'setBushes'):\n cmds.sets(name=f'setBushes')\n MGlobal.displayInfo('Created setBushes.')\nelse:\n if cmds.sets(im=f'setBushes'):\n cmds.sets(remove=f'setBushes')\n MGlobal.displayInfo('Removed selected from setBushes.')\n else:\n cmds.sets(addElement=f'setBushes')\n MGlobal.displayInfo('Assigned selected to setBushes.')"
596 | -sourceType "python"
597 | -commandRepeatable 1
598 | -flat 1
599 | ;
600 | shelfButton
601 | -enableCommandRepeat 1
602 | -flexibleWidthType 3
603 | -flexibleWidthValue 32
604 | -enable 1
605 | -width 35
606 | -height 34
607 | -manage 1
608 | -visible 1
609 | -preventOverride 0
610 | -annotation "User Script"
611 | -enableBackground 0
612 | -backgroundColor 0 0 0
613 | -highlightColor 0.321569 0.521569 0.65098
614 | -align "center"
615 | -label "setBaron"
616 | -labelOffset 0
617 | -rotation 0
618 | -flipX 0
619 | -flipY 0
620 | -useAlpha 1
621 | -font "plainLabelFont"
622 | -overlayLabelColor 1 1 1
623 | -overlayLabelBackColor 0 0 0 0.5
624 | -image "C:/Users/tarng/Documents/maya/2024/prefs/icons/baron.png"
625 | -image1 "C:/Users/tarng/Documents/maya/2024/prefs/icons/baron.png"
626 | -style "iconOnly"
627 | -marginWidth 0
628 | -marginHeight 1
629 | -command "from maya import cmds\nfrom maya.OpenMaya import MGlobal\n\nselected = cmds.ls(sl = True)\nif not cmds.objExists(f'setBaron'):\n cmds.sets(name=f'setBaron')\n MGlobal.displayInfo('Created setBaron.')\nelse:\n if cmds.sets(im=f'setBaron'):\n for obj in selected:\n flag = cmds.attributeQuery('buckethash', node=obj, ex=True)\n if not flag:\n cmds.addAttr(longName='buckethash', niceName='Bucket Hash', dataType='string')\n cmds.setAttr(f'{obj}.buckethash', '00000000', type='string')\n cmds.sets(remove=f'setBaron')\n MGlobal.displayInfo('Removed selected from setBushes.')\n else:\n for obj in selected:\n flag = cmds.attributeQuery('buckethash', node=obj, ex=True)\n if not flag:\n cmds.addAttr(longName='buckethash', niceName='Bucket Hash', dataType='string')\n cmds.setAttr(f'{obj}.buckethash', '00000000', type='string')\n cmds.sets(addElement=f'setBaron')\n MGlobal.displayInfo('Assigned selected to setBaron.')"
630 | -sourceType "python"
631 | -commandRepeatable 1
632 | -flat 1
633 | ;
634 | separator
635 | -enable 1
636 | -width 34
637 | -height 35
638 | -manage 1
639 | -visible 1
640 | -preventOverride 0
641 | -enableBackground 0
642 | -backgroundColor 0 0 0
643 | -highlightColor 0.321569 0.521569 0.65098
644 | -style "shelf"
645 | -horizontal 0
646 | ;
647 | shelfButton
648 | -enableCommandRepeat 1
649 | -flexibleWidthType 3
650 | -flexibleWidthValue 32
651 | -enable 1
652 | -width 35
653 | -height 34
654 | -manage 1
655 | -visible 1
656 | -preventOverride 0
657 | -annotation "Display and edit connections in shading networks"
658 | -enableBackground 0
659 | -backgroundColor 0 0 0
660 | -highlightColor 0.321569 0.521569 0.65098
661 | -align "center"
662 | -label "Hypershade"
663 | -labelOffset 0
664 | -rotation 0
665 | -flipX 0
666 | -flipY 0
667 | -useAlpha 1
668 | -font "plainLabelFont"
669 | -overlayLabelColor 0.8 0.8 0.8
670 | -overlayLabelBackColor 0 0 0 0.5
671 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/hs.png"
672 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/hs.png"
673 | -style "iconOnly"
674 | -marginWidth 0
675 | -marginHeight 1
676 | -command "HypershadeWindow"
677 | -sourceType "mel"
678 | -commandRepeatable 1
679 | -flat 1
680 | ;
681 | shelfButton
682 | -enableCommandRepeat 1
683 | -flexibleWidthType 3
684 | -flexibleWidthValue 32
685 | -enable 1
686 | -width 35
687 | -height 34
688 | -manage 1
689 | -visible 1
690 | -preventOverride 0
691 | -annotation "Select all faces that have same material of selected face."
692 | -enableBackground 0
693 | -backgroundColor 0 0 0
694 | -highlightColor 0.321569 0.521569 0.65098
695 | -align "center"
696 | -label "Select Connected material faces"
697 | -labelOffset 0
698 | -rotation 0
699 | -flipX 0
700 | -flipY 0
701 | -useAlpha 1
702 | -font "plainLabelFont"
703 | -imageOverlayLabel "MAT"
704 | -overlayLabelColor 0.8 0.8 0.8
705 | -overlayLabelBackColor 0 0 0 1
706 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/psf.png"
707 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/psf.png"
708 | -style "iconOnly"
709 | -marginWidth 0
710 | -marginHeight 1
711 | -command "from maya.OpenMaya import *\n\nmesh_components=[]\nselections = MSelectionList()\nMGlobal.getActiveSelectionList(selections)\niterator = MItSelectionList(selections)\nwhile not iterator.isDone():\n if iterator.hasComponents():\n component=MObject()\n mesh_dagpath = MDagPath()\n iterator.getDagPath(mesh_dagpath,component)\n mesh_components.append((\n mesh_dagpath,component\n ))\n iterator.next()\n\nres_selections = MSelectionList()\nfor mesh_dagpath,component in mesh_components:\n mesh=MFnMesh(mesh_dagpath)\n # get shader/materials\n shaders = MObjectArray()\n face_shader = MIntArray()\n instance = mesh_dagpath.instanceNumber() if mesh_dagpath.isInstanced() else 0\n mesh.getConnectedShaders(instance, shaders, face_shader)\n shader_count = shaders.length()\n # check no material assigned\n if shader_count < 1:\n continue\n spread_faces=MIntArray()\n face_count=face_shader.length()\n iterator=MItMeshPolygon(mesh_dagpath,component)\n iterator.reset()\n while not iterator.isDone():\n selected_face=iterator.index()\n selected_shader=face_shader[selected_face]\n for i in range(face_count):\n if face_shader[i]==selected_shader:\n if i not in spread_faces:\n spread_faces.append(i)\n iterator.next()\n component2 = MFnSingleIndexedComponent()\n face_component = component2.create(\n MFn.kMeshPolygonComponent)\n component2.addElements(spread_faces)\n res_selections.add(mesh_dagpath, face_component)\n\nMGlobal.selectCommand(res_selections)"
712 | -sourceType "python"
713 | -commandRepeatable 1
714 | -flat 1
715 | ;
716 | shelfButton
717 | -enableCommandRepeat 1
718 | -flexibleWidthType 3
719 | -flexibleWidthValue 32
720 | -enable 1
721 | -width 35
722 | -height 34
723 | -manage 1
724 | -visible 1
725 | -preventOverride 0
726 | -annotation "Set all black emission weight to 0."
727 | -enableBackground 0
728 | -backgroundColor 0 0 0
729 | -highlightColor 0.321569 0.521569 0.65098
730 | -align "center"
731 | -label "Zero Black Emission"
732 | -labelOffset 0
733 | -rotation 0
734 | -flipX 0
735 | -flipY 0
736 | -useAlpha 1
737 | -font "plainLabelFont"
738 | -overlayLabelColor 0.8 0.8 0.8
739 | -overlayLabelBackColor 0 0 0 0.5
740 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/bem.png"
741 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/bem.png"
742 | -style "iconOnly"
743 | -marginWidth 0
744 | -marginHeight 1
745 | -command "from maya import cmds\nfrom maya.OpenMaya import MGlobal\n\nfor shading_engine in cmds.ls(type='shadingEngine'):\n if cmds.sets(shading_engine, q=True):\n mats = cmds.ls(cmds.listConnections(shading_engine), materials=True)\n for mat in mats:\n if cmds.attributeQuery('emission', node = mat, ex = True) and cmds.attributeQuery('emissionColor', node = mat, ex = True):\n files = cmds.listConnections(f'{mat}.emissionColor', type = 'file')\n if files:\n continue\n weight = cmds.getAttr(f'{mat}.emission')\n color = cmds.getAttr(f'{mat}.emissionColor')[0]\n if weight > 0 and color == (0.0, 0.0, 0.0):\n cmds.setAttr(f'{mat}.emission', 0.0)\n MGlobal.displayInfo(f'Changed {mat}.emission to 0')\nMGlobal.displayInfo('Changed all black emission weight to 0.')\n"
746 | -sourceType "python"
747 | -commandRepeatable 1
748 | -flat 1
749 | ;
750 | shelfButton
751 | -enableCommandRepeat 1
752 | -flexibleWidthType 3
753 | -flexibleWidthValue 32
754 | -enable 1
755 | -width 35
756 | -height 34
757 | -manage 1
758 | -visible 1
759 | -preventOverride 0
760 | -annotation "Fix shared vertices of all meshes in scene."
761 | -enableBackground 0
762 | -backgroundColor 0 0 0
763 | -highlightColor 0.321569 0.521569 0.65098
764 | -align "center"
765 | -label "Fix shared vertices"
766 | -labelOffset 0
767 | -rotation 0
768 | -flipX 0
769 | -flipY 0
770 | -useAlpha 1
771 | -font "plainLabelFont"
772 | -imageOverlayLabel "shared"
773 | -overlayLabelColor 0.8 0.8 0.8
774 | -overlayLabelBackColor 0 0 0 1
775 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/ef.png"
776 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/ef.png"
777 | -style "iconOnly"
778 | -marginWidth 0
779 | -marginHeight 1
780 | -command "\nfrom maya.OpenMaya import *\nfrom maya.OpenMayaAnim import *\n\niterator = MItDag(MItDag.kDepthFirst, MFn.kMesh)\nwhile not iterator.isDone():\n mesh_dagpath = MDagPath()\n iterator.getPath(mesh_dagpath)\n mesh = MFnMesh(mesh_dagpath)\n\n # get shader/materials\n shaders = MObjectArray()\n face_shader = MIntArray()\n instance = mesh_dagpath.instanceNumber() if mesh_dagpath.isInstanced() else 0\n mesh.getConnectedShaders(instance, shaders, face_shader)\n shader_count = shaders.length()\n if shader_count < 1:\n iterator.next()\n continue\n\n # extract all shared vertices first\n face_count = face_shader.length()\n map_faces = []\n for i in range(0, shader_count):\n map_faces.append(MIntArray())\n for i in range(0, face_count):\n map_faces[face_shader[i]].append(i)\n\n for i in range(0, shader_count-1):\n component = MFnSingleIndexedComponent()\n face_component = component.create(\n MFn.kMeshPolygonComponent)\n component.addElements(map_faces[i])\n selections = MSelectionList()\n selections.add(mesh_dagpath, face_component)\n MGlobal.selectCommand(selections)\n MGlobal.executeCommand(\n 'polyChipOff -ch 1 -kft 1 -dup 0 -off 0')\n iterator.next()\nMGlobal.executeCommand('select -cl')\nMGlobal.executeCommand('DeleteAllHistory')\nMGlobal.executeCommand('confirmDialog -message \"Fixed all shared vertices.\" -button \"Ok\" -defaultButton \"Ok\" -cancelButton \"Ok\"')\n"
781 | -sourceType "python"
782 | -commandRepeatable 1
783 | -flat 1
784 | ;
785 | separator
786 | -enable 1
787 | -width 34
788 | -height 35
789 | -manage 1
790 | -visible 1
791 | -preventOverride 0
792 | -enableBackground 0
793 | -backgroundColor 0 0 0
794 | -highlightColor 0.321569 0.521569 0.65098
795 | -style "shelf"
796 | -horizontal 0
797 | ;
798 | shelfButton
799 | -enableCommandRepeat 1
800 | -flexibleWidthType 3
801 | -flexibleWidthValue 32
802 | -enable 1
803 | -width 35
804 | -height 34
805 | -manage 1
806 | -visible 1
807 | -preventOverride 0
808 | -annotation "Read mapgeo.materials.py and import all textures at same location."
809 | -enableBackground 0
810 | -backgroundColor 0 0 0
811 | -highlightColor 0.321569 0.521569 0.65098
812 | -align "center"
813 | -label "Import material"
814 | -labelOffset 0
815 | -rotation 0
816 | -flipX 0
817 | -flipY 0
818 | -useAlpha 1
819 | -font "plainLabelFont"
820 | -imageOverlayLabel "IMPPY"
821 | -overlayLabelColor 0.8 0.8 0.8
822 | -overlayLabelBackColor 0 0 0 1
823 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/texture.png"
824 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/texture.png"
825 | -style "iconOnly"
826 | -marginWidth 0
827 | -marginHeight 1
828 | -command "\nfrom maya import cmds\nfrom maya.OpenMaya import *\nfrom maya.utils import executeDeferred\nimport json\n\nclass RoundingFloat(float):\n __repr__ = staticmethod(lambda x: format(x, '.4f'))\njson.encoder.float = RoundingFloat\n\nclass MAPGEOMaterial():\n def __init__(self):\n self.name = None\n self.base = None\n self.coat = None\n self.coat_normal = None\n self.transmission = None\n self.emission = None\n self.emission_texture = None\n\n\nclass MAPGEOPy():\n def __init__(self):\n self.dirname = None \n self.materials = {}\n\n def read(self, path):\n def SCToFloat(color):\n try:\n r = float(color[0])\n g = float(color[1])\n b = float(color[2])\n return True, (r,g,b)\n except:\n return False, ''\n\n self.dirname = '/'.join(path.split('/')[:-1])\n with open(path, 'r') as f:\n self.path = '/'.join(path.split('/')[:-1])\n lines = f.readlines()\n\n # get material block\n i = 0\n len12345 = len(lines)\n mat_lines = []\n while i < len12345:\n if 'StaticMaterialDef' in lines[i]:\n a = i\n for j in range(a, len12345):\n if lines[j] == ' }\\n':\n b = j\n break\n mat_lines.append((a, b))\n i = b\n i += 1\n\n for a, b in mat_lines:\n material = MAPGEOMaterial()\n\n # parse data \n for i in range(a, b):\n if 'StaticMaterialDef' in lines[i]:\n material.name = lines[i+1].split('=')[1][1:-1].replace('\"', '').replace('/', '__')\n\n # diffuse texture\n if 'DiffuseTexture' in lines[i]:\n material.base = lines[i + 1].split('=')[1][1:].replace('\"', '')[:-1]\n if 'Diffuse_Texture' in lines[i]:\n material.base = lines[i + 1].split('=')[1][1:].replace('\"', '')[:-1]\n \n\n # mask textures \n if 'Mask_Textures' in lines[i]:\n material.base = lines[i + 1].split('=')[1][1:].replace('\"', '')[:-1]\n for j in range(i+2, b):\n if 'BaseColor' in lines[j]:\n colors = lines[j+1].split('=')[1][2:-1].replace(' ', '').split(',')\n material.coat = (float(colors[0]), float(colors[1]), float(colors[2]))\n\n # mask texture with diffuse texture and color\n elif 'Mask_Texture' in lines[i]:\n material.coat_normal = lines[i + 1].split('=')[1][1:].replace('\"', '')[:-1]\n for j in range(i+2, b):\n if 'Base_Color' in lines[j]:\n colors = lines[j+1].split('=')[1][2:-1].replace(' ', '').split(',')\n material.coat = (float(colors[0]), float(colors[1]), float(colors[2]))\n # glow \n if 'GlowTexture' in lines[i]:\n material.base = lines[i + 1].split('=')[1][1:].replace('\"', '')[:-1]\n for j in range(i+2, b):\n if 'Color_Mult' in lines[j]:\n colors = lines[j+1].split('=')[1][2:-1].replace(' ', '').split(',')\n material.transmission = (float(colors[0]), float(colors[1]), float(colors[2]))\n\n # emissive \n if 'Emissive_Texture' in lines[i]:\n material.emission_texture = lines[i + 1].split('=')[1][1:].replace('\"', '')[:-1]\n if 'Emissive_Color' in lines[i]:\n colors = lines[i+1].split('=')[1][2:-1].replace(' ', '').split(',')\n res, c = SCToFloat(colors)\n if res:\n material.emission = c\n\n self.materials[material.name] = material\n\n def load(self):\n for submesh_name in self.materials:\n material = self.materials[submesh_name]\n if not cmds.objExists(material.name):\n continue\n MGlobal.displayInfo(f'Loading: {material.name}')\n t = cmds.nodeType(material.name)\n if 'standardsurface' not in t.lower():\n if cmds.attributeQuery('color', node = submesh_name, ex = True):\n texture_path = self.dirname + '/' + material.base\n\n # create file + p2d node\n MGlobal.executeCommand((\n f'shadingNode -asTexture -isColorManaged file -name \"{submesh_name}_file\";'\n f'setAttr {submesh_name}_file.fileTextureName -type \"string\" \"{texture_path}\";'\n f'shadingNode -asUtility place2dTexture -name \"{submesh_name}_p2d\";'\n ))\n\n # connect \n cmd = ''\n attributes = [\n 'coverage',\n 'translateFrame',\n 'rotateFrame',\n 'mirrorU',\n 'mirrorV',\n 'stagger',\n 'wrapU',\n 'wrapV',\n 'repeatUV',\n 'offset',\n 'rotateUV',\n 'noiseUV',\n 'vertexUvOne',\n 'vertexUvTwo',\n 'vertexUvThree',\n 'vertexCameraOne'\n ]\n for attribute in attributes:\n cmd += f'connectAttr -f {submesh_name}_p2d.{attribute} {submesh_name}_file.{attribute};'\n cmd += f'connectAttr -f {submesh_name}_p2d.outUV {submesh_name}_file.uv;'\n cmd += f'connectAttr -f {submesh_name}_p2d.outUvFilterSize {submesh_name}_file.uvFilterSize;'\n cmd += f'connectAttr -f {submesh_name}_file.outColor {submesh_name}.color;'\n cmd += f'connectAttr -f {submesh_name}_file.outTransparency {submesh_name}.transparency;'\n MGlobal.executeCommand(cmd) \n else:\n MGlobal.executeCommand(f'setAttr \"{submesh_name}.specular\" 0;')\n if material.base:\n texture_path = self.dirname + '/' + material.base\n\n # create file + p2d node\n MGlobal.executeCommand((\n f'shadingNode -asTexture -isColorManaged file -name \"{submesh_name}_file\";'\n f'setAttr {submesh_name}_file.fileTextureName -type \"string\" \"{texture_path}\";'\n f'shadingNode -asUtility place2dTexture -name \"{submesh_name}_p2d\";'\n ))\n\n # connect \n cmd = ''\n attributes = [\n 'coverage',\n 'translateFrame',\n 'rotateFrame',\n 'mirrorU',\n 'mirrorV',\n 'stagger',\n 'wrapU',\n 'wrapV',\n 'repeatUV',\n 'offset',\n 'rotateUV',\n 'noiseUV',\n 'vertexUvOne',\n 'vertexUvTwo',\n 'vertexUvThree',\n 'vertexCameraOne'\n ]\n for attribute in attributes:\n cmd += f'connectAttr -f {submesh_name}_p2d.{attribute} {submesh_name}_file.{attribute};'\n cmd += f'connectAttr -f {submesh_name}_p2d.outUV {submesh_name}_file.uv;'\n cmd += f'connectAttr -f {submesh_name}_p2d.outUvFilterSize {submesh_name}_file.uvFilterSize;'\n cmd += f'connectAttr -f {submesh_name}_file.outColor {submesh_name}.baseColor;'\n MGlobal.executeCommand(cmd)\n if material.coat:\n MGlobal.executeCommand((\n f'setAttr \"{submesh_name}.coat\" 1;'\n f'setAttr \"{submesh_name}.coatColor\" -type double3 {material.coat[0]} {material.coat[1]} {material.coat[2]};'\n ))\n if material.coat_normal:\n texture_path = self.dirname + '/' + material.coat_normal\n\n # create file + p2d node\n MGlobal.executeCommand((\n f'shadingNode -asTexture -isColorManaged file -name \"{submesh_name}_coatfile\";'\n f'setAttr {submesh_name}_coatfile.fileTextureName -type \"string\" \"{texture_path}\";'\n f'shadingNode -asUtility place2dTexture -name \"{submesh_name}_coatp2d\";'\n ))\n\n # connect\n cmd = ''\n attributes = [\n 'coverage',\n 'translateFrame',\n 'rotateFrame',\n 'mirrorU',\n 'mirrorV',\n 'stagger',\n 'wrapU',\n 'wrapV',\n 'repeatUV',\n 'offset',\n 'rotateUV',\n 'noiseUV',\n 'vertexUvOne',\n 'vertexUvTwo',\n 'vertexUvThree',\n 'vertexCameraOne'\n ]\n for attribute in attributes:\n cmd += f'connectAttr -f {submesh_name}_coatp2d.{attribute} {submesh_name}_coatfile.{attribute};'\n cmd += f'connectAttr -f {submesh_name}_coatp2d.outUV {submesh_name}_coatfile.uv;'\n cmd += f'connectAttr -f {submesh_name}_coatp2d.outUvFilterSize {submesh_name}_coatfile.uvFilterSize;'\n cmd += f'connectAttr -f {submesh_name}_coatfile.outColor {submesh_name}.coatNormal;'\n MGlobal.executeCommand(cmd)\n if material.transmission:\n MGlobal.executeCommand((\n f'setAttr \"{submesh_name}.transmission\" 1;'\n f'setAttr \"{submesh_name}.transmissionColor\" -type double3 {material.transmission[0]} {material.transmission[1]} {material.transmission[2]};'\n ))\n if material.emission_texture:\n texture_path = self.dirname + '/' + material.emission_texture\n\n # create file + p2d node\n MGlobal.executeCommand((\n f'shadingNode -asTexture -isColorManaged file -name \"{submesh_name}_emissionfile\";'\n f'setAttr {submesh_name}_emissionfile.fileTextureName -type \"string\" \"{texture_path}\";'\n f'shadingNode -asUtility place2dTexture -name \"{submesh_name}_emissionp2d\";'\n ))\n\n # connect\n cmd = ''\n attributes = [\n 'coverage',\n 'translateFrame',\n 'rotateFrame',\n 'mirrorU',\n 'mirrorV',\n 'stagger',\n 'wrapU',\n 'wrapV',\n 'repeatUV',\n 'offset',\n 'rotateUV',\n 'noiseUV',\n 'vertexUvOne',\n 'vertexUvTwo',\n 'vertexUvThree',\n 'vertexCameraOne'\n ]\n for attribute in attributes:\n cmd += f'connectAttr -f {submesh_name}_emissionp2d.{attribute} {submesh_name}_emissionfile.{attribute};'\n cmd += f'connectAttr -f {submesh_name}_emissionp2d.outUV {submesh_name}_emissionfile.uv;'\n cmd += f'connectAttr -f {submesh_name}_emissionp2d.outUvFilterSize {submesh_name}_emissionfile.uvFilterSize;'\n cmd += f'connectAttr -f {submesh_name}_emissionfile.outColor {submesh_name}.emissionColor;'\n MGlobal.executeCommand(cmd)\n else:\n if material.emission:\n MGlobal.executeCommand((\n f'setAttr \"{submesh_name}.emission\" 1;'\n f'setAttr \"{submesh_name}.emissionColor\" -type double3 {material.emission[0]} {material.emission[1]} {material.emission[2]};'\n ))\n\n def dump(self):\n meshes=cmds.ls(sl=True,dag=True,s=True)\n if meshes != None and len(meshes)>0:\n scope=cmds.listConnections(meshes, type ='shadingEngine')\n else:\n scope=cmds.ls(type='shadingEngine')\n if scope == None:\n return\n mats = []\n for shading_engine in scope:\n if cmds.sets(shading_engine, q=True):\n mats += cmds.ls(cmds.listConnections(shading_engine), materials=True)\n for material in mats:\n MGlobal.displayInfo(f'Dumping: {material}')\n t = cmds.nodeType(material)\n m = MAPGEOMaterial()\n m.name = material\n if 'standardsurface' not in t.lower():\n if cmds.attributeQuery('color', node = m.name, ex = True):\n colorfiles = cmds.listConnections(f'{m.name}.color', type = 'file')\n if colorfiles:\n m.base = cmds.getAttr(f'{colorfiles[0]}.fileTextureName')\n else:\n \n colorfiles = cmds.listConnections(f'{m.name}.baseColor', type = 'file')\n if colorfiles:\n m.base = cmds.getAttr(f'{colorfiles[0]}.fileTextureName')\n\n if cmds.getAttr(f'{m.name}.transmission') > 0.0:\n m.transmission = cmds.getAttr(f'{m.name}.transmissionColor')[0]\n\n if cmds.getAttr(f'{m.name}.coat') > 0.0:\n m.coat = cmds.getAttr(f'{m.name}.coatColor')[0]\n coatfiles = cmds.listConnections(f'{m.name}.coatNormal', type = 'file')\n if coatfiles:\n m.coat_normal = cmds.getAttr(f'{coatfiles[0]}.fileTextureName')\n\n if cmds.getAttr(f'{m.name}.emission') > 0.0:\n emissionfiles = cmds.listConnections(f'{m.name}.emissionColor', type = 'file')\n if emissionfiles:\n m.emission_texture = cmds.getAttr(f'{emissionfiles[0]}.fileTextureName')\n else:\n m.emission = cmds.getAttr(f'{m.name}.emissionColor')[0]\n\n self.materials[m.name] = m\n\n def write(self, path):\n if cmds.window('CHOOSEMAPGEONAME', ex=True):\n cmds.deleteUI('CHOOSEMAPGEONAME')\n\n window = cmds.window(\n \"CHOOSEMAPGEONAME\", \n title = \"Name of this map:\", \n sizeable = False\n )\n\n layout = cmds.rowLayout (p = window, nc = 2)\n textfield = cmds.textField(p = layout, w = 500, h = 30)\n old_str = cmds.optionVar(q ='lolmaya_mapname')\n if old_str:\n cmds.textField(textfield, e = True, it = old_str)\n\n def ok(*args):\n mapname = cmds.textField(textfield, q = True, tx=True)\n cmds.optionVar(sv=('lolmaya_mapname',mapname)) \n texture_path = f'ASSETS/Maps/KitPieces/{mapname}/textures/'\n real_texture_path = '/'.join(path.split('/')[:-1]) + '/' + texture_path\n cmds.sysFile(real_texture_path, makeDir=True )\n \n if mapname:\n executeDeferred(\"cmds.deleteUI('CHOOSEMAPGEONAME')\")\n matlist = []\n for matname in self.materials:\n dic = {}\n m = self.materials[matname]\n dic['name'] = m.name.replace('__', '/')\n if m.base:\n dic['type'] = 'diffuse'\n texture = m.base.split('/')[-1]\n dic['diffuse_texture'] = texture_path + texture\n cmds.sysFile(m.base, copy=real_texture_path + texture)\n\n if m.coat:\n dic['type'] = 'mask'\n if m.coat_normal:\n texture = m.coat_normal.split('/')[-1]\n dic['mask_texture'] = texture_path + texture\n cmds.sysFile(m.coat_normal, copy=real_texture_path + texture)\n dic['mask_color'] = m.coat\n\n if m.transmission:\n dic['type'] = 'glow'\n dic['glow_color'] = m.transmission\n \n if m.emission_texture or m.emission:\n dic['type'] = 'emissive'\n if m.emission_texture:\n texture = m.emission_texture.split('/')[-1]\n dic['emissive_texture'] = texture_path + texture\n cmds.sysFile(m.emission_texture, copy=real_texture_path + texture)\n else:\n dic['emissive_color'] = m.emission\n \n matlist.append(dic)\n \n with open(path, 'w+') as f:\n json.dump(matlist, f, indent=4)\n else:\n raise Exception('Please enter map name to export materials.')\n\n cmds.textField(textfield, edit = True, cc = ok)\n cmds.button('OK', p = layout, w = 100, h = 30, c = ok)\n cmds.showWindow(window)\n\n\ndef read():\n result = cmds.fileDialog2(\n ds = 2, fm = 1,\n ff = 'Material PY(*.py)',\n cap = 'Import material PY file',\n okc = 'Import'\n )\n if result:\n py_path = result[0]\n mgpy = MAPGEOPy()\n mgpy.read(py_path)\n mgpy.load()\n\ndef write():\n result = cmds.fileDialog2(\n ds = 2, fm = 0,\n ff = 'Material JSON(*.json)',\n cap = 'Export material JSON file',\n okc = 'Export'\n )\n if result:\n json_path = result[0]\n mgpy = MAPGEOPy()\n mgpy.dump()\n mgpy.write(json_path)\n\nread()\n"
829 | -sourceType "python"
830 | -commandRepeatable 1
831 | -flat 1
832 | ;
833 | shelfButton
834 | -enableCommandRepeat 1
835 | -flexibleWidthType 3
836 | -flexibleWidthValue 32
837 | -enable 1
838 | -width 35
839 | -height 34
840 | -manage 1
841 | -visible 1
842 | -preventOverride 0
843 | -annotation "Export all materials in scene to a JSON file, then you can convert it to league shader with Avatar made by Killery. "
844 | -enableBackground 0
845 | -backgroundColor 0 0 0
846 | -highlightColor 0.321569 0.521569 0.65098
847 | -align "center"
848 | -label "Export material"
849 | -labelOffset 0
850 | -rotation 0
851 | -flipX 0
852 | -flipY 0
853 | -useAlpha 1
854 | -font "plainLabelFont"
855 | -imageOverlayLabel "EXPJS"
856 | -overlayLabelColor 0.8 0.8 0.8
857 | -overlayLabelBackColor 0 0 0 1
858 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/texture.png"
859 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/texture.png"
860 | -style "iconOnly"
861 | -marginWidth 0
862 | -marginHeight 1
863 | -command "\nfrom maya import cmds\nfrom maya.OpenMaya import *\nfrom maya.utils import executeDeferred\nimport json\n\nclass RoundingFloat(float):\n __repr__ = staticmethod(lambda x: format(x, '.4f'))\njson.encoder.float = RoundingFloat\n\nclass MAPGEOMaterial():\n def __init__(self):\n self.name = None\n self.base = None\n self.coat = None\n self.coat_normal = None\n self.transmission = None\n self.emission = None\n self.emission_texture = None\n\n\nclass MAPGEOPy():\n def __init__(self):\n self.dirname = None \n self.materials = {}\n\n def read(self, path):\n def SCToFloat(color):\n try:\n r = float(color[0])\n g = float(color[1])\n b = float(color[2])\n return True, (r,g,b)\n except:\n return False, ''\n\n self.dirname = '/'.join(path.split('/')[:-1])\n with open(path, 'r') as f:\n self.path = '/'.join(path.split('/')[:-1])\n lines = f.readlines()\n\n # get material block\n i = 0\n len12345 = len(lines)\n mat_lines = []\n while i < len12345:\n if 'StaticMaterialDef' in lines[i]:\n a = i\n for j in range(a, len12345):\n if lines[j] == ' }\\n':\n b = j\n break\n mat_lines.append((a, b))\n i = b\n i += 1\n\n for a, b in mat_lines:\n material = MAPGEOMaterial()\n\n # parse data \n for i in range(a, b):\n if 'StaticMaterialDef' in lines[i]:\n material.name = lines[i+1].split('=')[1][1:-1].replace('\"', '').replace('/', '__')\n\n # diffuse texture\n if 'DiffuseTexture' in lines[i]:\n material.base = lines[i + 1].split('=')[1][1:].replace('\"', '')[:-1]\n if 'Diffuse_Texture' in lines[i]:\n material.base = lines[i + 1].split('=')[1][1:].replace('\"', '')[:-1]\n \n\n # mask textures \n if 'Mask_Textures' in lines[i]:\n material.base = lines[i + 1].split('=')[1][1:].replace('\"', '')[:-1]\n for j in range(i+2, b):\n if 'BaseColor' in lines[j]:\n colors = lines[j+1].split('=')[1][2:-1].replace(' ', '').split(',')\n material.coat = (float(colors[0]), float(colors[1]), float(colors[2]))\n\n # mask texture with diffuse texture and color\n elif 'Mask_Texture' in lines[i]:\n material.coat_normal = lines[i + 1].split('=')[1][1:].replace('\"', '')[:-1]\n for j in range(i+2, b):\n if 'Base_Color' in lines[j]:\n colors = lines[j+1].split('=')[1][2:-1].replace(' ', '').split(',')\n material.coat = (float(colors[0]), float(colors[1]), float(colors[2]))\n # glow \n if 'GlowTexture' in lines[i]:\n material.base = lines[i + 1].split('=')[1][1:].replace('\"', '')[:-1]\n for j in range(i+2, b):\n if 'Color_Mult' in lines[j]:\n colors = lines[j+1].split('=')[1][2:-1].replace(' ', '').split(',')\n material.transmission = (float(colors[0]), float(colors[1]), float(colors[2]))\n\n # emissive \n if 'Emissive_Texture' in lines[i]:\n material.emission_texture = lines[i + 1].split('=')[1][1:].replace('\"', '')[:-1]\n if 'Emissive_Color' in lines[i]:\n colors = lines[i+1].split('=')[1][2:-1].replace(' ', '').split(',')\n res, c = SCToFloat(colors)\n if res:\n material.emission = c\n\n self.materials[material.name] = material\n\n def load(self):\n for submesh_name in self.materials:\n material = self.materials[submesh_name]\n if not cmds.objExists(material.name):\n continue\n MGlobal.displayInfo(f'Loading: {material.name}')\n t = cmds.nodeType(material.name)\n if 'standardsurface' not in t.lower():\n if cmds.attributeQuery('color', node = submesh_name, ex = True):\n texture_path = self.dirname + '/' + material.base\n\n # create file + p2d node\n MGlobal.executeCommand((\n f'shadingNode -asTexture -isColorManaged file -name \"{submesh_name}_file\";'\n f'setAttr {submesh_name}_file.fileTextureName -type \"string\" \"{texture_path}\";'\n f'shadingNode -asUtility place2dTexture -name \"{submesh_name}_p2d\";'\n ))\n\n # connect \n cmd = ''\n attributes = [\n 'coverage',\n 'translateFrame',\n 'rotateFrame',\n 'mirrorU',\n 'mirrorV',\n 'stagger',\n 'wrapU',\n 'wrapV',\n 'repeatUV',\n 'offset',\n 'rotateUV',\n 'noiseUV',\n 'vertexUvOne',\n 'vertexUvTwo',\n 'vertexUvThree',\n 'vertexCameraOne'\n ]\n for attribute in attributes:\n cmd += f'connectAttr -f {submesh_name}_p2d.{attribute} {submesh_name}_file.{attribute};'\n cmd += f'connectAttr -f {submesh_name}_p2d.outUV {submesh_name}_file.uv;'\n cmd += f'connectAttr -f {submesh_name}_p2d.outUvFilterSize {submesh_name}_file.uvFilterSize;'\n cmd += f'connectAttr -f {submesh_name}_file.outColor {submesh_name}.color;'\n cmd += f'connectAttr -f {submesh_name}_file.outTransparency {submesh_name}.transparency;'\n MGlobal.executeCommand(cmd) \n else:\n MGlobal.executeCommand(f'setAttr \"{submesh_name}.specular\" 0;')\n if material.base:\n texture_path = self.dirname + '/' + material.base\n\n # create file + p2d node\n MGlobal.executeCommand((\n f'shadingNode -asTexture -isColorManaged file -name \"{submesh_name}_file\";'\n f'setAttr {submesh_name}_file.fileTextureName -type \"string\" \"{texture_path}\";'\n f'shadingNode -asUtility place2dTexture -name \"{submesh_name}_p2d\";'\n ))\n\n # connect \n cmd = ''\n attributes = [\n 'coverage',\n 'translateFrame',\n 'rotateFrame',\n 'mirrorU',\n 'mirrorV',\n 'stagger',\n 'wrapU',\n 'wrapV',\n 'repeatUV',\n 'offset',\n 'rotateUV',\n 'noiseUV',\n 'vertexUvOne',\n 'vertexUvTwo',\n 'vertexUvThree',\n 'vertexCameraOne'\n ]\n for attribute in attributes:\n cmd += f'connectAttr -f {submesh_name}_p2d.{attribute} {submesh_name}_file.{attribute};'\n cmd += f'connectAttr -f {submesh_name}_p2d.outUV {submesh_name}_file.uv;'\n cmd += f'connectAttr -f {submesh_name}_p2d.outUvFilterSize {submesh_name}_file.uvFilterSize;'\n cmd += f'connectAttr -f {submesh_name}_file.outColor {submesh_name}.baseColor;'\n MGlobal.executeCommand(cmd)\n if material.coat:\n MGlobal.executeCommand((\n f'setAttr \"{submesh_name}.coat\" 1;'\n f'setAttr \"{submesh_name}.coatColor\" -type double3 {material.coat[0]} {material.coat[1]} {material.coat[2]};'\n ))\n if material.coat_normal:\n texture_path = self.dirname + '/' + material.coat_normal\n\n # create file + p2d node\n MGlobal.executeCommand((\n f'shadingNode -asTexture -isColorManaged file -name \"{submesh_name}_coatfile\";'\n f'setAttr {submesh_name}_coatfile.fileTextureName -type \"string\" \"{texture_path}\";'\n f'shadingNode -asUtility place2dTexture -name \"{submesh_name}_coatp2d\";'\n ))\n\n # connect\n cmd = ''\n attributes = [\n 'coverage',\n 'translateFrame',\n 'rotateFrame',\n 'mirrorU',\n 'mirrorV',\n 'stagger',\n 'wrapU',\n 'wrapV',\n 'repeatUV',\n 'offset',\n 'rotateUV',\n 'noiseUV',\n 'vertexUvOne',\n 'vertexUvTwo',\n 'vertexUvThree',\n 'vertexCameraOne'\n ]\n for attribute in attributes:\n cmd += f'connectAttr -f {submesh_name}_coatp2d.{attribute} {submesh_name}_coatfile.{attribute};'\n cmd += f'connectAttr -f {submesh_name}_coatp2d.outUV {submesh_name}_coatfile.uv;'\n cmd += f'connectAttr -f {submesh_name}_coatp2d.outUvFilterSize {submesh_name}_coatfile.uvFilterSize;'\n cmd += f'connectAttr -f {submesh_name}_coatfile.outColor {submesh_name}.coatNormal;'\n MGlobal.executeCommand(cmd)\n if material.transmission:\n MGlobal.executeCommand((\n f'setAttr \"{submesh_name}.transmission\" 1;'\n f'setAttr \"{submesh_name}.transmissionColor\" -type double3 {material.transmission[0]} {material.transmission[1]} {material.transmission[2]};'\n ))\n if material.emission_texture:\n texture_path = self.dirname + '/' + material.emission_texture\n\n # create file + p2d node\n MGlobal.executeCommand((\n f'shadingNode -asTexture -isColorManaged file -name \"{submesh_name}_emissionfile\";'\n f'setAttr {submesh_name}_emissionfile.fileTextureName -type \"string\" \"{texture_path}\";'\n f'shadingNode -asUtility place2dTexture -name \"{submesh_name}_emissionp2d\";'\n ))\n\n # connect\n cmd = ''\n attributes = [\n 'coverage',\n 'translateFrame',\n 'rotateFrame',\n 'mirrorU',\n 'mirrorV',\n 'stagger',\n 'wrapU',\n 'wrapV',\n 'repeatUV',\n 'offset',\n 'rotateUV',\n 'noiseUV',\n 'vertexUvOne',\n 'vertexUvTwo',\n 'vertexUvThree',\n 'vertexCameraOne'\n ]\n for attribute in attributes:\n cmd += f'connectAttr -f {submesh_name}_emissionp2d.{attribute} {submesh_name}_emissionfile.{attribute};'\n cmd += f'connectAttr -f {submesh_name}_emissionp2d.outUV {submesh_name}_emissionfile.uv;'\n cmd += f'connectAttr -f {submesh_name}_emissionp2d.outUvFilterSize {submesh_name}_emissionfile.uvFilterSize;'\n cmd += f'connectAttr -f {submesh_name}_emissionfile.outColor {submesh_name}.emissionColor;'\n MGlobal.executeCommand(cmd)\n else:\n if material.emission:\n MGlobal.executeCommand((\n f'setAttr \"{submesh_name}.emission\" 1;'\n f'setAttr \"{submesh_name}.emissionColor\" -type double3 {material.emission[0]} {material.emission[1]} {material.emission[2]};'\n ))\n\n def dump(self):\n meshes=cmds.ls(sl=True,dag=True,s=True)\n if meshes != None and len(meshes)>0:\n scope=cmds.listConnections(meshes, type ='shadingEngine')\n else:\n scope=cmds.ls(type='shadingEngine')\n if scope == None:\n return\n mats = []\n for shading_engine in scope:\n if cmds.sets(shading_engine, q=True):\n mats += cmds.ls(cmds.listConnections(shading_engine), materials=True)\n for material in mats:\n MGlobal.displayInfo(f'Dumping: {material}')\n t = cmds.nodeType(material)\n m = MAPGEOMaterial()\n m.name = material\n if 'standardsurface' not in t.lower():\n if cmds.attributeQuery('color', node = m.name, ex = True):\n colorfiles = cmds.listConnections(f'{m.name}.color', type = 'file')\n if colorfiles:\n m.base = cmds.getAttr(f'{colorfiles[0]}.fileTextureName')\n else:\n \n colorfiles = cmds.listConnections(f'{m.name}.baseColor', type = 'file')\n if colorfiles:\n m.base = cmds.getAttr(f'{colorfiles[0]}.fileTextureName')\n\n if cmds.getAttr(f'{m.name}.transmission') > 0.0:\n m.transmission = cmds.getAttr(f'{m.name}.transmissionColor')[0]\n\n if cmds.getAttr(f'{m.name}.coat') > 0.0:\n m.coat = cmds.getAttr(f'{m.name}.coatColor')[0]\n coatfiles = cmds.listConnections(f'{m.name}.coatNormal', type = 'file')\n if coatfiles:\n m.coat_normal = cmds.getAttr(f'{coatfiles[0]}.fileTextureName')\n\n if cmds.getAttr(f'{m.name}.emission') > 0.0:\n emissionfiles = cmds.listConnections(f'{m.name}.emissionColor', type = 'file')\n if emissionfiles:\n m.emission_texture = cmds.getAttr(f'{emissionfiles[0]}.fileTextureName')\n else:\n m.emission = cmds.getAttr(f'{m.name}.emissionColor')[0]\n\n self.materials[m.name] = m\n\n def write(self, path):\n if cmds.window('CHOOSEMAPGEONAME', ex=True):\n cmds.deleteUI('CHOOSEMAPGEONAME')\n\n window = cmds.window(\n \"CHOOSEMAPGEONAME\", \n title = \"Name of this map:\", \n sizeable = False\n )\n\n layout = cmds.rowLayout (p = window, nc = 2)\n textfield = cmds.textField(p = layout, w = 500, h = 30)\n old_str = cmds.optionVar(q ='lolmaya_mapname')\n if old_str:\n cmds.textField(textfield, e = True, it = old_str)\n\n def ok(*args):\n mapname = cmds.textField(textfield, q = True, tx=True)\n cmds.optionVar(sv=('lolmaya_mapname',mapname)) \n texture_path = f'ASSETS/Maps/KitPieces/{mapname}/textures/'\n real_texture_path = '/'.join(path.split('/')[:-1]) + '/' + texture_path\n cmds.sysFile(real_texture_path, makeDir=True )\n \n if mapname:\n executeDeferred(\"cmds.deleteUI('CHOOSEMAPGEONAME')\")\n matlist = []\n for matname in self.materials:\n dic = {}\n m = self.materials[matname]\n dic['name'] = m.name.replace('__', '/')\n if m.base:\n dic['type'] = 'diffuse'\n texture = m.base.split('/')[-1]\n dic['diffuse_texture'] = texture_path + texture\n cmds.sysFile(m.base, copy=real_texture_path + texture)\n\n if m.coat:\n dic['type'] = 'mask'\n if m.coat_normal:\n texture = m.coat_normal.split('/')[-1]\n dic['mask_texture'] = texture_path + texture\n cmds.sysFile(m.coat_normal, copy=real_texture_path + texture)\n dic['mask_color'] = m.coat\n\n if m.transmission:\n dic['type'] = 'glow'\n dic['glow_color'] = m.transmission\n \n if m.emission_texture or m.emission:\n dic['type'] = 'emissive'\n if m.emission_texture:\n texture = m.emission_texture.split('/')[-1]\n dic['emissive_texture'] = texture_path + texture\n cmds.sysFile(m.emission_texture, copy=real_texture_path + texture)\n else:\n dic['emissive_color'] = m.emission\n \n matlist.append(dic)\n \n with open(path, 'w+') as f:\n json.dump(matlist, f, indent=4)\n else:\n raise Exception('Please enter map name to export materials.')\n\n cmds.textField(textfield, edit = True, cc = ok)\n cmds.button('OK', p = layout, w = 100, h = 30, c = ok)\n cmds.showWindow(window)\n\n\ndef read():\n result = cmds.fileDialog2(\n ds = 2, fm = 1,\n ff = 'Material PY(*.py)',\n cap = 'Import material PY file',\n okc = 'Import'\n )\n if result:\n py_path = result[0]\n mgpy = MAPGEOPy()\n mgpy.read(py_path)\n mgpy.load()\n\ndef write():\n result = cmds.fileDialog2(\n ds = 2, fm = 0,\n ff = 'Material JSON(*.json)',\n cap = 'Export material JSON file',\n okc = 'Export'\n )\n if result:\n json_path = result[0]\n mgpy = MAPGEOPy()\n mgpy.dump()\n mgpy.write(json_path)\n\nwrite()\n"
864 | -sourceType "python"
865 | -commandRepeatable 1
866 | -flat 1
867 | ;
868 | shelfButton
869 | -enableCommandRepeat 1
870 | -flexibleWidthType 3
871 | -flexibleWidthValue 32
872 | -enable 1
873 | -width 35
874 | -height 34
875 | -manage 1
876 | -visible 1
877 | -preventOverride 0
878 | -annotation "Export all materials in scene to a PY file, then you can add it to original materials.py. (ONLY diffuse)"
879 | -enableBackground 0
880 | -backgroundColor 0 0 0
881 | -highlightColor 0.321569 0.521569 0.65098
882 | -align "center"
883 | -label "Export material (py)"
884 | -labelOffset 0
885 | -rotation 0
886 | -flipX 0
887 | -flipY 0
888 | -useAlpha 1
889 | -font "plainLabelFont"
890 | -imageOverlayLabel "EXPPY"
891 | -overlayLabelColor 0.8 0.8 0.8
892 | -overlayLabelBackColor 0 0 0 1
893 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/texture.png"
894 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/texture.png"
895 | -style "iconOnly"
896 | -marginWidth 0
897 | -marginHeight 1
898 | -command "\nfrom maya import cmds\nfrom maya.OpenMaya import *\nfrom maya.utils import executeDeferred\n\n\nsr_defmat = \"\"\"\n\"custom_material\" = StaticMaterialDef {\n name: string = \"custom_material\"\n type: u32 = 0\n defaultTechnique: string = \"normal\"\n samplerValues: list2[embed] = {\n StaticMaterialShaderSamplerDef {\n samplerName: string = \"DiffuseTexture\"\n textureName: string = \"custom_texture\"\n addressU: u32 = 1\n }\n }\n switches: list2[embed] = {\n StaticMaterialSwitchDef {\n name: string = \"MASK_FX_IN_MAP_CENTER\"\n on: bool = false\n }\n }\n shaderMacros: map[string,string] = {\n \"NO_BAKED_LIGHTING\" = \"1\"\n \"DISABLE_DEPTH_FOG\" = \"1\"\n \"PREMULTIPLIED_ALPHA\" = \"1\"\n }\n techniques: list[embed] = {\n StaticMaterialTechniqueDef {\n name: string = \"normal\"\n passes: list[embed] = {\n StaticMaterialPassDef {\n shader: link = \"Shaders/StaticMesh/SRX_Blend_Master\"\n cullEnable: bool = false\n }\n }\n }\n }\n childTechniques: list[embed] = {\n StaticMaterialChildTechniqueDef {\n name: string = \"env_transition\"\n parentName: string = \"normal\"\n shaderMacros: map[string,string] = {\n \"ENV_TRANSITION\" = \"1\"\n }\n }\n }\n}\"\"\"\n\n\nclass MAPGEOMaterial():\n def __init__(self):\n self.name = None\n self.base = None\n self.coat = None\n self.coat_normal = None\n self.transmission = None\n self.emission = None\n self.emission_texture = None\n\n\nclass MAPGEOPy():\n def __init__(self):\n self.dirname = None\n self.materials = {}\n\n def dump(self):\n meshes=cmds.ls(sl=True,dag=True,s=True)\n if meshes != None and len(meshes)>0:\n scope=cmds.listConnections(meshes, type ='shadingEngine')\n else:\n scope=cmds.ls(type='shadingEngine')\n if scope == None:\n return\n mats = []\n for shading_engine in scope:\n if cmds.sets(shading_engine, q=True):\n mats += cmds.ls(cmds.listConnections(shading_engine),\n materials=True)\n for material in mats:\n MGlobal.displayInfo(f'Dumping: {material}')\n t = cmds.nodeType(material)\n m = MAPGEOMaterial()\n m.name = material\n if 'standardsurface' not in t.lower():\n if cmds.attributeQuery('color', node=m.name, ex=True):\n colorfiles = cmds.listConnections(\n f'{m.name}.color', type='file')\n if colorfiles:\n m.base = cmds.getAttr(\n f'{colorfiles[0]}.fileTextureName')\n else:\n\n colorfiles = cmds.listConnections(\n f'{m.name}.baseColor', type='file')\n if colorfiles:\n m.base = cmds.getAttr(f'{colorfiles[0]}.fileTextureName')\n\n if cmds.getAttr(f'{m.name}.transmission') > 0.0:\n m.transmission = cmds.getAttr(\n f'{m.name}.transmissionColor')[0]\n\n if cmds.getAttr(f'{m.name}.coat') > 0.0:\n m.coat = cmds.getAttr(f'{m.name}.coatColor')[0]\n coatfiles = cmds.listConnections(\n f'{m.name}.coatNormal', type='file')\n if coatfiles:\n m.coat_normal = cmds.getAttr(\n f'{coatfiles[0]}.fileTextureName')\n\n if cmds.getAttr(f'{m.name}.emission') > 0.0:\n emissionfiles = cmds.listConnections(\n f'{m.name}.emissionColor', type='file')\n if emissionfiles:\n m.emission_texture = cmds.getAttr(\n f'{emissionfiles[0]}.fileTextureName')\n else:\n m.emission = cmds.getAttr(f'{m.name}.emissionColor')[0]\n\n self.materials[m.name] = m\n\n def write(self, path):\n if cmds.window('CHOOSEMAPGEONAME', ex=True):\n cmds.deleteUI('CHOOSEMAPGEONAME')\n\n window = cmds.window(\n \"CHOOSEMAPGEONAME\",\n title=\"Name of this map:\",\n sizeable=False\n )\n\n layout = cmds.rowLayout(p=window, nc=2)\n textfield = cmds.textField(p=layout, w=500, h=30)\n old_str = cmds.optionVar(q='lolmaya_mapname')\n if old_str:\n cmds.textField(textfield, e=True, it=old_str)\n\n def ok(*args):\n mapname = cmds.textField(textfield, q=True, tx=True)\n cmds.optionVar(sv=('lolmaya_mapname', mapname))\n texture_path = f'ASSETS/Maps/KitPieces/{mapname}/textures/'\n real_texture_path = '/'.join(path.split('/')\n [:-1]) + '/' + texture_path\n cmds.sysFile(real_texture_path, makeDir=True)\n\n if mapname:\n executeDeferred(\"cmds.deleteUI('CHOOSEMAPGEONAME')\")\n matlist = []\n for matname in self.materials:\n dic = {}\n m = self.materials[matname]\n dic['name'] = m.name.replace('__', '/')\n if m.base:\n dic['type'] = 'diffuse'\n texture = m.base.split('/')[-1]\n dic['diffuse_texture'] = texture_path + texture\n cmds.sysFile(m.base, copy=real_texture_path + texture)\n\n if m.coat:\n dic['type'] = 'mask'\n if m.coat_normal:\n texture = m.coat_normal.split('/')[-1]\n dic['mask_texture'] = texture_path + texture\n cmds.sysFile(\n m.coat_normal, copy=real_texture_path + texture)\n dic['mask_color'] = m.coat\n\n if m.transmission:\n dic['type'] = 'glow'\n dic['glow_color'] = m.transmission\n\n if m.emission_texture or m.emission:\n dic['type'] = 'emissive'\n if m.emission_texture:\n texture = m.emission_texture.split('/')[-1]\n dic['emissive_texture'] = texture_path + texture\n cmds.sysFile(m.emission_texture,\n copy=real_texture_path + texture)\n else:\n dic['emissive_color'] = m.emission\n\n matlist.append(dic)\n\n with open(path, 'w+') as f:\n for dic in matlist:\n if 'diffuse_texture' in dic:\n f.write(\n sr_defmat.replace(\n 'custom_material', dic['name']\n ).replace(\n 'custom_texture', dic['diffuse_texture']\n )\n )\n\n else:\n raise Exception('Please enter map name to export materials.')\n\n cmds.textField(textfield, edit=True, cc=ok)\n cmds.button('OK', p=layout, w=100, h=30, c=ok)\n cmds.showWindow(window)\n\n\ndef write():\n result = cmds.fileDialog2(\n ds=2, fm=0,\n ff='Material PY(*.py)',\n cap='Export material py file',\n okc='Export'\n )\n if result:\n py_path = result[0]\n mgpy = MAPGEOPy()\n mgpy.dump()\n mgpy.write(py_path)\n\n\nwrite()\n"
899 | -sourceType "python"
900 | -commandRepeatable 1
901 | -flat 1
902 | ;
903 | shelfButton
904 | -enableCommandRepeat 1
905 | -flexibleWidthType 3
906 | -flexibleWidthValue 32
907 | -enable 1
908 | -width 35
909 | -height 34
910 | -manage 1
911 | -visible 1
912 | -preventOverride 0
913 | -annotation "Check if scene material is not definied (missing) in materials.py"
914 | -enableBackground 0
915 | -backgroundColor 0 0 0
916 | -highlightColor 0.321569 0.521569 0.65098
917 | -align "center"
918 | -label "Check missing material defined"
919 | -labelOffset 0
920 | -rotation 0
921 | -flipX 0
922 | -flipY 0
923 | -useAlpha 1
924 | -font "plainLabelFont"
925 | -imageOverlayLabel "CHECK"
926 | -overlayLabelColor 0.8 0.8 0.8
927 | -overlayLabelBackColor 0 0 0 1
928 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/texture.png"
929 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/texture.png"
930 | -style "iconOnly"
931 | -marginWidth 0
932 | -marginHeight 1
933 | -command "\nfrom maya import cmds\nfrom maya.OpenMaya import *\nfrom maya.utils import executeDeferred\nimport json\n\nclass RoundingFloat(float):\n __repr__ = staticmethod(lambda x: format(x, '.4f'))\njson.encoder.float = RoundingFloat\n\nclass MAPGEOMaterial():\n def __init__(self):\n self.name = None\n self.base = None\n self.coat = None\n self.coat_normal = None\n self.transmission = None\n self.emission = None\n self.emission_texture = None\n\n\nclass MAPGEOPy():\n def __init__(self):\n self.dirname = None \n self.materials = {}\n\n def read(self, path):\n def SCToFloat(color):\n try:\n r = float(color[0])\n g = float(color[1])\n b = float(color[2])\n return True, (r,g,b)\n except:\n return False, ''\n\n self.dirname = '/'.join(path.split('/')[:-1])\n with open(path, 'r') as f:\n self.path = '/'.join(path.split('/')[:-1])\n lines = f.readlines()\n\n # get material block\n i = 0\n len12345 = len(lines)\n mat_lines = []\n while i < len12345:\n if 'StaticMaterialDef' in lines[i]:\n a = i\n for j in range(a, len12345):\n if lines[j] == ' }\\n':\n b = j\n break\n mat_lines.append((a, b))\n i = b\n i += 1\n\n for a, b in mat_lines:\n material = MAPGEOMaterial()\n\n # parse data \n for i in range(a, b):\n if 'StaticMaterialDef' in lines[i]:\n material.name = lines[i+1].split('=')[1][1:-1].replace('\"', '').replace('/', '__')\n\n # diffuse texture\n if 'DiffuseTexture' in lines[i]:\n material.base = lines[i + 1].split('=')[1][1:].replace('\"', '')[:-1]\n if 'Diffuse_Texture' in lines[i]:\n material.base = lines[i + 1].split('=')[1][1:].replace('\"', '')[:-1]\n \n\n # mask textures \n if 'Mask_Textures' in lines[i]:\n material.base = lines[i + 1].split('=')[1][1:].replace('\"', '')[:-1]\n for j in range(i+2, b):\n if 'BaseColor' in lines[j]:\n colors = lines[j+1].split('=')[1][2:-1].replace(' ', '').split(',')\n material.coat = (float(colors[0]), float(colors[1]), float(colors[2]))\n\n # mask texture with diffuse texture and color\n elif 'Mask_Texture' in lines[i]:\n material.coat_normal = lines[i + 1].split('=')[1][1:].replace('\"', '')[:-1]\n for j in range(i+2, b):\n if 'Base_Color' in lines[j]:\n colors = lines[j+1].split('=')[1][2:-1].replace(' ', '').split(',')\n material.coat = (float(colors[0]), float(colors[1]), float(colors[2]))\n # glow \n if 'GlowTexture' in lines[i]:\n material.base = lines[i + 1].split('=')[1][1:].replace('\"', '')[:-1]\n for j in range(i+2, b):\n if 'Color_Mult' in lines[j]:\n colors = lines[j+1].split('=')[1][2:-1].replace(' ', '').split(',')\n material.transmission = (float(colors[0]), float(colors[1]), float(colors[2]))\n\n # emissive \n if 'Emissive_Texture' in lines[i]:\n material.emission_texture = lines[i + 1].split('=')[1][1:].replace('\"', '')[:-1]\n if 'Emissive_Color' in lines[i]:\n colors = lines[i+1].split('=')[1][2:-1].replace(' ', '').split(',')\n res, c = SCToFloat(colors)\n if res:\n material.emission = c\n\n self.materials[material.name] = material\n\n def load(self):\n meshes=cmds.ls(sl=True,dag=True,s=True)\n if meshes != None and len(meshes)>0:\n scope=cmds.listConnections(meshes, type ='shadingEngine')\n else:\n scope=cmds.ls(type='shadingEngine')\n if scope == None:\n return\n mats = []\n for shading_engine in scope:\n if cmds.sets(shading_engine, q=True):\n mats += cmds.ls(cmds.listConnections(shading_engine), materials=True)\n missing_mats=[]\n for material in mats:\n if material not in self.materials:\n if material not in missing_mats:\n missing_mats.append(material)\n\n missing_mats_count=len(missing_mats)\n if missing_mats_count>0:\n missing_mats_str='\\n'.join(missing_mats)\n MGlobal.displayInfo(\n f'Found {missing_mats_count} selected scene materials that are not defined in materials.py:\\n{missing_mats_str}'\n )\n else:\n MGlobal.displayInfo('All selected scene materials are defined in materials.py')\n\ndef read():\n result = cmds.fileDialog2(\n ds = 2, fm = 1,\n ff = 'Material PY(*.py)',\n cap = 'Import material PY file',\n okc = 'Import'\n )\n if result:\n py_path = result[0]\n mgpy = MAPGEOPy()\n mgpy.read(py_path)\n mgpy.load()\n\nread()\n"
934 | -sourceType "python"
935 | -commandRepeatable 1
936 | -flat 1
937 | ;
938 | separator
939 | -enable 1
940 | -width 34
941 | -height 35
942 | -manage 1
943 | -visible 1
944 | -preventOverride 0
945 | -enableBackground 0
946 | -backgroundColor 0 0 0
947 | -highlightColor 0.321569 0.521569 0.65098
948 | -style "shelf"
949 | -horizontal 0
950 | ;
951 | shelfButton
952 | -enableCommandRepeat 1
953 | -flexibleWidthType 3
954 | -flexibleWidthValue 32
955 | -enable 1
956 | -width 35
957 | -height 34
958 | -manage 1
959 | -visible 1
960 | -preventOverride 0
961 | -annotation "Generated lightmap UV on 2nd UV set of selected objects. (Overwrite if existed)"
962 | -enableBackground 0
963 | -backgroundColor 0 0 0
964 | -highlightColor 0.321569 0.521569 0.65098
965 | -align "center"
966 | -label "Generate lightmap UV"
967 | -labelOffset 0
968 | -rotation 0
969 | -flipX 0
970 | -flipY 0
971 | -useAlpha 1
972 | -font "plainLabelFont"
973 | -overlayLabelColor 0.8 0.8 0.8
974 | -overlayLabelBackColor 0 0 0 0.5
975 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/lmuv.png"
976 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/lmuv.png"
977 | -style "iconOnly"
978 | -marginWidth 0
979 | -marginHeight 1
980 | -command "from maya import cmds\nfrom maya.OpenMaya import MGlobal\n\ndef on_textfield(textfield):\n cmds.optionVar(sv=('lolmaya_lightmapuv', cmds.textField(textfield, q=True, tx=True)))\n\n\nif cmds.window('LIGHTMAPUV', ex=True):\n cmds.deleteUI('LIGHTMAPUV')\n\nwindow = cmds.window(\n \"LIGHTMAPUV\", \n title = 'Name of lightmap UV set:', \n sizeable = False\n)\n\nlayout = cmds.rowLayout (p = window, nc = 2)\ntextfield = cmds.textField(p = layout, w = 500, h = 30)\nold_str = cmds.optionVar(q='lolmaya_lightmapuv')\nif old_str:\n cmds.textField(textfield, e=True, it = old_str)\ncmds.textField(textfield, e = True, cc = lambda c: on_textfield(textfield))\ndef apply(*args):\n lightmap = cmds.textField(textfield, q = True, tx=True)\n if lightmap:\n \n # create second uv set and name it\n selected = cmds.ls(sl = True)\n for obj in selected: \n uv_sets = cmds.polyUVSet(obj, query=True, allUVSets=True)\n if len(uv_sets) > 1:\n if uv_sets[1] != lightmap:\n cmds.polyUVSet(obj, rename=True, newUVSet=lightmap, uvSet=uv_sets[1])\n else:\n cmds.polyUVSet(obj, create=True, uvSet=lightmap)\n cmds.polyUVSet(obj, copy=True, nuv=lightmap, uvSet=uv_sets[0])\n \n # layout the second uv set\n cmds.polyMultiLayoutUV(\n selected,\n lm=1, sc=1, rbf=2, fr=1, ps=0.2, l=2, gu=1, gv=1, psc=0, su=1, sv=1, ou=0, ov=0,\n uvs=lightmap\n )\n \n MGlobal.displayInfo('Generated 2nd UV set for lightmap.')\n\ncmds.textField(textfield, edit = True, ec = apply)\ncmds.button('Apply', p = layout, w = 100, h = 30, c = apply)\n\ncmds.showWindow(window)"
981 | -sourceType "python"
982 | -commandRepeatable 1
983 | -flat 1
984 | ;
985 | shelfButton
986 | -enableCommandRepeat 1
987 | -flexibleWidthType 3
988 | -flexibleWidthValue 32
989 | -enable 1
990 | -width 35
991 | -height 34
992 | -manage 1
993 | -visible 1
994 | -preventOverride 0
995 | -annotation "Delete 2nd UV set of setlected meshes."
996 | -enableBackground 0
997 | -backgroundColor 0 0 0
998 | -highlightColor 0.321569 0.521569 0.65098
999 | -align "center"
1000 | -label "Delete lightmap UV"
1001 | -labelOffset 0
1002 | -rotation 0
1003 | -flipX 0
1004 | -flipY 0
1005 | -useAlpha 1
1006 | -font "plainLabelFont"
1007 | -overlayLabelColor 0.8 0.8 0.8
1008 | -overlayLabelBackColor 0 0 0 0.5
1009 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/lmuvd.png"
1010 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/lmuvd.png"
1011 | -style "iconOnly"
1012 | -marginWidth 0
1013 | -marginHeight 1
1014 | -command "from maya import cmds\nfrom maya.OpenMaya import MGlobal\n\nselected = cmds.ls(sl = True)\nfor obj in selected: \n uv_sets = cmds.polyUVSet(obj, query=True, allUVSets=True)\n if len(uv_sets) > 1:\n cmds.polyUVSet(obj, delete=True, uvSet=uv_sets[1])\nMGlobal.displayInfo('Deleted 2nd UV set of selected of selected objects.')\n"
1015 | -sourceType "python"
1016 | -commandRepeatable 1
1017 | -flat 1
1018 | ;
1019 | shelfButton
1020 | -enableCommandRepeat 1
1021 | -flexibleWidthType 3
1022 | -flexibleWidthValue 32
1023 | -enable 1
1024 | -width 35
1025 | -height 34
1026 | -manage 1
1027 | -visible 1
1028 | -preventOverride 0
1029 | -annotation "Bake texture with arnold"
1030 | -enableBackground 0
1031 | -backgroundColor 0 0 0
1032 | -highlightColor 0.321569 0.521569 0.65098
1033 | -align "center"
1034 | -label "Bake Texture (Arnold)"
1035 | -labelOffset 0
1036 | -rotation 0
1037 | -flipX 0
1038 | -flipY 0
1039 | -useAlpha 1
1040 | -font "plainLabelFont"
1041 | -overlayLabelColor 0.8 0.8 0.8
1042 | -overlayLabelBackColor 0 0 0 0.5
1043 | -image "C:/Users/tarng/Documents/maya/2023/prefs/icons/bakec.png"
1044 | -image1 "C:/Users/tarng/Documents/maya/2023/prefs/icons/bakec.png"
1045 | -style "iconOnly"
1046 | -marginWidth 0
1047 | -marginHeight 1
1048 | -command "from maya import cmds\nfrom maya.OpenMaya import MGlobal\n\ndef on_toggle(checkbox):\n cmds.optionVar(sv=('lolmaya_bakediffuse', cmds.checkBox(checkbox, q=True, v=True)))\n\ndef on_optmenu(optmenu):\n cmds.optionVar(sv=('lolmaya_bakequality', cmds.optionMenu(optmenu, q=True, v=True)))\n\ndef on_textfield(textfield):\n cmds.optionVar(sv=('lolmaya_bakeres', cmds.textField(textfield, q=True, tx=True)))\n\ndef on_bakepath(bakepath):\n cmds.optionVar(sv=('lolmaya_bakepath', cmds.textField(bakepath, q=True, tx=True)))\n\ndef browse_bakepath(bakepath):\n result = cmds.fileDialog2(\n ds = 2, fm = 3,\n cap = 'Output location for baked textures',\n okc = 'Select'\n )[0]\n cmds.textField(bakepath, e = True, tx=result)\n cmds.optionVar(sv=('lolmaya_bakepath', cmds.textField(bakepath, q=True, tx=True)))\n\ndef bake(bakepath, checkbox, optmenu, textfield):\n output = cmds.textField(bakepath, q=True, tx=True)\n nodiffuse = cmds.checkBox(checkbox, q=True, v=True)\n quality = cmds.optionMenu(optmenu, q=True, v=True)\n aa = 2\n if quality == 'Medium':\n aa = 4\n elif quality == 'High':\n aa = 8\n elif quality == 'Very High':\n aa = 16\n res = cmds.textField(textfield, q=True, tx=True)\n try:\n res = int(res)\n except:\n raise Exception('Bad resolution input, should be integer: 512, 1024, 2048,...')\n\n selected = cmds.ls(sl = True)\n if not selected:\n raise Exception('Nothing selected.')\n\n if nodiffuse:\n if not cmds.objExists('standardSurface1'):\n cmds.shadingNode('standardSurface', asShader=True, name='standardSurface1')\n \n # map objects by lightmap\n map_obj = {}\n for obj in selected:\n uv_sets = cmds.polyUVSet(obj, query=True, allUVSets=True)\n if not uv_sets:\n raise Exception(f'{obj} doesnt have any UV data or not a mesh.')\n if len(uv_sets) < 2:\n raise Exception(f'{obj} doesnt have 2nd UV set.')\n if uv_sets[1] not in map_obj:\n map_obj[uv_sets[1]] = []\n map_obj[uv_sets[1]].append(obj)\n \n for lightmap in map_obj:\n cmds.select(cl = True)\n \n # hide original\n cmds.hide(map_obj[lightmap])\n\n # create a combined mesh\n dupes = cmds.duplicate(map_obj[lightmap])\n if len(dupes) > 1:\n temp_mesh = cmds.polyUnite(\n dupes,\n ch=1,\n mergeUVSets=1,\n centerPivot=True,\n name=f'm_{lightmap}'\n )[0]\n cmds.DeleteAllHistory()\n else:\n temp_mesh = f'm_{lightmap}'\n cmds.rename(dupes[0], temp_mesh)\n cmds.polyUVSet(temp_mesh, rename=True, newUVSet='t_'+lightmap, uvSet=lightmap)\n cmds.sets(temp_mesh, e=True, forceElement='initialShadingGroup')\n\n # bake\n cmds.arnoldRenderToTexture(\n temp_mesh,\n shader='standardSurface1', uv_set='t_'+lightmap,\n folder=output, resolution=res, aa_samples=aa, filter='gaussian', filter_width=2.0,\n extend_edges=False, u_start=0.0, v_start=0.0, u_scale=1.0, v_scale=1.0\n )\n\n # show original again\n cmds.showHidden(map_obj[lightmap])\n\n # delete combined mesh and rename baked texture\n if output.endswith('/'):\n output = output[:-1]\n cmds.delete(temp_mesh)\n cmds.sysFile(output + f'/{temp_mesh}Shape.exr', rename=output + '/' + lightmap + '.exr')\n\n else:\n # bake\n cmds.arnoldRenderToTexture(\n folder=output, resolution=res, aa_samples=aa, filter='gaussian', filter_width=2.0,\n extend_edges=False, u_start=0.0, v_start=0.0, u_scale=1.0, v_scale=1.0\n )\n \n MGlobal.displayInfo('Textures baked at ' + output)\n cmds.select(selected)\n \n \n\ndef GUI():\n if cmds.window('BAKELIGHT', ex=True):\n cmds.deleteUI('BAKELIGHT')\n window = cmds.window(\n \"BAKELIGHT\", \n title = 'Texture Baking', \n sizeable = False\n )\n cmds.columnLayout()\n\n cmds.rowLayout(nc = 3)\n cmds.text(label = 'Output:', h = 30)\n\n bakepath = cmds.textField(w = 500, h = 30)\n old_path = cmds.optionVar(q='lolmaya_bakepath')\n if old_path:\n cmds.textField(bakepath, e=True, it = old_path)\n cmds.textField(bakepath, e = True, cc = lambda c: on_bakepath(bakepath))\n cmds.button('Browse', h = 30, c = lambda c: browse_bakepath(bakepath))\n \n\n cmds.setParent('..')\n cmds.rowLayout(nc = 2)\n\n checkbox = cmds.checkBox(label = 'No diffuse', h = 30, w = 200, v = True)\n old_toggle = cmds.optionVar(q='lolmaya_bakediffuse')\n if old_toggle != None:\n cmds.checkBox(checkbox, e = True, v = (old_toggle == 'True'))\n cmds.checkBox(checkbox, e = True, cc = lambda c: on_toggle(checkbox))\n \n optmenu = cmds.optionMenu(label='Quality:', h = 30)\n cmds.menuItem(label='Low')\n cmds.menuItem(label='Medium')\n cmds.menuItem(label='High')\n cmds.menuItem(label='Very High')\n cmds.optionMenu(optmenu, e = True, v = 'Medium')\n old_quality = cmds.optionVar(q='lolmaya_bakequality')\n if old_quality:\n cmds.optionMenu(optmenu, e = True, v = old_quality)\n cmds.optionMenu(optmenu, e = True, cc = lambda c: on_optmenu(optmenu))\n\n cmds.setParent('..')\n cmds.rowLayout(nc = 4)\n cmds.text(label = 'Resolution:', h = 30, w = 80)\n textfield = cmds.textField(w = 80, h = 30)\n old_res = cmds.optionVar(q='lolmaya_bakeres')\n if old_res:\n cmds.textField(textfield, e = True, it = old_res)\n else:\n cmds.textField(textfield, e = True, it = '1024')\n cmds.textField(textfield, e = True, cc = lambda c: on_textfield(textfield))\n\n cmds.text(label = '', w = 300)\n\n cmds.button(\n 'Bake', w = 100, h = 30, align = 'right',\n c = lambda x: bake(bakepath, checkbox, optmenu, textfield)\n )\n cmds.showWindow(window)\n\nGUI()"
1049 | -sourceType "python"
1050 | -commandRepeatable 1
1051 | -flat 1
1052 | ;
1053 |
1054 | }
1055 |
--------------------------------------------------------------------------------