在 C++ 中实现有趣的粒子效果的想法和 DirectX。请
我目前正在使用我自己的游戏引擎制作一个游戏,该引擎是用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你可以做这样的事情来表示粒子,
然后只需根据速度更新 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,
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