Received: from SpoolDir by BAGPUSS (Mercury 1.21); 15 Sep 97 12:29:51 +0
Return-path: <nikh@camrose.demon.co.uk>
Received: from argonaut.com by bagpuss.argonaut.com (Mercury 1.21);
    15 Sep 97 12:29:47 +0
Received: from relay-5.mail.demon.net by argonaut.com with smtp
	(Smail3.1.28.1 #5) id m0xAZEb-0003naC; Mon, 15 Sep 97 12:22 BST
Received: from punt-2.mail.demon.net by mailstore for martinp@argonaut.com
          id 874322705:05:20115:0; Mon, 15 Sep 97 12:25:05 BST
Received: from camrose.demon.co.uk ([194.222.230.237]) by punt-2.mail.demon.net
           id ag0623536; 15 Sep 97 12:25 BST
Received: by MAILSERV1 with Internet Mail Service (5.0.1457.3)
	id <SCHJQDQ0>; Mon, 15 Sep 1997 11:32:06 +0100
Message-ID: <D1B8B19992E1D011BFAB00400521DD3B149A@MAILSERV1>
From: Niki Hemmings <nikh@camrose.demon.co.uk>
To: "'martinp@argonaut.com'" <martinp@argonaut.com>
Subject: morph thing
Date: Mon, 15 Sep 1997 11:32:04 +0100
X-Priority: 3
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.0.1457.3)
Content-Type: text/plain
X-PMFLAGS: 34078848

/* "Morph" one matrix to another
 */
static void ZoomToMatrix34(br_matrix34 *a, br_matrix34 *b, float speed)
{
    int i, j;

    for(i = 0; i < 4; i++)
        for(j = 0; j < 3; j++)
            a->m[i][j] = BR_ADD(BR_MUL(a->m[i][j], BR_SCALAR(1-speed)),
                                BR_MUL(b->m[i][j], BR_SCALAR(speed)));
}

void c_SkeletonAnimate(c_skeleton *skeleton)
{
    br_matrix34 *matptr;
    int i;

    if(skeleton->curframe >= skeleton->anims[skeleton->curanim]->nframes
||
        skeleton->curframe < 0)
        skeleton->curframe = 0;

    matptr = (skeleton->anims[skeleton->curanim]->transforms)+
        skeleton->curframe*(skeleton->nparts-1);

    for(i = 1; i < skeleton->nparts; i++)
        if(skeleton->morphtime > 0)
            ZoomToMatrix34(&skeleton->actors[i]->t.t.mat, matptr++,
                BR_SCALAR(1)-skeleton->morphtime);
        else
            skeleton->actors[i]->t.t.mat = *matptr++;
    if(skeleton->morphtime > 0)
        skeleton->morphtime -= BR_SCALAR(0.1);

    skeleton->curframe += 2;
    if(skeleton->curframe >=
skeleton->anims[skeleton->curanim]->nframes)
        skeleton->curframe = 0;
}

