Trail Meshes

Showcase your libraries, tools and other projects that help your fellow love users.
Spyro
Prole
Posts: 3
Joined: Mon Mar 17, 2014 9:07 pm

Trail Meshes

Post by Spyro »

Well, I have been seeing many others creating trails using the particle systems that LOVE2D has provided, but what I seen in some other games is that they use a ribbon type of mesh that gets created. Basically what I wanted to share is similar to this using the new version of LOVE2D (0.9.0). Not sure if anyone else has made one yet.

Settings:
(x, y, image, width of trail/ribbon, trail lifetime, interval (how "detailed" the trail is), method ("stretch" default, "repeat"))
or you can look at the file itself to see how it works

I'm still new to this so if the script is quite dirty, please tell me if there is a was to optimize it, math is still fresh in my mind since I'm still in school so I might understand what you may say. Also I am trying to understand classes more, I'm used to python.
Attachments
Trailmesh.love
(3.76 KiB) Downloaded 569 times
User avatar
NightKawata
Party member
Posts: 294
Joined: Tue Jan 01, 2013 9:18 pm
Location: Cyberspace, Room 6502
Contact:

Re: Trail Meshes

Post by NightKawata »

Very nice.

Image

Just an image if anyone wanted to see what this looked like.
"I view Python for game usage about the same as going fishing with a stick of dynamite. It will do the job but it's big, noisy, you'll probably get soaking wet and you've still got to get the damn fish out of the water." -taylor
Spyro
Prole
Posts: 3
Joined: Mon Mar 17, 2014 9:07 pm

Re: Trail Meshes

Post by Spyro »

Yea, that is how it looks like. If he would have moved the mouse faster you would see the little things that orbit the circle follow the same behavior. My only problem is the overlapping where you can see lighter parts an random cuts when you stop for a moment then move again.

To me I think it would look better when used with a game that has some sort of physics. (either one made up or used by the 2d box physics engine) instead of something that is... well, stiff like the mouse.
User avatar
R-BG
Prole
Posts: 11
Joined: Sat Jan 11, 2014 11:37 pm
Contact:

Re: Trail Meshes

Post by R-BG »

I'm using this in my game. Thank you very much.
User avatar
Taehl
Dreaming in associative arrays
Posts: 1025
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

Re: Trail Meshes

Post by Taehl »

Amazing! I've wanted this feature for years! :awesome:

Seriously, ribbons are a powerful basic tool for adding visual flair, much like particle effects. Blizzard has used them in every game of theirs since 'Warcraft 3'. If I could request any feature to be added to this, it would be the ability to add motion to individual trail "points". This would open up even more graphical possibilities, like some of the fancier effects used in 'Half-Life 2: Episode Two'.

EDIT) Take that, mysterious code! I modified it so each trail point can have its own position and velocity. I've uploaded my improved version of your demo, download it here!.

Image
What's added:
- A bit of cursor smoothing (it makes everything look much nicer)
- Colors
- A second, thicker dotted trail, except this one "jets out" opposite the motion of the cursor
- A fourth blue trail, except this one changes width and drifts upward and reacts to cursor motion somewhat like smoke
- A green trail which just moves to the right. Simple, but pleasing to watch
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
netgrim
Prole
Posts: 3
Joined: Fri Jul 17, 2015 2:16 am

Re: Trail Meshes

Post by netgrim »

The way vertices disapears after it's life time is weird
remove.png
remove.png (2.39 KiB) Viewed 8584 times
And line joint are bad when angle is sharp
line joint.png
line joint.png (5.61 KiB) Viewed 8584 times
I will work on that
Spyro
Prole
Posts: 3
Joined: Mon Mar 17, 2014 9:07 pm

Re: Trail Meshes

Post by Spyro »

If you can post a fix of it, that would be great for others to see, this was my first attempt to achieve what other game engines has been doing, like I said its dirty but gets most of the job done. I'll probably edit the first post, its been a while since I used lua but im still used to it. Maybe better preview images too. Its up to you anyways. :)
Muzz
Citizen
Posts: 54
Joined: Sun Jun 28, 2015 1:24 pm

Re: Trail Meshes

Post by Muzz »

I think this would make a great little library that would be super helpful to people ;).
netgrim
Prole
Posts: 3
Joined: Fri Jul 17, 2015 2:16 am

Re: Trail Meshes

Post by netgrim »

I managed to fix the vertex removal problem,
Fixed the texture was flipped
I have completely rewritten the library using vector.lua and merged the method "stretch" and "repeated" together
I have added a color transition like in ParticuleSystem
I'm working on the line joint problem
and I will add a width transition after a look on Taehl's work

The vertex index is for debug purpose
ending fixed.png
ending fixed.png (27.17 KiB) Viewed 8476 times
User avatar
Taehl
Dreaming in associative arrays
Posts: 1025
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

Re: Trail Meshes

Post by Taehl »

Superb work! I'm so glad this is being refined. If you need help dissecting my code, or would rather discuss the concept rather than my implementation, please feel free to contact me.

The general idea is, you want trail points to be able to independently execute simple transformations, rather than just staying in at their point of creation.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest