3es
0.7
|
The 3rd Eye Scene protocol is extensible and allows for user defined messages. Writing 3rd Eye Scene handles for user messages requires authoring of a viewer plugin. Viewer plugins are .Net DLLs which include derivations of the Tes.Runtime.MessageHandler
for dealing with user messages.
Most MessageHandler
implementations deal with 3D objects; primitives, meshes and text. However, some message handlers deal with other types of data. The CategoriesHandler
for example, manages the names of and links between categories and has 3D representation. User messages may follow either pattern, depending on the need.
For example, in games, user messages may be used to visualise an agent's game attributes in a single message. Health, primary AI state, ammunition, etc. may be collated into a much smaller single message as opposed to using multiple text messages.
To author a 3rd Eye Scene plugin;
Tes.Runtime.MessageHandler
GameObject
to act as a root for all objects created by this handler.MessageHandler.Initialise()
add the handler's root GameObject
either to:root
if the handler's object transformation coordinates are in the server's coordinate frame, orserverRoot
if the handler's object transformation coordinates are in Unity's coordinate frameCopy the DLL to the viewer's plugin directory (create this directory alongside the executable).
See Referencing Unity Engine for guidelines on referencing UnityEngine.dll
The 3esRuntime library serves an example of how to reference the UnityEngine dll in a cross platform way. This relies on a few assumptions:
UNITY_DLL_PATH
environment variable to locate the DLL when possibleA discussion of MSBuild files is beyond the scope of this documentation, other than to note that both Visual Studio and Xamarin Studio use MSBuild files to control compilation and both support conditional blocks.
Essentially, 3esRuntime.csproj references UnityEngine.DLL via the XML code below. The same code can be used to reference the DLL in other .Net project files. Be aware that this code must be manually edited into the project file as Visual Studio and Xamarin Studio do not support creating conditional statements via the UI, but do respect them on reading such project files.
The build guidelines above illustrate how to integrate a user plugin into a pre-built version of the 3rd Eye Scene viewer. To facilitate debugging and testing, it is recommended that user plugin DLLs are added to the 3rd Eye Scene viewer Unity project instead. Build the DLL as described above, then copy the DLL into the viewer Assets folder under: Assets/plugins
. Unity will automatically include this DLL while running under in the Unity editor and on building the project.
There is an alternative way to author custom MessageHandler
implementations. In this option, the custom handlers are packaged as part of the 3rd Eye Scene viewer as a customised viewer build. This may be more convenient when distribution is tightly controlled and provides an simpler workflow.
MessageHandler
objects within this project.It is recommended that the viewer executable name is changed in these circumstances, to reflect the custom build to avoid confusion with the default 3rd Eye Scene viewer application.
An example plugin project and program are provided as part of the C# core libraries. To see the plugin in in effect: