Ejemplo n.º 1
0
/*--------------------------------------------------------------------------
 | PutOmnilightMotion3ds
 | Puts Omnilight keyframe information into database. 
 | 
 |  kfOmnilight3ds--->db
 |
 | KFDATA
 |  ...
 |  LIGHT_NODE
 |   NODE_ID
 |   NODE_HDR
 |   APP_DATA 
 |   POS_TRACK
 |   COL_TRACK 
 |
 | Needs Work:
 |   1. NodeId: what value?
 |
 +--------------------------------------------------------------------------*/
void PutOmnilightMotion3ds(database3ds *db, kfomni3ds *kfomni)
{
    chunk3ds 
    *pKfChunk, *pOmniChunk, *pOmniXdata = NULL;
    
    if(db == NULL || kfomni == NULL)
      SET_ERROR_RETURN(ERR_INVALID_ARG); 

    if(db->topchunk == NULL) 
      SET_ERROR_RETURN(ERR_INVALID_DATABASE);
    
    if (!(db->topchunk->tag == M3DMAGIC || db->topchunk->tag == CMAGIC))
      SET_ERROR_RETURN(ERR_WRONG_DATABASE);

    MakeNodeTagListDirty3ds(db);

    /*--- Find KFSEG chunk to put keyframe data into */
    kfGetKfSeg(db->topchunk, &pKfChunk);

    /*--- Destroy old chunks, Copy any XData and reattach it later */
    kfExtractXdata(db, kfomni->name, LIGHT_NODE_TAG, &pOmniXdata);

    
    pOmniChunk = kfPutGenericNode(LIGHT_NODE_TAG, pKfChunk);
    kfPutNodeId(pOmniChunk);
    kfPutNodeHeader(kfomni->name, 
            kfomni->flags1,
            kfomni->flags2,
            kfomni->parent,
            pOmniChunk);

    MakeNodeTagListDirty3ds(db);
    
    
    if (kfomni->npkeys>0 && kfomni->pkeys && kfomni->pos)
    kfPutPosTrack(kfomni->npkeys,
              kfomni->npflag,
              kfomni->pkeys,
              kfomni->pos,
              pOmniChunk);
    
    if (kfomni->nckeys>0 && kfomni->ckeys && kfomni->color)
    kfPutColorTrack(kfomni->nckeys,
            kfomni->ncflag,
            kfomni->ckeys,
            kfomni->color,
            pOmniChunk);
    
    /*--- Replace XData */
    if (pOmniXdata)
    AddChildOrdered3ds(pOmniChunk, pOmniXdata);
}
Ejemplo n.º 2
0
/*--------------------------------------------------------------------------
 | PutAmbientLightMotion3ds
 | Puts AmbientLight keyframe information into database. 
 | 
 |  kfAmbientLight3ds--->db
 |
 | KFDATA
 |  ...
 |  LIGHT_NODE
 |   NODE_ID
 |   NODE_HDR
 |   APP_DATA 
 |   COL_TRACK 
 |
 | Needs Work:
 |   1. NodeId: what value?
 |
 +--------------------------------------------------------------------------*/
void PutAmbientLightMotion3ds(database3ds *db, kfambient3ds *kfambient)
{
  chunk3ds 
    *pKfChunk, *pAmbientChunk, *pAmbientXdata = NULL;
    
  if(db == NULL || kfambient == NULL)
    SET_ERROR_RETURN(ERR_INVALID_ARG); 

  if(db->topchunk == NULL) 
    SET_ERROR_RETURN(ERR_INVALID_DATA);
    
  if (!(db->topchunk->tag == M3DMAGIC || db->topchunk->tag == CMAGIC))
    SET_ERROR_RETURN(ERR_WRONG_DATABASE);
    
  /*--- Find KFSEG chunk to put keyframe data into */
  kfGetKfSeg(db->topchunk, &pKfChunk);

  /*--- Destroy old chunks, Copy any XData and reattach it later */
  kfExtractXdata(db, kAmbientName, AMBIENT_NODE_TAG, &pAmbientXdata);
    
  pAmbientChunk = kfPutGenericNode(AMBIENT_NODE_TAG, pKfChunk);
  kfPutNodeId(pAmbientChunk);
  kfPutNodeHeader(kAmbientName,
          kfambient->flags1,
          kfambient->flags2,
          (char3ds *)0,
          pAmbientChunk);
    
  if (kfambient->nckeys>0 && kfambient->ckeys && kfambient->color)
    kfPutColorTrack(kfambient->nckeys,
            kfambient->ncflag,
            kfambient->ckeys,
            kfambient->color,
            pAmbientChunk);
    
  /*--- Replace XData */
  if (pAmbientXdata)
    AddChildOrdered3ds(pAmbientChunk, pAmbientXdata);
}
Ejemplo n.º 3
0
/*--------------------------------------------------------------------------
 | PutCameraMotion3ds
 | Puts camera keyframe information into database. 
 | 
 |  kfcamera3ds--->db
 |
 | KFDATA
 |  ...
 |  TARGET
 |  CAMERA_NODE
 |   NODE_ID
 |   NODE_HDR
 |   APP_DATA 
 |   POS_TRACK
 |   FOV_TRACK
 |   ROLL_TRACK
 |
 | Needs Work:
 |   1. NodeId: what value?
 |
 +--------------------------------------------------------------------------*/
void PutCameraMotion3ds(database3ds *db, kfcamera3ds *kfcam)
{
    chunk3ds 
    *pKfChunk, *pCamChunk, *pTargetChunk = NULL, 
    *pCameraXdata = NULL, *pTargetXdata = NULL;
    
    if(db == NULL || kfcam == NULL) 
      SET_ERROR_RETURN(ERR_INVALID_ARG);

    if (db->topchunk == NULL)
      SET_ERROR_RETURN(ERR_INVALID_DATA);

    if (!(db->topchunk->tag == M3DMAGIC) || (db->topchunk->tag == CMAGIC))
      SET_ERROR_RETURN(ERR_INVALID_DATA);
    
    /*--- Find KFSEG chunk to put keyframe data into */
    kfGetKfSeg(db->topchunk, &pKfChunk);
    ON_ERROR_RETURN;

    /*--- Destroy old chunks, Copy any XData and reattach it later */
    kfExtractXdata(db, kfcam->name, TARGET_NODE_TAG, &pTargetXdata);
    kfExtractXdata(db, kfcam->name, CAMERA_NODE_TAG, &pCameraXdata);

    MakeNodeTagListDirty3ds(db);
    
    /*--- TARGET TRACK */
    if (kfcam->ntkeys>0 && kfcam->tkeys && kfcam->tpos)
    pTargetChunk = kfPutTargetTrack(kfcam->tparent,
                    kfcam->ntkeys,
                    kfcam->ntflag,
                    kfcam->tkeys,
                    kfcam->tpos,
                    kfcam->name,
                    kfcam->tflags1,
                    kfcam->tflags2,
		    CameraTarget,		    
                    pKfChunk);
    
    pCamChunk = kfPutGenericNode(CAMERA_NODE_TAG, pKfChunk);
    kfPutNodeId(pCamChunk);
    kfPutNodeHeader(kfcam->name, 
            kfcam->flags1,
            kfcam->flags2,
            kfcam->parent,
            pCamChunk);
    
    if (kfcam->npkeys>0 && kfcam->pkeys && kfcam->pos)
    kfPutPosTrack(kfcam->npkeys,
              kfcam->npflag,
              kfcam->pkeys,
              kfcam->pos,
              pCamChunk);
    
    /*-- FIELD OF VIEW */
    if (kfcam->nfkeys>0 && kfcam->fkeys && kfcam->fov){
    FovTrackTag *data;
    chunk3ds *temp = NULL;
    int nKeys;
    
    /*--- Create the FOV_TRACK_TAG chunk */
    InitChunk3ds(&temp);
    temp->tag = FOV_TRACK_TAG;
    data = InitChunkData3ds(temp);
    
    /*--- Initialize trackhdr field */
    data->trackhdr.flags = kfcam->nfflag;
    nKeys = data->trackhdr.keycount = kfcam->nfkeys;
    data->trackhdr.nu1 = data->trackhdr.nu2 = 0;  /* Not Used */
    
    /*--- Copy headers */
    data->keyhdrlist  = malloc(nKeys * sizeof(keyheader3ds));
    memcpy(data->keyhdrlist, kfcam->fkeys, nKeys * sizeof(keyheader3ds));
    
    /*--- Copy Points */
    data->fovanglelist = malloc(nKeys * sizeof(float3ds));
    memcpy(data->fovanglelist, kfcam->fov, nKeys * sizeof(float3ds));
    
    /*--- Make if a child of the kframe node */
    AddChildOrdered3ds(pCamChunk, temp);
    }
    
    if (kfcam->nrkeys>0 && kfcam->rkeys && kfcam->roll)
    kfPutRollTrack(kfcam->nrkeys,
               kfcam->nrflag,
               kfcam->rkeys,
               kfcam->roll,
               pCamChunk);
    
    /*--- Replace XData */
    if (pCameraXdata)
    AddChildOrdered3ds(pCamChunk, pCameraXdata);
    if (pTargetXdata)
    AddChildOrdered3ds(pTargetChunk, pTargetXdata);
}