2016-11-21 14 views
0

我一直在使用holo-toolkit运行SpatialUnderstandingExample场景。无法弄清楚如何将我的物体放入场景中。我想用我自己的对象替换那些带有默认值的小盒子。我怎样才能做到这一点? 谢谢Hololens使用空间理解来放置对象

编辑:发现绘制框,但我如何推动我的对象呢?

edit2:终于推了一个对象的位置,但仍然是代码是非常复杂的,它搞乱了我的对象的大小和形状。将尽量使它干净整洁。

+0

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

回答

1

自从我看过这个例子以来,我已经有一段时间了,所以希望我记得它的方法名称是正确的。它包含一个“DrawBox”方法,在成功调用来获取空间理解位置后调用。创建该对话框中的调用看起来是这样的:

DrawBox(toPlace, Color.red); 

替换该呼叫满足以下(假设“toPlace”包含了从空间理解调用的结果和“模型”包含你正在试图把那里的模型):

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; 
} 
+0

我更新了我的问题请大家看看 – firativerson