/// Initialize from data. /// /// \param data Frame data. /// \param bone_amount Amount of bone elements. void initFromData(const int16_t *data, unsigned frame_amount, float scale) { m_time = fixed_8_8_to_float(data[0]); //std::cout << m_time << std::endl; #if defined(USE_LD) if((frame_amount % 7) != 0) { std::ostringstream sstr; sstr << "invalid frame amount: " << frame_amount; BOOST_THROW_EXCEPTION(std::runtime_error(sstr.str())); } #endif for(unsigned ii = 1; ((frame_amount + 1) > ii); ii += 7) { vec3 pos(static_cast<float>(data[ii + 0]), static_cast<float>(data[ii + 1]), static_cast<float>(data[ii + 2])); quat rot(fixed_4_12_to_float(data[ii + 3]), fixed_4_12_to_float(data[ii + 4]), fixed_4_12_to_float(data[ii + 5]), fixed_4_12_to_float(data[ii + 6])); //std::cout << pos << " ; " << rot << std::endl; m_bones.emplace_back(pos * scale, rot); } }
/// Get a fresh animation state. /// /// Data contained in the returned animation state is undefined, but not invalid. /// /// \return Animation state. AnimationState& newAnimationState() { unsigned ret = m_current_animation_state++; if(m_animation_states.size() <= ret) { m_animation_states.emplace_back(); } return m_animation_states[ret]; }