Realidade Aumentada e Unity3D Allan Oliveira. Começando...(veja a apresentacao em tela cheia) ...
Transcript of Realidade Aumentada e Unity3D Allan Oliveira. Começando...(veja a apresentacao em tela cheia) ...
Realidade Aumentada e Unity3DAllan Oliveira
Começando...(veja a apresentacao em tela cheia)
Abram a Unity3D Criem um projeto novo Importem o Vuforia 3.0 para o novo projeto
vuforia-unity-android-ios-3-0-9.unitypackage Caso não tenha procure por Unity Extension -
Vuforia v3.0, cadastre no site e faça o download Baixem projetos conceitos para olharmos se
sobrar tempo https://developer.vuforia.com/resources/sample-
apps/features
Vamos criar nossos próprios marcadores? Acessem o site https://
developer.vuforia.com/resources/dev-guide/target-manager-user-guide
Registre-se caso ainda não tenha feito Clique no menu superior “Target
Manager” Criem um novo Database Add new Target
Meu modelo de Target
Criando os próprios marcadores
No gerenciador de Targets, é possivel explorar cada Target criado e ver quao rastreavel ele é em estrelas de 1 a 5
O site tmb da dicas de como melhorar o seu marcador ou que tipo de marcador criar, e na opcao Show Features é possivel ver o seu Target pelo algoritmo de reconhecimento de padroes do Vuforia
Com o Target criado... Baixe o Target para seu computador, e
importe ele no projeto da Unity
Hora de começar a diversão!
Revisao rapida de Unity Interface da Unity
Oque é um Transform? Oque é um Gameobject? Oque é uma Camera?
Começando: Delete a Main Camera na cena Coloque na cena o Prefab ARCamera
Path: Qualcomm Augmented Reality\Prefabs\ARCamera Do manual: “The ARCamera is responsible for rendering the
camera image in the background and manipulating scene objects to react to tracking data”
Configurando a Webcam do PC
Como o tempo é curto, vamos fazer os testes no PC. Porem o plugin foi feito para Android e iOS
Configurando o marcador (Target)
Criando um simples objeto 3D para ser renderizado Crie um cubo Coloque ele como filho do ImageTarget Ajuste sua posição e tamanho
O gerenciador de rastreamento: TrackableEventHandler The Default Trackable Event Handler
(DefaultTrackableEventHandler) is a script component of the Image Target that causes the cube you just drew to appear or disappear automatically – an automatic reaction to the appearance of the target in the video.
You can override this default behavior – one could also imagine playing a fade-out animation, showing an info screen or playing a sound for example. For a more detailed description of the ITrackableEventHandlerinterface, please see 'Responding to Tracking Events' in here: https://developer.vuforia.com/resources/dev-guide/special-
options-unity
Se tivermos tempo...Vamos criar botões virtuais!!!
Importe o projeto VirtualButtons
Abre a cena Vuforia-VirtualButtons Path: Qualcomm Augmented Reality\Scenes\
Vuforia-VirtualButtons
Fazer as trocas necessárias para usar o marcador de escolha Ou somente salve a imagem do
marcador desse projeto no seu celular e mostra para a câmera. \Editor\QCAR\ImageTargetTextures\
StonesAndWood\wood_scaled
Restrições Virtual buttons work only with image targets, and not with
frame markers or multi-targets. Virtual buttons need to cover an area of the target that
includes detectable features. Create a new virtual button for a given image target at
runtime by calling the CreateVirtualButton member function on the corresponding instance of your ImageTargetBehaviour. Note: The position and size arguments are defined in the local
image target space. Destroy a virtual button by calling DestroyVirtualButton,
which is also defined inImageTargetBehaviour. Note: Because of swappable databases, the database must be
deactivated before creating a virtual button.
Código de exemplo para criar um botão novo em runtime// Deactivate the current data setImageTracker imageTracker = (ImageTracker) TrackerManager.Instance.GetTracker<ImageTracker>();//Here we assume that the first active data set contains the image targetDataSet dataSet = imageTracker, GetActiveDataSets().First();imageTracker.DeactivateDataSet(myDataSet); // Create a virtual buttonImageTargetBehaviour itb = GetComponent<ImageTargetBehaviour>();VirtualButtonBehaviour vbb = itb.CreateVirtualButton("mybutton", new Vector2(0, 0), new Vector2(0.1f, 0.1f)); // Register an event handler// Here we assume this class extends IVirtualButtonEventHandlervbb.RegisterEventHandler(this); // Reactivate the datasetimageTracker.ActivateDataSet(myDataSet);