Ejemplo n.º 1
0
        public void AddObject(SceneObject obj)
        {
            if (obj.GetName() == ObjectName)
            {
                WaitTillInitialized();

                if (PrivateRendererContext.Application.ManagedThreadId == System.Threading.Thread.CurrentThread.ManagedThreadId)
                {
                    if (!NeedsInit)
                    {
                        if (!obj.IsInitialized)
                            obj.Init(PrivateRendererContext);
                    }
                    else
                    {
                        if(!obj.IsInitialized)
                            PrivateRendererContext.AddRCActionJob(new CoreScene.RCActionInitSceneObject(obj, PrivateRendererContext));
                    }

                    lock (ListLock)
                    {
                        SceneObjects.Add(obj);
                        ObjectsChanged.Add(SceneObjects.IndexOf(obj));
                        obj.SceneObjectChanged += SceneObjectChangedHandler;
                    }
                           
                }
                else
                {
                    if(!obj.IsInitialized)
                        PrivateRendererContext.AddRCActionJob(new CoreScene.RCActionInitSceneObject(obj, PrivateRendererContext));

                    obj.WaitTillInitialized();

                    lock (ListLock)
                    {
                        SceneObjects.Add(obj);
                        ObjectsChanged.Add(SceneObjects.IndexOf(obj));
                        obj.SceneObjectChanged += SceneObjectChangedHandler;
                    }
                }

                obj.IsAddedToScene = true;
                obj.Scene = this.Scene;

                Logger.Log.AddLogEntry (LogLevel.Debug, "SceneObjectArray", "Object Added");
            }
            else
                FreezingArcher.Output.Logger.Log.AddLogEntry(FreezingArcher.Output.LogLevel.Error, "SceneObjectArray", 
                    FreezingArcher.Core.Status.YouShallNotPassNull, "Object name does not match");
        }
Ejemplo n.º 2
0
        public void AddObject(SceneObject obj)
        {
            if(obj == null)
            {
                Output.Logger.Log.AddLogEntry(FreezingArcher.Output.LogLevel.Error, "CoreScene", FreezingArcher.Core.Status.BadArgument,
                    "SceneObject = null");
                return;
            }

            if (IsInitialized)
            {
                if (obj.IsAddedToScene)
                {
                    Output.Logger.Log.AddLogEntry(FreezingArcher.Output.LogLevel.Error, "CoreScene", FreezingArcher.Core.Status.BadArgument,
                        "Object was already added to Scene!");
                    
                    return;
                }

                if (PrivateRendererContext.Application.ManagedThreadId == System.Threading.Thread.CurrentThread.ManagedThreadId)
                {
                    if (!obj.IsInitialized)
                    {
                        if (obj.Init(PrivateRendererContext))
                            Objects.Add(obj);
                        else
                            Output.Logger.Log.AddLogEntry(FreezingArcher.Output.LogLevel.Error, "CoreScene", 
                                FreezingArcher.Core.Status.AKittenDies, "Object could not be initialized!");
                    }
                }
                else
                {
                    if (!obj.IsInitialized)
                    {
                        PrivateRendererContext.AddRCActionJob(new RCActionInitSceneObject(obj, PrivateRendererContext));
                        obj.WaitTillInitialized();
                    }
                    Objects.Add(obj);
                }

                if (obj.Priority == -1)
                    obj.Priority = Objects.Count;

                obj.Scene = this;
                obj.IsAddedToScene = true;
            }
            else
                Output.Logger.Log.AddLogEntry(FreezingArcher.Output.LogLevel.Error, "CoreScene", FreezingArcher.Core.Status.AKittenDies, "Scene is not initialized!"); 

        }