In order to access spatial information from the Voxel Farm, the application will have to create at least one instance of the “VoxelFarmView” class.


MyView = new VoxelFarm.VoxelFarmView();

 

The view object will connect to the server to request data based on user input and camera location. The application must provide the server information by calling the “SetServer” method:


MyView.SetServer(“http://localhost:3983”, “localhost”, 3333, false);

 

The first parameter is the URL for the server. If no port is included in the URL, port 80 will be assumed. HTTPS URLs are supported. The second and third parameter are the address and port for the Content Server. The last parameter indicates whether SSL should be used for the Content Server connection.


A single Voxel Farm deployment will host many different projects. The application must also define which project should be used by providing the project’s ID:


MyView.SetProjectId(“mytestprject001”);

 

At this point, we can ask the view to load the project’s information from the server. This is accomplished by calling the “LoadProject” method. This method takes an action function as a parameter, this action will be called when the project load operation completes:


MyView.LoadProject((HttpStatusCode code) =>
{
   // code contains a System.Net.HttpStatusCode for the result of the request
});

 

The “code” result parameter passed to the callback is the HTTP code returned by the server. If the server requires authentication and the default user credentials are rejected, this code will return HttpStatusCode.Unauthorized. In this case, the application can prompt the user for new credentials. To set the credentials, call the “SetCredentials” method:


MyView.SetCredentials(NewUserCredentials);

 

Note that it is necessary to call the “LoadProject” again, so the new credentials are used.