Changeset 230 for trunk/src/gfx


Ignore:
Timestamp:
05/06/14 12:39:51 (11 years ago)
Author:
epyon
Message:
  • animated_mesh, scene_node, camera and transform classes added
  • order in mesh hierarchies
  • simplified and generified animation class hierarchy
Location:
trunk/src/gfx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gfx/keyframed_mesh.cc

    r224 r230  
    1515using namespace nv;
    1616
    17 keyframed_mesh::keyframed_mesh( context* a_context, mesh_data* a_data, program* a_program )
    18         : m_context( a_context )
     17keyframed_mesh::keyframed_mesh( context* a_context, mesh_data* a_data )
     18        : animated_mesh( a_context )
    1919        , m_data( a_data )
    20         , m_program( a_program )
    21         , m_va( nullptr )
    2220        , m_start_frame( false )
    2321        , m_stop_frame( false )
     
    3836}
    3937
    40 mat4 keyframed_mesh::get_tag( const std::string& tag ) const
    41 {
    42         const std::vector< nv::mat4 >& transforms = m_data->get_tag_map().at( tag );
    43         return glm::interpolate( transforms[ m_last_frame ], transforms[ m_next_frame ], m_interpolation );
     38transform keyframed_mesh::get_tag( const std::string& tag ) const
     39{
     40        const std::vector< transform >& transforms = m_data->get_tag_map().at( tag );
     41        return interpolate( transforms[ m_last_frame ], transforms[ m_next_frame ], m_interpolation );
    4442}
    4543
     
    10199}
    102100
    103 void nv::keyframed_mesh::draw( render_state& rstate )
    104 {
    105         m_program->set_opt_uniform( "nv_interpolate", m_interpolation );
    106         m_context->draw( nv::TRIANGLES, rstate, m_program, m_va, m_data->get_index_count() );
     101void nv::keyframed_mesh::update( program* a_program )
     102{
     103        a_program->set_opt_uniform( "nv_interpolate", m_interpolation );
    107104}
    108105
     
    112109}
    113110
     111void nv::keyframed_mesh::run_animation( animation_entry* a_anim )
     112{
     113        keyframed_animation_entry * anim = down_cast<keyframed_animation_entry>(a_anim);
     114        setup_animation( anim->m_start, anim->m_frames, anim->m_fps, anim->m_looping );
     115}
     116
    114117keyframed_mesh_gpu::keyframed_mesh_gpu( context* a_context, mesh_data* a_data, program* a_program )
    115         : keyframed_mesh( a_context, a_data, a_program )
     118        : keyframed_mesh( a_context, a_data )
    116119        , m_loc_next_position( 0 )
    117120        , m_loc_next_normal( 0 )
     
    120123{
    121124        nv::vertex_buffer* vb;
    122         m_loc_next_position = m_program->get_attribute( "nv_next_position" )->get_location();
    123         m_loc_next_normal   = m_program->get_attribute( "nv_next_normal" )->get_location();
     125        m_loc_next_position = a_program->get_attribute( "nv_next_position" )->get_location();
     126        m_loc_next_normal   = a_program->get_attribute( "nv_next_normal" )->get_location();
    124127
    125128        vb = m_context->get_device()->create_vertex_buffer( nv::STATIC_DRAW, m_data->get_vertex_count() * sizeof( nv::vec3 ) * m_data->get_frame_count(), (void*)m_data->get_positions().data() );
     
    137140}
    138141
    139 void nv::keyframed_mesh_gpu::draw( render_state& rstate )
    140 {
     142void nv::keyframed_mesh_gpu::update( uint32 ms )
     143{
     144        keyframed_mesh::update( ms );
     145
    141146        size_t vtx_count = m_data->get_vertex_count();
    142147        if ( m_gpu_last_frame != m_last_frame )
     
    152157                m_gpu_next_frame = m_next_frame;
    153158        }
    154         keyframed_mesh::draw( rstate );
    155 }
    156 
    157 
    158 nv::keyframed_mesh_cpu::keyframed_mesh_cpu( context* a_context, mesh_data* a_data, program* a_program )
    159         : keyframed_mesh( a_context, a_data, a_program )
     159}
     160
     161
     162nv::keyframed_mesh_cpu::keyframed_mesh_cpu( context* a_context, mesh_data* a_data )
     163        : keyframed_mesh( a_context, a_data )
    160164{
    161165        m_vb_position = m_context->get_device()->create_vertex_buffer( nv::STATIC_DRAW, m_data->get_vertex_count() * sizeof( nv::vec3 ), (void*)m_data->get_position_frame(0) );
  • trunk/src/gfx/skeletal_mesh.cc

    r227 r230  
    1111
    1212
    13 nv::skeletal_mesh::skeletal_mesh( context* a_context, program* a_program, md5_loader* a_loader )
    14         : m_context( a_context )
    15         , m_program( a_program )
    16         , m_va( nullptr )
     13nv::skeletal_mesh::skeletal_mesh( context* a_context, md5_loader* a_loader )
     14        : animated_mesh( a_context )
    1715        , m_data( a_loader )
    1816        , m_animation( nullptr )
     
    3836        if ( m_animation ) m_animation->reset_animation();
    3937        m_animation = a_anim;
     38        // TODO : INSTANCE!
    4039        m_animation->reset_animation();
    4140}
     
    6463}
    6564
    66 void nv::skeletal_mesh::draw( render_state& rstate )
    67 {
    68         m_context->draw( nv::TRIANGLES, rstate, m_program, m_va, m_data->get_index_count(0) );
    69 }
    70 
    7165nv::skeletal_mesh::~skeletal_mesh()
    7266{
    7367        delete m_va;
    7468}
     69
     70void nv::skeletal_mesh::run_animation( animation_entry* a_anim )
     71{
     72        skeletal_animation_entry * anim = down_cast<skeletal_animation_entry>(a_anim);
     73        // TODO : INSTANCE!
     74        setup_animation( anim->m_animation );
     75}
Note: See TracChangeset for help on using the changeset viewer.