Sign in to follow this  
ghotirein

Particles in my game

Recommended Posts

ghotirein    122
Hi folks, I have never created particle effects before so i thought lets make some :) Here is what i want: I have missiles, i want to render trails. I have bomb, i want to make explosions. I'd like to make scratsing metal yellow thingies when I touch the wall. Also my spacecrafts have some kind of jet propulsion maybe smoke when you are damaged ? I don't have any engine or so available since i program not for a normal pc so i like to do it without. I think i have to render just a bunch of triangles but how exactly? what kind of numbers (for example: 20 triangles or 1000 triangles)? What physics are used for this if any? Are there any efficient algorithms or something to know about ? Any pointers on these things ?

Share this post


Link to post
Share on other sites
Dunge    405
I don't know what language you use and everything, but usually it work more or less that way:

You should have a class "particle emitter" who have a position and lot of variables to define the particles who come out of it (let's say you attach it to the spaceship and it follow it). Then you have a class particle who keep track of every single particles.

Example of emitter variables:
Position, direction, angle spread, nb of particles to emit per second, time to live of the emitter, particle starting velocity min/max, acceleration min/max, color min/max, time to live of particle min/max, textures of particles, size of particles, etc.

The variables inside each particles will have the starting values set by the emitter and some random, and will be updated each frame. Each frame you should loop trough your particle list and render then all with their current properties. This can be done in multiple way depending of your gfx api (for example as a sprite batch in a dynamic vertex buffer).

Share this post


Link to post
Share on other sites
ghotirein    122
Hi thanks for the reply, well i use c++ as language but the problem i thought was, i could use like an emitter and then i attach a vector with n particles to it. Then i could just iterate through all the particles and call an update function. this should work great however what about the rendering :S
if i iterate through it then i would call the settexturefunction n times and call the rendersprite n times. the first can be solved by just setting the texture in the render function of the emitter and then iterate through the particles attached to it however then i still have to render call every sprite.
What i want (i guess if it possible) is that i can send 1 array with all the vertices of all the n particles so that i only have to call the renderfunction...
i can do this with first storing every particlessprite into an array but that would be as expensive as calling the renderingfunction n times ?

so basicly what i want to ask is is it less expensive to call the render function n times or is it less expensive to the vertices of n particles into an array and then pass it to the render function so that it would be called only once ?

P.S. the system i program for is the Playstation Portable.

Share this post


Link to post
Share on other sites
Slackweed    100
You would build your vertex array dynamically each frame, then render it as you would a normal non-indexed mesh.

Your on the PSP so I assume it has a drawlist of sorts. However you currently render a mesh- you want to do the same thing except you are building that mesh each frame. You do NOT want to have a render call for each particle.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this