Пример #1
0
/*--------------------------------------------------------------------------
 | GetCameraMotion3ds
 | 
 | pCamChunk:CAMERA_NODE_TAG chunk to extract data from
 | pTargetChunk: TARGET_NODE_TAG chunk to extract target data from
 | kfcam: Structure to fill in with chunk data
 |
 |  chunk----->kfcamera3ds
 |
 | Gets camera keyframe information from chunk
 | 
 +--------------------------------------------------------------------------*/
void GetCameraMotion3ds(chunk3ds *pCamChunk,
            chunk3ds *pTargetChunk,
            kfcamera3ds **kfcam)
{
    kfcamera3ds 
    *pKfCam;
    chunk3ds 
    *pNodeHdrChunk, *pPosChunk, *pFovChunk, 
    *pRollChunk, *pTargetPosChunk = NULL, *pTargetHdrChunk = NULL;
    ulong3ds 
    i, nPosKeys = 0, nFovKeys = 0, nRollKeys = 0, nTargetKeys = 0;
    NodeHdr
    *pNodeHdr, *pTargetHdr = NULL;
    PosTrackTag 
    *pPosData = NULL, *pTargetData = NULL;
    FovTrackTag
    *pFovData = NULL;
    RollTrackTag 
    *pRollData = NULL;
    
    if(pCamChunk == NULL) 
      SET_ERROR_RETURN(ERR_INVALID_ARG);

    
    /*-------------------------------
      |  Get information from chunks 
      +-------------------------------*/
    /*--- Search children of camera chunk */
    FindChunk3ds(pCamChunk, NODE_HDR, &pNodeHdrChunk);
    FindChunk3ds(pCamChunk, POS_TRACK_TAG, &pPosChunk);
    FindChunk3ds(pCamChunk, FOV_TRACK_TAG, &pFovChunk);
    FindChunk3ds(pCamChunk, ROLL_TRACK_TAG, &pRollChunk);
    
    ReadChunkData3ds(pNodeHdrChunk);
    pNodeHdr = pNodeHdrChunk->data;
    
    if(pPosChunk){
    ReadChunkData3ds(pPosChunk);
    pPosData = pPosChunk->data;
    nPosKeys = pPosData->trackhdr.keycount;
    }
    
    if(pFovChunk){
    ReadChunkData3ds(pFovChunk);
    pFovData = pFovChunk->data;
    nFovKeys = pFovData->trackhdr.keycount;
    }
    
    if(pRollChunk){
    ReadChunkData3ds(pRollChunk);
    pRollData = pRollChunk->data;
    nRollKeys = pRollData->trackhdr.keycount;
    }
    
    if (pTargetChunk){
      FindChunk3ds(pTargetChunk, NODE_HDR, &pTargetHdrChunk);
      if (pTargetHdrChunk){
    ReadChunkData3ds(pTargetHdrChunk);
    pTargetHdr = pTargetHdrChunk->data;
      }

      FindChunk3ds(pTargetChunk, POS_TRACK_TAG, &pTargetPosChunk);
      if (pTargetPosChunk){
    ReadChunkData3ds(pTargetPosChunk);
    pTargetData = pTargetPosChunk->data;
    nTargetKeys = pTargetData->trackhdr.keycount;
      }
    }
    
    /*--------------------------------------------
      | Set-up and fill-in the kfcamera structure 
      +--------------------------------------------*/
    InitCameraMotion3ds(kfcam, 
            nPosKeys, 
            nFovKeys, 
            nRollKeys, 
            nTargetKeys);
    
    pKfCam = *kfcam;
    
    /*--- Header Information */
    strcpy(pKfCam->name, pNodeHdr->objname);
    pKfCam->flags1 = pNodeHdr->flags1;
    pKfCam->flags2 = pNodeHdr->flags2;

    /*--- Parents */
    kfGetParentName(pNodeHdrChunk, pKfCam->parent);
    kfGetParentName(pTargetHdrChunk, pKfCam->tparent);

    /*--- Target Information */
    if (nTargetKeys){
    pKfCam->ntflag = pTargetData->trackhdr.flags;
    
    for(i=0; i<nTargetKeys; i++){
        memcpy(&((pKfCam->tkeys)[i]), 
           &((pTargetData->keyhdrlist)[i]),
           sizeof(keyheader3ds));
        memcpy(&((pKfCam->tpos)[i]),
           &((pTargetData->positionlist)[i]),
           sizeof(point3ds));
    }
    }
    if (pTargetHdr) {
        pKfCam->tflags1 = pTargetHdr->flags1;
        pKfCam->tflags2 = pTargetHdr->flags2;
	}
    
    /*--- Position Information */
    if (nPosKeys){
    pKfCam->npflag = pPosData->trackhdr.flags;
    for (i=0; i<nPosKeys; i++){
        memcpy(&((pKfCam->pkeys)[i]),
           &((pPosData->keyhdrlist)[i]),
           sizeof(keyheader3ds));
        memcpy(&((pKfCam->pos)[i]),
           &((pPosData->positionlist)[i]),
           sizeof(point3ds));
    }
    }
    
    /*--- Field of view Information */
    if (nFovKeys){
    pKfCam->nfflag = pFovData->trackhdr.flags;
    for (i=0; i<nFovKeys; i++){
        memcpy(&((pKfCam->fkeys)[i]), 
           &((pFovData->keyhdrlist)[i]),
           sizeof(keyheader3ds));
        memcpy(&((pKfCam->fov)[i]),
           &((pFovData->fovanglelist)[i]),
           sizeof(float3ds));
    }
    }
    
    /*--- Roll Track Information */
    if (nRollKeys){
    pKfCam->nrflag = pRollData->trackhdr.flags;
    for (i=0; i<nRollKeys; i++){
        memcpy(&((pKfCam->rkeys)[i]), 
           &((pRollData->keyhdrlist)[i]),
           sizeof(keyheader3ds));
        memcpy(&((pKfCam->roll)[i]),
           &((pRollData->rollanglelist)[i]),
           sizeof(float3ds));
    }
    }
    
    /*--- Free Chunk Data */
    FreeFileChunkData3ds(pPosChunk);
    FreeFileChunkData3ds(pFovChunk);
    FreeFileChunkData3ds(pRollChunk);
    FreeFileChunkData3ds(pNodeHdrChunk);
    if (pTargetPosChunk)
      FreeFileChunkData3ds(pTargetPosChunk);
    if (pTargetHdrChunk)
      FreeFileChunkData3ds(pTargetHdrChunk);
}
Пример #2
0
/*--------------------------------------------------------------------------
 | GetOmnilightMotion3ds
 | 
 | pOmniChunk:SPOTLIGHT_NODE_TAG chunk to extract data from
 | pTargetChunk: L_TARGET_NODE_TAG chunk to extract target data from
 | kfspot: Structure to fill in with chunk data
 |
 |  chunk----->kfOmni3ds
 |
 | Gets Omnilight keyframe information from chunk
 | 
 |  L_TARGET
 |  NODE_ID
 |  NODE_HDR
 |  APP_DATA
 |  POS_TRACK
 |  COL_TRACK
 |  HOT_TRACK
 |  FALL_TRACK
 |  ROLL_TRACK 
 | 
 +--------------------------------------------------------------------------*/
void GetOmnilightMotion3ds(chunk3ds *pOmniChunk,
               kfomni3ds **kfomni)
{
    kfomni3ds *pKfOmni;
    chunk3ds *pNodeHdrChunk, *pPosChunk, *pColChunk;
    ulong3ds i, nPosKeys = 0, nColKeys = 0;
    NodeHdr *pNodeHdr;
    PosTrackTag *pPosData = NULL;
    ColTrackTag *pColData = NULL;
    

    if (pOmniChunk == NULL)
      SET_ERROR_RETURN(ERR_INVALID_ARG); 
    
    /*-------------------------------
      |  Get information from chunks 
      +-------------------------------*/
    /*--- Search children of OmniLight chunk */
    FindChunk3ds(pOmniChunk, NODE_HDR, &pNodeHdrChunk);
    FindChunk3ds(pOmniChunk, POS_TRACK_TAG, &pPosChunk);
    FindChunk3ds(pOmniChunk, COL_TRACK_TAG, &pColChunk);
    
    ReadChunkData3ds(pNodeHdrChunk);
    pNodeHdr = pNodeHdrChunk->data;
    
    if(pPosChunk){
    ReadChunkData3ds(pPosChunk);
    pPosData = pPosChunk->data;
    nPosKeys = pPosData->trackhdr.keycount;
    }
    
    if(pColChunk){
    ReadChunkData3ds(pColChunk);
    pColData = pColChunk->data;
    nColKeys = pColData->trackhdr.keycount;
    }
    
    /*--------------------------------------------
      | Set-up and fill-in the kfomni3ds structure 
      +--------------------------------------------*/
    InitOmnilightMotion3ds(kfomni, nPosKeys, nColKeys); 
    
    pKfOmni = *kfomni;
    
    /*--- Header Information */
    strcpy(pKfOmni->name, pNodeHdr->objname);
    pKfOmni->flags1 = pNodeHdr->flags1;
    pKfOmni->flags2 = pNodeHdr->flags2;
    kfGetParentName(pNodeHdrChunk, pKfOmni->parent);

    /*--- Position Information */
    if (nPosKeys){
    pKfOmni->npflag = pPosData->trackhdr.flags;
    for (i=0; i<nPosKeys; i++){
        memcpy(&((pKfOmni->pkeys)[i]), &((pPosData->keyhdrlist)[i]),
           sizeof(keyheader3ds));
        memcpy(&((pKfOmni->pos)[i]), &((pPosData->positionlist)[i]),
           sizeof(point3ds));
    }
    }
    
    /*--- Color Information */
    if (nColKeys){
    pKfOmni->ncflag = pColData->trackhdr.flags;
    for (i=0; i<nColKeys; i++){
        memcpy(&((pKfOmni->ckeys)[i]), &((pColData->keyhdrlist)[i]),
           sizeof(keyheader3ds));
        memcpy(&((pKfOmni->color)[i]), &((pColData->colorlist)[i]),
           sizeof(fcolor3ds));
    }
    }

    /*--- Free Chunk Data */
    if (pNodeHdrChunk)
    FreeFileChunkData3ds(pNodeHdrChunk);
    if (pPosChunk)
    FreeFileChunkData3ds(pPosChunk);
    if (pColChunk)
    FreeFileChunkData3ds(pColChunk);
}