/*---------------------------------------------------------------------- | | GetCameraMotionByIndex3ds | | db: database to be searched | index: index of camera in name list | kfcam: Ptr to the addr of kfcamera3ds structure, if (*kfcam) | is null, then memory will be allocated for the new | structure, otherwise, the existing structure will be | filled in with the new values. If no match is found, then | kfcam remains unchanged. | +----------------------------------------------------------------------*/ void GetCameraMotionByIndex3ds(database3ds *db, ulong3ds index, kfcamera3ds **kfcam) { chunk3ds *pCameraChunk, *pTargetChunk; namelist3ds *list = NULL; char3ds *name; if(db == NULL) SET_ERROR_RETURN(ERR_INVALID_ARG); GetCameraNodeNameList3ds(db, &list); if(index < list->count){ name = list->list[index].name; kfFindNamedAndTaggedChunk(db, name, CAMERA_NODE_TAG, &pCameraChunk); if (pCameraChunk){ kfFindNamedAndTaggedChunk(db, name, TARGET_NODE_TAG, &pTargetChunk); GetCameraMotion3ds(pCameraChunk, pTargetChunk, kfcam); } } /*--- release list when done using name */ ReleaseNameList3ds(&list); }
/*-------------------------------------------------------------------------- | InitLight3ds | | Initializes the light3ds structure. If *light is null, | memory is also allocated for it. Note that the *spot field is | ignored when an existing structure is used. | +--------------------------------------------------------------------------*/ void InitLight3ds(light3ds **light) { if (light == NULL) SET_ERROR_RETURN(ERR_INVALID_ARG); /* If (*light) a null pointer, then alloc new memory for the pointer */ if (*light == NULL){ *light = malloc(sizeof(light3ds)); if(*light == NULL) SET_ERROR_RETURN(ERR_NO_MEM); /* Set all fields with pointer to NULL as well */ (*light)->spot = NULL; (*light)->exclude = NULL; } (*light)->name[0] = 0; (*light)->pos.x = 0.0F; (*light)->pos.y = 0.0F; (*light)->pos.z = 0.0F; (*light)->color.r = 0.708852F; (*light)->color.g = 0.708852F; (*light)->color.b = 0.708852F; (*light)->multiplier = 1.0F; (*light)->dloff = False3ds; (*light)->attenuation.on = False3ds; (*light)->attenuation.inner = 10.0F; (*light)->attenuation.outer = 100.0F; if ((*light)->exclude != NULL) ReleaseNameList3ds(&((*light)->exclude)); InitNameList3ds( &((*light)->exclude), (long3ds)0); }
/*----------------------------------------------------------- | ReleaseLight3ds | +-----------------------------------------------------------*/ void ReleaseLight3ds(light3ds **light) { if((*light) == NULL) SET_ERROR_RETURN(ERR_INVALID_ARG); if ((*light)->exclude != NULL) ReleaseNameList3ds(&((*light)->exclude)); ON_ERROR_RETURN; if ((*light)->spot != NULL){ if ((*light)->spot->projector.bitmap != NULL) free((*light)->spot->projector.bitmap); ON_ERROR_RETURN; free((*light)->spot); } ON_ERROR_RETURN; free(*light); *light = NULL; }
/*---------------------------------------------------------------------- | | GetOmnilightMotionByIndex3ds | | db: database to be searched | index: index of Omnilight in name list | kfomni: Ptr to the addr of kfomni3ds structure, if (*kfomni) | is null, then memory will be allocated for the new | structure, otherwise, the existing structure will be | filled in with the new values. If no match is found, then | kfomni remains unchanged. | +----------------------------------------------------------------------*/ void GetOmnilightMotionByIndex3ds(database3ds *db, ulong3ds index, kfomni3ds **kfomni) { chunk3ds *pOmniChunk; namelist3ds *list = NULL; char3ds *name; if (db == NULL) SET_ERROR_RETURN(ERR_INVALID_ARG); GetOmnilightNodeNameList3ds(db, &list); if (index < list->count){ name = list->list[index].name; kfFindNamedAndTaggedChunk(db, name, LIGHT_NODE_TAG, &pOmniChunk); if (pOmniChunk) GetOmnilightMotion3ds(pOmniChunk, kfomni); } /*--- release list when done using name */ ReleaseNameList3ds(&list); }