Archived

This topic is now archived and is closed to further replies.

CD579

Scripted Particles

Recommended Posts

Okay guys, need your opinion on the way I am doing things with my particle system. I have Lua integrated with my particle system to allow complete customization of the way the particles work. The way I have it set up to work is like so: in psuedo c++ code
for(int i=0; i < particles.size(); i++){
    // send variables to Lua(as globals) such as

    // particle position/velocity/color/ect.


    // call a function in a lua script that

    // alters said global variables

    script->Call("Execute");

    // gather those variables and set this particle's

    // data members to reflect what happened in the script


    // move the particle(vel*elapsedTime)

    particle[i]->Process(elapsedTime);
}
 
rinse and repeat each frame. As you can imagine, it is relatively slow. I have also set it up so that it will only execute the script at a set interval, and gather the time that elapses between execution and pass it to the script. Since I take time into consideration(dist = vel*time) in my script, this works pretty well. The effects don't look exactly the same, but pretty close for the speed increase I get(about 40% depending on the interval between executions of the script). My question is this: How do you guys do your scripted particles? Or how do the pros do it? Any ideas/comments? CD Jesus is Lord!! [edited by - CD579 on April 21, 2004 7:37:41 PM]

Share this post


Link to post
Share on other sites
Simple answer, you don''t. That''s not what scripting is for. You could possibly have the script store some parameters for the particle engine, but nothing that gets called once per particle. Calling it once per frame, could maybe be ok, but even then it''s just as easy to do code the behaviour in native code than in the script.

Share this post


Link to post
Share on other sites