Has anyone cracked the ragdoll code?


8baller

 

Posted

Wow. I think you just won yourself an internet for that one.


 

Posted

[ QUOTE ]
Why arent you working for NCsoft?

[/ QUOTE ]

They probably want to hire professionals, rather than people who just hack stuff together because they feel like it.

My plan for this thing is to get the stick figure model to look right with all the joint PYRs, and once that is done, add an animation timeline to it; then you can define keyframes and export a demo of your animation.

Getting all the joint rotations in my stick figure is by far the hardest part. I really, really, really hate dealing with the exact kind of code this thing requires.


www.SaveCOH.com: Calls to Action and Events Calendar
This is what 3700 heroes in a single zone looks like.
Thanks to @EnsonsDeath for the GVE code that made me VIP again!

 

Posted

So. You know how I said, "all the Pitch translations seem to be working; I made some progress with Yaw and Roll but they're giving me hideous headaches"?

Looking for an answer, I ran into this nice little page on the web that said, "It is important to perform the roll first, then the pitch, and finally the yaw. If the order of these operations is changed, a different rotation matrix would result."

So... yeah. That's why the other two weren't working, I was starting with the wrong rotation.

Now that I know that, though, all the Rolls are working fine: COH Poser v0.30 (I wish I was that flexible, btw.)

Here's hoping that Pitch and Yaw decide to behave this time...


www.SaveCOH.com: Calls to Action and Events Calendar
This is what 3700 heroes in a single zone looks like.
Thanks to @EnsonsDeath for the GVE code that made me VIP again!

 

Posted

[ QUOTE ]
Why arent you working for NCsoft?

[/ QUOTE ]

I think Leandro should join me up at HeroCon and we'll inveigle ourselves into the company of the Powers That Be and try and score jobs for ourselves.

Michelle
aka
Samuraiko/Dark_Respite


Dark_Respite's Farewell Video: "One Last Day"
THE COURSE OF SUPERHERO ROMANCE CONTINUES!
Book I: A Tale of Nerd Flirting! ~*~ Book II: Courtship and Crime Fighting - Chap Nine live!
MA Arcs - 3430: Hell Hath No Fury / 3515: Positron Gets Some / 6600: Dyne of the Times / 351572: For All the Wrong Reasons
378944: Too Clever by Half / 459581: Kill or Cure / 551680: Clerical Errors (NEW!)

 

Posted

[ QUOTE ]
... inveigle ...

[/ QUOTE ]

I love it when you talk nerdy...

;]


 

Posted

I have a vocabulary of 75,000+ words and I'm not afraid to use it.

Michelle
aka
Samuraiko/Dark_Respite


Dark_Respite's Farewell Video: "One Last Day"
THE COURSE OF SUPERHERO ROMANCE CONTINUES!
Book I: A Tale of Nerd Flirting! ~*~ Book II: Courtship and Crime Fighting - Chap Nine live!
MA Arcs - 3430: Hell Hath No Fury / 3515: Positron Gets Some / 6600: Dyne of the Times / 351572: For All the Wrong Reasons
378944: Too Clever by Half / 459581: Kill or Cure / 551680: Clerical Errors (NEW!)

 

Posted

LOL - I started to say, "Psst - Your vocabulary is showing..."

BTW (off topic) - Anyone know if "TomStrong" is also on this site?


 

Posted

[ QUOTE ]
LOL - I started to say, "Psst - Your vocabulary is showing..."

BTW (off topic) - Anyone know if "TomStrong" is also on this site?

[/ QUOTE ]

Don't know, don't care.

I just really hope that someone does a write-up in the next City Scoop on the machinima contest (even if we're still in the finals at that point) - the videographers deserve all the attention they can get.

Or maybe I'll write one...

Michelle
aka
Samuraiko/Dark_Respite


Dark_Respite's Farewell Video: "One Last Day"
THE COURSE OF SUPERHERO ROMANCE CONTINUES!
Book I: A Tale of Nerd Flirting! ~*~ Book II: Courtship and Crime Fighting - Chap Nine live!
MA Arcs - 3430: Hell Hath No Fury / 3515: Positron Gets Some / 6600: Dyne of the Times / 351572: For All the Wrong Reasons
378944: Too Clever by Half / 459581: Kill or Cure / 551680: Clerical Errors (NEW!)

 

Posted

OK, posting this code here hoping for the chance that someone who is good at 3D rotations is reading this. I can do 2D rotations easy, but I've been banging my head against this code for hours and this is the best I've come up with.

(a bunch of source code removed from here to keep the page clean)

So what's the problem you say? Well, the rolls work. All of them. The joints inherit the parents' angles, and it all works beautifully.

However, the pitch and the yaw just won't behave. They kinda work: the FIRST joints of the tree (those that are derived directly from neck or torso) rotate just fine. But the rotation isn't being inherited to the "child" joints (elbows, knees, hands and feet), or at least not right. If you pitch the whole body 90 degrees (by setting waist pitch to 255), it will look correct from the "top" view, but the other two will be garbage.

I might find a solution, but right now I'm only finding headaches. If someone can figure this out, I can start working in the keyframing/animation thing instead, that is something I'm familiar with and won't give me any headaches.

Here's a compiled version of this bugged version, if you want to play around with it and see how badly broken the Pitch and Yaw rotations are: COH Poser v0.40. Just unzip to any folder and run.

Edit: added some comments to the source that I had deleted in one of the bajillion tries to write code that works.

Edit, the next day: removed the bunch of source code because it made the page all ugly, and the solution had nothing to do with trigonometry after all.


www.SaveCOH.com: Calls to Action and Events Calendar
This is what 3700 heroes in a single zone looks like.
Thanks to @EnsonsDeath for the GVE code that made me VIP again!

 

Posted

Hey, Leandro --

I'm jumping in here just after skimming this thread and without actually playing with any actual EntRagdoll commands. However, if I can get a good understanding of how the PYR commands for each joint works, I think I might be able to help you with the math part of the code.

Here's my understanding of how things are supposed to work, based solely on several unsupported assumptions:
<ul type="square">[*] Pitch defines a rotation around a horizontal axis running "left" to "right."[*] Yaw defines a rotation around a vertical axis.[*] Roll defines a rotation around a horizontal axis running "front" to "back."[*] The joints are attached to each other in a tree. Each joint inherits the rotations from all parents joints in this tree.[*] When more than one of the PYR rotations is used, they are applied in the order of R-P-Y.[*] The axes of rotation are absolute (meaning that each axis is independent of rotations about the other two axes).[/list]The last bullet point is the one I am most uncertain about, although it would be much simpler for the algorithm to be programmed this way than the other. Are these assumptions correct?

On a side note, are the second and third entries of the EntRagdoll command well-understood?


 

Posted

Hi Balshor:

Pitch is the elevation, making the character look "up" or "down".
Yaw is the heading, makes the character look "left" or "right".
Roll rotates the character without changing the way it's facing; if you downloaded the alpha I linked above, roll works just fine.

Yes, joints are attached to each other in a tree. Joints 0-10 as defined above are the ones in the ragdoll, joints 11-16 in my program are auxiliary endpoints (hands, feet, top of head). Each joint inherits the rotation from all the parents; the main joint that defines all other is the waist (joint 10).

I assume the order is RPY, but that's what makes the most sense from what I've read.

I'm not sure about the last one either, to be honest. The demo program I linked above CAN create demos with the rotations you define, so you could set rotations in the program (even if they look bad in the wireframe previews) then run the demo and see if the results are what you expect or not.

The second and third entries of the EntRagdoll command are for timing. Not sure how the game uses them, but while experimenting with the numbers I found that using numbers that deviate too much from the demo timing "resets" the ragdoll to the screwy state it spawns in.


www.SaveCOH.com: Calls to Action and Events Calendar
This is what 3700 heroes in a single zone looks like.
Thanks to @EnsonsDeath for the GVE code that made me VIP again!

 

Posted

Lets look at something simple first.

Set pitch 767 on the Left leg. I see the upper left leg at 90deg but the lower left leg doesnt follow. Its only at about 45 degrees.

Furthermore, I see the upper left leg with a dist of about 13mm, same as when it was striaght. But the lower left leg is now almost 20mm in legnth where as it started at 15mm as well. Your rotate added 33% to the legnth of the inherited limb. Thats not good and could certainly be part of the problem.

Ill dig up some of my old OpenGL code I did for something very very similar I did about 12 years ago and see how I did the 3-D joint manipulation (OpenGL has those nice glRotate and glTranslate functions). Ill likely find something in there of help


Net


Tanker Tuesday #72 Oct 5 @Champion

"I am not sure if my portrayal of being insane is accurate, but damn its fun all the same."

 

Posted

[ QUOTE ]
Furthermore, I see the upper left leg with a dist of about 13mm, same as when it was striaght. But the lower left leg is now almost 20mm in legnth where as it started at 15mm as well. Your rotate added 33% to the legnth of the inherited limb. Thats not good and could certainly be part of the problem.

[/ QUOTE ]

Something to take into account: for a pitch, the Z coordinate *is* being calculated properly, it's the Y coordinate that doesn't work. The stretching you see when you set the leg to 767 is because the feet is going to the right Z coordinate (all the way left) but the Y coordinate is slightly down.

You can confirm that the Z coordinate works on Pitch by setting the waist pitch to 767 -- The front and right side will be a bunch of garbage lines, but the top view will show all the Z and X coordinates correctly.

Similarly, setting just the Yaw screws the X coordinates, but the "right side" display shows all the Y and Z coordinates are being calculated properly.

I've tried a bunch of small changes but they end up screwing the whole thing way worse.


www.SaveCOH.com: Calls to Action and Events Calendar
This is what 3700 heroes in a single zone looks like.
Thanks to @EnsonsDeath for the GVE code that made me VIP again!

 

Posted

Try the following:

<font class="small">Code:[/color]<hr /><pre> 'Perform the roll.
JointCos = Cos((-Pi / 2) + ((JRoll + JointRoll(JSrc)) * (Pi * 2)))
JointSin = Sin((-Pi / 2) + ((JRoll + JointRoll(JSrc)) * (Pi * 2)))
JointX(JDest) = JointX(JSrc) + (JointCos * JLen)
JointY(JDest) = JointY(JSrc) + (JointSin * JLen)

'Perform the pitch.
JointCos = Cos(JointPitch(JSrc) * (Pi * 2))
JointSin = Sin(JointPitch(JSrc) * (Pi * 2))
JointY(JDest) = JointY(JSrc) + (JointCos * JLen)
JointZ(JDest) = JointZ(JSrc) + (JointSin * JLen)

'Perform the yaw.
JointCos = Cos(JointYaw(JSrc) * (Pi * 2))
JointSin = Sin(JointYaw(JSrc) * (Pi * 2))
JointZ(JDest) = JointZ(JSrc) + (JointCos * JLen)
JointX(JDest) = JointX(JSrc) + (JointSin * JLen)
</pre><hr />

This is entirely unchecked, and you'll probably need to add some constants into the JointCos and JointSin variables to get the angle offsets correct. However, give it a shot and tell me how it looks!


 

Posted

My brain hurts just looking at this stuff... how YOU guys do this is a mystery.

Michelle
aka
Samuraiko/Dark_Respite


Dark_Respite's Farewell Video: "One Last Day"
THE COURSE OF SUPERHERO ROMANCE CONTINUES!
Book I: A Tale of Nerd Flirting! ~*~ Book II: Courtship and Crime Fighting - Chap Nine live!
MA Arcs - 3430: Hell Hath No Fury / 3515: Positron Gets Some / 6600: Dyne of the Times / 351572: For All the Wrong Reasons
378944: Too Clever by Half / 459581: Kill or Cure / 551680: Clerical Errors (NEW!)

 

Posted

Oh. My. Freaking. Atheism.

I solved the problem. Everything works now. After two days burning my brain over this, the solution was one line:

JointZ(JDest) = JointZ(JSrc)

The destination joint was not inheriting the parent's Z coordinate. That was the entire problem.

I HAD LEFT OUT ONE LINE.


www.SaveCOH.com: Calls to Action and Events Calendar
This is what 3700 heroes in a single zone looks like.
Thanks to @EnsonsDeath for the GVE code that made me VIP again!

 

Posted

*tries unsuccessfully to hold back her laughter*

Sorry, Leandro, I'm not laughing at you, I swear. I just know how it feels to bust your [censored] only to realize it was one stupid thing that was messing everything else up.

Looking forward to COH Poser 5.0.

Michelle
aka
Samuraiko/Dark_Respite


Dark_Respite's Farewell Video: "One Last Day"
THE COURSE OF SUPERHERO ROMANCE CONTINUES!
Book I: A Tale of Nerd Flirting! ~*~ Book II: Courtship and Crime Fighting - Chap Nine live!
MA Arcs - 3430: Hell Hath No Fury / 3515: Positron Gets Some / 6600: Dyne of the Times / 351572: For All the Wrong Reasons
378944: Too Clever by Half / 459581: Kill or Cure / 551680: Clerical Errors (NEW!)

 

Posted

[ QUOTE ]
Oh. My. Freaking. Atheism.

I solved the problem. Everything works now. After two days burning my brain over this, the solution was one line:

JointZ(JDest) = JointZ(JSrc)

The destination joint was not inheriting the parent's Z coordinate. That was the entire problem.

I HAD LEFT OUT ONE LINE.

[/ QUOTE ]

Bane of developers of all type out there...

"What do you mean I left out a semicolon?"

Though for me, the problem is more using '=' instead of '==' in boolean checks. 10 years and that bad habit still haunts me at the worst of times...


Arc #345863 - When The Bough Breaks
"Curse you Perry the Plata...wait, is that Love Handel?" - Dr. Heinz Doofenshmirtz, Phineas and Ferb

 

Posted

Not a problem in Visual Basic.


 

Posted

Okay, I had to fix the display panels so they actually matched the generated viewpoint, plus I ate, so this got delayed a bit.

Sample screenshot
Download here.

I'm pretty sure that the order of the rotations is still wrong, that's why this is v0.45 and not v0.50. I'll make the wireframe display slightly more detailed for the next version, that'll help me catch bugs.

Thanks Balshor for trying to help me figure out the problem, by the way... I didn't think it was going to be something THIS simple!


www.SaveCOH.com: Calls to Action and Events Calendar
This is what 3700 heroes in a single zone looks like.
Thanks to @EnsonsDeath for the GVE code that made me VIP again!

 

Posted

[ QUOTE ]
Okay, I had to fix the display panels so they actually matched the generated viewpoint, plus I ate, so this got delayed a bit.

Sample screenshot
Download here.

I'm pretty sure that the order of the rotations is still wrong, that's why this is v0.45 and not v0.50. I'll make the wireframe display slightly more detailed for the next version, that'll help me catch bugs.

Thanks Balshor for trying to help me figure out the problem, by the way... I didn't think it was going to be something THIS simple!

[/ QUOTE ]
I'll test it in Linux...

AND FOR YOU .NET FOLK
stick to the IEEE standard for .net and Mono will run it fine. 8)


 

Posted

Eh? Mono? That's, like, a kissing disease isn't it??


 

Posted

I have found this thread a good read! wow!
I use Excel to do most of of my demorecording, I wrote macros that strip out components and reconstruct them. I thought someone else has to be using excel too. Looking at this ragdoll thread- the possibilities are endless once this ironed out. If anyone needed this (I didnt' write the function, I found it online.., I included the little code so you can try it out with an input box.. just to see how it works

Option Explicit

Public Function HexToDec(Hex As String) As Double

Dim i As Long
Dim j As Variant
Dim k As Long
Dim n As Long
Dim HexArray() As Double

n = Len(Hex)
k = -1
ReDim HexArray(1 To n)
For i = n To 1 Step -1
j = Mid(Hex, i, 1)
k = k + 1
Select Case j
Case 0 To 9
HexArray(i) = j * 16 ^ (k)
Case Is = "A"
HexArray(i) = 10 * 16 ^ (k)
Case Is = "B"
HexArray(i) = 11 * 16 ^ (k)
Case Is = "C"
HexArray(i) = 12 * 16 ^ (k)
Case Is = "D"
HexArray(i) = 13 * 16 ^ (k)
Case Is = "E"
HexArray(i) = 14 * 16 ^ (k)
Case Is = "F"
HexArray(i) = 15 * 16 ^ (k)
End Select
Next i
HexToDec = Application.WorksheetFunction.Sum(HexArray)

End Function

Sub convertme()
Dim hexvar As String
Dim decvar As String
hexvar = InputBox("enter hex")
decvar = HexToDec(hexvar)
MsgBox "your decimal is:" &amp; decvar, vbCritical
End Sub


 

Posted

I haven't tried this code- but it's from the same user:
http://vbaexpress.com/kb/getarticle.php?kb_id=306

Option Explicit

Public Function DecToHex(Dec As Double) As String

Dim i As Long
Dim n As Long
Dim PlaceValHex As Long
Dim Hex(1 To 256) As String
Dim HexTemp As String
Dim Divisor As Long

Dec = Int(Dec)

For i = 256 To 2 Step -1
If Dec &gt;= 16 ^ (i - 1) And Dec &gt; 15 Then
PlaceValHex = Int(Dec / (16 ^ (i - 1)))
Dec = Dec - (16 ^ (i - 1)) * PlaceValHex
Select Case PlaceValHex
Case 0 To 9
Hex(i) = CStr(PlaceValHex)
Case Is = 10
Hex(i) = "A"
Case Is = 11
Hex(i) = "B"
Case Is = 12
Hex(i) = "C"
Case Is = 13
Hex(i) = "D"
Case Is = 14
Hex(i) = "E"
Case Is = 15
Hex(i) = "F"
End Select
Else
Hex(i) = "0"
End If
Next i
PlaceValHex = Dec
Select Case PlaceValHex
Case 0 To 9
Hex(1) = CStr(PlaceValHex)
Case Is = 10
Hex(1) = "A"
Case Is = 11
Hex(1) = "B"
Case Is = 12
Hex(1) = "C"
Case Is = 13
Hex(1) = "D"
Case Is = 14
Hex(1) = "E"
Case Is = 15
Hex(1) = "F"
End Select
For i = 256 To 1 Step -1
If Hex(i) = "0" Then
Else
n = i
Exit For
End If
Next i
For i = n To 1 Step -1
HexTemp = HexTemp &amp; Hex(i)
Next i
DecToHex = HexTemp

End Function