Specifying additional attributes

While it is often quickest to just allow Coden to translate a native function or class into a plug-in sometimes you might want to add extra information to them. To make your plug-in more user friendly and generally useful Coden contains a set of attributes that can be applied to each plug-in and its parameters.

All of these attributes are located inside the Ephere.Modeling.Attributes namespace.

Pluggable attribute

Pluggable attribute has two functions- it marks a class or function as a plug-in for Coden to scan and it also specifies some additional parameters such as a user-friendly, localized, plug-in title.

[Pluggable( Title = "Ephere Mesh Generator!" )]
public PolygonMesh3 MeshGenerator( float width, float height, bool flag )
  • Title parameter allows you to specify a user-friendly name for your plug-in. It can contain spaces and Unicode characters

Input attribute

Input attribute has two functions: first, to explicitly mark a parameter as an input (as opposed to an output) and, second, to provide additional information about an input. Consider the following example:

public PolygonMesh3 MeshGenerator(
	[Input( Title = "Mesh Width", Category = "Dimensions", Default = 10.0f, Minimum = 0.0f, Maximum = 99.0f, AffectsOutputs = new string[] { "output" } )]
	float width,
	[Input( Title = "Mesh Height", Category = "Dimensions", Default = 10.0f, Minimum = 0.0f, Maximum = 99.0f )]
	float height,
	[Input( Title = "Optional Flag", Category = "Flags", Default = true )]
	bool flag )

Each function argument has an Input attribute specified along with it. This attribute tells Coden that following argument is meant to be an input and provides additional information about the argument.

  • Title property specifies a localized user-friendly title of the input
  • Category property allows you to group inputs together into categories
  • Default property specifies a default value of the input
  • Minimum property specifies a minimum value (only applies to float, double, and integer inputs)
  • Maximum property specifies a maximum value (only applies to float, double, and integer inputs)
  • AffectsOutputs property explicitly provides a list of outputs that depend on this input. If not specified it is assumed that all outputs are affected.

Output attribute

Output attribute allows you to explicitly specify a field, property, or a parameter as an output. For example:

public PolygonMesh3 MeshGenerator( float width, float height, [Output( Title = "Optional Flag" )] out bool flag )

Here we have two function arguments acting as inputs and one out argument. Because it is marked with an out keyword, Coden will automatically scan it as an output. However, we can also provide some additional data about it such as its user-friendly title.

Input and output groups and tags

Coden plug-ins are defined as a set of inputs and outputs. These, in turn, specify the type of the plug-in, its parameters, and what it produces as a result. In the simplest scenario a parameter is defined using a name and its type. For example, if you want to accept a polygon mesh as an input for your plug-in, you specify PolygonMesh3 input type and give it some name.

However, many times a need arises to pass additional information along with a parameter. For example, you might want to also accept texture coordinates for a PolygonMesh3 input. Inside Coden texture coordinates are provided as a separate polygon mesh input. You, therefore, need to group the two ports, one for the mesh data and one for texture coordinates, to specify that this information represents the same input. This can be done by using named input groups.

To use an input group add a Group parameter with a name unique for that group inside the Input attribute placed on your function argument or class member. Multiple inputs can be grouped by reusing the same group name. For example, the mesh and texture coordinate example described above can be presented as:

Note that there is also an additional Tags parameter for the Input attribute. Tags allow you to specify the function of each input or output within a group. In the above example we mark that input to produce texture coordinates by assigning it the "textureCoordinates" tag.

The exact same logic is applied to outputs. So, consider an example where you want to produce an object with a mesh and its texture coordinates:

Tags can also be used to specify special inputs such as the current scene time:

Please read the tags reference for a full list of tags which can be specified within a port group.