当前位置: 首页>>代码示例>>C++>>正文


C++ AnimationFrame::getTime方法代码示例

本文整理汇总了C++中AnimationFrame::getTime方法的典型用法代码示例。如果您正苦于以下问题:C++ AnimationFrame::getTime方法的具体用法?C++ AnimationFrame::getTime怎么用?C++ AnimationFrame::getTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AnimationFrame的用法示例。


在下文中一共展示了AnimationFrame::getTime方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: interpolateFrom

    /// Interpolate animation frame from two other frames.
    ///
    /// \param src Source frame (earlier).
    /// \param dst Destination frame (later).
    /// \param current_time Animation time.
    void interpolateFrom(const AnimationFrame &lhs, const AnimationFrame &rhs, float current_time)
    {
      unsigned bone_count = lhs.getBoneCount();
#if defined(USE_LD)
      if(rhs.getBoneCount() != bone_count)
      {
        std::ostringstream sstr;
        sstr << "cannot interpolate between frames of size " << bone_count << " and " << rhs.getBoneCount();
        BOOST_THROW_EXCEPTION(std::runtime_error(sstr.str()));
      }
#endif

      //std::cout << "resizing bones or not? " << m_bones.size() << " vs " << bone_count << std::endl;

      m_time = current_time;
      m_bones.resize(bone_count);

      for(unsigned ii = 0; (bone_count > ii); ++ii)
      {
        const BoneState &ll = lhs.getBoneState(ii);
        const BoneState &rr = rhs.getBoneState(ii);
        float ltime = lhs.getTime();
        float rtime = rhs.getTime();
        float mix_time = (current_time - ltime) / (rtime - ltime);
        vec3 mix_pos = mix(ll.getPosition(), rr.getPosition(), mix_time);
        quat mix_rot = mix(ll.getRotation(), rr.getRotation(), mix_time);

        //std::cout << "mix time: " << mix_time << ": " << mix_pos << " ; " << mix_rot << std::endl;

        m_bones[ii] = BoneState(mix_pos, mix_rot);
      }
    }
开发者ID:faemiyah,项目名称:faemiyah-demoscene_2016-08_80k-intro_my_mistress_the_leviathan,代码行数:37,代码来源:verbatim_animation_frame.hpp

示例2: draw

void Animation::draw(ResourceLoader *resLoader, SDL_Surface *screen, AnimationInstance *ai, float x, float y)
{
	AnimationFrame *currFrame = NULL;
	float cumulativeTime = 0;
	float timeThisFrame = 0;
	float timeInSeconds = ai->getComplete()*totalTime;
	for (int i = 0; i < numFrames; ++i)
	{
		if (timeInSeconds >= cumulativeTime)
		{
			timeThisFrame = timeInSeconds-cumulativeTime;
			currFrame = &(frames[i]);
		}else
		{
			break;
		}
		cumulativeTime += currFrame->getTime();
	}
	if (currFrame != NULL)
	{
		for (int i = 0; i < currFrame->getEffectSize(); ++i)
			currFrame->getEffect(i)->setTime(timeThisFrame);
		for (int i = 0; i < currFrame->getNumImages(); ++i)
		{
			Pos2 *offset = currFrame->getOffset(i);
			resLoader->draw_image(
				currFrame->getImage(i), 
				screen, x+offset->getX(), 
				y+offset->getY(), currFrame->getEffects(), currFrame->getEffectSize());
		}
	}
	//SDL_BlitSurface( resLoader->get_image(currFrame->image_type), src_rect, screen, dst_rect );
}
开发者ID:happypandaface,项目名称:sdl_wii,代码行数:33,代码来源:animation.cpp

示例3: duplicate

    /// Duplicate from given frame.
    ///
    /// \param op Frame to duplicate.
    void duplicate(const AnimationFrame &op)
    {
      unsigned bone_count = op.getBoneCount();

      m_time = op.getTime();
      m_bones.resize(bone_count);

      for(unsigned ii = 0; (bone_count > ii); ++ii)
      {
        m_bones[ii] = op.getBoneState(ii);
      }
    }
开发者ID:faemiyah,项目名称:faemiyah-demoscene_2016-08_80k-intro_my_mistress_the_leviathan,代码行数:15,代码来源:verbatim_animation_frame.hpp


注:本文中的AnimationFrame::getTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。