Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411708 Posts in 69402 Topics- by 58457 Members - Latest Member: FezzikTheGiant

May 20, 2024, 02:36:26 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Curvy Laser?
Pages: 1 [2]
Print
Author Topic: Curvy Laser?  (Read 5150 times)
gunmaggot
Guest
« Reply #20 on: March 21, 2010, 02:00:33 PM »

Oh jeez, I wish this thread had been made a month ago.

Does some programming saint want to code a curvy laser for me in Game Maker?  I have a guy who gave me the source code of his curvy laser-related project but I can't make head or tail of it and he's been damnably hard to contact (even though he's a wonderful person who has been VERY helpful).

I will do favours for you.
Logged
Hima
Level 4
****


OM NOM NOM


View Profile WWW
« Reply #21 on: March 22, 2010, 08:41:49 AM »

Ok, I'm using cubic bezier and this is what I have so far.
http://hima.gptouch.com/testbed/bezier.swf

Is there anyway to control how the image is rotated? I'm calculating the angle by finding the angle between two points v1 and v2 where

Code:
  
  v1 = sample_curve(t - 0.05)
  v2 = sample_curve(t)

Number 0 - 3 are vertices of a quad that represent the image. I coded it so that 1 and 2 are always at 90 degree to v2 and 0 and 3 are 90 degree to v1.

Also, thank you so much for all the replies and the resources. Really appreciate it Smiley
Logged

ChevyRay
Guest
« Reply #22 on: March 22, 2010, 09:02:54 AM »

What I'd do is just record the current and previous position, and make the display rotation the angle represented by the vector currentPos - lastPos.
Logged
Hima
Level 4
****


OM NOM NOM


View Profile WWW
« Reply #23 on: March 22, 2010, 06:28:19 PM »

Turned out I was stupid and got the finding angle function wrong  Facepalm  It's working fine now.
Logged

Ivan
Owl Country
Level 10
*


alright, let's see what we can see


View Profile
« Reply #24 on: March 23, 2010, 11:19:08 AM »

Here is a very good tutorial on bezier curves.

http://www.gamedev.net/reference/articles/article1808.asp
Logged

http://polycode.org/ - Free, cross-platform, open-source engine.
Zaknafein
Level 4
****



View Profile WWW
« Reply #25 on: March 23, 2010, 11:23:58 AM »

I like me some catmull-rom splines. They're less controllable, but they're simpler to play with because you don't have to specify tangents, and as a bonus (though you may not want that) the curve actually touches every control point.
Logged

Zaphos
Guest
« Reply #26 on: March 23, 2010, 12:01:22 PM »

I like to think of catmull-rom as just a way of specifying bezier (or semi-equivalently hermite) control points automatically.  It just says "the tangent at control point p(i) should be .5*(p(i+1)-p(i-1))".  Once you understand it like that, you can play with the formula and put in something better for your application -- for example, since for a 'curvy laser' you don't care about the "speed" at the control point being continuous, you just care about the direction, so you're free to make the tangent magnitudes mismatch across the control point, which is quite useful for fixing the problem that the catmull-rom spline doesn't look good if the control points are very unevenly spaced.  You can also usually pick a better tangent direction than p(i+1)-p(i-1), for example (p(i+1)-p(i)).normalized() + (p(i)-p(i-1)).normalized() might be more 'fair'.
Logged
CiroContinisio
Level 3
***


Eat this!


View Profile WWW
« Reply #27 on: March 23, 2010, 12:38:41 PM »

ChevyRay, that is one of the smoothest dynamically generated curves I've seen in Flash, any chance you're going to share the code? Wink Wink
Logged

Pages: 1 [2]
Print
Jump to:  

Theme orange-lt created by panic