public override void Calculate() { frame = leap.Frame(); if (!frame.Hands.IsEmpty) { var volDistance = frame.Pointables.Min(p => p.TipPosition.DistanceTo(volumeAntenna.Center)); var freqDistance = frame.Pointables.Min(p => p.TipPosition.DistanceTo(freqAntenna.Center)); //var volDistance = frame.Hands.Min(h => h.SphereCenter.DistanceTo(volumeAntenna.Center)); //var freqDistance = frame.Hands.Min(h => h.SphereCenter.DistanceTo(freqAntenna.Center)); volSend = mapVolume(volDistance); freqSend = mapFreq(freqDistance); /* Send Arduino Wave Generator*/ if (waveGen.IsOpen) { waveGen.UpdateFreq(freqSend); waveGen.UpdateVol(volSend); } DX.SetMaterialParam(volumeColor); DX.DrawCube3D(volumeIndicator.ToDX(), new Leap.Vector(volumeIndicator.x + indicatorWidth, volumeIndicator.y + (indicatoHeight * (volSend / (float)0xff)), volumeIndicator.z + 10).ToDX(), DX.GetColor(0xff, 0xff, 0xff), DX.GetColor(0xff, 0xff, 0xff), DX.TRUE); DX.SetMaterialParam(freqColor); DX.DrawCube3D(freqIndicator.ToDX(), new Leap.Vector(freqIndicator.x + indicatorWidth, freqIndicator.y + (indicatoHeight * (1.0f - freqSend / (float)1000)), freqIndicator.z + 10).ToDX(), DX.GetColor(0xff, 0xff, 0xff), DX.GetColor(0xff, 0xff, 0xff), DX.TRUE); if (isDebugMode) { DX.DrawString(10, 50, string.Format("vol = {0}, freq = {1}", volDistance, freqDistance), DX.GetColor(0xff, 0xff, 0xff)); DX.DrawString(10, 70, string.Format("vol = {0}, freq = {1}", volSend, freqSend), DX.GetColor(0xff, 0xff, 0xff)); } } moveCamera(); }
private void drawThereminAntenna() { DX.SetMaterialParam(volumeColor); DX.DrawCube3D(volumeAntenna.Pos1.ToDX(), volumeAntenna.Pos2.ToDX(), 0, 0, DX.FALSE); DX.SetMaterialParam(freqColor); DX.DrawCube3D(freqAntenna.Pos1.ToDX(), freqAntenna.Pos2.ToDX(), 0, 0, DX.FALSE); DX.SetMaterialParam(thememinColor); DX.DrawCube3D(thereminBoxPos1.ToDX(), thereminBoxPos2.ToDX(), 0, 0, DX.FALSE); }