示例#1
0
/**
 *	Create animation for a model. Called from animation script.
 */
bool anim_Create3D(char szPieFileName[], UWORD uwStates, UWORD uwFrameRate, UWORD uwObj,
                   ANIM_MODE ubType, UWORD uwID)
{
    ANIM3D		*psAnim3D;
    iIMDShape	*psFrames;
    UWORD		uwFrames, i;

    /* allocate anim */
    if ((psAnim3D = (ANIM3D *)malloc(sizeof(ANIM3D))) == NULL)
    {
        return false;
    }

    /* get local pointer to shape */
    psAnim3D->psFrames = modelGet(szPieFileName);

    /* count frames in imd */
    psFrames = psAnim3D->psFrames;
    uwFrames = 0;
    while (psFrames != NULL)
    {
        uwFrames++;
        psFrames = psFrames->next;
    }

    /* check frame count matches script */
    if (ubType == ANIM_3D_TRANS && uwObj != uwFrames)
    {
        ASSERT(false, "Frames in pie %s != script objects %i", szPieFileName, uwObj);
        free(psAnim3D);
        return false;
    }

    /* get pointers to individual frames */
    psAnim3D->apFrame = (iIMDShape **)malloc(uwFrames * sizeof(iIMDShape *));
    psFrames = psAnim3D->psFrames;
    for (i = 0; i < uwFrames; i++)
    {
        psAnim3D->apFrame[i] = psFrames;
        psFrames = psFrames->next;
    }

    /* init members */
    psAnim3D->animType = ubType;
    anim_InitBaseMembers((BASEANIM *)psAnim3D, uwStates, uwFrameRate, uwObj, ubType, uwID);

    g_animGlobals.psAnimList.push_front(psAnim3D);

    /* update globals */
    g_animGlobals.uwCurObj = 0;

    return true;
}
示例#2
0
BOOL
anim_Create3D( char szPieFileName[], UWORD uwStates,
				UWORD uwFrameRate, UWORD uwObj, UBYTE ubType, UWORD uwID )
{
	ANIM3D		*psAnim3D;
	iIMDShape	*psFrames;
	UWORD		uwFrames, i;

	/* allocate anim */
	if ( (psAnim3D = MALLOC(sizeof(ANIM3D))) == NULL )
	{
		return FALSE;
	}

	/* get local pointer to shape */
	psAnim3D->psFrames = (g_animGlobals.pGetShapeFunc) (szPieFileName);

	/* count frames in imd */
	psFrames = psAnim3D->psFrames;
	uwFrames = 0;
	while ( psFrames != NULL )
	{
#ifdef DEBUG
		if (psFrames==0xcdcdcdcd)
		{
			printf("bad pointer in Create 3D !!!!  -[%s]\n", szPieFileName);
		}
#endif
		uwFrames++;
		psFrames = psFrames->next;
	}

	/* check frame count matches script */
	if ( ubType == ANIM_3D_TRANS && uwObj != uwFrames )
	{
		DBERROR( ("anim_Create3D: frames in pie %s != script objects %i\n",
					szPieFileName, uwObj ) );
		return FALSE;
	}

	/* get pointers to individual frames */
	psAnim3D->apFrame = MALLOC( uwFrames*sizeof(iIMDShape *) );
	psFrames = psAnim3D->psFrames;
	for ( i=0; i<uwFrames; i++ )
	{
		psAnim3D->apFrame[i] = psFrames;
		psFrames = psFrames->next;
	}

	/* init members */
	psAnim3D->animType = ubType;
	anim_InitBaseMembers( (BASEANIM * ) psAnim3D, uwStates,
							uwFrameRate, uwObj, ubType, uwID );

	/* add to head of list */
	psAnim3D->psNext = g_animGlobals.psAnimList;
	g_animGlobals.psAnimList = (BASEANIM * ) psAnim3D;

	/* update globals */
	g_animGlobals.uwCurObj = 0;

	return TRUE;
}