Unhide from Left to right

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Display Modes
  11 November 2010
Unhide from Left to right

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!
  11 November 2010
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.

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.
  11 November 2010
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

Online: LinkedIn
  11 November 2010
Perfect! Thanks Bobo and JHN!
  11 November 2010
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?

  11 November 2010
Thread automatically closed

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.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 11:13 AM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.