# Scene data

The Simplygon API represents a scene and a scene graph with the Scene class. A scene can contain materials, textures, bones and meshes. A scene by default contains a root node, a material table, a texture table, a bone table and a selection set table.

Scene graph

# Scene

The Scene class object can be created by the API object by calling the CreateScene method. The Scene class provides the GetNodeFromPath method to fetch nodes in the scene using a path, see SceneNode below for information on how to fetch the path of a node. Scene class also provides a method to save a scene as a binary representation using the SaveToFile method. The binary file can be loaded again for reuse using the LoadFromFile method. These methods are used internally and it is not guaranteed that they will work in later releases.

# SceneNode

The Simplygon API uses the SceneNode base class to represent nodes in the scene graph. A node can be created by using the API object and calling the CreateSceneNode method. Each node can have a name which can be used when navigating from an Scene object. The class allows the user to work with child nodes by using AddChild, GetChild, GetChildCount, RemoveChild, RemoveChildren, HasChild and FindNamedChild methods. The GetParent method is provided to access the parent node.

The SceneNode class also provides a method to retrieve the path of the node in the scene by calling the GetPath method. Each SceneNode object in Simplygon also keeps a relative transformation to its parent node which can be accessed using GetRelativeTransform method. The class also provides a method to get the absolute transform of a node in the scene hierarchy by using the EvaluateDefaultGlobalTransformation method. See figure 7 for an example of global and local transformations.

# Root node

The root node is an SceneNode that is automatically created when an Scene object is created. All nodes that are added to the scene must be placed in a hierarchy below the root node. See figure 8.

# SceneMesh

The Simplygon API provides an SceneMesh class to represent a mesh node in a scene. SceneMesh is derived from SceneNode. An SceneMesh object can be created from the API object by calling CreateSceneMesh method. To assign GeometryData to an SceneMesh object use the SetGeometry method. In figure 8 the blue mesh nodes belong to the SceneMesh class.

# SceneBone

The Simplygon API provides an SceneBone class to represent a bone in a scene. An SceneBone object can be created from the API object by calling CreateSceneBone method. SceneBone class also provides all the functionality of its parent class SceneNode. See the Bone Table section for more information. In figure 8 the green bone nodes belong to the SceneBone class.

# SceneCamera

The Simplygon API provides an SceneCamera class to represent a camera in a scene. The camera has properties that determine the field of view and the coordinate system. A camera can have multiple camera views that are each defined by a camera position and a target position. Cameras are used when computing the visibility in the scene.

# ScenePlane

The Simplygon API provides an ScenePlane class to represent an infinite geometrical plane in the scene, defined by an origin and a normal. These are not relevant for any reduction processing, but they can be used as cutting planes when performing remeshing.

# SelectionSet

An SelectionSet is a set of references to scene nodes, by their GUID. These sets can be created and added to the scene selection set table, and subsequently be used to set what nodes in a given scene will be processes in the reduction processors. Selection sets are also used to select which planes in the scenes are to be used as cutting planes by the remeshing processor, or which scene cameras are used in the visibility processing of both the reduction and remeshing processor.

# Material table

An Scene object internally maintains an IMaterialTable which is used to setup and maintain materials in a scene. To access the material table from an IScene object use the GetMaterialTable method. Each material created in the scene must be added to the material table. To add materials use AddMaterial method. The unique id returned by AddMaterial is then assigned to the items in the material id field in an IGeometryData object (per-triangle MaterialIds). See figure 8.

# Texture table

An Scene object internally maintains an ITextureTable which is used to add and cache textures used by material shading networks in a scene. To access the texture table from an Scene object use the GetTextureTable method. To add textures, i.e. objects of type ITexture, use the AddTexture method.

# Bone table

An Scene object internally maintains an BoneTable which is used to maintain bones in a scene. To access the bone table from an Scene object use the GetBoneTable method. Each bone that is created in the scene must be added to the bone table. To add a bone use AddBone method. When you add a bone to the bone table it returns a unique bone id which can then be bound to geometry data (Bones Ids). See figure 8. For bone reduction to work make sure that the scene's bone table is properly setup.

# SelectionSet Table

An Scene object internally maintains an SelectionSetTable which is used to maintain selection sets in a scene. The selection sets positions in this table determines their selection set id, which is used to set any selection set settings in the processors.

# Example

This example shows how to use the Reduction processor with material casting.