void clearAllMarkers() { List <int> keys = new List <int>(markerPoints.Keys); foreach (var key in keys) { MarkerUI markerUI = markerPoints[key]; GameObject.DestroyImmediate(markerUI.gameObject); MarkerGO markerGO = markerGOs[key]; GameObject.DestroyImmediate(markerGO.gameObject); } markerPoints.Clear(); markerGOs.Clear(); }
void CheckForClick() { if (Input.GetButtonDown("Fire1")) { RaycastHit hit; Ray ray = cam.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit, 10000, layerMask)) { Transform objectHit = hit.transform; // Do something with the object that was hit by the raycast. selectedMarker = objectHit.GetComponentInParent <Marker>(); if (selectedMarker != null) { if (markerUI == null) { markerUI = Instantiate(markerUiPrefab); markerUI.transform.SetParent(markerUiParent); } markerUI.DisplayName(selectedMarker.Title); markerUI.DisplayDate(selectedMarker.Date); } else { if (markerUI != null) { Destroy(markerUI.gameObject); } } } else { if (markerUI != null) { Destroy(markerUI.gameObject); } } } }
void Start() { markerUI = new MarkerUI(); markerPositions = new Dictionary <string, Vector3>(); // This one initilize the render marker to render the list of trackers written in the file alias_marker if (drawMarkers) { markerUI.InitMarkerRendering(); } mocapCaptureData = new List <MocapSample>(); fusedCaptureData = new List <FusedSample>(); handTemplate = new HandTemplate(); /* Marker IDs description: * 0 - Pinky base * 1 - Wrist * 2 - Index base * 3 - Ring fingertip * 4 - Pinky fingertip * 5 - Index fingertip * 6 - Middle fingertip * 7 - Thumb 2nd joint * 8 - Thumb fingertip */ /* * Specify the offsets for the alignment points. For instance, if the marker corresponding to the wrist is 3 cm above the wrist bone, you should define an offset of (-0.03, 0, 0). * This is not strictly necessary, but it helps with improving the precision (and allows the markers to be placed in arbitrary locations). * All coordinates are in object space. */ handTemplate.AddMarker("LEHAR", "l_pinky1", new Vector3(-0.01f, 0.0f, 0.0f), true); handTemplate.AddMarker("LEHAL", "l_wrist", new Vector3(-0.03f, 0.0f, 0.0f), true); handTemplate.AddMarker("WHARHAR", "l_index1", new Vector3(-0.01f, 0.0f, 0.0f), true); handTemplate.AddMarker("LRIF", "l_ring_tip", Vector3.zero); handTemplate.AddMarker("LBAF", "l_pinky_tip", Vector3.zero); handTemplate.AddMarker("LMIF", "l_index_tip", Vector3.zero); handTemplate.AddMarker("LINF", "l_middle_tip", Vector3.zero); handTemplate.AddMarker("LPAL", "l_thumb2", new Vector3(-0.01f, 0.0f, 0.0f)); handTemplate.AddMarker("LTHF", "l_thumb_tip", Vector3.zero); handTemplate.SetPivot("l_wrist"); handTemplate.SaveToFile(Constants.OutputDirectory + "\\hand.csv"); foreach (var marker in handTemplate.MarkerList) { markerPositions[marker] = handTemplate.GetInitialMarkerWorldPosition(marker); int j = markerUI.marker_alias_to_ids[marker]; markerUI.marker_positions[j, 0] = -markerPositions[marker].x; markerUI.marker_positions[j, 1] = markerPositions[marker].y; markerUI.marker_positions[j, 2] = markerPositions[marker].z; } markerUI.RenderMarkers(); jointPredictor = new JointPredictor("models/joint_model.bin", handTemplate); jointPredictor.AddJoint("l_index1", new Vector3(1, 1, 1)); jointPredictor.AddJoint("l_index2", new Vector3(0, 1, 0)); jointPredictor.AddJoint("l_index3", new Vector3(0, 1, 0)); jointPredictor.AddJoint("l_middle1", new Vector3(1, 1, 1)); jointPredictor.AddJoint("l_middle2", new Vector3(0, 1, 0)); jointPredictor.AddJoint("l_middle3", new Vector3(0, 1, 0)); jointPredictor.AddJoint("l_pinky1", new Vector3(1, 1, 1)); jointPredictor.AddJoint("l_pinky2", new Vector3(0, 1, 0)); jointPredictor.AddJoint("l_pinky3", new Vector3(0, 1, 0)); jointPredictor.AddJoint("l_ring1", new Vector3(1, 1, 1)); jointPredictor.AddJoint("l_ring2", new Vector3(0, 1, 0)); jointPredictor.AddJoint("l_ring3", new Vector3(0, 1, 0)); jointPredictor.AddJoint("l_thumb1", new Vector3(1, 1, 1)); jointPredictor.AddJoint("l_thumb2", new Vector3(1, 1, 0)); jointPredictor.AddJoint("l_thumb3", new Vector3(1, 0, 0)); occlusionManager = new OcclusionManager(handTemplate.MarkerList); occlusionManager.AddImplementation(new NaiveOcclusionPredictor()); }