private void DrawPinSword(Model model, Matrix view, Matrix projection, BTCHelper.Hand hand) { try { if (activeSkeleton != null) { if (activeSkeleton.TrackingState == SkeletonTrackingState.Tracked) { Joint joint; Color color = Color.Red;; if (hand == BTCHelper.Hand.Right) { joint = activeSkeleton.Joints[JointType.HandRight]; } else { joint = activeSkeleton.Joints[JointType.HandLeft]; } var position = GameWorldTransformation(joint.Position); BTCVector mydirection = BTCHelper.GetHandDirection(hand, activeSkeleton, new BTCVector(-1.0f, 1.0f, 1.0f)); Vector3 direction = new Vector3(mydirection.X, mydirection.Y, mydirection.Z); position = position + direction * 0.5f / 3.0f; pinModelMatrix = Matrix.CreateTranslation((float)position.X, (float)position.Y, (float)position.Z); pinModelMatrix = Matrix.CreateScale(.1f, .1f, .1f) * Matrix.CreateRotationY(MathHelper.Pi) * pinModelMatrix; DrawModel(pinModel, pinModelMatrix /*world matrix*/, view, projection); } } } catch { } }
private void DrawPrimitveSword(GeometricPrimitive primitive, Matrix view, Matrix projection, BTCHelper.Hand hand) { try { if (activeSkeleton != null) { if (activeSkeleton.TrackingState == SkeletonTrackingState.Tracked) { Joint joint; Color color = Color.Red;; if (hand == BTCHelper.Hand.Right) { joint = activeSkeleton.Joints[JointType.HandRight]; } else { joint = activeSkeleton.Joints[JointType.HandLeft]; } var position = GameWorldTransformation(joint.Position); BTCVector mydirection = BTCHelper.GetHandDirection(hand, activeSkeleton, new BTCVector(-1.0f, 1.0f, 1.0f)); Vector3 direction = new Vector3(mydirection.X, mydirection.Y, mydirection.Z); Matrix world = new Matrix(); for (int i = 1; i < 10; i++) { if (ii % 10 == 0) { Color temp = start; start = nect; nect = temp; ii++; } if (i % 2 != 0) { color = start; } else { color = nect; } position = position + direction * float.Parse(i.ToString()) * 0.5f / 3.0f; world = Matrix.CreateTranslation((float)position.X, (float)position.Y, (float)position.Z); primitive.Draw(world, view, projection * Matrix.CreateScale(1f, 1f, 1f), color); } ii++; } } } catch { } }