/// <summary> /// Initializes a new instance of the <see cref="SkeletonJointsFilterClippedLegs"/> class. /// </summary> public SkeletonJointsFilterClippedLegs() { this.lerpLeftKnee = new TimedLerp(); this.lerpLeftAnkle = new TimedLerp(); this.lerpLeftFoot = new TimedLerp(); this.lerpRightKnee = new TimedLerp(); this.lerpRightAnkle = new TimedLerp(); this.lerpRightFoot = new TimedLerp(); this.filteredSkeleton = new Skeleton(); this.filterDoubleExp = new SkeletonJointsPositionDoubleExponentialFilter(); // knee, ankle, foot blend amounts this.allTracked = new Vector3(0.0f, 0.0f, 0.0f); // All joints tracked this.footInferred = new Vector3(0.0f, 0.0f, 1.0f); // foot is inferred this.ankleInferred = new Vector3(0.5f, 1.0f, 1.0f); // ankle is inferred this.kneeInferred = new Vector3(1.0f, 1.0f, 1.0f); // knee is inferred this.Reset(); }
/// <summary> /// Initializes a new instance of the AvatarAnimator class. /// </summary> /// <param name="game">The related game object.</param> /// <param name="retarget">The avatar mesh re-targeting method to convert from the Kinect skeleton.</param> public AvatarAnimator(Game game, RetargetMatrixHierarchyToAvatarMesh retarget) : base(game) { if (null == game) { return; } this.retargetMethod = retarget; this.SkeletonDrawn = true; this.useKinectAvateering = true; this.AvatarHipCenterHeight = 0; // Create local axes inside the model to draw at each joint this.localAxes = new CoordinateCross(this.Game, 2f); this.drawLocalAxes = false; game.Components.Add(this.localAxes); // If we draw the Kinect 3D skeleton in BoneOrientationConstraints, we can offset it from the original // hip center position, so as not to draw over the top of the Avatar. Offset defined in m. this.kinectLineSkeletonWorldOffsetMatrix = Matrix.CreateTranslation(40.0f, 0.75f * 40.0f, 0); this.drawBoneConstraintsSkeleton = false; // Skeleton fixups this.frameTimer = new Timer(); this.lastNuiTime = 0; this.FloorClipPlane = new Tuple<float, float, float, float>(0, 0, 0, 0); this.clippedLegs = new SkeletonJointsFilterClippedLegs(); this.sensorOffsetCorrection = new SkeletonJointsSensorOffsetCorrection(); this.jointPositionFilter = new SkeletonJointsPositionDoubleExponentialFilter(); this.boneOrientationConstraints = new BoneOrientationConstraints(game); this.boneOrientationFilter = new BoneOrientationDoubleExponentialFilter(); this.filterClippedLegs = true; this.tiltCompensate = true; this.floorOffsetCompensate = false; this.selfIntersectionConstraints = true; this.mirrorView = true; this.boneConstraints = true; this.filterBoneOrientations = true; // For many applications we would enable the // automatic joint smoothing, however, in this // Avateering sample, we perform skeleton joint // position corrections, so we will manually // filter here after these are complete. // Typical smoothing parameters for the joints: var jointPositionSmoothParameters = new TransformSmoothParameters { Smoothing = 0.25f, Correction = 0.25f, Prediction = 0.75f, JitterRadius = 0.1f, MaxDeviationRadius = 0.04f }; this.jointPositionFilter.Init(jointPositionSmoothParameters); // Setup the bone orientation constraint system this.boneOrientationConstraints.AddDefaultConstraints(); game.Components.Add(this.boneOrientationConstraints); // Typical smoothing parameters for the bone orientations: var boneOrientationSmoothparameters = new TransformSmoothParameters { Smoothing = 0.5f, Correction = 0.8f, Prediction = 0.75f, JitterRadius = 0.1f, MaxDeviationRadius = 0.1f }; this.boneOrientationFilter.Init(boneOrientationSmoothparameters); }