Ignore:
Timestamp:
07/09/15 18:53:08 (10 years ago)
Author:
epyon
Message:
  • data_descriptor creators ( buggy )
File:
1 edited

Legend:

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

    r412 r413  
    77#include "nv/formats/assimp_loader.hh"
    88#include "nv/stl/unordered_map.hh"
    9 #include "nv/gfx/mesh_creator.hh"
    109#include "nv/lib/assimp.hh"
    1110
     
    123122        else
    124123                channel = raw_data_channel::create< assimp_plain_vtx >( mesh->mNumVertices );
     124        uint8* cdata = const_cast< uint8*>( channel->raw_data() );
    125125
    126126        data->add_channel( channel );
     
    139139                nv::vec4 vt ( t_i[0], t_i[1], t_i[2], det );
    140140                if ( skinned )
    141                         reinterpret_cast< assimp_skinned_vtx* >(channel->data)[i] = assimp_skinned_vtx( v, s, n, vt );
     141                        reinterpret_cast< assimp_skinned_vtx* >( cdata )[i] = assimp_skinned_vtx( v, s, n, vt );
    142142                else
    143                         reinterpret_cast< assimp_plain_vtx* >(channel->data)[i] = assimp_plain_vtx( v, s, n, vt );
     143                        reinterpret_cast< assimp_plain_vtx* >( cdata )[i] = assimp_plain_vtx( v, s, n, vt );
    144144        }
    145145
    146146        if ( skinned )
    147147        {
    148                 assimp_skinned_vtx* vtx = reinterpret_cast< assimp_skinned_vtx* >( channel->data );
     148                assimp_skinned_vtx* vtx = reinterpret_cast< assimp_skinned_vtx* >( cdata );
    149149                for (unsigned int m=0; m<mesh->mNumBones; m++)
    150150                {
     
    169169        }
    170170
    171         raw_data_channel* ichannel = raw_data_channel::create< index_u16 >( mesh->mNumFaces * 3 );
    172         data->add_channel( ichannel );
    173         uint16* indices = reinterpret_cast<uint16*>( ichannel->data );
     171        data_channel_creator< index_u16 > ichannel( mesh->mNumFaces * 3 );
     172        uint16* indices = reinterpret_cast<uint16*>( ichannel.raw_data() );
    174173        for (unsigned int i=0; i<mesh->mNumFaces; i++)
    175174        {
     
    180179                }
    181180        }
     181        data->add_channel( ichannel.release() );
    182182}
    183183
     
    315315                        if ( m > 0 && bones.size() > 0 )
    316316                        {
    317                                 raw_data_channel* channel = meshes[m].get_raw_channels()[0];
    318                                 assimp_skinned_vtx* va = reinterpret_cast< assimp_skinned_vtx* >( channel->data );
    319                                 for ( unsigned v = 0; v < channel->element_count(); ++v )
     317                                data_channel_creator< assimp_skinned_vtx > channel( meshes[m].get_raw_channels()[0] );
     318                                for ( unsigned v = 0; v < channel.size(); ++v )
    320319                                {
    321                                         assimp_skinned_vtx& vertex = va[v];
     320                                        assimp_skinned_vtx& vertex = channel.data()[v];
    322321
    323322                                        for ( int i = 0 ; i < 4; ++i)
     
    418417
    419418        data->data = new key_data;
    420         raw_data_channel* raw_pchannel = raw_data_channel::create<assimp_key_p>( node->mNumPositionKeys );
    421         raw_data_channel* raw_rchannel = raw_data_channel::create<assimp_key_r>( node->mNumRotationKeys );
    422         //raw_data_channel* raw_schannel = raw_data_channel::create<assimp_key_s>( node->mNumScalingKeys );
    423         data->data->add_channel( raw_pchannel );
    424         data->data->add_channel( raw_rchannel );
    425         //data->data->add_channel( raw_schannel );
    426         assimp_key_p* pchannel = reinterpret_cast< assimp_key_p* >( raw_pchannel->data );
    427         assimp_key_r* rchannel = reinterpret_cast< assimp_key_r* >( raw_rchannel->data );
     419        data_channel_creator< assimp_key_p > pchannel_creator( node->mNumPositionKeys );
     420        data_channel_creator< assimp_key_r > rchannel_creator( node->mNumRotationKeys );
     421//      data_channel_creator< assimp_key_s > schannel_creator( node->mNumScalingKeys );
     422
     423        assimp_key_p* pchannel = pchannel_creator.data();
     424        assimp_key_r* rchannel = rchannel_creator.data();
    428425        //assimp_key_s* schannel = ((assimp_key_s*)(raw_schannel->data));
    429426
     
    457454//              }
    458455//      }
    459 
     456        data->data->add_channel( pchannel_creator.release() );
     457        data->data->add_channel( rchannel_creator.release() );
     458//      data->data->add_channel( schannel_creator.release() );
    460459}
    461460
Note: See TracChangeset for help on using the changeset viewer.