Models and Geometries
Models
Model messages are structured to embed the geometry as this is a 1:1 relationship. The materials are referenced as this is a many to many relationship, the same material could be used in many models. A full discussion of materials is here.
The protobuf message is:
message Model {ModelReference ModelReference = 1;string Name = 2;Geometry Geometry = 3;map<int32, MaterialReference> MaterialReferences = 6;}
Reading Models
Reading models is done via the ReadModels
rpc.
This can be batched, it is recommended to read the models you need when loading the scene, with FatModels
set to true.
message ReadModelsRequest {StudioReference StudioReference = 1;ProjectReference ProjectReference = 2;bool FatModels = 3;repeated ModelReference Include = 4;Platform PlatformType = 5;}
The response will contain not only the models with their embedded geometries, but also any materials and logic graphs that you will need. These will come back in the following response:
message ReadModelsResponse {repeated Model Models = 7;repeated Material Materials = 8;repeated LogicGraph LogicGraphs = 9;}
You will then be able to pull out each part of the data and construct the complete object from the response message.
Geometries
The Geometry is based on lists of vertices, edges and faces. Each vertex message contains all the information that the vertex needs.
message Geometry {repeated Vertex Vertices = 3;repeated Face Faces = 6;repeated Edge Edges = 7;CoordinateType CoordinateType = 8;map<int32, string> UVMapNames = 9;}
With the following component parts.
message Vertex {Vector3 Position = 1;Vector3 Normal = 2;map<int32, Vector2> UV = 3;}
message Edge {repeated int32 Indices = 1;}
message Face {repeated int32 Indices = 1;int32 MaterialIndex = 3;}