负载AR模型,通过按钮水龙头的Andr​​oid [英] Load AR-model through button tap in Android

查看:194
本文介绍了负载AR模型,通过按钮水龙头的Andr​​oid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Unity与放一个基本的AR-应用; Vuforia并将其导出到Android,这样我就可以增加一些活动出现。当我扫描与AR-摄像机在应用程序中的图像,模型弹出。没有新那里。

I have made a basic AR-app using Unity & Vuforia and exported it to Android, so I can add some activities there. When I scan the image with the AR-camera in the app, a model pops up. Nothing new there.

我想实现什么,是当用户点击某个活动的一个按钮,可以说按钮上的文字是大象的AR-相机应用程序打开时,扫描图像,并加载模型大象。

What I want to achieve, is that when a user taps a button in some activity, lets say the text on the button is "Elephant", the AR-camera in the app opens, scans the image and loads a model of an Elephant.

我的问题是:这可能吗?是否有可能加载根据用户输入一个模型?如果这是可能的,什么是搜索一些关于它的文档最好的地方?我已经在互联网上搜索,但无法找到任何这种特定的。我也新到团结和放大器; Vuforia,所以我不知道很多有关程序。只有东西一些教程包括在内。

My question is: is this possible? Is it possible to load a model depending on the user-input? And if this is possible, what would be the best place to search for some documentation about it? I've already searched on the internet, but can't find anything this specific. I'm also new to Unity & Vuforia, so I don't know that much about the program. Only the things some tutorials covered.

我的道歉,如果这个问题已经被问/回答。

My apologies if this question has already been asked/answered.

在此先感谢!

推荐答案

嗯,是的,它是可能的。而为了让您的应用程序真正使用的AR功能,您可以实现虚拟按键技术。

Well, yes it is possible. And to make your app really use the AR feature you can implement the Virtual Button technique.

说实话,当它涉及到的文档,高通也没用。但由于使用统一的Vuforia扩展,最大特点是幸运的统一文档中。

Honestly, when it comes to documentation, Qualcomm is useless. But since you use Unity with the Vuforia Extension, most features are luckily within the Unity Documentation.

我将解释如何,你可以通过两种方式实现这一点:

I'll explain how you can achieve this in two ways:

1。使用虚拟按键(VB)

首先,通过添加/从删除一个VB冒头资产和GT开始,高通> prefabs>虚拟按钮。确保VB是目标使用的图像的孩子。

First off, start by adding/dropping a VB onto the scene from Assets>Qualcomm>Prefabs>Virtual Button. Make sure the VB is a child of the Image Target used.

创建,它定义了你的VB需要做的图像目标一个新的脚本。

Create a new script for the Image Target that defines what your VB needs to do.

您将开始与注册键:

void Start () {
        VirtualButtonBehaviour[] vbs = transform.GetComponentsInChildren<VirtualButtonBehaviour> ();

        for (int i=0; i < vbs.Length; ++i) {
            vbs[i].RegisterEventHandler(this);
        }

现在你继续前进,并开始与按钮的功能

And now you go ahead and start with the function of the button

public void OnButtonPressed(VirtualButtonAbstractBehaviour vb){
    //specify which button you want to function by using the if statement
    if(vb.name=="ButtonName") { callButtonfunction();}
    }

如果同样你想有一个按钮,做一些关于发布

Similarly if you want a button to do something on release:

public void OnButtonReleased(VirtualButtonAbstractBehaviour vb){
    //specify which button you want to function by using the if statement
    if(vb.name=="ButtonName") { callButtonfunction();}
    }

如果你希望你的按键来控制游戏物体,然后继续前进,并宣布游戏对象作为类中的公共变量,以便它可以在检查进行访问,并相应分配。

In case you want your button to control a Gameobject, then go ahead and declare the GameObject as a public variable in the class so that it can be accessed in the Inspector and assigned accordingly.

public GameObject human;

如果游戏对象是变量类型,人类是,我们将其作为参考变量名

Where GameObject is the variable type and human is the variable name that we use for reference

现在再次,根据你想获得什么,有什么赋予了 callbuttonfunction()可以做两种方式。

Now again, as per what you're trying to gain, there are two ways of assigning what the callbuttonfunction() can do.

  • Application.LoadLeve(Levelname)

这其中,加载新的对象被加载到同一个图像目标

This loads a new scene where the new object is loaded onto the same Image Target

  • Model.enabled(假) Elephant.enabled(真)

这只是禁用当前模型并启用了Elepant模型。 在你的课程开始,这些设置为公共变量会更容易分配在检查元素的车型。

This simply disabled the current model and enabled the Elepant Model. Setting these to public variables at the start of your class will make it easier to assign the models within Inspect element.

2。屏幕上的按钮(OB)

  • 如果你想在屏幕上的按钮,然后就家长按钮UI将相机和位置在屏幕或东西的特定角落。
  • 现在,如果功能按钮,它会在无效更新()键,你可以使用从的 统一 使用触摸功能。
  • If you want on-screen buttons, then just parent the button UI to the Camera and position in a particular corner of the screen or something.
  • Now if you function the button it will be within void Update() and you could use the scripting reference from Unity using the touch functions.

真希望这可以帮助你和其他人谁患有   绝对没有支持高通。   如果你需要更多的澄清打我。

Really hope this helps you and everyone else who suffers from absolutely NO support from Qualcomm. Hit me up if you need more clarification.

这篇关于负载AR模型,通过按钮水龙头的Andr​​oid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆