source: trunk/src/gfx/skeletal_mesh.cc @ 240

Last change on this file since 240 was 240, checked in by epyon, 11 years ago
  • multiple mesh per file interface for all mesh loaders added
  • multiple mesh per file obj and md5 loader support added
File size: 1.5 KB
RevLine 
[227]1// Copyright (C) 2011 Kornel Kisielewicz
2// This file is part of NV Libraries.
3// For conditions of distribution and use, see copyright notice in nv.hh
4
5#include "nv/gfx/skeletal_mesh.hh"
6
7#include <glm/gtc/matrix_access.hpp>
8#include <glm/gtx/matrix_interpolation.hpp>
9#include "nv/interface/context.hh"
10#include "nv/interface/device.hh"
11
12
[239]13nv::skeletal_mesh::skeletal_mesh( context* a_context, md5_mesh_data* a_mesh_data )
[231]14        : animated_mesh()
[239]15        , m_mesh_data( a_mesh_data )
[227]16        , m_animation( nullptr )
17{
[239]18        m_va = a_context->get_device()->create_vertex_array( a_mesh_data, nv::STREAM_DRAW );
19}
[227]20
21
22void nv::skeletal_mesh::setup_animation( md5_animation* a_anim )
23{
24        if ( m_animation ) m_animation->reset_animation();
25        m_animation = a_anim;
[230]26        // TODO : INSTANCE!
[227]27        m_animation->reset_animation();
28}
29
30void nv::skeletal_mesh::update( uint32 ms )
31{
32        if (m_animation != nullptr)
33        {
34                m_animation->update( ms * 0.001f );
[239]35                m_mesh_data->apply( *m_animation );
36                vertex_buffer* vb = m_va->find_buffer( nv::POSITION );
37                const mesh_raw_channel* pch = m_mesh_data->get_channel_data()[0];
38                vb->bind();
39                vb->update( (const void*)pch->data, 0, pch->size );
40                vb->unbind();
[227]41        }
42}
43
[230]44nv::skeletal_mesh::~skeletal_mesh()
[227]45{
[230]46        delete m_va;
[240]47        // TODO : INSTANCE!
48        //      delete m_mesh_data;
[227]49}
50
[230]51void nv::skeletal_mesh::run_animation( animation_entry* a_anim )
[227]52{
[230]53        skeletal_animation_entry * anim = down_cast<skeletal_animation_entry>(a_anim);
54        // TODO : INSTANCE!
55        setup_animation( anim->m_animation );
[227]56}
Note: See TracBrowser for help on using the repository browser.