C# XNA Farseer - 从纹理创建形状
我想根据加载的纹理 2D 创建碰撞顶点以使用 Farseer 附加到 XNA 中的主体。
首先,需要注意的是。是我除了碰撞之外没有使用 Farseer 进行任何其他操作。渲染和所有其他游戏代码都是使用我自己的引擎完成的。 Farseer 只是用作背景物理模拟器(并且只会在发生碰撞时告诉我,然后我会自己处理)。
我应该在这里指出,我对 Farseer 是 100% 的新手。以前从未使用过它。
因此,如果我使用 BayazitDecomposer.ConvexPartition(verts) 创建列表,我是否应该将此数据与Texture2D 对象一起存储?然后当我创建可碰撞演员时动态创建列表对象?或者我做错了什么?
此外,在 http://farseerphysicals.codeplex.com/documentation 的示例中,它将顶点缩放为Vertices.Scale()...如果我将所有 Farseer 主体保留在像素空间中,我需要这样做吗?
谢谢。
I want to create collision vertices to attach to bodies in XNA with Farseer, according to loaded Texture2Ds.
A caveat, first of all. is that I'm not using Farseer for anything other than collision. Rendering and all other game code is done using my own engine. Farseer is just used as a background physics simulator (and will only tell me when a collision happens, and then I'll handle that myself).
I should point out here that I'm 100% new to Farseer. Never used it before.
So, if I create my List using BayazitDecomposer.ConvexPartition(verts), should I then store this data alongside the Texture2D objects; and then create List objects on the fly when I create my collidable actors? Or am I doing something wrong?
Furthermore, in the example at http://farseerphysics.codeplex.com/documentation, it scales the vertices by Vertices.Scale()... If I keep all my Farseer bodies in pixel space, do I need to do this?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 BodyFactory 从顶点列表创建 Body 类的实例。我建议为每个演员都这样做。但是,您可以通过重用主体来节省一些处理器资源。因此,如果演员死亡,请将尸体添加到队列中,然后将其捕捉到创建的新演员。
没有。然而,这意味着对于 Farseer 而言,一个像素就是一米。我相信扭矩的公式是半径 * 力,因此任何依赖于半径的东西都不会按预期运行。我建议使米等于游戏中实际的米。它只是一点额外的划分。
You create an instance of the Body class from a list of verts using the BodyFactory. I would suggest doing this for each actor you have. However, you can save yourself some processor power by reusing bodies. So if an actor dies add the body to a queue and then snap it to a new actor that is created.
Nope. However that means that a pixel is a meter as far as Farseer is concerned. I believe the formula for Torque if Radius * Force so anything reliant on a radius wouldn't behave as expected. I suggest making the metes equivalent to what actually is a meter in the game. Its just a bit of extra division.