/// <summary> /// Overridden NewScene function /// </summary> /// <param name="relFileName"></param> /// <param name="bPlainEmpty"></param> /// <returns></returns> public override bool NewScene(string relFileName, bool bPlainEmpty) { object[] parameters = { this, relFileName }; EditorScene editorScene = EditorManager.SceneFactory.CreateInstance(parameters) as EditorScene; if (editorScene == null) { EditorManager.ShowMessageBox("Scene must be derived from class 'EditorScene'", "Failed to create scene", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } EditorManager.ActiveView.SetCameraPosition(editorScene.Settings.CameraPosition); EditorManager.ActiveView.SetCameraRotation(editorScene.Settings.CameraAngles); _scene = editorScene; // save the scene (empty) such that all layers can be safely saved editorScene.SaveAs(relFileName); if (!bPlainEmpty) { V3DLayer MainLayer = new V3DLayer("Main layer"); editorScene.AddLayer(MainLayer, true, false); // mark the layer as dirty, to ensure that it will be saved now MainLayer.Dirty = true; } // this will fire an event that is often used to set things up, so only now the scene will be set up completely Scene = editorScene; // set it afterwards so the OnSceneChanged callback has the correct name // save the scene again, now with all layers, because NOW all scene elements will be really setup editorScene.SaveAs(relFileName); return(true); }