游戏动漫最好的方法? [英] Best approach for game animation?

查看:161
本文介绍了游戏动漫最好的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在OpenGL的课程练习写的一个游戏了几个对象的简单动画

I have a course exercise in OpenGL to write a game with simple animation of a few objects

虽然与我的伙伴讨论,我们已经意识到我们的动画是如何去工作,无论是两个主要的选择,我们的设计方案

While discussing with my partner our design options we've realized we have two major choices for how the animation is going to work, Either

  • 设置为一个固定间隔定时器,例如30毫秒,当计时器命中,计算出物体的地方应该和绘制框架。或 -
  • 请不要使用定时器,只是运行所有的时间和每次迭代检查过了多少时间,计算出那里的对象应该根据间隔和绘制框架正常循环。

我应该一般是preferred的方法呢?有没有人有两种方法具体经验?

What should generally be the preferred approach? Does anyone have concrete experience with either approach?

推荐答案

渲染和计算一样快,你可以​​得到的最高帧速率(如上限由垂直同步)

Render and compute as fast as you can to get the maximum frame rate (as capped by the vertical sync)

不要使用定时器,他们是不可靠< 50-100毫秒在Windows上。检查多少时间已经过去了。 (通常情况下,你需要两个三角洲T和绝对值,具体取决于如果你的动画是基于物理或关键帧。)

Don't use a timer, they're not reliable < 50-100 ms on Windows. Check how much time has passed. (Usually, you need both delta t and an absolute value, depending on if your animation is physics or keyframe based.)

另外,如果你想成为稳定的,使用上/下限的时间步长,进入慢动作如果一个框架需要几秒钟来呈现(被另一个进程?光盘存取)或跳过如果你让他们两个人在说10 ms的更新。

Also, if you want to be stable, use an upper/lower bound on your time-step, to go into slow-motion if a frame takes a few secs to render (disc access by another process?) or skip an update if you get two of them within say 10 ms.

更新 (因为这是一个相当流行的答案)

我通常$有一个固定的时间,工序P $ PFER,因为它使一切更稳定。大多数的物理引擎是pretty的对变化的时间强劲,但其他的东西,如粒子系统或各种简单的动画,甚至是游戏逻辑,更容易进行优化时,拥有一切在一个固定的时间步运行。

I usually prefer having a fixed time-step, as it makes everything more stable. Most physics engines are pretty robust against varying time, but other things, like particle systems or various simpler animations or even game logic, are easier to tune when having everything run in a fixed time step.

UPDATE2 (因为我得到了10 upvotes)

有关进一步的稳定性运行的长周期(> 4小时),你可能想确保你没有使用花车/双打计算大的时间差异,因为你输了precision这样做,你的游戏中的动画/物理学会受到影响。使用固定点(或64位微秒为主)的整数代替。

For further stability over long periods of running (>4 hours), you probably want to make sure you're not using floats/doubles to compute large time differences, since you lose precision doing so and your game's animations/physics will suffer. Use fixed point (or 64-bit microsecond-based) integers instead.

有关毛茸茸的详细信息,我建议你阅读的的precision问题由汤姆·福赛思的。

For the hairy details, I recommend reading A matter of precision by Tom Forsyth.

这篇关于游戏动漫最好的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆