# View Configuration

<span class="rvts6">Once the project loads, the application must determine how to configure the client view. A single project may contain multiple datasets. Configuring the view in the client involves selecting which datasets should be used and how will they be combined and presented in the client.</span>

<span class="rvts6">There are two main ways to set up the client view:</span>

1. <span class="rvts6">Use a predefined View Entity in the project.</span>
2. <span class="rvts6">Create a new view definition on the client by instantiating view metadata.</span>

<span class="rvts6">It is possible to mix these two approaches, that is, load the metadata for a predefined view, further modify it on the client, and the using the modified metadata for the view.</span>

<span class="rvts6">  
</span>

##### <span class="rvts16">Using predefined views</span>

<span class="rvts6">The project may already contain a file entity of type “VIEW” that holds the desired configuration. The client allows to load any predefined view by calling:</span>

<table border="1" id="bkmrk-myview.setviewid%28%E2%80%9C53" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td><span class="rvts25">MyView.SetViewId(“539CE7EFAA1F4F0BA6CF037F936BF035”);</span></td></tr></tbody></table>

<span class="rvts27"> </span><span class="rvts6">Where the parameter is the ID for the view in the project’s entity model.</span>

<span class="rvts6">If this ID is unknown, it is possible to get a list of all available pre-defined views in a project. To do this the application may call the “GetEntities” function to the client view object:</span>

<table border="1" id="bkmrk-var-views-%3D-myview.g" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td><span class="rvts25">var views = MyView.GetEntities(VoxelFarm.VoxelFarmEntityType.View);</span></td></tr></tbody></table>

<span class="rvts27"> </span><span class="rvts6">The parameter is the type of entity to return. Only entities of that type will be returned by the function.</span>

<span class="rvts6">This function returns a list of dictionaries, where each dictionary represents a different entity in the project.</span>

<span class="rvts6">The application can use the “ID” key to obtain the unique identifier for the entity, in this case the view. This is the identifier that would be provided to the “SetViewId” function.</span>

<span class="rvts6">  
</span>

##### <span class="rvts16">Creating view metadata</span>

<span class="rvts6">The C# Client uses view metadata objects to describe how different datasets in a project can be combined.</span>

<span class="rvts6">The view metadata is always an instance of the “VoxelFarmViewMeta” class.</span>

<span class="rvts6">An instance of VoxelViewMeta will contain a list of inner components. Each component represents a different type of spatial data that should appear in the view. For instance, view that shows a terrain surface with ortho-imagery laid on top of it, would contain two different components: the terrain surface geometry and the ortho imagery set.</span>

<span class="rvts6">  
</span>

<span class="rvts6">All components inherit from the “VoxelFarmMetaComponent” class. The available components in this version are:</span>

1. <span class="rvts6">VoxelFarmMetaPointCloud. Used for point clouds.</span>
2. <span class="rvts6">VoxelFarmMetaSurface. Used for volumetric entities (terrain, block models, etc.) and indexed meshes.</span>
3. <span class="rvts6">VoxelFarmMetaOrthoImagery. Used to apply imagery to surfaces.</span>

<span class="rvts6">  
</span>

<span class="rvts6">The VoxelFarmMetaSurface class not only represents volumetric components, but also components that are the result of volumetric operations between components. To combine different surfaces into a single operation, use the “VoxelFarmMetaSurfaceOperation” class.</span>

<span class="rvts6">For volumetric surfaces that are not the result of surface operations, use the “VoxelFarmMetaLayerStack” class. An instance of this class represents a surface that is the result of multiple volumetric layers added together. The layers can be of any of the following types:</span>

1. <span class="rvts6">VoxelFarmMetaLayerHM. Represents voxel terrain.</span>
2. <span class="rvts6">VoxelFarmMetaLayerBM. Represents a voxelized block model.</span>
3. <span class="rvts6">VoxelFarmMetaLayerPython. Represents a Python voxel generator.</span>

<span class="rvts6">The following example creates view metadata for a terrain with ortho imagery applied to it and loads it into a client view object:</span>

<table border="1" id="bkmrk-var-components-%3D-new" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td><span class="rvts25">var components = new List&lt;VoxelFarmMetaComponent&gt;();</span>  
<span class="rvts25">var componentMasks = new List&lt;ushort&gt;();</span>  
<span class="rvts25">var images = new VoxelFarmMetaOrthoImagery {Id = item\["ID"\], Diffuse = hasOrtho, Normal = hasNormals, Config = item\["runtime"\] };</span>  
<span class="rvts25">components.Add(images);</span>  
<span class="rvts25">componentMasks.Add(0x01);</span>  
<span class="rvts25">var hmLayer = new VoxelFarmMetaLayerHM { Id = item\["ID"\], Config = item\["runtime"\] };</span>  
<span class="rvts25">List&lt;VoxelFarmMetaLayer&gt; layerStack = new List&lt;VoxelFarmMetaLayer&gt;();</span>  
<span class="rvts25">layerStack.Add(hmLayer);</span>  
<span class="rvts25">var layers = new VoxelFarmMetaLayerStack(layerStack);</span>  
<span class="rvts25">var surface = new VoxelFarmMetaSurfaceOperation { OpId = VoxelFarmMetaID.META\_OP\_NONE, OpA = layers, OpB = null, Images = images };</span>  
<span class="rvts25">components.Add(surface);</span>  
<span class="rvts25">componentMasks.Add(0x02);</span>  
<span class="rvts25">var viewMeta = new VoxelFarmViewMeta { Components = components, ComponentMasks = componentMasks };</span>  
<span class="rvts25">MyView.SetViewMetaData(viewMeta);</span></td></tr></tbody></table>

<span class="rvts16">  
</span>

##### <span class="rvts16">Getting metadata for a predefined view</span>

<span class="rvts6">  
</span>

<span class="rvts6">If required to modify a predefined view, without saving any changes to it on the server, the application may obtain a local copy of the view definition by calling the “GetViewMetaData” function:</span>

<table border="1" id="bkmrk-var-viewmetadata-%3D-m" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td><span class="rvts25">var viewMetaData = MyView.GetViewMetaData();</span></td></tr></tbody></table>

<span class="rvts6">The view metadata can then be set back into the client view by calling the “SetViewMetaData” function:</span>

<span class="rvts6">  
</span>

<table border="1" id="bkmrk-myview.setviewmetada" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td><span class="rvts25">MyView.SetViewMetaData(viewMetaData);</span></td></tr></tbody></table>