我一直在使用holo-toolkit運行SpatialUnderstandingExample場景。無法弄清楚如何將我的物體放入場景中。我想用我自己的對象替換那些帶有默認值的小盒子。我怎樣才能做到這一點? 謝謝Hololens使用空間理解來放置對象
編輯:發現繪製框,但我如何推動我的對象呢?
edit2:終於推了一個對象的位置,但仍然是代碼是非常複雜的,它搞亂了我的對象的大小和形狀。將盡量使它乾淨整潔。
我一直在使用holo-toolkit運行SpatialUnderstandingExample場景。無法弄清楚如何將我的物體放入場景中。我想用我自己的對象替換那些帶有默認值的小盒子。我怎樣才能做到這一點? 謝謝Hololens使用空間理解來放置對象
編輯:發現繪製框,但我如何推動我的對象呢?
edit2:終於推了一個對象的位置,但仍然是代碼是非常複雜的,它搞亂了我的對象的大小和形狀。將盡量使它乾淨整潔。
自從我看過這個例子以來,我已經有一段時間了,所以希望我記得它的方法名稱是正確的。它包含一個「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;
}
我更新了我的問題請大家看看 – firativerson
幫我一個忙,發佈你的編輯2作爲一個新問題。我可以給你一些我如何處理這個問題的例子,我不想違反堆棧溢出規則,並在同一個問題中回答兩個不同的問題... –