VR Dev – Part 7: Frustrating Flailing Arms

Posted: April 8, 2013 in Hydra support in UDK, VR Dev
Tags: , , ,

Hey VR Heads!

Work and volunteering took up a lot of my time this week, but I managed to make some meager progress with Hydra integration in UDK. I used examples from a couple of places:

http://forums.epicgames.com/threads/937066-Razer-Hydra-Dll-Bind-Player-Input-and-Player-Controller-Ready-to-go/page2
Craig just keeps posting awesome things! I took the camera modes that he constructed from his latest release.

http://forums.epicgames.com/threads/734592-Making-a-Skeletal-Control-to-move-an-arm
This post by Comicaztaway is a tutorial for getting the arm of a skeletal mesh to move with the mouse, Little Big Planet style.

After a lot of experimentation and frustration, I arrived at what you see in the video. Nowhere close to where I want to be, but its progress nonetheless. I will make a tutorial video outlining what I did in the near future. In the mean time, here is the quick-and-dirty tutorial:

  • Make a copy of, and then edit CH_AnimHuman_Tree. Add b_RightWeapon and b_LeftWeapon to the AnimTree. Create 2 new SkelControl_CCD_IKs named RightArmIK and LeftArmIK.
  • Make the edits that Comicaztaway sugests in his post, then close and save the package.
  • Add the following code to your Pawn.uc:

var SkelControl_CCD_IK RightArmIK;
var SkelControl_CCD_IK LeftArmIK;

simulated event PostInitAnimTree(SkeletalMeshComponent SkelComp)
{
super.PostInitAnimTree(SkelComp);
RightArmIK = SkelControl_CCD_IK( mesh.FindSkelControl('RightArmIK') );
LeftArmIK = SkelControl_CCD_IK( mesh.FindSkelControl('LeftArmIK') );
}

defaultproperties
{
Begin Object class=SkeletalMeshComponent Name=SkeletalMeshComponent0
SkeletalMesh=SkeletalMesh'CH_IronGuard_MaleHG.Mesh.SK_CH_IronGuard_MaleA'
PhysicsAsset=PhysicsAsset'CH_AnimCorrupt.Mesh.SK_CH_Corrupt_Male_Physics'
Animsets(0)=AnimSet'CH_AnimHumanHG.Anims.K_AnimHuman_AimOffset'
Animsets(1)=AnimSet'CH_AnimHumanHG.Anims.K_AnimHuman_BaseMale'
AnimTreeTemplate=AnimTree'CH_AnimHuman_MyTree.AT_CH_Human'
End Object
Mesh=SkeletalMeshComponent0
Components.Add(SkeletalMeshComponent0)

Name="Default__HydraGamePawn"
}
  • Add the following code to your PlayerController.uc:

var vector RightArmLocation;
var vector LeftArmLocation;
var HydraGamePawn Utp;
var HydraGamePlayerInput Hgp;

// function for SkelControl movement.
function UpdateRotation(float DeltaTime)
{
Hgp = HydraGamePlayerInput(PlayerInput); // gives us access to the Hydra variables
Utp = HydraGamePawn(Pawn); // this simply gets our pawn so we can then point to our SkelControl

// assigns vector RightArmLocation to the position of the Right Hydra Wand.
RightArmLocation.Z = Pawn.Location.Z + Hgp.RightHandPosition.Z;
RightArmLocation.Y = Pawn.Location.Y - 200 - Hgp.RightHandPosition.Y;
RightArmLocation.X = Pawn.Location.X - 400 - Hgp.RightHandPosition.X;
Utp.RightArmIK.EffectorLocation = RightArmLocation;

// assigns vector LeftArmLocation to the position of the Left Hydra Wand.
LeftArmLocation.Z = Pawn.Location.Z + Hgp.LeftHandPosition.Z;
LeftArmLocation.Y = Pawn.Location.Y - 400 - Hgp.LeftHandPosition.Y;
LeftArmLocation.X = Pawn.Location.X - 400 - Hgp.LeftHandPosition.X;
Utp.LeftArmIK.EffectorLocation = LeftArmLocation;

// Optional log feed, so you can see the number values and decide how to tweak the assignments above.
`log("RightArmIK.EffectorLocation Value is :"$Utp.RightArmIK.EffectorLocation);

}

I have weird numbers in there to offset position based on how I have my Hydra situated on my desk. The base station is off to my right. This solution is brute force and is not at all flexible, but may serve as a jump-off point for someone out there.

I will post the full files to GitHub sometime tomorrow, for now I have to get some sleep.

Oh yeah, on other thing: my Rift is due to arrive tomorrow! Next week’s video will include impressions and direct feeds if I can swing it.

Excelsior,

–Bruce

Advertisements
Comments
  1. Daryl Lee says:

    Great job on the arm movement. It’s a real tough cookie to get down. Look forward to the more in-depth tutorial on that if you get the chance, but even what you have here is great.

  2. James says:

    Hehehe, progressing quickly! Enjoying the updates, hope you get your kit as expected!

    The ideal solution would involve an inverse kinematics solver which incorporates constraints based on the physiology of the avatar (twists at wrists, bends at elbows), in finding a realistic-looking pose corresponding to the position and orientation of the Hydra controllers. I’m not sure it’s something even the best of us could belt out in a single weekly update though (and also wedging the solution to this general problem somehow into the UDK) πŸ˜‰

    Hopefully you arrive at something that is both simple and works well!

    PS The flailing arms were hilarious

    • Awesome, thanks for the encouragement! I am glad you enjoyed the flailing! πŸ˜€

      That ideal solution sounds complicated, but fantastic. I still have a long way to go before I am at that level!

  3. cTool says:

    Awesome ! Let us know when you upload it to git, it will be a great VR playground πŸ™‚ (for me, at least)

  4. Ganonmaster says:

    I’ve been struggling to get a similar system working. For some reason I couldn’t get the right values into the skeletal control and my character’s arms would spaz out. I hope you can share some of the code when you’ve refined the controls. πŸ™‚

  5. Homepage says:

    Very good article! We will be linking to this great post on our site.
    Keep up the good writing.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s