Obuka
Modul
Render a 3D model with Azure Remote Rendering - Training
Use Azure Remote Rendering to render a 3D model in a Unity project. You can deploy the model to HoloLens 2 or use the power of mixed reality with the MRTK.
Ovaj preglednik više nije podržan.
Prijeđite na Microsoft Edge, gdje vas čekaju najnovije značajke, sigurnosna ažuriranja i tehnička podrška.
Meshes are immutable shared resources that can only be created through model conversion. Meshes are used for rendering but also to provide a physics representation for ray cast queries. To place a mesh in 3D space, add a MeshComponent to an Entity.
There are two distinct types of mesh resources in ARR: Triangular meshes and point clouds. Both types are represented by the same API class Mesh
. Except for minor differences in behavior for the distinct mesh types, the exposed API functionality is identical.
The conversion service automatically determines the appropriate mesh type by source file extension. For example, an FBX file is always converted as a triangular mesh, whereas PLY is treated as a point cloud. For the complete list of supported file formats, refer to the list of source file formats.
There are two significant user-facing differences between point cloud- and triangular mesh conversions:
The Mesh
class properties are:
Materials: An array of materials. Each material is used by a different submesh. Multiple entries in the array may reference the same material. Entries in this array can't be changed at runtime, however the material properties can. For point clouds, this array is empty.
Bounds: A local-space axis-aligned bounding box (AABB) of the mesh vertices.
The MeshComponent
class is used to place an instance of a mesh resource. Each MeshComponent references a single mesh. It may override which materials are used to render each submesh.
Mesh: The mesh resource that is used by this component.
Materials: The array of materials specified on the mesh component itself. The array will always have the same length as the Materials array on the mesh resource. Materials that shall not be overridden from the mesh default, are set to null in this array.
UsedMaterials: The array of actually used materials for each submesh. Will be identical to the data in the Materials array, for non-null values. Otherwise it contains the value from the Materials array in the mesh instance. This array is read-only.
A Mesh
resource can be shared across multiple instances of mesh components. Furthermore, the Mesh
resource that is assigned to a mesh component can be changed programmatically at any time. The code below demonstrates how to clone a mesh:
Entity CloneEntityWithModel(RenderingConnection api, Entity sourceEntity)
{
MeshComponent meshComp = sourceEntity.FindComponentOfType<MeshComponent>();
if (meshComp != null)
{
Entity newEntity = api.CreateEntity();
MeshComponent newMeshComp = api.CreateComponent(ObjectType.MeshComponent, newEntity) as MeshComponent;
newMeshComp.Mesh = meshComp.Mesh; // share the mesh
return newEntity;
}
return null;
}
ApiHandle<Entity> CloneEntityWithModel(ApiHandle<RenderingConnection> api, ApiHandle<Entity> sourceEntity)
{
if (ApiHandle<MeshComponent> meshComp = sourceEntity->FindComponentOfType<MeshComponent>())
{
ApiHandle<Entity> newEntity = *api->CreateEntity();
ApiHandle<MeshComponent> newMeshComp = api->CreateComponent(ObjectType::MeshComponent, newEntity)->as<RemoteRendering::MeshComponent>();
newMeshComp->SetMesh(meshComp->GetMesh()); // share the mesh
return newEntity;
}
return nullptr;
}
Obuka
Modul
Render a 3D model with Azure Remote Rendering - Training
Use Azure Remote Rendering to render a 3D model in a Unity project. You can deploy the model to HoloLens 2 or use the power of mixed reality with the MRTK.