コード例 #1
0
ファイル: Scene.cs プロジェクト: RolandKoenig/SeeingSharp2
        /// <summary>
        /// Initializes a new instance of the <see cref="Scene" /> class.
        /// </summary>
        public Scene()
        {
            _perFrameData = new CBPerFrame();

            this.TransformMode2D     = Graphics2DTransformMode.Custom;
            this.CustomTransform2D   = Matrix3x2.Identity;
            this.VirtualScreenSize2D = new SizeF();

            _sceneComponents = new SceneComponentFlyweight(this);

            _sceneLayers = new UnsafeList <SceneLayer>();
            _sceneLayers.Add(new SceneLayer(DEFAULT_LAYER_NAME, this));
            this.Layers = new ReadOnlyCollection <SceneLayer>(_sceneLayers);

            _drawing2DLayers = new List <Custom2DDrawingLayer>();

            _asyncInvokesBeforeUpdate          = new ConcurrentQueue <Action>();
            _asyncInvokesUpdateBesideRendering = new ConcurrentQueue <Action>();

            _registeredResourceDicts = new IndexBasedDynamicCollection <ResourceDictionary>();
            _registeredViews         = new IndexBasedDynamicCollection <ViewInformation>();
            _renderParameters        = new IndexBasedDynamicCollection <SceneRenderParameters>();

            this.CachedUpdateState = new SceneRelatedUpdateState();

            // Try to initialize this scene object
            this.InitializeResourceDictionaries();
        }
コード例 #2
0
ファイル: Scene.cs プロジェクト: Alan-Baylis/SeeingSharp
        /// <summary>
        /// Initializes a new instance of the <see cref="Scene" /> class.
        /// </summary>
        /// <param name="name">The global name of this scene.</param>
        /// <param name="registerOnMessenger">
        /// Do register this scene for application messaging?
        /// If true, then the caller has to ensure that the name is only used once
        /// across the currently executed application.
        /// </param>
        public Scene(
            string name = "",
            bool registerOnMessenger = false)
        {
            if (string.IsNullOrEmpty(name))
            {
                name = DEFAULT_SCENE_NAME;
            }
            this.Name = name;

            m_perFrameData = new CBPerFrame();

            m_transformMode2D     = Graphics2DTransformMode.Custom;
            m_customTransform2D   = Matrix3x2.Identity;
            m_virtualScreenSize2D = new Size2F();

            m_sceneLayers = new List <SceneLayer>();
            m_sceneLayers.Add(new SceneLayer(DEFAULT_LAYER_NAME, this));
            m_sceneLayersPublic = new ReadOnlyCollection <SceneLayer>(m_sceneLayers);

            m_drawing2DLayers = new List <Custom2DDrawingLayer>();

            m_sceneComponents = new SceneComponentFlyweight(this);

            m_asyncInvokesBeforeUpdate          = new ThreadSaveQueue <Action>();
            m_asyncInvokesUpdateBesideRendering = new ThreadSaveQueue <Action>();

            m_registeredResourceDicts = new IndexBasedDynamicCollection <ResourceDictionary>();
            m_registeredViews         = new IndexBasedDynamicCollection <ViewInformation>();
            m_renderParameters        = new IndexBasedDynamicCollection <SceneRenderParameters>();

            this.CachedUpdateState = new SceneRelatedUpdateState(this);

            // Try to initialize this scene object
            InitializeResourceDictionaries(false);

            // Register the scene for ApplicationMessaging
            if (registerOnMessenger)
            {
                m_syncContext = new SceneSynchronizationContext(this);
                m_messenger   = new SeeingSharpMessenger();
                m_messenger.ApplyForGlobalSynchronization(
                    SeeingSharpMessageThreadingBehavior.EnsureMainSyncContextOnSyncCalls,
                    this.Name,
                    m_syncContext);
            }
        }