Ideas for an interesting particle effect in C++ and DirectX. Please
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 par开发者_如何学Pythonticles 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
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
精彩评论