Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Weapon slash trails

Author
Message
The Bellmaker
18
Years of Service
User Offline
Joined: 22nd Dec 2007
Location: Over here
Posted: 26th Sep 2010 04:19
You know how in rpg games your character swings his weapons and a glowing trail shows up behind it?

I figured out an efficient way to create that effect.

This code records the positions of two points on the sword. I make one recording at frame X and one at frame X + 1. This give me four points. However, instead of just creating one plane and using vertexdata commands to adjust the position of the 4 vertexes to match the four points, I take it one step further. Because this algorithm only produces one trail segment per frame, I was wondering...

Using algorithms to find the intersection (or closest points) of two 3D lines, I was able to divide segments into 4 parts. Thus, when the sword swung fast, I could still have a relatively smooth trail.

Using this method, I could conform trails to match any motion of the sword, even rotation around the tip of the blade. In addition, I could up the level of detail by doing some clever copying and pasting.

No particles needed.

What do you guys think?

pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342177067... and yet I still have a life.
The Bellmaker
18
Years of Service
User Offline
Joined: 22nd Dec 2007
Location: Over here
Posted: 26th Sep 2010 04:32
Oops, forgot to mention attachment is in first post.

pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342177067... and yet I still have a life.
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 26th Sep 2010 05:20
Could I please see a screenshot?

My computer surpasses all the technologies of the day. What computer do I have?

Virtual Nomad
Moderator
20
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 26th Sep 2010 05:26 Edited at: 26th Sep 2010 05:32


not gonna comment/criticize much on this since i've never tried to tackle the effect in 3d myself but it seems like a lotta work for a pretty basic result. i think if you used tris instead of planes it would lend more toward the whirl of a sword swing, too. ie, more of a tapered trail look to it.

nonetheless, thanks for sharing

Virtual Nomad @ California, USA . DBPro V7.5
AMD Phenomâ„¢ X4 9750 Quad-Core @ 2.4 GHz . 8 GB PC2-6400 RAM
ATI Radeon HD 3650 @ 512 MB . Vista Home Premium 64 Bit
Stab in the Dark software
Valued Member
23
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 26th Sep 2010 06:23
WOW what a ingenious bit of math,How long did it take you to work out all the bugs?We have been working on rotation of limbs recently
but this goes way beyond that.



Custom,intel 3.0GHz Hyper Threaded,4GB RAM,ATI X1500 256mb,
WindowsXP DBpro v7.4 Synergy
The coffee is lovely dark and deep,and I have code to write before I sleep.
The Bellmaker
18
Years of Service
User Offline
Joined: 22nd Dec 2007
Location: Over here
Posted: 26th Sep 2010 06:55
The main issue for me was finding out how to find the intersection of two 3D lines, or if they don't intersect, how to find the point at which they are closest to each other.

Found after two pages of vector calculations


After that, everything else was pretty easy.

pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342177067... and yet I still have a life.
BillR
23
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 27th Sep 2010 01:13
Nice work!
The Bellmaker
18
Years of Service
User Offline
Joined: 22nd Dec 2007
Location: Over here
Posted: 5th Oct 2010 01:19
Thank you kind sir

pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342177067... and yet I still have a life.

Login to post a reply

Server time is: 2026-07-22 03:51:40
Your offset time is: 2026-07-22 03:51:40