Author Topic: Box2D Rope  (Read 19411 times)

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Box2D Rope
« Reply #15 on: 2012-07-23, 05:01:57 AM »
That looks like a lot more than 5 points. Didn't you say you wouldn't do more than 5?
I wonder if it is being drawn translucently, and if that would explain the gray color.
Is there any good way to make it less stretchy?

Vincent

  • SGDK2 Addict
  • Expert
  • Fanatic
  • *****
  • Posts: 612
  • Legacy of Kain: Revival is completed!!!
    • View Profile
    • Chivalrous Games
    • Email
Re: Box2D Rope
« Reply #16 on: 2012-07-23, 05:54:59 AM »
Very nice! :)
Legacy of Kain: Revival completed!
http://lokrevival.webs.com

See also my company website:
http://chivalrousgames.com

v6v

  • Clever
  • Fanatic
  • ***
  • Posts: 500
  • Has renamed his project to Galaxy!
    • View Profile
    • My Developer Page!
    • Email
Re: Box2D Rope
« Reply #17 on: 2012-07-23, 09:26:10 AM »
That looks like a lot more than 5 points. Didn't you say you wouldn't do more than 5?
I wonder if it is being drawn translucently, and if that would explain the gray color.
Is there any good way to make it less stretchy?

1.I'll make a video with all of the points shown, I actually disabled point plotting to see how  the hair would look on it's own. The hair never exceeds the amount of points that it originally has.

2.Actually, I think that that's the problem, I created 2 HairEmitters on the same layer and tested how they acted when the hair strands crossed paths, the alpha values/transparency seems to double at the points where they cross.

3. Make it less stretchy? I've been trying for the longest time. Actually, things move like a slinky (I've been using spring physics, so when the sprite gains any velocity, the hair stretches and when it rests, it coils back to it's original position. I'm trying to find out what I can do to fix this.



Very nice! :)

Thanks Vincent!

Edit, Video of the game with the ConnectPointsWithALine rule suspended

http://www.youtube.com/watch?v=OcJchIkXil8&feature=youtu.be

When the hair moves, the points are stretched apart, is this what should be happenning? I figured that the faster you move, the most stretched and alligned the hair points should be towards an angle equal to that of the direction of motion but with a direction opposite to that to the direction of motion (newton's third)

Although the number of points is dynamic and can be controlled, I'm thinking of using greater point distance in combination without the need of more points, I might have jagged hair strands though.


Edit

I need to ask, how to I get the current coordinates of the CurrentView? OpenGL coordinates and Game coordinates are different, because the game coordinates are OpenGL coordinates plus the X and Y of the CurrentView (offset). I need to sync the coordinates of the hair drawn to keep the hair on the screen, otherwise it flies off whenever I reach the scroll margins

Edit

Solution to that^ is simple. If HairEmitter.x >CxrrentView.X then HairEmitter.X = CurrentView.X
« Last Edit: 2012-07-23, 01:06:50 PM by #Sharp »

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Box2D Rope
« Reply #18 on: 2012-07-24, 05:04:13 AM »
I don't know how Physics2D does it (that's what the spider project uses), but it limits springiness and can make segments behave more like bars than springs. I think by somehow forcing the points to prioritize maintaining a set distance between their neighboring points, you could make it less springy and more stringy. Mind you, this doesn't mean that points should affect all other points in the strand, only the points adjacent to them in the strand.

v6v

  • Clever
  • Fanatic
  • ***
  • Posts: 500
  • Has renamed his project to Galaxy!
    • View Profile
    • My Developer Page!
    • Email
Re: Box2D Rope
« Reply #19 on: 2012-07-24, 08:59:26 AM »
I was thinking about modifying your GetNearestDistanceFunction to return a value and checking if that value was greater than a constant value.

The problem is how to naturally constrain it- should it be decrement PixelX and PixelY until they're lesser than or equal to the constant?

By the way, would you happen to have any code that I could use to return the current OpenGL coordinates of the mouse cursor or current sprite?

For some operations I'll need to return these coordinates.