Changeset 278 for trunk/src/formats
- Timestamp:
- 07/08/14 03:20:06 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/formats/assimp_loader.cc
r277 r278 87 87 88 88 mat3 scaled_rotatation = glm::mat3( glm::scale( m_scale, m_scale, m_scale ) * m_rotate_transform ); 89 //mat3 scaled_rotatation = glm::mat3( m_rotate_transform ); 89 90 vec3 vertex_offset = glm::vec3(); 90 91 mat3 vertex_transform = scaled_rotatation; … … 169 170 if ( mesh->mNumBones == 0 ) return false; 170 171 171 mat4 bone_transform = glm::inverse( glm::scale( m_scale, m_scale, m_scale ) * glm::mat4(m_rotate_transform) ); //glm::scale( 1.f/m_scale, 1.f/m_scale, 1.f/m_scale ) * m_rotate_transform; 172 mat4 bone_transform = glm::scale( 1.f/m_scale, 1.f/m_scale, 1.f/m_scale ) * glm::inverse( glm::mat4(m_rotate_transform) ); 173 mat4 bone_pre_transform = glm::scale( m_scale, m_scale, m_scale ); 172 174 173 175 for (unsigned int m=0; m<mesh->mNumBones; m++) 174 176 { 175 177 aiBone* bone = mesh->mBones[m]; 176 mat4 offset = assimp_mat4_cast( bone->mOffsetMatrix ) * bone_transform;178 mat4 offset = bone_pre_transform * assimp_mat4_cast( bone->mOffsetMatrix ) * bone_transform; 177 179 bones.emplace_back( bone->mName.data, offset ); 178 180 } … … 211 213 aiMesh* mesh = scene->mMeshes[mc]; 212 214 213 NV_LOG( nv::LOG_NOTICE, "Mesh #"<<mc<<" - " << mesh->mName.data);215 NV_LOG( nv::LOG_NOTICE, "Mesh #"<<mc<<" - " << std::string( mesh->mName.data ) ); 214 216 NV_LOG( nv::LOG_NOTICE, " bones - " << mesh->mNumBones ); 215 217 NV_LOG( nv::LOG_NOTICE, " uvs - " << mesh->mNumUVComponents[0] ); … … 329 331 330 332 load_node( result, root, 0, -1 ); 331 result->nodes[0].transform = glm::scale( m_scale, m_scale, m_scale ) * result->nodes[0].transform;333 // TODO: this is not used when pretransformed, is it used otherwise? 332 334 333 335 if ( bone_data ) … … 422 424 nv::vec3 pos = nv::assimp_vec3_cast(node->mPositionKeys[pn].mValue); 423 425 nv::quat rot = nv::assimp_quat_cast(node->mRotationKeys[rn].mValue); 424 nv::transform ptr; 426 // TODO: only do the calculation when a rotate transform is present! 427 nv::transform ptr( vec3(), glm::quat_cast( m_rotate_transform ) ); 425 428 if ( parent_keys ) 426 429 { … … 428 431 if ( pv && pv->size() > 0 ) ptr = pv->get( glm::min( n, pv->size()-1 ) ); 429 432 } 430 431 nv::vec3 rot_pos = ptr.get_orientation() * pos; 432 pos = ptr.get_position() + rot_pos; 433 rot = glm::normalize( ptr.get_orientation() * rot ); 434 keys->insert( nv::transform( pos, rot ) ); 433 nv::transform key( ptr * nv::transform( pos * m_scale, rot ) ); 434 keys->insert( key ); 435 435 } 436 436 return keys; … … 439 439 key_animation_data* nv::assimp_loader::create_direct_keys( const void* vnode ) 440 440 { 441 // TODO : support for m_rotate_transform and m_scale! ( should be easy ) 441 442 const aiNodeAnim* node = (const aiNodeAnim*)vnode; 442 443 if ( node->mNumPositionKeys == 0 && node->mNumRotationKeys == 0 && node->mNumScalingKeys == 0 ) return nullptr; … … 445 446 for ( unsigned np = 0; np < node->mNumPositionKeys; ++np ) 446 447 { 447 keys->insert_position( (float)node->mPositionKeys[np].mTime, assimp_vec3_cast(node->mPositionKeys[np].mValue) );448 keys->insert_position( (float)node->mPositionKeys[np].mTime, m_scale * assimp_vec3_cast(node->mPositionKeys[np].mValue) ); 448 449 } 449 450 for ( unsigned np = 0; np < node->mNumRotationKeys; ++np )
Note: See TracChangeset
for help on using the changeset viewer.