PDA

View Full Version : ChannelHandlers



avogad
04-25-2007, 09:25 AM
Hi,

following my idea http://www.newtek.com/forums/showthread.php?t=67500 I'm now trying to apply my channel handler through a layout generic plugin. However, I face some problems :

1. How to select a channel or get the selected channel in order to apply the channel handler to it
2. When I load my scene, the handler is applied to both .LegacyZoomFactor and ZoomFactor. Where does LegacyZoomFactor comes from ?! I can't even see it in the graph editor !!

Cheers.

dpont
04-25-2007, 10:22 AM
2-> Legacy is a temporary envelope channel to store a zoom env
for exchange purpose between different camera types.
Channel names with a point as prefix are hidden in GE.

Denis.

avogad
04-25-2007, 11:04 AM
Thanks.

I've also read that these temp envelopes used the Copy() function to set the real envelope. My Copy() function works fine but the ZoomFactor envelope still don' thave the right values.

Any ideas ?!

Cheers

dpont
04-25-2007, 11:29 AM
You may copy an entire envelope if you got one to the Zoomfactor
or add/remove individual key,
first you need to have already a zoom env (if you don't ->command)
then you will need the group ID (Camera ID)
to iterate all channels which are owned by this group
until the channel name match "ZoomFactor" and
you get the envelope channel id.
(see anenvel.html in SDK)

Denis.

avogad
04-26-2007, 02:41 AM
Hi,

Thanks for answering. I already did that and the last ChannelID selected before I apply the ChannelHandler is ZoomFactor. However, I've read several stuff on the web.

1- While loading, LW uses the Copy() function in order to copy the LegacyZoomFactor values to the ZoomFactor ones. When I check the values into the Copy() function, both are similar. However, inside LW, my handler is set to ZoomFactor but datas are missing. Where could it come from ?!

2- In the Evaluate() function, my LWInstance datas are correct. However, when LW reaches the Save() fucntion, all theses datas are empty ?! What the hell is going on ?!

Cheers.

Ben

dpont
04-26-2007, 02:55 AM
This is something difficult to figure without your code,
because what I said depends of context.
If you want to modify the zoomfactor of an existing camera
from an external plugin, you don't need to modify the
legacy since it is only used by LW or plugin Camera,
you need just to use the global envelope functions
to modify the "ZoomFactor" of the selected camera.

Don't understand what you mean by loading or saving,
do you speak of the handler Load() and Save() functions?

Denis.

avogad
04-26-2007, 03:12 AM
you need just to use the global envelope functions
to modify the "ZoomFactor" of the selected camera.

Ok sorry. I think I must explain what I'm doing. I've developped a ChannelHandler plugin that set the ZoomFactor envelope reading an external file. To do that, I use:

access->setChannel(access->chan, zoom);

If I set the handler manually, it works fine (except loading and saving). What I want to do now, is to apply that handler to each cameras of my scene. If they don't have a ZoomFactor envelope, I create it and then try to apply the handler.

That's where problems occur !!! The handler isn't applied !


Don't understand what you mean by loading or saving,
do you speak of the handler Load() and Save() functions?

Yes!
EDIT: I need to save the path to the file read. This path is an instance attribute of my instance.


LWError Save( LWInstance inst, const LWSaveState *save_state )
{
CZFReader *reader = (CZFReader*) inst;
LWSAVE_STR( save_state, reader->getFilename() );
return NULL;
}

dpont
04-26-2007, 03:46 AM
Do you used the "GE_SetEnvID" to select the correct channel before "GE_ApplyServer"?

What is "reader->getFilename()" in your Save() function,
if you used a requester in your plugin option panel,
you should get a path string like inst->filename
and :
LWSAVE_STR( save_state, inst->filename);

I suppose you have two separate plugins here,
a channel modifier and a generic to apply the
channel plugin?

Denis.

avogad
04-26-2007, 04:34 AM
I suppose you have two separate plugins here,
a channel modifier and a generic to apply the
channel plugin?

Exactly.
Here is the code sample from my LayoutGeneric Activation function:


zoom_env = findEnv(group, "ZoomFactor");
if (!zoom_env)
{
local->evaluate( local->data, "AddEnvelope ZoomFactor" );
zoom_env = findEnv( group, "ZoomFactor" );

char cmd[128];
sprintf(cmd,"GE_SetEnvID %x %d",chanZoomID,1);

local->evaluate( local->data,cmd );
local->evaluate( local->data, "GE_ApplyServer " LWCHANNEL_HCLASS " CZFReader" );
}

and here is the findEnv function (from the SDK) that return the right envelope and channelID

LWEnvelopeID findEnv( LWChanGroupID group, char *name )
{
LWChannelID chan;
chan = chinfo->nextChannel( group, NULL );
while ( chan )
{
if ( !strcmp( chinfo->channelName( chan ), name ))
{
chanZoomID = chan;
return chinfo->channelEnvelope( chan );
}
chan = chinfo->nextChannel( group, chan );
}
return NULL;
}

The results stills the same...
Am I missing something ?!


What is "reader->getFilename()" in your Save() function
reader is an instance of CZFReader, a class that reads a file and store values it reads. That class also holds the full path to the file. That reader is the instance created in the handlre Create() function.


LWInstance Create( void *priv, LWChannelID chan, LWError *err )
{
CZFReader *reader = new CZFReader();

reader->clearVectors();
reader->setFilename( toRead );
reader->load();

return reader;
}

Cheers

dpont
04-26-2007, 05:36 AM
Not sure I could help you, but I have some comments,
-"group" must be the cameraID
-The channel ID returned by FindEnv() is "zoom_env",
then you send a command with "chanZoomID"?

-"LWSAVE_STR" is for character string only, are you sure
your getFilename() return a string?
A path saving and may be some other parameter beside
could be enough, then in the Load() function
after loading your path/param,
you could init any further function.

-Do you need really an instance for your function calls
in Create(), some static functions could do the job?

Denis.

avogad
04-26-2007, 05:50 AM
Not sure I could help you

Actually, you're helping me a lot. Cos' after reading and reading again, i can't see anything. A new point of view is always welcome !


"group" must be the cameraID

group is a LWChanGroupID


The channel ID returned by FindEnv() is "zoom_env",
then you send a command with "chanZoomID"?

findEnv() returns a LWEnvelopeID, however GE_SetEnvID parameter is a ChannelID


"LWSAVE_STR" is for character string only, are you sure
your getFilename() return a string?

Yes sure. In the Evaluate() function, getFilename() returns the right path, so does Describe(). In the Save() function, getFilename() return an empty string

Any ideas ?!

Cheers.

Ben

dpont
04-26-2007, 06:41 AM
Sorry if I misread some parts,
So for "group" you have an "iteminfo->chanGroup( cameraID )"?
You could also return ChanZoomID instead of LWEnvelopeID
in FindEnv().

You can also verify the name of your plugin,
suppose you know it :-) but in some plugins
there are different typos, this one is the
second field in ServerRecord?

In Save() you should try an inst->filename char variable
filled anywhere your GetFilename() works.

Denis.

avogad
04-26-2007, 07:24 AM
I've found a solution!

To set the selected channel, I first have to open the Graph Editor. Then my plugin is add !!


sprintf(cmd,"GE_OpenWindow %d",chanZoomID,1);
local->evaluate( local->data,cmd);

// Camera. has to be replaced by the real camera name
sprintf(cmd,"GE_SetEnv %s %d","Camera.ZoomFactor",1);
local->evaluate( local->data,cmd );

local->evaluate( local->data, "GE_ApplyServer " LWCHANNEL_HCLASS " CZFReader" );

Stills the Load / Save problem...

avogad
04-26-2007, 09:51 AM
After sevral tests, here are the results of the Save() function:

1. If the path is set through the option() function of the interface, the full path isn't written.

2. if the path is set inside the plugin, the full path is written by the save function.

3. If I just save the envelope, the path is written in the .envl file.

I don't understand anything...

It's driving me crazy !!!!!

avogad
04-27-2007, 05:14 AM
I'm still trying to make the ChannelHandler works.

Some other problems appears:

The function

access->setChannel( access->chan, zoom );

is working. However, when the handler is applied on the ZoomFactor envelope, the view doesn't match the ZommFactor values seen in the property editor. The worst is that if I apply that handler on the Position.X envelope for example, everything works, eg the camera moves !!

Where could it come from ?!

Cheers