Ignore:
Timestamp:
07/09/15 20:02:58 (10 years ago)
Author:
epyon
Message:
  • naming scheme for data_descriptor changed
  • channels can only be created by data_channel_creators
File:
1 edited

Legend:

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

    r413 r415  
    117117
    118118        bool skinned = mesh->mNumBones > 0;
    119         raw_data_channel* channel = nullptr;
     119
     120        data_descriptor desc;
    120121        if ( skinned )
    121                 channel = raw_data_channel::create< assimp_skinned_vtx >( mesh->mNumVertices );
     122                desc.initialize< assimp_skinned_vtx >();
    122123        else
    123                 channel = raw_data_channel::create< assimp_plain_vtx >( mesh->mNumVertices );
    124         uint8* cdata = const_cast< uint8*>( channel->raw_data() );
    125 
    126         data->add_channel( channel );
     124                desc.initialize< assimp_plain_vtx >();
     125        raw_data_channel_creator channel( desc, mesh->mNumVertices );
     126        uint8* cdata = channel.raw_data();
     127
    127128        if ( mesh->mTangents && mesh->mBitangents )
    128         for (unsigned int i=0; i<mesh->mNumVertices; i++)
    129         {
    130                 vec3 v = assimp_vec3_cast( mesh->mVertices[ i ] );
    131                 vec3 n = glm::normalize( assimp_vec3_cast( mesh->mNormals[ i ] ) );
    132                 vec3 t = glm::normalize( assimp_vec3_cast( mesh->mTangents[ i ] ) );
    133                 vec3 b = glm::normalize( assimp_vec3_cast( mesh->mBitangents[ i ] ) );
    134                 vec2 s = assimp_st_cast( mesh->mTextureCoords[ 0 ][ i ] );
    135 
    136                 glm::vec3 t_i = glm::normalize (t - n * glm::dot (n, t));
    137                 float det = (glm::dot (glm::cross (n, t), b));
    138                 det = (det < 0.0f ? -1.0f : 1.0f );
    139                 nv::vec4 vt ( t_i[0], t_i[1], t_i[2], det );
    140                 if ( skinned )
    141                         reinterpret_cast< assimp_skinned_vtx* >( cdata )[i] = assimp_skinned_vtx( v, s, n, vt );
    142                 else
    143                         reinterpret_cast< assimp_plain_vtx* >( cdata )[i] = assimp_plain_vtx( v, s, n, vt );
    144         }
     129                for ( unsigned int i = 0; i < mesh->mNumVertices; i++ )
     130                {
     131                        vec3 v = assimp_vec3_cast( mesh->mVertices[i] );
     132                        vec3 n = glm::normalize( assimp_vec3_cast( mesh->mNormals[i] ) );
     133                        vec3 t = glm::normalize( assimp_vec3_cast( mesh->mTangents[i] ) );
     134                        vec3 b = glm::normalize( assimp_vec3_cast( mesh->mBitangents[i] ) );
     135                        vec2 s = assimp_st_cast( mesh->mTextureCoords[0][i] );
     136
     137                        glm::vec3 t_i = glm::normalize( t - n * glm::dot( n, t ) );
     138                        float det = ( glm::dot( glm::cross( n, t ), b ) );
     139                        det = ( det < 0.0f ? -1.0f : 1.0f );
     140                        nv::vec4 vt( t_i[0], t_i[1], t_i[2], det );
     141                        if ( skinned )
     142                                reinterpret_cast<assimp_skinned_vtx*>( cdata )[i] = assimp_skinned_vtx( v, s, n, vt );
     143                        else
     144                                reinterpret_cast<assimp_plain_vtx*>( cdata )[i] = assimp_plain_vtx( v, s, n, vt );
     145                }
    145146
    146147        if ( skinned )
     
    179180                }
    180181        }
     182        data->add_channel( channel.release() );
    181183        data->add_channel( ichannel.release() );
    182184}
Note: See TracChangeset for help on using the changeset viewer.