在 C++ 中实现有趣的粒子效果的想法和 DirectX。请

发布于 2024-12-02 11:09:06 字数 290 浏览 0 评论 0原文

我目前正在使用我自己的游戏引擎制作一个游戏,该引擎是用 C++ 编写的,并且我正在使用最新的 directx SDK。

该游戏是一款自上而下的太空射击游戏(有一个非常有趣的转折),我希望有一种玩家可以飞过的星云效果。我真的很想尝试确定数百个粒子在玩家飞船飞入其中时移开的美妙触觉。有点像 XBLA 上的《Geomtry Wars》中粒子如何移开玩家的路线。

在 C++ 方面,我是一位经验丰富的程序员。但我不知道如何开始实现这种效果。有人有我想要研究的很酷的想法或设计选择吗?请随意回答您喜欢的任何深度。

谢谢, 马特

I'm currently making a game with my own game engine which I've written in C++ and I'm using the most recent directx SDK.

The game is a top down space shooter (with a pretty interesting twist) and I'm looking to have a sort of nebula effect that the player will fly through. I really want to try and nail that nice tactile feel of hundreds of particles moving out of the way of the player ship as it flies into them. Somewhat like how particles would move out the way of the player in Geomtry Wars on XBLA.

I'm an experienced programmer when it comes to C++. I don't know however how to start implementing this effect. Does anyone have any cool ideas or design choices I might want to look into? Feel free to answer to any degree of depth you fancy.

Thanks,
Matt

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

楠木可依 2024-12-09 11:09:06

你可以做这样的事情来表示粒子,

struct Particle
{
      D3DXVECTOR3 position;
      float angle;
};

然后只需根据速度更新 x 和 y 坐标(如果你的船在该平面上移动,则更新 x 和 z )并使用一些基本公式而不是物理公式计算新高度,即。带有“罪恶”和“时间”的东西,这样它就不会离船移动的平面太远。您可以将它们全部放在动态顶点着色器中,并在一次调用中将它们全部渲染在一起。

对于 directx 9 你有“点精灵”
http://msdn.microsoft.com/en -us/library/bb147281%28v=vs.85%29.aspx

我认为对于较新的版本,您必须在着色器中完成这项工作,但我 没有把握。这个想法只是发送带有位置的点以及可能需要的一些属性,并在着色器中构造一次粒子图像(最有可能具有某些纹理的四边形)。

您可能会发现此链接很有用,至少可以得到一些想法。虽然它有点旧,但许多概念仍然适用:
http://www.markmark.net/clouds/RTCRPubs.html

还有其他您甚至不必修改缓冲区的方式...您可以在给定起始位置和自开始以来经过的时间的情况下计算轨迹的点,但随后会更难实现由力引起的效果通过船舶的运动。因此,您必须找到适合您需求的最佳方法。

编辑:抱歉,我的意思是说单个调用的“动态顶点缓冲区”

you can do something like this to represent the particle,

struct Particle
{
      D3DXVECTOR3 position;
      float angle;
};

then just update the x and y coordinates (or x and z if your ship moves on that plane) from a velocity and calculate the new height with some basic formula instead of a physics one ie. something with "sin" and "time" so it doesn't get too far from the plane where the ship moves. You can have them all in a dynamic vertex shader and render them all together in a single call.

For directx 9 you have "point sprites"
http://msdn.microsoft.com/en-us/library/bb147281%28v=vs.85%29.aspx

I think for newer versions you have to do the job in the shader, but I'm not sure. The idea would be just send points with the positions and probably some attribute you need and constructing the particle image once in the shader (a quad with some texture most likely).

You will probably find this link useful, at least to get some ideas. It's a bit old though but many concepts still apply:
http://www.markmark.net/clouds/RTCRPubs.html

There are also other ways in which you don't even have to modify the buffer... you can calculate a point for a trajectory given a starting position and a time elapsed since the start, but then it would be harder to implement an effect of a force caused by the ship's movement. So you have to find the best method to suit your needs.

EDIT: Sorry I meant to say a "dynamic vertex buffer" for the single call

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文