Skip to content

Game Scene

Romulion edited this page Mar 12, 2020 · 1 revision

Scene is used to store all menegable units.
SceneNode - used to store basic element on scene. It has Transform class to storage position data.
To add new node to Scene root use method AddNode2Root. To add node to another nodes child use SetParent.
Updating hierarchy transform performs each frame. If node disabled, all child nodes will be disabled in hierarchy.
Each node knowns aboun its parent and scene it belongs to. Scene node can have Components.

Availible Components:

  • AudioListener - "Microphone on scene". Can be only one on scene
  • AudioSource - Sound making component.
  • MeshDrawer - component for storing model data
  • MeshDrawerRigged - component for storing rigged model data
  • Camera - Render camera. Can be only one on scene
  • ScriptingComponent - Proggramable component
  • Animator - Animation managing component

To create new component use Components base class and setup "system" that process component

Example:

//get current scene object
var scene = CoreEngine.MainScene;

SceneNode cameraNode = new SceneNode();
cameraNode.Name = "Camera";
var camera = new Camera();
cameraNode.AddComponent(camera);
//script from ScriptingComponent to controll camera
cameraNode.AddComponent<CameraControllScript>();
//script that discpay current render times
cameraNode.AddComponent<FrameTimeScript>();
//scene space utints 1 - 1m
cameraNode.GetTransform.Position = new Vector3(0, 1f, 3);
scene.AddNode2Root(camera);
Clone this wiki locally