PDA

View Full Version : Which object does a channel belong to?



Anti-Distinctly
01-11-2008, 04:15 AM
Hi all,
I'm trying to write what I thought would be a simple script yet I can't make headway with it as I can't access the information I need.
I'm writing a simple channel modifier lscript intended for lights, to simply match the light intensity or multiply it. So I can attach it to my flare intensity channel and have it match the light intensity channel. (I'm not using expressions as those are instantly broken upon cloning)

Now, when in the channel modifier plugin, I can't seem to gain access to the 'parent' object (i.e. the light). This data member is not available which is daft. Anyway, I thought I'd just use the scene OA and get a list of all lights, cycle through their channels and find a match for the current channel. But I can't seem to find a way to get a list of the object/lights in scene. The seleted object yes, but all obejects...nope. Is this seriously the case?

Dodgy
01-11-2008, 05:13 AM
That was broken up until 9.3.1, it should work now.

Anti-Distinctly
01-11-2008, 05:24 AM
To get & cycle through lights, is it:

light = Light(); //sel first light
while(light)
light.next();

or something similar?

Edit: I'm on 9.3, so that would explain it...

Dodgy
01-11-2008, 05:26 AM
To get a list of lights, use

i=1;
temp=Light();
while(temp)
{


mylight[i]=temp;
temp=temp.next();
i++

}

Anti-Distinctly
01-11-2008, 05:27 AM
Dodgy, you're a star. Cheers.

Anti-Distinctly
01-12-2008, 12:03 PM
Dodgy, in the LScript docs it says that there is a 'parent' function or variable:

parent
parent holds the parent channel group of the current Object Agent. If no parent exists, this data member will be 'nil.'

Mine, however, does not work. yours?

Anti-Distinctly
01-12-2008, 01:59 PM
I was mistaking the channel’s Channel Access Agent (ca) in the process function
process: ca, frame, time
{}
as a Channel Object Agent and was trying to grab its parent parameter. Whcih obviously failed. I set a variable in the constructor
create: channel
{
// one-time initialization takes place here
setdesc("Match light, multiplier: " + m);
//debug();
parentObject = channel.parent;
}
Originally the template did not include the 'channel' variable you see above, so I added it manually.

evenflcw
01-12-2008, 02:09 PM
And now it's working?

I remember stumbling over the parent member aswell and if you read the description closely it can't give you the item. It only gives you the channel group the channel belongs to - such as all morphs belong to the MorphGroup channel group.

I still think you need to go from each direction to find the matching oa. Ie travel up the the channel hierarchy using the parent until it returns nil, which means you are on the top level. If it returned nil immediatly it was a transform channel, if it didn't log the last channelgroup id. Parse through all items looking for the matching id by traversing all transform channels and/or channel group ids.

Anti-Distinctly
01-12-2008, 02:29 PM
The channel.parent parameter returns an object agent to the object to which the channel belongs. I thought it was reeeally stupid to have to go through all that just to find the object.
Now, what's really daft is that I can't find a way to get the light intensity from the Light Object Agent that is returned :(

evenflcw
01-12-2008, 02:56 PM
The channel.parent parameter returns an object agent to the object to which the channel belongs. I thought it was reeeally stupid to have to go through all that just to find the object.

Ah. And this is what got fixed in 9.3.1 as Dodgy mentioned?


Now, what's really daft is that I can't find a way to get the light intensity from the Light Object Agent that is returned :(

Could this be because there is no envelope created for that channel yet? Channels can only be referenced if they have an envelope explicitly created, or rather you reference them through the envelope or whatever. Another design mistake by the old team that needs to be dealt with.

Anti-Distinctly
01-12-2008, 03:22 PM
Yeah, thats ok, btu I wanted to reference just the intensity if there was no envelope present. It's a similar situation with a channel follower or an expression. You have to put an envelope on a channel if you wish to refence it, which can be irriating - but I can't even work around this by using lscript. Arg!
Now the trouble that I'm having is that when I clone the light this function;

create: channel
{
// one-time initialization takes place here
setdesc("Match light, multiplier: " + m);
debug();
l = channel.parent;
}

always has the same object returned from channel.parent.
This isn't right is it? Is there something special I have to do to account for cloned objects?