private void Ray(Camera3D activeCamera, TouchLocation touchLocation) { // Creates Ray from Touch 2D position _nearPosition.X = touchLocation.Position.X; _nearPosition.Y = touchLocation.Position.Y; _nearPosition.Z = 0.0f; _farPosition.X = touchLocation.Position.X; _farPosition.Y = touchLocation.Position.Y; _farPosition.Z = 1.0f; // Unproject Mouse Position _nearPosition = activeCamera.Unproject(ref _nearPosition); _farPosition = activeCamera.Unproject(ref _farPosition); // Update ray. Ray launched from nearPosition in rayDirection direction. _rayDirection = _farPosition - _nearPosition; _rayDirection.Normalize(); _ray.Direction = _rayDirection; _ray.Position = _nearPosition; foreach (Entity entity in this.Owner.Scene.EntityManager.FindAllByTag("touchable")) { _entityBoxCollider = entity.FindComponent <BoxCollider3D>(); if (_entityBoxCollider != null) { _materialComponent = entity.FindComponent <MaterialComponent>(); _collisionResult = _entityBoxCollider.Intersects(ref _ray); if (_collisionResult.HasValue) { PushpinTapped?.Invoke(this, new PushpinTappedEventArgs(entity.Name)); } } } }
private static void OnPushpinTapped(object sender, PushpinTappedEventArgs e) { PushpinTapped?.Invoke(sender, e); }