PDA

View Full Version : 3rd tutorial in SDK, just some questions...


kvernon
09-30-2003, 04:24 AM
After replying to Lyle's response about anyone needing help and Thomas with a great reply to mine (I needed that humor! :) ) I decided to jump on here and ask some questions about the Normal Scale tutorial, so I won't feel so lost in the dark.

This is one thing that isn't included in the tutorial, but in the example file, could some one explain what this does?

static FX_EFFECTSCAN(EffectScan, NormScaleState, state);
static FX_DISPLACESCAN(DisplaceScan, NormScaleState, state);

From the C book I have static means that it takes the value and alters it internally, but how does this work for a funtion (as I'm quessing that is what this is doing -- calling a function)

kvernon
09-30-2003, 04:29 AM
Oh,

Also, after doing the tutorial, how would you check off the other sliders tabs when writing the plugin?

Example:

Factor
ypos
zpos
heading
pitch
bank

Since we know factor is the only channel being used, how do switch the others off or state that factor (xpos) is the only channel to show/use.

FB_Turbine
09-30-2003, 01:13 PM
For switching off the slider channels I believe that will be in the next rev. For now you can use fxExpressionCompute from the command header to use the messiah script function to activate/deactivate channels.


static FX_EFFECTSCAN(EffectScan, NormScaleState, state);
static FX_DISPLACESCAN(DisplaceScan, NormScaleState, state);

Are function definitions. The 3 params are the required user input, but the true functions more complex. This simplifies the params for the developer. The params are the scan function to call, your effects data and the data structure for your effect defined i your effect header. Effectscan can be effectscan or motion scan, from what I found so far. Using effect scan you can use displacescan to operate on the vertices of the effect target.

Hope that makes some sense, if I got anything wrong hopefully someone else will jump into correct me. It's really easy to use once you start experimenting.

kvernon
09-30-2003, 02:56 PM
Thanks FB_Turbine, :beer:

Taking a stab at what you said:
You say these are function definitions, aren't those setup to go with writing the functions? So from what you are saying, it's like declaring varibles but declaring functions at the top of the page? Is this something you have to do for all function, except main?

for example...

static airguitar (somevariable, impressivevariable, crowd){
//..
}

I just need to do that same thing at the top of my page...
or are they the same thing?

static airguitar (somevariable, impressivevariable, crowd)

In the Norm scale example, at the top of the page it had:

static FX_EFFECTSCAN(EffectScan, NormScaleState, state);
static FX_DISPLACESCAN(DisplaceScan, NormScaleState, state);

then at the bottom it had

static FX_DISPLACESCAN(DisplaceScan, NormScaleState, state){
// FXint f(FX_DisplacePoint *p, dt *ed)
FXdouble norm[3];
fxMeshPointNormal( p->objID, p->ID, norm, FX_NOFLAG );
p->new_pos[0] = p->cur_pos[0] + (state->scale * norm[0]);
p->new_pos[1] = p->cur_pos[1] + (state->scale * norm[1]);
p->new_pos[2] = p->cur_pos[2] + (state->scale * norm[2]);
return FX_TRUE;
}

static FX_EFFECTSCAN(EffectScan, NormScaleState, state){
// FXint f(FXeffect effect, FXtool tool, FXobject target, dt *ed)
// Process each point in target, DisplaceScan() gets called once for each point
fxDisplaceScan( target, FX_NULLID, FX_NOFLAG, &DisplaceScan, state, FX_NOFLAG );
return FX_TRUE;
}

To me at the moment, it looks like the same thing, not even a call back.

If that's not it, I'm sorry that I'm not getting it at the moment. :hmm: ... I'M TRYING!!!! :scream:

markpassion
09-30-2003, 03:13 PM
static functions can only be called within the file they are declared in. I believe. Its like the opposite of extern.

In the example code you are looking at a prototype then an implementation. In C and more so in C++ you should prototype your functions, that way you can call them from anywhere in the file.

Does that make sense?

Mark

kvernon
09-30-2003, 03:33 PM
Hi Mark!

First, it shows the format of calling this function. Also it tells the code that there is a function in here that need thse passing variables (kind of like getting your name and address in the phone book ~ if you need to find me I'm in there). By doing this protyping, it makes it easier for the coder, so he doesn't have to place a function above the function that needs to use it.

YAY!!! word of the day "extern" <-- gunna go read up about it! :)


Does that seem right about functions?

FB_Turbine
09-30-2003, 03:40 PM
The effect scans are pre defined in the SDK so to define them for use you just use


static FX_EFFECTSCAN(EffectScan, NormScaleState, state);


But if your defining a new function you need to specify the return.


static FXvoid myfunc();


then use it like


FXvoid mffunc(){
do something
}


But if you return a variable you need to state it in the define.


static FXint myCalc(FXint);


Then in use:


FXint myCalc(FXint passedNumber){
FXint newNumber;

newNumber = passedNumber+5;

return(newNumber);
}


This is different from the SDK define effects scan. effectscan is really:


FXintf f(FXeffect effect, FXtool tool, FXobject target, dt *ed)


But the SDK provides you with

FX_EFFECTSCAN (f,dt,ed)


And it iterates over the targets of the effect for you making life much easier rather then having to determine and loop over the targets yourself.

From the SDK

scan_func() is just a name that we are giving to any callback function that you define using the FX_EFFECTSCAN() macro. You use this callback by passing it to fxEffectTargetScan(), your callback will then be called one time for each of the effect's targets. This is how you will make sure that your effect is applied to all of its targets.

kvernon
09-30-2003, 03:49 PM
COOL! Mucho gracias FB_Turbine!!

I'm starting to understand it between the two of you :)

I haven't had a chance to read up about extern tho! <- you can bet I'll have questions on that! :)

LOL

Thanks you two!
Kelly :buttrock:

markpassion
09-30-2003, 05:27 PM
glad to hear you're getting your head round it. extern is easy. All it does is allow you to do global variables across different files in the same project. So you could have say:

MyPluginMain.c
MypluginFuncs.c

and if you wanted to use a global variable across the two, you would do something like:

at the top of MyPluginMain.c float myfloat;
and at the top of MypluginFuncs.c extern float myfoat;

So when the compiler comes to look for myfloat in MypluginFuncs.c it knows you require the data that has been specified in another file. So it goes and gets it. which is nice. ;-) Obviously it only works on files in the same project.

Hope that helps.

Mark

kvernon
09-30-2003, 09:11 PM
That's great to know!:thumbsup:

(still haven't had a chance to look at it, in the c book)

It seemed like that was what you were discribing before, but I wanted to look in the book to make sure. I was drifting with the idea of ASP and how linking differenty files would be fine, but it seems as C needs this comment to have the variable noticed in the other files. It seems like that's some thing that will come in quite handy! thanks!

lmilton
10-01-2003, 08:09 AM
Originally posted by FB_Turbine
For switching off the slider channels I believe that will be in the next rev....

If you're refering to channel visibility, the functionalilty already exists:

//hide a channel
fxChannelOptionsSet(obj, channel, FX_CHANFLAG_HIDE);

//show a channel
fxChannelOptionsClear(obj, channel, FX_CHANFLAG_HIDE);

Le me know if I've misunderstood what you need.

-lyle

kvernon
10-01-2003, 02:38 PM
Lyle,

that was exactly it. Thanks for helping! :)

FB_Turbine
10-01-2003, 06:28 PM
Originally posted by lmilton
If you're refering to channel visibility, the functionalilty already exists:
//hide a channel
fxChannelOptionsSet(obj, channel, FX_CHANFLAG_HIDE);
//show a channel
fxChannelOptionsClear(obj, channel, FX_CHANFLAG_HIDE);


Wow, how did I miss that? Thanks Lyle.

CGTalk Moderation
01-16-2006, 05:00 AM
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.