PDA

View Full Version : Unhide from Left to right


em3
11-16-2010, 04:58 AM
I have a script that will unhide objects randomly but What I would really like is to unhide based on an objects X, any ideas?

Here is my current script


for o in selection do
(
myNum = random 0 270 --frames
my2ndNum = random myNum myNum+5 --length of unhide
myX = o.pos.x
o.visibility = bezier_float() -- Track View: Add Visibility Track
addNewKey o.visibility.controller myNum #select
addNewKey o.visibility.controller my2ndNum #select
o.visibility.controller.keys[1].value = 0
o.visibility.controller.keys[2].value = 1
)

Thanks in advance!

Bobo
11-16-2010, 08:03 AM
Collect the objects to reveal into an array.
Collect the positions' X component (or whatever axis you want) in another array.
Collect the indices of the objects into yet another array.
Perform indexed sort using qsort (see help).
Set keys in the order defined by the index array.
Done.

Alternatively, use the distance from a given point in space to your objects for the sorting. This will produce a radial reveal if they are not in a row but spread around randomly.

JHN
11-16-2010, 01:18 PM
Like Bobo said,

Distance can be used quite simply, distance from world origin:

fn sortDist v1 v2 = if distance v1.pos [0,0,0] > distance v2.pos [0,0,0] then 1 else -1
sel = selection as array
qsort sel sortDist


-Johan

em3
11-16-2010, 04:24 PM
Perfect! Thanks Bobo and JHN!

em3
11-17-2010, 09:45 PM
Hey guys, now as part of this script I am trying to get the z value of the xform modifier. I can get the [x,y,z] values with

for o in sel do (
addModifier o (XForm ())
select o
m = -((getModContextBBoxMin o o.xform) - (getModContextBBoxMax o o.xform))
b = m * o.xform.gizmo.scale
print b
)

I was wondering if there was an easy way to get just the z?

Thanks!

CGTalk Moderation
11-17-2010, 09:45 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.