Changes

Jump to navigation Jump to search

Documentation/Engine/Units

4,064 bytes added, 13:14, 14 January 2016
Created page with "=What is unit?= Units are objects in Prism3d that have ability to be serialized or deserialized. Units has: * Name - units can be nameless or have some specified name names..."
=What is unit?=

Units are objects in Prism3d that have ability to be serialized or deserialized.

Units has:

* Name - units can be nameless or have some specified name names are divided into<br />
components which are 12-char tokens separated by dot - for example correct<br />
unit name will be <code>vehicle.dummy.truck however</code> in most cases you should not use<br />
them as in case engine detects two units with the same name it will fail so in<br />
case some mod is using name <code>vehicle.dummy.truck</code> and you will also use this your<br />
mod will fail to load. To create nameless unit simply use dot as the prefix for<br />
your unit name for example <code>.my_mod.nameless.units</code>
* Attributes - attributes is a set of the data unit can store, it can be number,<br />
text, other unit connection, set of them etc. Some units are failing in case they<br />
contain serialized some attribute that is no longer supported however some of<br />
them have special flag in the engine to allow loading not allowed attributes.

== SII files ==

Units are stored in SII files. There are two versions of this file supported by<br />
engine textual and binary however only textual form is used for definitions.

=== Struture ===

The magic mark - used to check if file is real SII file or not.

<pre>SiiNUnit</pre>
The opening bracket used to explicitly show the global file scope start

<pre>{</pre>
Here you put your unit definitions

<pre>some_unit : .my_mod.unit
{
attribute_number: 40
attribute_string: &quot;TEST STRING&quot;
attribute_token: TEST
attribute_vector3: (1.0, 1.0, 1.0)
attribute_float_number_ieee754: &amp;40490f5a
}</pre>
The closing bracked for the SiiNUnit

<pre>}</pre>
It's always good to add one blank line at the end of the file

=== Unit definition entry ===

Unit definition entry format is:

<pre>class name : unit name
{
attributes
}</pre>
=== Comments ===

You can comment some of your data using C-like multi-line comments syntax starting<br />
from <code>/*</code> and ending with <code>*/</code>.

'''Example:'''

<pre>/* Definition of some unit.
*
* Author: You */
some_unit : .my_mod.unit
{
}</pre>
Also you can use one-line comments those are starting from <code>#</code> or <code>//</code>.

'''Example:'''

<pre>some_unit : .my_mod.unit // Some unit
{
# This value should be tweaked after users feedback
some_value: 45.875
}</pre>
=== Includes ===

You can also include other files into another. To do this you need to use SII<br />
preprocessor directives <code>@include</code>.

'''Example:'''

<pre>@include &quot;some_file_to_include.sui&quot;</pre>
You may notice usage of the new extension - '''.sui'''. It's used for unit serialized<br />
files without magic mark <code>SiiNUnit</code> that are included somewhere in different files.<br />
We recommend you also using this extension.

== Attribute types ==

<pre>TODO: arrays</pre>
{| class="wikitable" width="100%"
!width="19%"| Type
!width="25%"| Value
!width="55%"| Example
|-
| string
| &quot;x&quot;
| attribute: &quot;String value&quot;
|-
| float
| x
| attribute: 1.0 // Using normal float-notation<br>attribute: &amp;3f800000 // using ieee754 hexa notation
|-
| float2
| (x, y)
| attribute: (1.0, 2.0)
|-
| float3
| (x, y, z)
| attribute: (1.0, 5.0, 3.0)
|-
| float4
| (x, y, z, w)
| attribute: (1.0, 5.0, 3.0, 9.0)
|-
| float4x4
| ?
| ?
|-
| fixed
| x
| ?
|-
| fixed2
| (x, y)
| ?
|-
| fixed3
| (x, y, z)
| ?
|-
| fixed4
| (x, y, z, w)
| ?
|-
| int2
| (x, y)
| attribute: (20, 69)
|-
| quaternion
| (w, x, y, z)
| attribute: (1.0, 0.0, 0.0, 0.0)
|-
| placement
| ?
| ?
|-
| placement_scale
| ?
| ?
|-
| placement_nonuniform
| ?
| ?
|-
| plane
| ?
| ?
|-
| aabox
| ?
| ?
|-
| token
| x
| attribute: value
|-
| s16
| x
| attribute: -15
|-
| s32
| x
| attribute: -15
|-
| s64
| x
| attribute: -15
|-
| u16
| x
| attribute: 15
|-
| u32
| x
| attribute: 15
|-
| u64
| x
| attribute: 15
|-
| bool
| x
| attribute: true<br>attribute: false
|-
| unit
| x
| attribute: my.unit
|}

Copyright © 2015 by SCS SOFTWARE
developer
1,626
edits

Navigation menu