/// <summary> /// Initializes a new instance of the BoneOrientationConstraints class. /// </summary> /// <param name="game">The related game object.</param> public BoneOrientationConstraints(Game game) : base(game) { drawKinectSkeletonConstraintCones = true; localJointCoordinateSystemCrosses = new CoordinateCross(this.Game, 2f); this.Game.Components.Add(localJointCoordinateSystemCrosses); }
public AvatarAnimator(Game game) : base(game) { if (null == game) { return; } this.SkeletonDrawn = true; this.useKinectAvateering = true; this.AvatarHipCenterHeight = 0; this.skeletonTransformHelper = new SkeletonTransformHelper(game); game.Components.Add(this.skeletonTransformHelper); // Create local axes inside the model to draw at each joint this.localAxes = new CoordinateCross(this.Game, 2.0f); 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); }