public void AddPossibleObject(SingleObject obj) { if (obj != null) { possibleObjects.Add(obj.GetObjectName(), obj); } }
public void SelectObject(string name) { if (name != null && usedObjects.ContainsKey(name)) { selectedObject = usedObjects[name]; } else { selectedObject = null; } }
// przesuwanie danego obiektu wg wspolrzednych Kinecta public void MoveTo(string name, double x, double y, double z) { if (ExistsUsedObject(name)) { SingleObject obj = usedObjects[name]; obj.KinectMoveTo(x, y, z); obj.SetScreenPosition(mainEngine.GetCalibrator().ScaleKinectPositionToScreen(x, y, z)); mainEngine.AddTextToLog("ObjectManager: przesunieto obiekt " + name + " na pozycje (" + x + "," + y + "," + z + ")"); } else { mainEngine.AddTextToLog("ObjectManager: nie ma obiektu do przesuniecia o nazwie " + name); // ... } }
// usuwanie obiektu z planszy public void RemoveUsedObject(string name) { if (ExistsUsedObject(name)) { SingleObject obj = usedObjects[name]; usedObjects.Remove(name); if (selectedObject == obj) { selectedObject = null; } mainEngine.AddTextToLog("ObjectManager: usunieto z planszy obiekt " + name); } else { mainEngine.AddTextToLog("ObjectManager: nie istnieje na planszy obiekt do usuniecia " + name); // ... } }
// dodawanie obiektu 'na plansze' wg wspolrzednych Kinecta public void AddUsedObject(string name, double kx, double ky, double kz) { if (possibleObjects.ContainsKey(name)) { SingleObject obj = possibleObjects[name]; if (!ExistsUsedObject(name)) { obj.KinectMoveTo(kx, ky, kz); usedObjects.Add(name, obj); mainEngine.AddTextToLog("ObjectManager: dodano na plansze obiekt o nazwie " + name); } else { mainEngine.AddTextToLog("ObjectManager: na planszy juz istnieje obiekt o nazwie " + name); } } else { mainEngine.AddTextToLog("ObjectManager: nie obsluguje obiektu o nazwie " + name + " na pozycje (" + kx + "," + ky + "," + kz + ")"); } }
public void DeselectObject() { selectedObject = null; }
public void CreateNewPossibleObject(string type, string name, int width, int height) { SingleObject obj = new SingleObject(type, name, width, height); possibleObjects.Add(name, obj); }
public void AddPossibleObject(SingleObject obj) { if (obj != null) possibleObjects.Add(obj.GetObjectName(), obj); }
public void SelectObject(string name) { if (name != null && usedObjects.ContainsKey(name)) selectedObject = usedObjects[name]; else selectedObject = null; }
// usuwanie obiektu z planszy public void RemoveUsedObject(string name) { if (ExistsUsedObject(name)) { SingleObject obj = usedObjects[name]; usedObjects.Remove(name); if (selectedObject == obj) selectedObject = null; mainEngine.AddTextToLog("ObjectManager: usunieto z planszy obiekt " + name); } else { mainEngine.AddTextToLog("ObjectManager: nie istnieje na planszy obiekt do usuniecia " + name); // ... } }
void speechEngine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { const double ConfidenceThreshold = 0.3; if (e.Result.Confidence >= ConfidenceThreshold) { if (e.Result.Semantics.Value != null) { string semValue = e.Result.Semantics.Value.ToString(); switch (semValue) { case "CALIB_CALIBRATE": mainEngine.AddTextToLog("SpeechRec: " + semValue); if (mainEngine.GetAppState() == ApplicationState.Ready) { mainEngine.SetAppState(ApplicationState.Calibration); mainEngine.service.send(Orders.CALIBRATE); // no i komunikat do klienta... } else { // jakies inne przypadki? np. ponowna kalibracja czy cos... } break; case "CALIB_MARK": mainEngine.AddTextToLog("SpeechRec: " + semValue); if (mainEngine.GetAppState() == ApplicationState.Calibration) { mainEngine.GetCalibrator().SetNextCalibrationPoint( mainEngine.GetSkeletonController().GetRightHandCoord()); if (mainEngine.GetAppState() == ApplicationState.Calibrated) { mainEngine.AddTextToLog("skalibrowane"); mainEngine.service.send(Orders.DONE); } else if (mainEngine.GetAppState() == ApplicationState.Calibration) { mainEngine.service.send(Orders.MARK); } } else { // cos poszlo zle... } break; case "ONN_MOVE": mainEngine.AddTextToLog("SpeechRec: " + semValue); break; case "ONN_THERE": mainEngine.AddTextToLog("SpeechRec: " + semValue); if (mainEngine.GetAppState() == ApplicationState.Working) { mainEngine.GetObjectManager().SelectedMoveTo(mainEngine.GetSkeletonController().GetRightHandCoord()); // no i komunikat do klienta... } else { // ... } break; case "ONN_REMOVE": mainEngine.AddTextToLog("SpeechRec: " + semValue); if (mainEngine.GetAppState() == ApplicationState.Working) { if (mainEngine.GetObjectManager().GetSelectedObject() != null) { mainEngine.service.sendRemoveObject(mainEngine.GetObjectManager().GetSelectedObject().GetObjectName()); mainEngine.GetObjectManager().RemoveSelectedObject(); } // no i komunikat do klienta... } else { // ... } break; } } else { var semVal = e.Result.Semantics; if (semVal.ContainsKey("OWN_MOVE_NAME")) { mainEngine.AddTextToLog("SpeechRec: move " + semVal["OWN_MOVE_NAME"].Value); if (mainEngine.GetAppState() == ApplicationState.Working) { string name = semVal["OWN_MOVE_NAME"].Value.ToString(); mainEngine.GetObjectManager().MoveTo(name, mainEngine.GetSkeletonController().GetRightHandCoord()); SingleObject so = mainEngine.GetObjectManager().GetUsedObjectByName(name); if (so != null) { mainEngine.service.sendMoveObject(so.GetObjectName(), so.GetScreenCentroidPosition().Y, so.GetScreenCentroidPosition().X); } } else { // ... } } else if (semVal.ContainsKey("OWN_NEW_NAME")) { mainEngine.AddTextToLog("SpeechRec: new " + semVal["OWN_NEW_NAME"].Value); if (mainEngine.GetAppState() == ApplicationState.Working) { mainEngine.GetObjectManager().AddUsedObject(semVal["OWN_NEW_NAME"].Value.ToString(), mainEngine.GetSkeletonController().GetRightHandCoord()); SingleObject so = mainEngine.GetObjectManager().GetUsedObjectByName(semVal["OWN_NEW_NAME"].Value.ToString()); so.SetScreenPosition(mainEngine.GetCalibrator().ScaleKinectPositionToScreen(so.GetCentroidPosition())); mainEngine.service.sendCreateObject(so.GetObjectName(), so.GetObjectType(), so.GetScreenCentroidPosition().Y, so.GetScreenCentroidPosition().X); } else { // ... } } else if (semVal.ContainsKey("OWN_REMOVE_NAME")) { mainEngine.AddTextToLog("SpeechRec: remove " + semVal["OWN_REMOVE_NAME"].Value); if (mainEngine.GetAppState() == ApplicationState.Working) { mainEngine.GetObjectManager().RemoveUsedObject(semVal["OWN_REMOVE_NAME"].Value.ToString()); mainEngine.service.sendRemoveObject(semVal["OWN_REMOVE_NAME"].Value.ToString()); } else { } } } } }