SCENE Files

SCENE files (also known as SCENEGRAPHS) are MBIN files used as containers for object references in the game. They can reference a lot of things - including **entities**, **effects**, additional **scenes**, **meshes**, and so forth. Using these SCENE files, you can attach scripts and objects together into one form, like a prefab.

All objects in the game are spawned from SCENE files (plants, ships, and even your multitool). As you will eventually find out, SCENE files are extremely powerful and can be used for more than just stringing objects together.

For those already used to game development, SCENE files are similar to Unity GameObjects - they are containers that reference models, sounds, scripts, and more.

## Scene Nodes

Each SCENE file contains Scene Nodes (TkSceneNodeData) which is a complete data structure that defines the basic structure of a SCENE. These include:

* **Name** - the name of the scene file. The root node of the scene file usually bears the directory and the name of the scene itself i.e. a DRONE.SCENE has the name "MODELS\COMMON\ROBOTS\DRONE"
* **Type** - the type of Scene Node. They are all listed in Types of Scene Nodes.This structure will influence the attributes declared within in the **Attribute** container.
* **Transform** - the **vector3** (x, y, z) position, rotation, and scale of an object
* **Attributes -** depending on the Scene Node **Type**, different fields will be declared here along with their corresponding values. Each attribute has a *Name, AltID, and Value.* The *AltID* is usually empty.
* **Children** - each Scene Node can have more scene nodes as children

## Types of Scene Nodes

* **MODEL** - this Scene Node Type references a GEOMETRY MBIN. Most SCENE files have this as the type used for their root node.
	+ **GEOMETRY** - this one single property simply references a GEOMETRY MBIN file (i.e. "MODELS\COMMON\ROBOTS\DRONE.GEOMETRY.MBIN"). These files are also serialized XML, containing 3D models for the game.
* **MESH** - this Scene Node Type explicitly takes mesh data from a root node's referenced GEOMETRY file to be displayed in-game. It is important to note that mesh data is obviously not supposed to be manually written by a human. See the Importing Custom Models page to see how this is done.
	+ BATCHSTART
	+ BATCHCOUNT
	+ VERTSTART
	+ VERTEND
	+ FIRSTSKINMAT
	+ LASTSKINMAT
	+ MATERIAL - path to the material file this mesh uses.
	+ ATTACHMENT - a path to the ENTITY MBIN this mesh uses. ENTITY files are MBIN's that define behaviors or interactions.

* **COLLISION** - this Scene Node Type is responsible for rendering collisions for objects with a wide array of options possible. Much like the MESH node type, data here is usually created during the import of custom models.
	+ TYPE - collisions can be in the form of meshes, or use more performance-efficient shape primitives provided by the engine
		- **Sphere** - The collision will be a round ball.
		- **Cylinder** - The collision will be a straight tube.
		- **Capsule** - The collision will be a straight tube with half spheres at each end.
		- **Mesh** **collision** - The collision will be the object's meshes.
* **JOINT** - possibly an element of the model's skeletal animation rig?
* **LOCATOR** - an empty node that simply holds transform data. These can be used quite heavily by ENTITY files for a number of things such as interactions being placed at specific locations with them as well as things like the location of the scanner icon if your object is scannable or the point from a gun model from which projectiles are shot from.

```
 <Property value="TkSceneNodeData.xml">
 <Property name="Name" value="LocatorName" />
 <Property name="Type" value="LOCATOR" />
 <Property name="Transform" value="TkTransformData.xml">
 <Property name="TransX" value="0" />
 <Property name="TransY" value="0" />
 <Property name="TransZ" value="0" />
 <Property name="RotX" value="0" />
 <Property name="RotY" value="0" />
 <Property name="RotZ" value="0" />
 <Property name="ScaleX" value="1" />
 <Property name="ScaleY" value="1" />
 <Property name="ScaleZ" value="1" />
 </Property>
 <Property name="Attributes" />
 <Property name="Children" />
 </Property>

```

* **LIGHT** - allows a light source to be attached to the SCENE file.
	+ **FOV** - controls the arc of a light's emission (light bending). The value "90" will create a 90-degree spotlight, while the value "360" replicates what a standard point light would do.
	+ **FALLOFF** - controls how light fades away over distance.
	+ **INTENSITY** - controls the light's brightness. A low value will make the light shine a little bit and appear as darker, while a high value will make the light shine a lot and will appear brighter)
* **COL\_R** - Red color channel's component. Values are set between 0 and 1 ; 0 being the lowest value (black) which equals to **0**/**255** , 1 being the highest value which equals to **255**/**255**.
* **COL\_G** - Green color channel's component. Values are set between 0 and 1 ; 0 being the lowest value (black) which equals to **0**/**255** , 1 being the highest value which equals to **255**/**255**.
* **COL\_B** - Blue color channel's component. Values are set between **0** and **1** ; **0** being the **lowest** value (**black**) which equals to **0**/**255** , 1 being the highest value which equals to **255**/**255**
	+ **RGB** stands for **R**ed **G**reen **B**lue. If all three channels are set to **255**, the displayed color will be **white**.

```
 <Property value="TkSceneNodeData.xml">
 <Property name="Name" value="pointLight1" />
 <Property name="Type" value="LIGHT" />
 <Property name="Transform" value="TkTransformData.xml">
 <Property name="TransX" value="0" />
 <Property name="TransY" value="0" />
 <Property name="TransZ" value="0" />
 <Property name="RotX" value="0" />
 <Property name="RotY" value="0" />
 <Property name="RotZ" value="0" />
 <Property name="ScaleX" value="1" />
 <Property name="ScaleY" value="1" />
 <Property name="ScaleZ" value="1" />
 </Property>
 <Property name="Attributes">
 <Property value="TkSceneNodeAttributeData.xml">
 <Property name="Name" value="FOV" />
 <Property name="AltID" value="" />
 <Property name="Value" value="360.000000" />
 </Property>
 <Property value="TkSceneNodeAttributeData.xml">
 <Property name="Name" value="FALLOFF" />
 <Property name="AltID" value="" />
 <Property name="Value" value="quadratic" />
 </Property>
 <Property value="TkSceneNodeAttributeData.xml">
 <Property name="Name" value="INTENSITY" />
 <Property name="AltID" value="" />
 <Property name="Value" value="83453.234375" />
 </Property>
 <Property value="TkSceneNodeAttributeData.xml">
 <Property name="Name" value="COL\_R" />
 <Property name="AltID" value="" />
 <Property name="Value" value="1.000000" />
 </Property>
 <Property value="TkSceneNodeAttributeData.xml">
 <Property name="Name" value="COL\_G" />
 <Property name="AltID" value="" />
 <Property name="Value" value="0.301729" />
 </Property>
 <Property value="TkSceneNodeAttributeData.xml">
 <Property name="Name" value="COL\_B" />
 <Property name="AltID" value="" />
 <Property name="Value" value="0.000000" />
 </Property>
 <Property value="TkSceneNodeAttributeData.xml">
 <Property name="Name" value="MATERIAL" />
 <Property name="AltID" value="" />
 <Property name="Value" value="MATERIALS/LIGHT.MATERIAL.MBIN" />
 </Property>
 </Property>
 <Property name="Children" />
 </Property>

```

* **REFERENCE** - allows you to link another SCENE file into this SCENE file, because you know you like putting SCENE files inside SCENE files. This gives a lot of flexibility, as it allows you to create a custom object and place already existing objects from the game into your scene.This referenced scene will be procedural if it is able to be (ie. if it has an associated descriptor, and the scene you are referencing it from is being called procedurally). If you want to avoid a scene being called procedurally, you can specify an AltID. This is a list of the names of nodes with space between them to specify exactly what parts you want. The model viewer can export AltID's for objects, so if you load a scene with it, you can set only the parts of the scene you want to be visible and then export the AltID and put this value here to reference that exact scene configuration.

* **SCENEGRAPH** - the relative path to the desired SCENE.

```
 <Property value="TkSceneNodeData.xml">
 <Property name="Name" value="NameForThisNode" />
 <Property name="Type" value="REFERENCE" />
 <Property name="Transform" value="TkTransformData.xml">
 <Property name="TransX" value="0" />
 <Property name="TransY" value="0" />
 <Property name="TransZ" value="0" />
 <Property name="RotX" value="0" />
 <Property name="RotY" value="0" />
 <Property name="RotZ" value="0" />
 <Property name="ScaleX" value="1" />
 <Property name="ScaleY" value="1" />
 <Property name="ScaleZ" value="1" />
 </Property>
 <Property name="Attributes">
 <Property value="TkSceneNodeAttributeData.xml">
 <Property name="Name" value="SCENEGRAPH" />
 <Property name="AltID" value="" />
 <Property name="Value" value="MODELS\WHATEVER\WHATEVER.SCENE.MBIN" />
 </Property>
 </Property>
 <Property name="Children" />
 </Property>

```