Posts Tagged ‘SkelControl’

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