Jump to content
A 2021 backup has been restored. Forums are closed and work in progress. Join our Discord server for more updates! ×
SoaH City Message Board

Curved Boss Arms


Recommended Posts

This script makes links to form a chain. It makes the chain move in straight lines. I need help making it curve starting at link[0] to link[8].

here's the script:

for (i=0;i<=8;i+=1)

{

angle=point_direction(x,y,link[8].x,link[8].y);

link.distance=point_distance(x,y,link[8].x,link[8].y)/8*i;

link.x=x+cos(degtorad(angle))*(i+link.distance);

link.y=y-sin(degtorad(angle))*(i+link.distance);

link[8].x=mouse_x

link[8].y=mouse_y

}

Thanks,

Justin123

Link to comment
Share on other sites

Could you perhaps make a graphical mock-up of what you want? Because this is either a really easy or a REALLY hard problem depending on what you want to do.

=Smidge=

All really need to do is find a way to add gravity to each of the links

Link to comment
Share on other sites

That much is easy.

Maintaining the links the proper distance from each other while still applying gravity to each one? A very difficult dynamic problem. I hope you're good at calculus.

=Smidge=

I just want each of the links to hang between the 2 point instead being straight.

Link to comment
Share on other sites

attachment.php?attachmentid=1173&stc=1&d=1249457919

Are you looking for something like this resembling what you'd get if you grabbed a piece of yarn at two ends or are you looking for something with less give?

Also do you want the nodes to move independently based on their own physics (would move more realistically but maybe too wiggly) or just a parabolic estimation (in other words the droop moves 1:1 with the two points with no momentum)?

post-20-138639763594_thumb.jpg

Link to comment
Share on other sites

I managed to solve the problem using a quasi-physical simulation method: Applying "gravity" to each link and then constraining each link to a maximum distance to both of its neighbors in the chain.

http://www.smidgeindustriesltd.com/LinkDemo.rar

VisualBasic 6 source code included.

Here's the meat of it, reduced to a pseudo-code:


/*plist is a collection of links form 0 to MaxLinks */

/* Fix the start link at (280,300) */
plist(MaxLinks).X = 280
plist(MaxLinks).Y = 300


Do

/* Apply simulated gravity to the link */
/* Links 0 (mouse) and MaxLinks (fixed) are exempt */

For i = 1 To MaxLinks - 1
plist(i).Y = plist(i).Y + Gravity

/* ChkDist checks the distance between the link centers and, if */
/* greater than LinkLength, moves the first link to be at that */
/* maximum distance. */
ChkDist(plist(i).X, plist(i).Y, 0, LinkLength, plist(i - 1).X, plist(i - 1).Y)
Next i

/* Now modify link locations in the other direction, from the */
/* fixed link to the mouse (movable) end, to create a sag. */
For i = MaxLinks - 1 To 1 Step -1
ChkDist plist(i).X, plist(i).Y, 0, LinkLength, plist(i + 1).X, plist(i + 1).Y
Next i

/* set the last link in the chain to the mouse's position */
plist(0).X = Mouse.X
plist(0).Y = Mouse.Y

/* Update everything graphically */
Drawlinks
Loop
[/CODE]

You can check the VB source for the whole thing. Files can be read using your favorite text editor.

Edit: I should explain that I copy-pasted ChkDist from another, older project and it was originally intended to do a bit more than what it does here... so the arguments are kinda odd. Sorry for any confusion.

=Smidge=

Link to comment
Share on other sites

I managed to solve the problem using a quasi-physical simulation method: Applying "gravity" to each link and then constraining each link to a maximum distance to both of its neighbors in the chain.

http://www.smidgeindustriesltd.com/LinkDemo.rar

VisualBasic 6 source code included.

Here's the meat of it, reduced to a pseudo-code:


/*plist is a collection of links form 0 to MaxLinks */

/* Fix the start link at (280,300) */
plist(MaxLinks).X = 280
plist(MaxLinks).Y = 300


Do

/* Apply simulated gravity to the link */
/* Links 0 (mouse) and MaxLinks (fixed) are exempt */

For i = 1 To MaxLinks - 1
plist(i).Y = plist(i).Y + Gravity

/* ChkDist checks the distance between the link centers and, if */
/* greater than LinkLength, moves the first link to be at that */
/* maximum distance. */
ChkDist(plist(i).X, plist(i).Y, 0, LinkLength, plist(i - 1).X, plist(i - 1).Y)
Next i

/* Now modify link locations in the other direction, from the */
/* fixed link to the mouse (movable) end, to create a sag. */
For i = MaxLinks - 1 To 1 Step -1
ChkDist plist(i).X, plist(i).Y, 0, LinkLength, plist(i + 1).X, plist(i + 1).Y
Next i

/* set the last link in the chain to the mouse's position */
plist(0).X = Mouse.X
plist(0).Y = Mouse.Y

/* Update everything graphically */
Drawlinks
Loop
[/CODE]

You can check the VB source for the whole thing. Files can be read using your favorite text editor.

Edit: I should explain that I copy-pasted ChkDist from another, older project and it was originally intended to do a bit more than what it does here... so the arguments are kinda odd. Sorry for any confusion.

=Smidge=

I try this. First I have to convert it to gml using similar functions.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...