The ModulePacker is where you collect togeather all of your content, add the script for interaction etc, try running it and finally submit the module to be published in the Imaginality Access Portal.
This page assumes you have installed the ModulePacker, and that you are adding some programming script to define interaction etc which will be used in the ModulePacker.
To learn mode about the ModulePacker, how to install it and how to use it, click here.
Or click here to download the Module Creation Tool (This link may only work through Internet Explorer).
Programming
Modules for Imaginality are written in the C# language. This is a language that runs on the .NET framework. If you have programmed in similar languages such as Java, you should have no problem with C#.
While the module creation tool does provide a very basic text editor, it is not intended for writing a complete module. It is only intended for quick changes and tweaking. When creating a module from scratch, it is highly recommended that you use a programming IDE. Two high quality, free IDEs available that support the C# language are:
Microsoft Visual C# 2005 Express Editionic#code SharpDevelop 2.0
Both of these IDEs can be downloaded from the web. The Microsoft IDE is more feature complete, however it is a larger download. For module creation, either IDE has more than enough features to ease module development.
To get started, a template project can be downloaded here (old for Visual Studio 2005, new for Visual Studio 2008, new for Visual Studio 2010). This project provides the starting point for the code needed to create a module.
After extracting the archive, open the 'project.sln' file. This solution is already setup for Visual Studio. SharpDevelop? supports .sln import, however it will not automatically open 'project.cs', which is the code file that will be edited.
There are two main points of interest.
Most importantly, is project.cs. This is the C# code file that will be edited, and later used in the module creation tool.
Secondly, there will be a 'References' project member. This is a list of the .NET assemblies (.dlls) that the project will link to. The default list should be 'Axiom.Mathlib', 'Imaginality.Unleashed.Core.Logic' and 'System'. The module creation tool will only link to these three assemblies when building a module. If you wish to view all the classes/interfaces an assembly makes available for you to use, simply double click on one of these assemblies. This is an easy way to discover the Imaginality API. Note that System is the default windows .NET assembly, so it will be quite large. Also note that for security reasons, significant areas of this assembly will not be accessible by the module at runtime (eg file system access).
You can also add these references manually. You might do this if you are not using the template project, or if you have started a project and then upgraded to a new version of the ModulePacker. Instructions to do this are at AddReferences.
The imaginality API has a number of interfaces and classes. The most important, is Module1, which represents version 1 of the Module abstract class. All modules built will inherit from this class, and in doing so, must override two methods. These methods are simply:
Initialise Process
The initialise method is called once, when the module starts. So all initialisation code should go in here. The Process method is called every rendered frame (eg, 30 times per second), it allows control of animations and logic for the module on a frame by frame basis.
The initialise method has a single input parameter, an interface to IPortalLoader1. IPortalLoader1 is the interface that describes everything the Portal software supports at load time. This interface allows loading of models, user interfaces, etc.
The Process method contains two input parameters, 'deltaTime', which is the number of seconds that has elapsed since the last frame (eg, 0.05 would be one twentieth of a second). This allows for timing of animation and logic. The second parameter is an IPortal1 interface. This interface exposes all the methods the portal software allows at runtime.
Note that a lot of method calls will return a different interface, which will provide extra functionality for the object created.
Simple Example
Loading a model, and placing it on paddle number 5: *When using this code in the Module Creation Tool, this example assumes there is a model named 'myModel.mesh' included as a resource.
The important method is 'AddModel' in the IPortalLoader interface. Adding a model is only a member of IPortalLoader, so it can only be done at load time.
The parameters of AddModel will be shown when writing it, thanks to IntelliSense. See IntelliSense to learn what it is, why it is so helpful, how to use it and reasons why it may not be working as expected.
The first parameter of AddModel is the name of the file, for this example 'myModel.mesh'.
AddModel allows you to optionally add a name to the model. This has no visual effect on the model, but can be a useful debugging tool. null may be used if a name is not desired.
Finally, the pattern to attach to must be specified. Currently "1" through "12" and "info" are supported.
When running the module in the Creation Tool, myModel.mesh will now appear on paddle 5.
However, to access the model, and change it's parameters, the interface reference must be kept. AddModel(...) returns an interface to an IModel1:
In the following example, two changes to the model are made.
First, when it is loaded, it's scale is divided by 2 (so it is half it's original size) And secondly, every frame, the model is rotated by N degrees around the xaxis, where N is the number of seconds elapsed. (So therefore, the model will rotate at 1 radian per second) This is a simple example of basic model logic.
In the ModulePacker, beside 'Module Script File', click on browse, point to your project.cs and click ok.
Note, that whenever you save changes in your code editor and switch back to the ModulePacker, it should notice there are changes and ask if you want to load these changes into the the script file in the ModulePacker.
Therefore, to test your code, it is quite easy to save your code, switch to the ModulePacker, click yes (or hit 'y') and click 'Run' (or hit space (if 'Run' was the last thing you clicked)).