public override void Initialize(IApplication application) { base.Initialize(application); LeapMotionService leapMotionService = new LeapMotionService(); WaveServices.RegisterService(leapMotionService); leapMotionService.StartSensor(LeapFeatures.Hands | LeapFeatures.CameraImages); ScreenContext screenContext = new ScreenContext(new MyScene()); WaveServices.ScreenContextManager.To(screenContext); }
/// <summary> /// Initialize this instance. /// </summary> protected override void Initialize() { base.Initialize(); this.leapService = WaveServices.GetService<LeapMotionService>(); if (this.leapService == null) { Console.WriteLine("You need to register the LeapMotion service."); return; } if (!this.leapService.IsReady) { Console.WriteLine("You need to call to start method before."); return; } Color rightColor = Color.LightGreen; Color leftColor = Color.LightBlue; float defaultScale = 0.018f; float palmScale = 0.025f; this.entities = new Dictionary<string, Entity>(); // Hands foreach (HandType handType in Enum.GetValues(typeof(HandType))) { string handName = handType.ToString(); Color color = (handType == HandType.R) ? rightColor : leftColor; // Palm this.entities.Add(string.Format("{0}Palm", handName), this.CreateNode(handName, color, palmScale)); this.entities.Add(string.Format("{0}Palm1", handName), this.CreateNode(handName, color, defaultScale)); string edgePalm1 = string.Format("{0}{1}{2}_To_{0}Palm1", handName, Finger.FingerType.TYPE_THUMB, Finger.FingerJoint.JOINT_MCP); this.entities.Add(edgePalm1, this.CreateEdge(handName)); string edgePalm2 = string.Format("{0}Palm1_To_{0}{1}{2}", handName, Finger.FingerType.TYPE_PINKY, Finger.FingerJoint.JOINT_MCP); this.entities.Add(edgePalm2, this.CreateEdge(handName)); // Fingers string beforeMCPFinger = string.Empty; foreach (Finger.FingerType fingerType in Enum.GetValues(typeof(Finger.FingerType))) { string beforeNodeName = string.Empty; foreach (Finger.FingerJoint jointType in Enum.GetValues(typeof(Finger.FingerJoint))) { string nodeName = string.Format("{0}_{1}_{2}", handName, fingerType, jointType).ToLowerInvariant(); this.entities.Add(nodeName, this.CreateNode(handName, color, defaultScale)); if (!string.IsNullOrEmpty(beforeNodeName)) { string edgeName = string.Format("{0}_To_{1}", beforeNodeName, nodeName).ToLowerInvariant(); this.entities.Add(edgeName, this.CreateEdge(handName)); } if (jointType == Finger.FingerJoint.JOINT_MCP && !string.IsNullOrEmpty(beforeMCPFinger)) { string edgeName = string.Format("{0}_To_{1}", beforeMCPFinger, nodeName).ToLowerInvariant(); this.entities.Add(edgeName, this.CreateEdge(handName)); } beforeNodeName = nodeName; if (jointType == Finger.FingerJoint.JOINT_MCP) { beforeMCPFinger = nodeName; } } } } foreach (Entity e in this.entities.Values) { this.Owner.AddChild(e); } }