简体   繁体   English

如何在iPhone上“渲染” Box2D场景

[英]How to “render” a Box2D scene on iPhone

I'm currently using box2d with cocos2d on iPhone. 我目前在iPhone上使用box2d和cocos2d。 I have quite a complex scene set up, and I want the end user to be able to record it as video as part of the app. 我设置了一个非常复杂的场景,我希望最终用户能够将其录制为视频,并将其作为应用程序的一部分。 I have implemented a recorder using the AVAssetWriter etc. and have managed to get it recording frames grabbed from OpenGL pixel data. 我已经使用AVAssetWriter等实现了一个记录器,并设法使其记录了从OpenGL像素数据获取的帧。

However, this video recording seems to a) slow down the app a bit, but more importantly b) only record a few frames per second at best. 但是,此视频记录似乎a)稍微放慢了应用程序的速度,但更重要的是b)每秒最多只能记录几帧。

This led me to the idea of rendering a Box2D scene, manually firing ticks and grabbing an image every tick. 这使我想到了渲染Box2D场景,手动触发刻度线并在每个刻度线抓取图像的想法。 However, dt could be an issue here. 但是,dt在这里可能是个问题。

Just wondering if anyone has already done this, or if anyone has any better ideas? 只是想知道是否有人已经这样做了,还是有人有更好的主意?

我猜一个好的解决方案是使用ScreenFlow解决方案,例如ScreenFlow或类似的解决方案。

I think your box2d is a good idea... however, you would want to used a fixed-time step. 我认为您的box2d是个好主意...但是,您可能要使用固定时间的步骤。 if you use dt the steps in the physics simulation will be to big, and box2d will be unstable and jittery. 如果使用dt,则物理模拟中的步骤将很大,而box2d将变得不稳定且不稳定。

http://gafferongames.com/game-physics/fix-your-timestep/ http://gafferongames.com/game-physics/fix-your-timestep/

The frame rate will take a hit, but you'll get every frame. 帧速率会受到打击,但您会得到每一帧。 I don't think you'll be able to record every frame and still maintain a steady frame rate - that seems to be asking a lot of the hardware. 我认为您将无法记录每帧并仍保持稳定的帧率-这似乎在要求很多硬件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM