- Timestamp:
- 07/21/14 02:19:34 (11 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/formats/assimp_loader.cc
r284 r285 367 367 if (this_id == 0) 368 368 a_data.transform = mat4(); 369 a_data. channel_count = 0;369 a_data.data = nullptr; 370 370 371 371 if (anode) … … 394 394 size_t max_keys = glm::max( node->mNumPositionKeys, node->mNumRotationKeys ); 395 395 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)); 399 400 400 401 for ( unsigned n = 0; n < max_keys; ++n ) … … 406 407 // TODO: only do the calculation when a rotate transform is present! 407 408 nv::transform ptr; 408 if ( parent )409 { 410 key_raw_channel* pchannel = parent->channels[0];411 if ( p arent->channels[0] && parent->channels[0]->count > 0 )412 { 413 ptr = ((assimp_key_tr*)pchannel->data)[ glm::min( n, p arent->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; 414 415 } 415 416 } … … 422 423 void nv::assimp_loader::create_direct_keys( assimp_animated_node_data* data, const void* vnode ) 423 424 { 424 data->channel_count = 0;425 425 const aiNodeAnim* node = (const aiNodeAnim*)vnode; 426 426 if ( node->mNumPositionKeys == 0 && node->mNumRotationKeys == 0 && node->mNumScalingKeys == 0 ) … … 429 429 } 430 430 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)); 438 441 439 442 for ( unsigned np = 0; np < node->mNumPositionKeys; ++np ) -
trunk/src/formats/md3_loader.cc
r282 r285 407 407 for ( sint32 i = 0; i < md3->header.num_tags; ++i ) 408 408 { 409 const md3_tag_t& rtag = md3->tags[i + md3->header.num_tags];409 const md3_tag_t& rtag = md3->tags[i]; 410 410 std::string name( (char*)(rtag.name) ); 411 nv::key_raw_channel* keys = load_tags( name ); 412 result->insert( name, keys ); 411 412 key_data* data = new key_data; 413 data->add_channel( load_tags( name ) ); 414 result->insert( name, data ); 413 415 } 414 416 return result; 415 417 } 416 418 419 mesh_node_data* nv::md3_loader::release_mesh_node_data( size_t index ) 420 { 421 md3_t* md3 = (md3_t*)m_md3; 422 const md3_tag_t& rtag = md3->tags[index]; 423 std::string name( (char*)(rtag.name) ); 424 425 mesh_node_data* result = new mesh_node_data; 426 result->transform = mat4(); 427 result->name = name; 428 result->parent_id = -1; 429 result->target_id = -1; 430 result->data = new key_data; 431 432 key_raw_channel* keys = load_tags( name ); 433 result->data->add_channel( keys ); 434 return result; 435 } 436 437 size_t nv::md3_loader::get_node_count() const 438 { 439 return ((md3_t*)m_md3)->header.num_tags; 440 } 441 417 442 size_t md3_loader::get_max_frames() const 418 443 { -
trunk/src/formats/nmd_loader.cc
r284 r285 138 138 m_animation->nodes[i].parent_id = node_header.parent_id; 139 139 m_animation->nodes[i].transform = node_header.transform; 140 m_animation->nodes[i].channel_count = ch_count; 141 m_animation->nodes[i].channels = nullptr; 140 m_animation->nodes[i].data = nullptr; 142 141 if ( ch_count > 0 ) 143 142 { 144 m_animation->nodes[i].channels = new key_raw_channel* [ch_count]; 143 key_data* kdata = new key_data; 144 m_animation->nodes[i].data = kdata; 145 145 for ( uint32 c = 0; c < ch_count; ++c ) 146 146 { … … 151 151 key_raw_channel* channel = key_raw_channel::create( cheader.format, cheader.count ); 152 152 source.read( channel->data, channel->desc.size, channel->count ); 153 m_animation->nodes[i].channels[c] = channel;153 kdata->add_channel( channel ); 154 154 } 155 155 } … … 168 168 { 169 169 nmd_node& node = m_animation->nodes[n]; 170 key_animation_data* keys = nullptr; 171 if ( node.channel_count > 1 ) 172 { 173 keys = new nv::key_vectors_prs( node.channels[0], node.channels[1], node.channels[2] ); 174 } 175 else if ( node.channel_count == 1 ) 176 { 177 keys = new nv::transform_vector( node.channels[0] ); 178 node.channels[0] = nullptr; 179 node.channel_count = 0; 180 } 181 m_data.push_back( keys ); 170 m_data.push_back( node.data ); 171 node.data = nullptr; 182 172 } 183 173 … … 239 229 nv::mat4 node_mat( node->transform ); 240 230 241 if ( m_data[n] && !m_data[n]->empty())231 if ( m_data[n] ) 242 232 { 243 233 node_mat = m_data[n]->get_matrix( anim_time ); … … 257 247 mat4 node_mat( node->transform ); 258 248 259 if ( m_data[ node_id ] && !m_data[ node_id ]->empty())249 if ( m_data[ node_id ] ) 260 250 { 261 251 node_mat = m_data[ node_id ]->get_matrix( time ); -
trunk/src/gfx/keyframed_mesh.cc
r283 r285 40 40 } 41 41 42 transform keyframed_mesh::get_tag( const std::string&tag ) const42 transform keyframed_mesh::get_tag( uint32 tag ) const 43 43 { 44 44 NV_ASSERT( m_tag_map, "TAGMAP FAIL" ); 45 const transform* transforms = m_tag_map->get_tag( tag ); 46 NV_ASSERT( transforms, "TAG FAIL" ); 47 return interpolate( transforms[ m_last_frame ], transforms[ m_next_frame ], m_interpolation ); 45 const key_data* data = m_tag_map->get_tag( tag ); 46 NV_ASSERT( data, "TAG FAIL" ); 47 transform last = data->get_raw_transform( m_last_frame ); 48 transform next = data->get_raw_transform( m_next_frame ); 49 return interpolate( last, next, m_interpolation ); 48 50 } 49 51
Note: See TracChangeset
for help on using the changeset viewer.