Custom User Data Types

 

About

Custom User Data Types, classes in particular, are used by the User Data Page.

These types are defined in XML files, typically named with a .userdatatypes.xml extension.

Names

When choosing names for your data, such as class names and data items, you should only use alphanumeric characters (A-Z, a-z, 0-9), '-', or '_'.

Sample

The following is a commented sample based on the Example.userdatatypes.xml file, which is included with the OgreMax Viewer.

<userDataTypes>
    <include file="Subdirectory/OtherExample1.userdatatypes.xml" /> (This is how other files are included)
    <include file="Subdirectory/OtherExample2" /> (If a file being included doesn't have an extension, it is assumed to be .userdatatypes.xml)
    <enum name="WeekDay" type="string"> (An enum is a collection of values. Valid types are: string, intX, floatX, bool, rgb, and rgba. The 'X' is optional - it can be 1,2,3 or 4)
        <enumItem name="Monday" value="mon" /> (intX, floatX, rgb, and rgba values are specified as comma separated values, for example "1.0,3,4")
        <enumItem name="Tuesday" value="tues" />
        <enumItem name="Wednesday" value="wed" />
        <enumItem name="Thursday" value="thu" />
        <enumItem name="Friday" value="fri" />
    </enum>
    <enum name="WeekendDay" type="string">
        <enumItem name="Saturday" value="sat" />
        <enumItem name="Sunday" value="sun" />
    </enum>
    <enum name="Day" type="string" super="WeekDay,WeekendDay"> (The 'super' attribute allows the enum to inherit from other enums)
        <enumItem name="Wednesday" value="wed" /> (This value overrides the value defined by WeekDay)
        <enumItem name="Thursday" value="thu" />
    </enum>
    <class name="LivingThing" displayName="Living Thing" usage="private"> (Private usage prevents the class from appearing on any User Data Page)
        <data name="Alive" displayName="Alive?" type="bool" defaultValue="true"/> (Default values may be specified)
        <data name="Age" type="int" defaultValue="0" minValue="0" maxValue="100" increment="1" visibilityParentName="Alive"/>
(Min, max and increment attributes are available for intX and floatX types)
        <data name="PositionInScene" displayName="Position In Scene" type="float3" minValue="-100000" maxValue="100000" increment=".01" visibilityParentName="Alive"/> (Data visibility in the dialogs and exported data can be controlled by a previously declared boolean/checkbox data item)
    </class>
    <class name="Human" super="LivingThing" usage="object"> (Object usage limits the class to appearing on the Object Settings User Data Page)
        <data name="FirstName" displayName="First Name" groupName="Name" type="string"/> (Values may be grouped together using the 'groupName' attribute)
        <data name="LastName" displayName="Last Name" groupName="Name" type="string"/>
        <data name="EyeColor" displayName="Eye Color" groupName="Colors" type="rgb"/>
        <data name="FavoriteColorWithAlpha" displayName="Favorite Color With Alpha" groupName="Colors" type="rgba" defaultValue="1,1,1,1" />
        <data name="Biography" type="string" groupName="Stuff" editWidth="200" editHeight="100" /> (String values can specify the dimensions of the edit control)
        <data name="Interests" type="string" groupName="Stuff" editWidth="200" editHeight="100" />
        <data name="FavoriteDay" displayName="Favorite Day" type="Day" defaultValue="sat"/>
    </class>
    <class name="Dog" usage="object">
        <data name="FurColor" displayName="Fur Color" type="rgb"/>
    </class>
    <class name="DogHuman" displayName="Dog Human" super="Dog,Human" usage="object"> (The 'super' attribute allows the class to inherit from other classes)
        <data name="TwoNumbers" displayName="Two Numbers" type="float2" controlType="edit"/>
    </class>
    <class name="SceneSettings" displayName="Scene Settings" usage="scene"> (Scene usage limits the class to appearing on the Scene Settings User Data Page)
        <data name="Introduction" type="string" editWidth="200" editHeight="100" />
        <data name="Conclusion" type="string" editWidth="200" editHeight="100" />
    </class>
    <class name="MaterialSettings" displayName="Material Settings" usage="material"> (Material usage is for the OgreMax material)
     <data name="Sound" type="string" />
     <data name="Friction" type="float" minValue="0" maxValue="100"/>
    </class>
</userDataTypes>

Integration with the User Data Page

Once the User Data Type files have been configured in the User Data Class Settings Dialog, classes will appear in the User Data Class list. After selecting a class, controls will be displayed to allow the class data to be modified: