Super Particle Editting and Rendering Machine

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
adnzzzzZ
Party member
Posts: 305
Joined: Sun Dec 26, 2010 11:04 pm
Location: Porto Alegre, Brazil

Super Particle Editting and Rendering Machine

Post by adnzzzzZ »

Image

BIG GIF 1
BIG GIF 2
BIG GIF 3

USAGE

1. Open the .love file and change the save directory (first line in love.load function) to where you wanna save the particle systems to;
2. Use the editor! Controls: CTRL+Click to move the particle system, F1 to hide UI.

Video "tutorial":



GAME INTEGRATION

1. Download the example project and see how it's done there or;
1. Copy the getPS function to somewhere in your game and just call it using the name of the particle system (the name of the .lua file the editor generates to your save directory) and passing an image. It returns a ParticleSystem and you should need to start, update and draw it (and set blend modes yourself, since those don't magically carry over).

Code: Select all

function getPS(name, image)
    local ps_data = require(name)
    local particle_settings = {}
    particle_settings["colors"] = {}
    particle_settings["sizes"] = {}
    for k, v in pairs(ps_data) do
        if k == "colors" then
            local j = 1
            for i = 1, #v , 4 do
                local color = {v[i], v[i+1], v[i+2], v[i+3]}
                particle_settings["colors"][j] = color
                j = j + 1
            end
        elseif k == "sizes" then
            for i = 1, #v do particle_settings["sizes"][i] = v[i] end
        else particle_settings[k] = v end
    end
    local ps = love.graphics.newParticleSystem(image, particle_settings["buffer_size"])
    ps:setAreaSpread(string.lower(particle_settings["area_spread_distribution"]), particle_settings["area_spread_dx"] or 0 , particle_settings["area_spread_dy"] or 0)
    ps:setBufferSize(particle_settings["buffer_size"] or 1)
    local colors = {}
    for i = 1, 8 do 
        if particle_settings["colors"][i][1] ~= 0 or particle_settings["colors"][i][2] ~= 0 or particle_settings["colors"][i][3] ~= 0 or particle_settings["colors"][i][4] ~= 0 then
            table.insert(colors, particle_settings["colors"][i][1] or 0)
            table.insert(colors, particle_settings["colors"][i][2] or 0)
            table.insert(colors, particle_settings["colors"][i][3] or 0)
            table.insert(colors, particle_settings["colors"][i][4] or 0)
        end
    end
    ps:setColors(unpack(colors))
    ps:setColors(unpack(colors))
    ps:setDirection(math.rad(particle_settings["direction"] or 0))
    ps:setEmissionRate(particle_settings["emission_rate"] or 0)
    ps:setEmitterLifetime(particle_settings["emitter_lifetime"] or 0)
    ps:setInsertMode(string.lower(particle_settings["insert_mode"]))
    ps:setLinearAcceleration(particle_settings["linear_acceleration_xmin"] or 0, particle_settings["linear_acceleration_ymin"] or 0, 
                             particle_settings["linear_acceleration_xmax"] or 0, particle_settings["linear_acceleration_ymax"] or 0)
    if particle_settings["offsetx"] ~= 0 or particle_settings["offsety"] ~= 0 then
        ps:setOffset(particle_settings["offsetx"], particle_settings["offsety"])
    end
    ps:setParticleLifetime(particle_settings["plifetime_min"] or 0, particle_settings["plifetime_max"] or 0)
    ps:setRadialAcceleration(particle_settings["radialacc_min"] or 0, particle_settings["radialacc_max"] or 0)
    ps:setRotation(math.rad(particle_settings["rotation_min"] or 0), math.rad(particle_settings["rotation_max"] or 0))
    ps:setSizeVariation(particle_settings["size_variation"] or 0)
    local sizes = {}
    local sizes_i = 1 
    for i = 1, 8 do 
        if particle_settings["sizes"][i] == 0 then
            if i < 8 and particle_settings["sizes"][i+1] == 0 then
                sizes_i = i
                break
            end
        end
    end
    if sizes_i > 1 then
        for i = 1, sizes_i do table.insert(sizes, particle_settings["sizes"][i] or 0) end
        ps:setSizes(unpack(sizes))
    end
    ps:setSpeed(particle_settings["speed_min"] or 0, particle_settings["speed_max"] or 0)
    ps:setSpin(math.rad(particle_settings["spin_min"] or 0), math.rad(particle_settings["spin_max"] or 0))
    ps:setSpinVariation(particle_settings["spin_variation"] or 0)
    ps:setSpread(math.rad(particle_settings["spread"] or 0))
    ps:setTangentialAcceleration(particle_settings["tangential_acceleration_min"] or 0, particle_settings["tangential_acceleration_max"] or 0)
    return ps
end
If you want to use other images to test the particle systems, just unzip the .love, add the images to the same folder level as the main.lua file is in and then run the folder.
Attachments
SPERM.love
(283.55 KiB) Downloaded 2314 times
User avatar
Snuux
Prole
Posts: 49
Joined: Sun Dec 15, 2013 10:43 am
Location: Russia, Moskow
Contact:

Re: Super Particle Editting and Rendering Machine

Post by Snuux »

It's awesome! And export work fine! Thanks!
My library for easy saving Slib! Try this! Now you can encrypt your save!
- Drop of light LD#30
- OUTRANGE LD#31
(Sorry for my english. I learn it myself, and I don't have enough experience)
bekey
Party member
Posts: 255
Joined: Tue Sep 03, 2013 6:27 pm

[]

Post by bekey »

-snip-
Last edited by bekey on Fri Jan 24, 2014 2:19 am, edited 2 times in total.
User avatar
Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

Re: Super Particle Editting and Rendering Machine

Post by Ranguna259 »

Realy nice work man :awesome:
This kinda looks like source's particle editing menu, so awesome.

You should take a look at Source for more particle related features.
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping :D

Check out my twitter.
User avatar
Helvecta
Party member
Posts: 167
Joined: Wed Sep 26, 2012 6:35 pm

Re: Super Particle Editting and Rendering Machine

Post by Helvecta »

You had me at Tool. Nice job! I know a lot of people have been waiting for an app like yours. ^^
"Bump." -CMFIend420
User avatar
SiENcE
Party member
Posts: 805
Joined: Thu Jul 24, 2008 2:25 pm
Location: Berlin/Germany
Contact:

Re: Super Particle Editting and Rendering Machine

Post by SiENcE »

Cool Editor and for 0.9.0. Nice. A performance monitor would be useful.

Saving crashs the editor. It seems you hardcoded the path. I have no User "Waffles" :).

Bugfix for your example:
instead of:

Code: Select all

function getPS(name)
this:

Code: Select all

function getPS(name, image)
Zarty55
Citizen
Posts: 79
Joined: Thu Jul 25, 2013 2:36 am

Re: Super Particle Editting and Rendering Machine

Post by Zarty55 »

Really awesome!

When you set the buffer to negative or nil the program crashes, when loading the preset already loaded it crashes as well btw. But it is really cool and useful :D
Tapatun
Prole
Posts: 2
Joined: Mon Feb 24, 2014 5:28 pm

Re: Super Particle Editting and Rendering Machine

Post by Tapatun »

That thing really helped me in creating astounding sword effects with very little effort! Great tool, though there're a couple of annonying bugs still not fixed..
One of them is that getPS() cannot find an image for rendering particles, e.g. "square.png", "plus.png" etc.
Here's the code causing problem:

Code: Select all

local ps = love.graphics.newParticleSystem(image, particle_settings["buffer_size"])
As image is not declared as the second argument for getPS() function, it gets thrown away:

Code: Select all

square = love.graphics.newImage("data/square.png")
ps = getPS('Blue Fire', square) -- ignores the square image, have to hardcode it into the body of getPS function

--[[ ]]--

function getPS(name) -- Takes name only
Hope you'll continue developing and extending that LÖVEly editor!
User avatar
adnzzzzZ
Party member
Posts: 305
Joined: Sun Dec 26, 2010 11:04 pm
Location: Porto Alegre, Brazil

Re: Super Particle Editting and Rendering Machine

Post by adnzzzzZ »

You're supposed to just change that function yourself to fit your needs. In any case, the code in the first post does take an image like you mentioned, so I don't understand what problems you're having.
1. Copy the getPS function to somewhere in your game and just call it using the name of the particle system (the name of the .lua file the editor generates to your save directory) and passing an image. It returns a ParticleSystem and you should need to start, update and draw it (and set blend modes yourself, since those don't magically carry over).
Tapatun
Prole
Posts: 2
Joined: Mon Feb 24, 2014 5:28 pm

Re: Super Particle Editting and Rendering Machine

Post by Tapatun »

adnzzzzZ wrote:You're supposed to just change that function yourself to fit your needs. In any case, the code in the first post does take an image like you mentioned, so I don't understand what problems you're having.
..Ah, got it
Instead of manually copying getPS() function from the first post, I've downloaded the example project, which is bugged!

By the way, wiki says that setting buffer size as an argument for newParticleSystem() function will be available since unreleased LÖVE 0.9.1, but you are using it.. A typo?
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests