Ragdoll Physics
I quit.
Seriously though, I can't get it to work. When I run it like that, it just goes crazy and flies off screen even if I'm clicking and dragging (which sets the position of the anchor circle). I just don't get it. It obviously works for you and Jake, but my code just doesn't want to work or something. I still have my particles that seem to like me a little but I would like to get some ragdolls or cool things using this technology.
If anyone on a Mac can download the source (get it here) and try to get it working and let me know what you had to change to get it working, I would greatly appreciate it.
Seriously though, I can't get it to work. When I run it like that, it just goes crazy and flies off screen even if I'm clicking and dragging (which sets the position of the anchor circle). I just don't get it. It obviously works for you and Jake, but my code just doesn't want to work or something. I still have my particles that seem to like me a little but I would like to get some ragdolls or cool things using this technology.
If anyone on a Mac can download the source (get it here) and try to get it working and let me know what you had to change to get it working, I would greatly appreciate it.
sorry
©h€ck øut µy stuƒƒ åt ragdollsoft.com
New game in development Rubber Ninjas - Mac Games Downloads
Don't be sorry. You helped me tons. Even if for some reason it won't work. I'll just wait for someone to have that revelationary (is that a word?) moment and realize something that will completely fix this. Now I must go back up my hard drive and reformat and reinstall Mac OS X because something got screwed up and the comp needs it.
It's the trouble of coding physics. I remember when I was trying to put the balls into a shape.
Well I tried 6 months ago for 3-4 days and didn't manage, so incredibly frustrated I gave up, then I tried 3 months ago and still didn't, finally I tried again 1 month ago and I managed so I could do ragdoll masters
Well I tried 6 months ago for 3-4 days and didn't manage, so incredibly frustrated I gave up, then I tried 3 months ago and still didn't, finally I tried again 1 month ago and I managed so I could do ragdoll masters
©h€ck øut µy stuƒƒ åt ragdollsoft.com
New game in development Rubber Ninjas - Mac Games Downloads
I think I might just try and rethink some things and give it another try later tonight. See what happens.
ok, I made one in blitzmax, so I'm sure that works. Useless to say, I did put in about 5 bugs that took me about 15 minutes fo find, despite it's only 40 lines and relatively simple, and despite I consider myself a bit of an expert after all I've been through.
I found 2 more problems in your code: it should be
Anyway I still dont know if it works but I'm sure the following does (blitzmax code)
I found 2 more problems in your code: it should be
Code:
(void)updateCircles
{
int i,j;
SEVector shift[NUM_CIRCLES];
SEVector tempVector;
SEVector oldPos[NUM_CIRCLES];
float tempFloat,tempFloat2;
//add the velocities to the circles
for(i = 0; i < NUM_CIRCLES; i++)
{
oldPos[i] = circlePos[i];
circlePos[i].x += circleVel[i].x;
circlePos[i].y += circleVel[i].y;
}
for (j= 0; j < 40; j++)
{
shift[i].x=0;
shift[i].y=0;
//figure out shifts for circles
for(i = 0; i < NUM_CIRCLES - 1; i++)
{
tempFloat = sqrt(pow(circlePos[i+1].x - circlePos[i].x,2) +
pow(circlePos[i+1].y - circlePos[i].y,2));
shift[i].x += ((tempFloat - (CIRCLE_RADIUS * 2)) / 4) *
((circlePos[i+1].x - circlePos[i].x) / tempFloat);
shift[i].y += ((tempFloat - (CIRCLE_RADIUS * 2)) / 4) *
((circlePos[i+1].y - circlePos[i].y) / tempFloat);
//wrong! shift[i+1].x = -shift[i].x;
//wrong! shift[i+1].y = -shift[i].y;
shift[i+1].x +=- ((tempFloat - (CIRCLE_RADIUS * 2)) / 4) *((circlePos[i+1].x - circlePos[i].x) / tempFloat);
shift[i+1].y +=- ((tempFloat - (CIRCLE_RADIUS * 2)) / 4) *((circlePos[i+1].y - circlePos[i].y) / tempFloat);
}
//apply the shifts
for(i = 0; i < NUM_CIRCLES; i++)
{
circlePos[i].x += shift[i].x;
circlePos[i].y += shift[i].y;
}
}
//reset the velocities based on actual movement
for(i = 0; i < NUM_CIRCLES; i++)
{
circleVel[i].x = (circlePos[i].x - oldPos[i].x);
circleVel[i].y = (circlePos[i].y - oldPos[i].y - GRAVITY);
}
}Anyway I still dont know if it works but I'm sure the following does (blitzmax code)
Code:
Global distance#
Global numballs=30
Global shiftx#[numballs]
Global shifty#[numballs]
Global g#=0.1 'gravity
Global r#=10 'radius
Global x#[numballs]
Global y#[numballs]
Global xv#[numballs] 'x velocity
Global yv#[numballs] 'y velocity
Global dx#
Global dy#
Global oldx#[numballs]
Global oldy#[numballs]
For i=0 To numballs-1
x[i]=i
y[i]=i
Next
Graphics (800,600,0,60)
Repeat
Cls
x[0]=MouseX()
y[0]=MouseY()
xv[0]=0
yv[0]=0
For i=0 To numballs-1
yv[i]=yv[i]+g
oldx[i]=x[i]
oldy[i]=y[i]
x[i]=x[i]+xv[i]
y[i]=y[i]+yv[i]
Next
For j= 0 To 30
For i=0 To numballs-1
shiftx[i]=0
shifty[i]=0
Next
For i=0 To numballs-2
dx=(x[i+1]-x[i])
dy=(y[i+1]-y[i])
distance = Sqr(dx*dx + dy*dy)
shiftx[i]=shiftx[i]+((distance - 2*r) / 4.0) * (dx / distance );
shifty[i]=shifty[i]+((distance - 2*r) / 4.0) * (dy / distance );
shiftx[i+1] = shiftx[i+1]-((distance - 2*r) / 4.0) * (dx / distance );
shifty[i+1] = shifty[i+1]-((distance - 2*r) / 4.0) * (dy / distance );
Next
For i=0 To numballs-1
x[i] = x[i]+shiftx[i]
y[i] = y[i]+shifty[i]
Next
Next
For i=0 To numballs-1
xv[i] = x[i]-oldx[i]
yv[i] = y[i]-oldy[i]
Next
For i=0 To numballs-1
DrawOval(x[i],y[i],2*r,2*r)
Next
FlushMem()
Flip
Until (KeyDown(key_escape))©h€ck øut µy stuƒƒ åt ragdollsoft.com
New game in development Rubber Ninjas - Mac Games Downloads
even I write o-o code nowadays, but to test stuff you would probably go easier with some noobcode :-P
©h€ck øut µy stuƒƒ åt ragdollsoft.com
New game in development Rubber Ninjas - Mac Games Downloads
I think I'm doing the for() loops wrong. I need some help with my C/C++ (kinda sad). I have an array declared like
and later I want to change all the positions. What should the for loop condition be? What if I don't want to change the last one entry? I believe that changing all of them (without going out of bounds) would just be i < NUM_CIRCLES because then I would never be NUM_CIRCLES and thus would be one lower and a correct value. Therefore, to change all but the last, should it be i < NUM_CIRCLES - 1? The problem is that never seems to leave the last one alone.
Code:
SEVector circlePos[NUM_CIRCLES];
why would you want to leave the last value alone? just put something like
x[0]=MouseX()
y[0]=MouseY()
xv[0]=0
yv[0]=0
(like I put in my code)
to set the position of the first ball
x[0]=MouseX()
y[0]=MouseY()
xv[0]=0
yv[0]=0
(like I put in my code)
to set the position of the first ball
©h€ck øut µy stuƒƒ åt ragdollsoft.com
New game in development Rubber Ninjas - Mac Games Downloads
Nick Wrote:I think I'm doing the for() loops wrong. I need some help with my C/C++ (kinda sad). I have an array declared like
and later I want to change all the positions. What should the for loop condition be? What if I don't want to change the last one entry? I believe that changing all of them (without going out of bounds) would just be i < NUM_CIRCLES because then I would never be NUM_CIRCLES and thus would be one lower and a correct value. Therefore, to change all but the last, should it be i < NUM_CIRCLES - 1? The problem is that never seems to leave the last one alone.Code:
SEVector circlePos[NUM_CIRCLES];
Loop through entire array:
for(int i = 0; i < NUM_CIRCLES; i++)
Loop up to (but not including) the last slot
for(int i = 0; i < NUM_CIRCLES - 1; i++)
There was a long silence...
'I claim them all,' said the Savage at last.
...though disturbing. This doesn't really help, though...
It's not magic, it's Ruby.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Ragdoll Physics | merrill541 | 1 | 2,296 |
Feb 5, 2009 09:09 AM Last Post: JustinFic |
|
| Ragdoll Physic's: (For GML).. | Master_Computer | 0 | 2,159 |
Jan 27, 2008 11:55 AM Last Post: Master_Computer |
|
| Bullet Physics Library / COLLADA physics viewer | erwincoumans | 14 | 11,244 |
Aug 12, 2006 12:59 AM Last Post: Fenris |
|
| Ragdoll Physics | Duane | 3 | 3,716 |
Jul 7, 2005 09:55 AM Last Post: Duane |
|
| Ragdoll and cloth physics | Skorche | 28 | 12,012 |
Jun 10, 2003 03:12 PM Last Post: Fenris |
|

