Ignore:
Timestamp:
07/21/14 02:19:34 (11 years ago)
Author:
epyon
Message:
  • full pure data model for animation
  • all loaders now use pure data model instead of the template/virtual one
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/formats/assimp_loader.cc

    r284 r285  
    367367        if (this_id == 0)
    368368                a_data.transform = mat4();
    369         a_data.channel_count = 0;
     369        a_data.data = nullptr;
    370370
    371371        if (anode)
     
    394394        size_t max_keys = glm::max( node->mNumPositionKeys, node->mNumRotationKeys );
    395395
    396         data->channel_count = 1;
    397         data->channels[0] = key_raw_channel::create<assimp_key_tr>( max_keys );
    398         assimp_key_tr* channel = ((assimp_key_tr*)(data->channels[0]->data));
     396        key_raw_channel* raw_channel = key_raw_channel::create<assimp_key_tr>( max_keys );
     397        data->data = new key_data;
     398        data->data->add_channel( raw_channel );
     399        assimp_key_tr* channel = ((assimp_key_tr*)(raw_channel->data));
    399400
    400401        for ( unsigned n = 0; n < max_keys; ++n )
     
    406407                // TODO: only do the calculation when a rotate transform is present!
    407408                nv::transform ptr;
    408                 if ( parent )
    409                 {
    410                         key_raw_channel* pchannel = parent->channels[0];
    411                         if ( parent->channels[0] && parent->channels[0]->count > 0 )
    412                         {
    413                                 ptr = ((assimp_key_tr*)pchannel->data)[ glm::min( n, parent->channels[0]->count-1 ) ].tform;
     409                if ( parent && parent->data )
     410                {
     411                        const key_raw_channel* pchannel = parent->data->get_channel(0);
     412                        if ( pchannel && pchannel->count > 0 )
     413                        {
     414                                ptr = ((assimp_key_tr*)pchannel->data)[ glm::min( n, pchannel->count-1 ) ].tform;
    414415                        }
    415416                }
     
    422423void nv::assimp_loader::create_direct_keys( assimp_animated_node_data* data, const void* vnode )
    423424{
    424         data->channel_count = 0;
    425425        const aiNodeAnim* node = (const aiNodeAnim*)vnode;
    426426        if ( node->mNumPositionKeys == 0 && node->mNumRotationKeys == 0 && node->mNumScalingKeys == 0 )
     
    429429        }
    430430
    431         data->channel_count = 3;
    432         data->channels[0] = key_raw_channel::create<assimp_key_p>( node->mNumPositionKeys );
    433         data->channels[1] = key_raw_channel::create<assimp_key_r>( node->mNumRotationKeys );
    434         data->channels[2] = key_raw_channel::create<assimp_key_s>( node->mNumScalingKeys );
    435         assimp_key_p* pchannel = ((assimp_key_p*)(data->channels[0]->data));
    436         assimp_key_r* rchannel = ((assimp_key_r*)(data->channels[1]->data));
    437         assimp_key_s* schannel = ((assimp_key_s*)(data->channels[2]->data));
     431        data->data = new key_data;
     432        key_raw_channel* raw_pchannel = key_raw_channel::create<assimp_key_p>( node->mNumPositionKeys );
     433        key_raw_channel* raw_rchannel = key_raw_channel::create<assimp_key_r>( node->mNumRotationKeys );
     434        key_raw_channel* raw_schannel = key_raw_channel::create<assimp_key_s>( node->mNumScalingKeys );
     435        data->data->add_channel( raw_pchannel );
     436        data->data->add_channel( raw_rchannel );
     437        data->data->add_channel( raw_schannel );
     438        assimp_key_p* pchannel = ((assimp_key_p*)(raw_pchannel->data));
     439        assimp_key_r* rchannel = ((assimp_key_r*)(raw_rchannel->data));
     440        assimp_key_s* schannel = ((assimp_key_s*)(raw_schannel->data));
    438441
    439442        for ( unsigned np = 0; np < node->mNumPositionKeys; ++np )
Note: See TracChangeset for help on using the changeset viewer.