Introduction: Starting your Plugin¶
Tutorial: WritingMy First VastParkPlugin
Summary: Learn how to develop a VastPark Plugin and use it in a virtual environment
Required Applications:VastPark Creator, VastPark Player, ImmlPad , Visual Studio
Created: 20 July 2011
The Plugin Framework¶
To ensure that VastPark Player can interact with your Plugin class, you will need to extend the PluginBase abstract class.
This class implements the IPluginComponent interface and the IParkObject interface. The IPluginComponent interface specifies a set of methods which are automatically called by the VastPark Player during certain events. A description of the methods enforced by the IPluginComponent interface can be found below.
IPluginComponent Interface:
public boolMyVariable { get; set; }
This is a property that is able to be set via a Parameter which is nested within a plugin. The Parameter tag is simply a <Key, Value> pair where Key is the property name and Value is the user defined value for that property. Below is an example of how to set the boolean property MyVariable.
1 <Plugin Name="Plugin.Example" Enabled="True" Source="Plugin.Example.plugin" >
2 <Parameter Key="MyVariable" Value="True">
3 </Plugin>
public void AddElement(ImmlElement element)
Elements passed into the plugin via <Element Name="SomeElement" /> appear here.
- In IMML
1 <Plugin Name="Plugin.Example" Enabled="True" Source="Plugin.Example.plugin" >
2 <Parameter Key="MyVariable" Value="True">
3 </Plugin>
- In plugin-side code
1 private ImmlElement _Element;
2 public void AddElement(ImmlElement element)
3 {
4 if(element.Name == "someElement")
5 {
6 _Element = element;
7 }
8 }
In the above example, "someElement" will be automatically passed into the AddElement() method by the VastPark Player.
public void Load()
This is the final step prior to the plugin being completely loaded. This is called after the plugin has been instantiated and all elements are added via AddElement(). Typically this method contains code to process IMML elements which were passed in to the Plugin.
public void Update()
This is called once each update cycle by the PluginManager, typically this is every ~17ms (60 updates per second)
public bool Enabled { get; set; }
This property can change at runtime, when it is false, the PluginManager will not call Update
public void Dispose()
Dispose is called when the user refreshes the current IMML document or navigates to another world. This method allows you to de-allocate unmanaged memory that may be in use and to release any other resources which the Plugin may be utilizing.
IParkObject Interface¶
For extended functionality within the VastPark API, you may wish to implement the IParkObject interface in your Plugin. By doing so, you can obtain access to the current running engines of the VastPark Player to build a more powerful and integrated Plugin. There is only one method to implement with this interface.
public void SetParkEngine(IParkEngine engine)
Should you choose to implement IParkObject, the VastPark Player will pass in the current IParkEngine object to your Plugin as it loads. With this, you are exposed to various internal utilities such as : NetworkClient, SoundEngine, ScriptEngine, RenderEngine, VideoEngine, UserCamera.
These are some basic methods found in Plugins. You can extend Plugins further, making your own public methods which can be triggered by scripts.
From here you should have some basic understanding of developing a VastPark Plugin and can move onto publishing.
(Follow this link to find out more about the plugin framework: http://www.vastpark.org/projects/vp/wiki/PluginFramework)