【问题标题】:Hololens Placing Objects With Spatial UnderstandingHololens 放置具有空间理解的对象
【发布时间】:2016-11-21 19:48:44
【问题描述】:

我一直在运行 holo-toolkit 中的 SpatialUnderstandingExample 场景。无法弄清楚如何将我的对象放入场景中。我想用我自己的对象替换那些默认的小盒子。我怎样才能做到这一点? 谢谢

编辑:找到了绘图框,但我如何将我的对象推到那里?

edit2:最终将一个对象推到该位置,但代码仍然非常复杂,它弄乱了我的对象的大小和形状。会尽量让它干净整洁。

【问题讨论】:

  • 帮我一个忙,并将您的编辑 2 作为新问题发布。我可以给你一堆我如何处理的例子,我不想违反堆栈溢出规则并在同一个问题中回答两个不同的问题......

标签: hololens


【解决方案1】:

我已经有一段时间没有看过那个例子了,所以希望我能正确记住它的方法名称。它包含一个“DrawBox”方法,在成功调用以从空间理解中获取位置后调用该方法。创建框的调用如下所示:

DrawBox(toPlace, Color.red);

将此调用替换为以下内容(假设“toPlace”包含空间理解调用的结果,“model”包含您尝试放置的模型):

var rotation = Quaternion.LookRotation(toPlace.Normal, Vector3.up);

// Stay center in the square but move down to the ground
var position = toPlace.Postion - new Vector3(0, RequestedSize.y * .5f, 0);

// instantiate the hologram from a model
GameObject newObject = Instantiate(model, position, rotation) as GameObject;

if (newObject != null)
{
     // Set the parent of the new object the GameObject it was placed on
     newObject.transform.parent = gameObject.transform;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-08-24
    • 1970-01-01
    • 1970-01-01
    • 2017-07-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多