public AugmentedModel spawnAugmentedModel(int modelId, Trackable b) { GameObject obj = _modelManager.createModel(modelId, true); AugmentedModel model = obj.AddComponent <AugmentedModel>(); model.setBase(b); model.setModelId(modelId); return(model); }
public void handleTouchInput() { foreach (Touch touch in Input.touches) { if (touch.phase == TouchPhase.Began) { Ray ray = Camera.main.ScreenPointToRay(touch.position); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { GameObject g = hit.collider.gameObject; AugmentedModel m = g.GetComponent <AugmentedModel>(); if (m != null) { _activeModel = m; } } } if (touch.phase == TouchPhase.Moved) { if (_activeModel != null) { float rotAmt = touch.deltaPosition.x; float scaleAmt = touch.deltaPosition.y; if (Mathf.Abs(rotAmt) > Mathf.Abs(scaleAmt)) { _activeModel.rotateRight(rotAmt * touch.deltaTime); } else { _activeModel.scale(scaleAmt * touch.deltaTime * 0.009f); } } } if (touch.phase == TouchPhase.Ended) { _activeModel = null; } } }
public void checkImagesAndSpawnModels() { List <AugmentedImage> trackedImages = new List <AugmentedImage>(); Session.GetTrackables <AugmentedImage>(trackedImages, TrackableQueryFilter.All); foreach (AugmentedImage img in trackedImages) { if (img.TrackingState == TrackingState.Tracking) { int modelId = int.Parse(img.Name); if (!_spawnedModels.ContainsKey(modelId)) { AugmentedModel m = spawnAugmentedModel(modelId, img); _spawnedModels.Add(modelId, m); } } } }
public void setControlle(AugmentedModel m) { _controlle = m; }