Angus Henderson (angus++at++death.reading.sgi.com)
Thu, 2 Feb 1995 08:29:25 +0000
FIrst of all the MultiGen loader I use gets the pfSequences wrong. The Sequence
time is broken making the sequence glitch - everyone out there thinks it was me
who dropped an image from the fire movie loop but it was MultiGen - j'accuse.
So I set them all to animate correctly by searching my scene tree for all
sequences, and fix them ...
...this code is rather different in 2.0 becuse they've done something
very abstract with all the types... ( this is the 1.2 version )
void
setSequences(pfNode *node)
{
long type, i;
long nc;
pfNode *child;
type = pfGetType(node);
if(type == PFTYPE_SEQUENCE)
{
pfSeqTime((pfSequence*)node, -1, 1.0 / pfGetFrameRate());
}
else if(type & PFCLASS_GROUP)
{
for(i = 0; i < (nc = pfGetNumChildren(node)); i++)
{
child = pfGetChild(node, i);
setSequences(child);
}
}
}
Them to manage Sequences more tightly ( not to just let them cycle for ever )
Heres a code fragment...
...I load up a model with a node called "E_r_exh" for the right reheat
pipe of an aircraft - it's an animation group bead with about 40 children
representing a nozzle winding up to full reheat...
...you can not get away without reading most of the pfSequence man page
I am afraid...
...then I initialise it once....
if(vehicle[i].vseq[0] = (pfSequence*)pfFindSeq("E_r_exh"))
{
int nc, j;
nc = pfGetNumChildren((pfGroup*)vehicle[i].vseq[0]);
printf("Found right exhaust with %d children\n", nc);
pfSeqTime(vehicle[i].vseq[0], -1, 1.0 / pfGetFrameRate());
pfSeqInterval(vehicle[i].vseq[0], PFSEQ_CYCLE, 0, nc - 1);
pfSeqDuration(vehicle[i].vseq[0], 1.0, -1);
}
...then in the main loop I set the range of children over which I want
to animate for a particular thrust level...
switch(engineState[i])
{
case DRY:
pfSeqInterval(vehicle[i].vseq[0], PFSEQ_CYCLE, 0, 0);
pfSeqInterval(vehicle[i].vseq[1], PFSEQ_CYCLE, 0, 0);
break;
case LIGHT_UP:
pfSeqInterval(vehicle[i].vseq[0], PFSEQ_CYCLE, 0, 11);
pfSeqInterval(vehicle[i].vseq[1], PFSEQ_CYCLE, 0, 11);
if( pfGetSeqFrame(vehicle[i].vseq[0], &repeat) == 11 )
engineState[i] = MAX_CRUISE;
break;
case MAX_CRUISE:
pfSeqInterval(vehicle[i].vseq[0], PFSEQ_CYCLE, 11, 16);
pfSeqInterval(vehicle[i].vseq[1], PFSEQ_CYCLE, 11, 16);
break;
case COMBAT_ON:
frame = pfGetSeqFrame(vehicle[i].vseq[0], &repeat);
pfSeqInterval(vehicle[i].vseq[0], PFSEQ_CYCLE, frame, 35);
pfSeqInterval(vehicle[i].vseq[1], PFSEQ_CYCLE, frame, 35);
if( pfGetSeqFrame(vehicle[i].vseq[0], &repeat) == 35 )
engineState[i] = MAX_COMBAT;
break;
case MAX_COMBAT:
pfSeqInterval(vehicle[i].vseq[0], PFSEQ_CYCLE, 35, 41);
pfSeqInterval(vehicle[i].vseq[1], PFSEQ_CYCLE, 35, 41);
break;
case COMBAT_OFF:
frame = pfGetSeqFrame(vehicle[i].vseq[0], &repeat);
pfSeqInterval(vehicle[i].vseq[0], PFSEQ_CYCLE, frame, 11);
pfSeqInterval(vehicle[i].vseq[1], PFSEQ_CYCLE, frame, 11);
if( pfGetSeqFrame(vehicle[i].vseq[0], &repeat) == 11 )
engineState[i] = MAX_CRUISE;
break;
case BURN_OFF:
frame = pfGetSeqFrame(vehicle[i].vseq[0], &repeat);
pfSeqInterval(vehicle[i].vseq[0], PFSEQ_CYCLE, frame, 0);
pfSeqInterval(vehicle[i].vseq[1], PFSEQ_CYCLE, frame, 0);
if( pfGetSeqFrame(vehicle[i].vseq[0], &repeat) == 0 )
engineState[i] = DRY;
break;
default:
engineState[i] = DRY;
break;
}
ANgus
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:52:21 PDT