|
2d only rope physics |
Ceagon Xylas
Member #5,495
February 2005
|
I've read NeHe's tutorial on rope physics, and it's a little over my head... I was wondering where I could get started on strictly 2d rope physics. Here's what I have in mind Where do I even begin with mounting the lamp on to the rope? I can see that the length, x, and y all stay constant during. |
FMC
Member #4,431
March 2004
|
I think you should cheat [FMC Studios] - [Caries Field] - [Ctris] - [Pman] - [Chess for allegroites] |
Birdeeoh
Member #6,862
February 2006
|
Most probably you would expect the lamp to go back and forth, much like a pendulum... so just make it follow a pendulum's movement! And, indeed after the initial impact, it will act just like a pendulum. However the difference between "rope physics" and pendulum physics is that pendulums are assumed to be stiff. The "fun" in the rope physics is the flexibility and how neat it will look upon initial impact when the "pendulum weight" is moving independently of the "pendulum arm" because it's a rope. I don't pretend to know how to implement this in code without studying up on it... [url http://developer.berlios.de/projects/openlayer/]OpenLayer[/url is an OpenGL accelerated 2D library for fast and easy graphics development under Allegro |
FrankyR
Member #243
April 2000
|
Well, I know nothing about rope physics, but off the top of my head I have an idea for an approach. 1)When the rope is slack treat the lamp as it if is just a freefalling object (should be easy to do). 2)When the rope goes tight (i.e. the distance between the lamp and the ceiling where the rope is attached == the length of the rope) apply a normal force to the lamp. That is a force along the rope toward the ceiling to cancel out any movement in the direction along the rope (plus any you want to add for the sake of elasticity in the rope). If you're in a situation where the rope is staying taut at all times, then giving the lamp pendulum motion sounds like a good idea. |
Evert
Member #794
November 2000
|
The easiest way that I know of to simulate a rope is to approximate it as a sequence of connected weights. Instead of stiff rods, you can use weights connected by massless springs. By varying the spring constant you can change how the rope reacts to being pulled and twisted - you can even vary it along the length of the rope to simulate a weak spot in the rope. In the limit where the spring constant becomes infinite you should get back the stiff rod. Be warned though that this approach gives rise to a rather bothersome set of coupled equations that will need to be solved (because the force on the first mass element produces a torque and a force on the second mass element, which produces a force and a torque on the third... etc). |
X-G
Member #856
December 2000
|
Also beware of the ghastly effects that occur if you don't integrate with a fine enough timestep or don't account for friction properly. -- |
Neil Walker
Member #210
April 2000
|
Couldn't you do something like plot three points, one at the top, one half way down and one at the bottom. Make the bottom one move further than the middle in a slight arc then join the top to the two points using catmull-rom spline? Neil. wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie |
nonnus29
Member #2,606
August 2002
|
I think for something like this it would be simpler in the end to implement some actual physics: Quote: Be warned though that this approach gives rise to a rather bothersome set of coupled equations that will need to be solved (because the force on the first mass element produces a torque and a force on the second mass element, which produces a force and a torque on the third... etc). Verlet! Verlet! This is the type of thing verlet integration excels at from what I've been able to gather.... |
Neil Walker
Member #210
April 2000
|
Or you could download newton dynamic library or ODE and create a 2d rope rather easily with some hinged joints Neil. wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie |
Ceagon Xylas
Member #5,495
February 2005
|
Ew ew ew, sorry guys. I stupidly posted this the day before Oblivion arrived at my front door. Of course I've been doing that with all my free time. Back to programming classic games! =D The reason I don't want a pendulum effect is precisely because of the stiffness. My game offers 360 degree directional shooting... So if you hit the lamp from the bottom, I want it to move up-wards into the ceiling and bounce off. Quote: The easiest way that I know of to simulate a rope is to approximate it as a sequence of connected weights. Yes, this sounds like the best choice to me. Would you know where I could see some code for it? Quote: Or you could download newton dynamic library or ODE Can I get some links for those? I searched and bleh nothing useful came up after a while of sifting through google pickups. |
lambik
Member #899
January 2001
|
I don't know if this is what you are looking for but just on the off chance:http://freespace.virgin.net/hugo.elias/models/m_main.htm |
Ceagon Xylas
Member #5,495
February 2005
|
Ooo...This is handy! [edit] [edit again]
http://img93.imageshack.us/img93/1467/rope0ue.gif My brain can almost grasp it... joint[0]'s x and y are controlled by up, down, left, and right; and will be assigned a static point later on in the coding of deploy();. So I need to make joint[max]'s x and y controllable by the lamp. But how?! |
fuzinavl
Member #4,105
December 2003
|
looks just like the old lamps in elevator action! __________________________ |
|