|
From: Johann D. <de...@if...> - 2002-02-16 21:21:42
|
Hi again,
This second mail deals with effects. We have to decide if we use open
structures or abstract data types.
The first solution is convenient to use, provided structures don't
change. The later is more flexible, but having to go through tens of
function calls to create an effect can be painful.
I personnaly prefer the second solution. It has the advantage that it
probably eases the interoperability with other languages (Perl, Python...).
1) Effect creation
/* Allocate an effect */
ff_effectId ff_effectCreate();
/* Note: effects are not bound to devices */
/* Initialize effects */
ff_error ff_effectSetType(ff_effectId, ff_effectType);
ff_error ff_effectSetParameter(ff_effectId, ff_effectParameter,
void* data);
Sample use:
ff_effectId fid;
fid = ff_effectCreate();
if (ff_effectSetType(fid, FF_SINE)) {
/* handle error */
}
ff_duration period = 100; /* 100 ms */
if (ff_effectSetParameter(fid, FF_PERIOD, &period))
{
...
}
if (ff_effectSetParameter(fid, FF_MAGNITUDE, &magnitude))
{
...
}
if (ff_effectSetParameter(fid, FF_OFFSET, &offset))
{
...
}
if (ff_effectSetParameter(fid, FF_DIRECTION, &direction))
{
...
}
...
Note: calling ff_effectSetParameter while an effect is playing will
update the effect. If dynamic updates is not supported by the device, we
must decide if we generate an error or perform a pause-update-play.
2) Then we need functions to control playing of effects:
ff_error ff_effectPlay(ff_device, ff_effect_id, int times);
ff_error ff_effectStop(ff_device, ff_effect_id);
ff_error ff_effectPause(ff_device, ff_effect_id);
Not all devices support pausing an effect (is there any device actually
supporting it ?). What do we do in that case ? emulation, or throw an
error ?
3) Grouped effects
If you had the occasion to have a look at Immersion Studio, you can see
that it's possible to create compounds of effects. This are groups of
effects used to render complex effects.
ff_compound_id ff_compoundCreate();
ff_error ff_compoundAddEffect(ff_compound_id, ff_effect_id,
ff_duration start_delay);
ff_error ff_compoundPlay(ff_device, ff_compound_id, int times);
... (same as for effects).
We could even remove ff_effectPlay and friends, and use compounds only.
--
Johann Deneux
______________________________________________________________________________
ifrance.com, l'email gratuit le plus complet de l'Internet !
vos emails depuis un navigateur, en POP3, sur Minitel, sur le WAP...
http://www.ifrance.com/_reloc/email.emailif
|