PDA

View Full Version : Getting an Object's channels via Channel Script



natha1
10-06-2007, 04:35 PM
Okay, I have a channel modifier script that I'm writing and I want to be able to control the object it is attached to's Position and rotation. I am creating keys so it's not using the "process" function at all.

So, this is what I originally wrote which worked fine when I only had one object in the scene.

create: channel
{
thisChannel = channel;

parentObj = thisChannel.parent;

theXChan = parentObj.firstChannel();
theYChan = parentObj.nextChannel();
theZChan = parentObj.nextChannel();
theHChan = parentObj.nextChannel();
thePChan = parentObj.nextChannel();
theBChan = parentObj.nextChannel();
}

Here's a hierarchy of my objects as it would appear in the Scene Editor:

-> Ground
-> Obj_Master
-> -> Obj_Mover
-> -> -> myScriptedObj - This is the object with the script attached to it via the modifiers tab in the Graph editor.

So, I assumed that the ".parent" of the channel would have been the object it was attached to, "myScriptedObj", but low and behold it's the first object that I added into the scene which is "Ground".

Am I doing something wrong? Is this a LScript bug? Does anyone have a solution?

Thanks a ton!
Nathan

adamredwoods
10-07-2007, 05:27 PM
You seem to be on something.

Returns only the OA for the first object in the scene.
Tested, same result on LW 8.2 and LW 9.2. Tested on nulls and meshes, parents, children, everything.


You should report this to support, unless I'm missing something here. Anyone else have any ideas?

The docs do state:
parent
parent contains the LightWave Object Agent to whom the channel belongs.

This doesn't seem to work this the following code:


@warnings
@script channel
@version 2.5
@name chModifier

//Global variables.
ch;


create: channel
{
ch = channel;
setdesc("start");
}
process: ca, frame, time
{
chParent = ch.parent;
de = ("p: "+chParent.name);
setdesc(de);

}


The workaround would be to pass the Mesh id somehow.


Additionally, in your above code, you shouldn't assume the channels will be in the same order everytime. Do a firstChannel(), while(), nextChannel() search as they recommend in the docs.

NateDawg
10-07-2007, 06:06 PM
Thanks for looking into that Adam! BTW, what system are you using? I'm on a Mac, is it the same on the PC? I have a PC, but, can't test it since I won't have Windows on it for about a month or so. Thanks.

adamredwoods
10-07-2007, 06:18 PM
Pc.

P.S. I also did a search for threads related to this problem but couldn't find anything. Does anyone else use channel modifiers?

NateDawg
10-07-2007, 06:19 PM
Thanks Adam, I'll report the bug for both then. Thanks again! :D

Dodgy
10-07-2007, 06:31 PM
I posted this a while back.
https://secure.newtek.com/FogBugz/default.asp?7355_JNIIRBMQ