Last active
October 1, 2017 07:22
-
-
Save TakahiroMiyaura/075fd124df17303dfcc85883403e0ebe to your computer and use it in GitHub Desktop.
UrhoSharpで作るHoloLens用の積木アプリ - SpatialMappingと簡単なイベント ref: http://qiita.com/miyaura/items/00447014492ea3562f65
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright(c) 2017 Takahiro Miyaura | |
// Released under the MIT license | |
// http://opensource.org/licenses/mit-license.php | |
public override void OnSurfaceAddedOrUpdated(SpatialMeshInfo surface, Model generatedModel) | |
{ | |
var isNew = false; | |
StaticModel staticModel = null; | |
//check already created by Id. | |
var node = environmentNode.GetChild(surface.SurfaceId, false); | |
if (node != null) | |
{ | |
//get StaticModel. | |
staticModel = node.GetComponent<StaticModel>(); | |
} | |
else | |
{ | |
//if it is new,create node. | |
isNew = true; | |
node = environmentNode.CreateChild(surface.SurfaceId); | |
staticModel = node.CreateComponent<StaticModel>(); | |
} | |
node.Position = surface.BoundsCenter; | |
node.Rotation = surface.BoundsRotation; | |
staticModel.Model = generatedModel; | |
if (isNew) | |
{ | |
//set collisionShape. | |
staticModel.SetMaterial(spatialMaterial); | |
var rigidBody = node.CreateComponent<RigidBody>(); | |
rigidBody.RollingFriction = 0.5f; | |
rigidBody.Friction = 0.5f; | |
var collisionShape = node.CreateComponent<CollisionShape>(); | |
collisionShape.SetTriangleMesh(generatedModel, 0, Vector3.One, Vector3.Zero, Quaternion.Identity); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright(c) 2017 Takahiro Miyaura | |
// Released under the MIT license | |
// http://opensource.org/licenses/mit-license.php | |
using System; | |
using Windows.ApplicationModel.Core; | |
using Urho; | |
namespace UrhnoBlockStackingSamples | |
{ | |
internal class Program | |
{ | |
[MTAThread] | |
private static void Main() | |
{ | |
var appViewSource = new UrhoAppViewSource<BlockStackingSamples>(); | |
CoreApplication.Run(appViewSource); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment