使用 Hololens 从场景开始将对象放置到墙上
Place object to a wall from the start of the scene with Hololens
我正在使用适用于 Hololens 的混合现实工具包开发 un Unity 2017 场景,并且我想将我的所有对象放置在场景开始后墙壁或地板的不同部分。
我已经知道如何使用水龙头在环境中放置物体,但我希望它能够分析 space 并根据房间的形状将物体放置在墙壁或地板上。
谢谢!
您需要查看 Spacial Understanding parts of the MixedRealityToolkit(README 中链接了一个 Unity 包下载)。
我只是简单地玩了一下,因为它不适合我正在从事的项目,但是有一些很容易找到的 getting started 资源。
该软件包允许设备扫描固定体积 space(让用户决定将其周围环境的哪些部分用于应用程序),作为开发人员,您可以指定应用程序的最小体积大小需要。扫描后,随着 Spacial Understanding 开始分析扫描区域,许多查询功能变得可用,允许您作为开发人员找到平台、墙壁、地板等,以便您可以将对象放置在适当的位置:
The below object placement query is looking for a place to put a half meter cube on the edge of a surface, away from other previously place objects and near the center of the room.
List<ObjectPlacementRule> rules =
new List<ObjectPlacementRule>() {
ObjectPlacementRule.Create_AwayFromOtherObjects(1.0f),
};
List<ObjectPlacementConstraint> constraints =
new List<ObjectPlacementConstraint> {
ObjectPlacementConstraint.Create_NearCenter(),
};
Solver_PlaceObject(
“MyCustomObject”,
new ObjectPlacementDefinition.Create_OnEdge(
new Vector3(0.25f, 0.25f, 0.25f),
new Vector3(0.25f, 0.25f, 0.25f)),
rules.Count,
UnderstandingDLL.PinObject(rules.ToArray()),
constraints.Count,
UnderstandingDLL.PinObject(constraints.ToArray()),
UnderstandingDLL.GetStaticObjectPlacementResultPtr());
If successful, a “ObjectPlacementResult” structure containing the placement position, dimensions and orientation is returned. In addition, the placement is added to the dll’s internal list of placed objects. Subsequent placement queries will take this object into account. The “LevelSolver.cs” file in the Unity sample contains more example queries.
我正在使用适用于 Hololens 的混合现实工具包开发 un Unity 2017 场景,并且我想将我的所有对象放置在场景开始后墙壁或地板的不同部分。
我已经知道如何使用水龙头在环境中放置物体,但我希望它能够分析 space 并根据房间的形状将物体放置在墙壁或地板上。
谢谢!
您需要查看 Spacial Understanding parts of the MixedRealityToolkit(README 中链接了一个 Unity 包下载)。
我只是简单地玩了一下,因为它不适合我正在从事的项目,但是有一些很容易找到的 getting started 资源。
该软件包允许设备扫描固定体积 space(让用户决定将其周围环境的哪些部分用于应用程序),作为开发人员,您可以指定应用程序的最小体积大小需要。扫描后,随着 Spacial Understanding 开始分析扫描区域,许多查询功能变得可用,允许您作为开发人员找到平台、墙壁、地板等,以便您可以将对象放置在适当的位置:
The below object placement query is looking for a place to put a half meter cube on the edge of a surface, away from other previously place objects and near the center of the room.
List<ObjectPlacementRule> rules =
new List<ObjectPlacementRule>() {
ObjectPlacementRule.Create_AwayFromOtherObjects(1.0f),
};
List<ObjectPlacementConstraint> constraints =
new List<ObjectPlacementConstraint> {
ObjectPlacementConstraint.Create_NearCenter(),
};
Solver_PlaceObject(
“MyCustomObject”,
new ObjectPlacementDefinition.Create_OnEdge(
new Vector3(0.25f, 0.25f, 0.25f),
new Vector3(0.25f, 0.25f, 0.25f)),
rules.Count,
UnderstandingDLL.PinObject(rules.ToArray()),
constraints.Count,
UnderstandingDLL.PinObject(constraints.ToArray()),
UnderstandingDLL.GetStaticObjectPlacementResultPtr());
If successful, a “ObjectPlacementResult” structure containing the placement position, dimensions and orientation is returned. In addition, the placement is added to the dll’s internal list of placed objects. Subsequent placement queries will take this object into account. The “LevelSolver.cs” file in the Unity sample contains more example queries.