-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmayatool.comp
More file actions
86 lines (66 loc) · 2.44 KB
/
mayatool.comp
File metadata and controls
86 lines (66 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/**
Two examples of working with Maya
Highlights:
- `!transact` wraps Maya scene operations in an undo chunk and selection preservation, one line replaces the typical try/finally pattern
- `@fmt` on string literals resolves names from the current scope, "%(name)%(config.suffix)" reads like a template but is statically checked
- Functions take pipeline input (the selection) and structured config (the layer spec) through separate channels, artist-facing parameters stay clean
- `!on` dispatches on `maya.exists` result, the "does this node exist" check becomes a branch rather than an if/else
*/
!import maya comp "maya-comp-spectacular@1.0.3"
/**
Maya tool to create offset transforms.
Insert a parent between two nodes and position it partway
between them, preserving positioning when reparenting.
(Which famously does not work once things are animated.)
Based on https://github.com/TrevisanGMW/gt-tools
*/
!func create-inbetween (
!param suffix ~text
!param parent-type ~(parent | selection)
!param layer-type ~(joint | locator | group)
!param outliner-color ~num*3 = {1.0 0.5 0.0}
//x !transact {maya.scene maya.preserve-selection}
[maya.selection
| map :(
!my parent [$ | maya.get-parent]
!my transform [parent
| maya.create-node
layer-type
name=@fmt"between%(suffix)"
| maya.set-attr use-outliner-color=true
| maya.set-attr outliner-color=outliner-color
| maya.parent parent
]
!my target [pick parent-type == parent parent $]
[if [target | maya.exists] [target | maya.constrain transform]]
[$ | maya.parent transform]
)]
)
/**
Create random bubble shapes.
Create a group of random positioned and sized spheres
around the selected objects.
Based on https://github.com/nestrada2/bubbles
*/
!func create-bubbles ~dag-path* (
!param count ~num = 10
!param radius-range ~num*2 = {0.1 0.5}
!param position-range ~num*2 = {0.1 5.0}
// defered partials allow repeated use later
!my rand-size :[radius-range | random]
!my rand-move :[repeat 3 :[position-range | random]]
//todo !transact {maya.scene}
!my group [$ | maya.create-node group name="bubbles" | maya.select replace]
//todo nowhere does this use count?
//todo !transact {maya.preserve-selection}
[$ | map :(
!my dag-path $
[dag-path
| group
| maya.poly-sphere
name=@fmt"bubble-%($.name)"
radius=rand-radius
| maya.xform position=rand-move
]
)]
)