示例#1
0
 public void LoadScene(LoadSceneEvent e, Node newSceneNode, [JoinAll] Optional <SingleNode <CurrentSceneComponent> > currentScene)
 {
     if (currentScene.IsPresent())
     {
         currentScene.Get().Entity.RemoveComponent <CurrentSceneComponent>();
     }
     UnityUtil.LoadScene(e.SceneAsset, e.SceneName, false);
     newSceneNode.Entity.AddComponent <CurrentSceneComponent>();
 }
    private void AddLoadSceneEventToDict()
    {
        if (LoadSceneEventDictionary.Count != 0)
        {
            LoadSceneEventDictionary.Clear();
        }

        if (scenarioContainer.EventSet.LoadSceneEventList == null)
        {
            Debug.Log("XML파일 EventSet의 LoadSceneEventList가 없다.");
            return;
        }

        for (int k = 0; k < scenarioContainer.EventSet.LoadSceneEventList.Length; k++)
        {
            int            key = scenarioContainer.EventSet.LoadSceneEventList[k].ID;
            LoadSceneEvent LoadSceneEventInfo = scenarioContainer.EventSet.LoadSceneEventList[k];

            if (!LoadSceneEventDictionary.ContainsKey(key))
            {
                LoadSceneEventDictionary.Add(key, LoadSceneEventInfo);
            }
        }
    }
示例#3
0
        /*!
         * @param ev	Vixen event to handle.
         * @param world	current world
         * Handles vixen events - content loading and animation.
         * This function also calls event handlers for AvatarEvents.
         */
        public virtual void OnVixen(Event ev, SharedWorld world)
        {
            int code = ev.Code;

            if (code == Event.STOP)
            {
                OnStopAnim(ev.Sender);
                return;
            }
            if (code == Event.LOAD_SCENE)
            {
                LoadSceneEvent le    = ev as LoadSceneEvent;
                String         fname = le.FileName;
                SharedObj      obj   = le.Object;

                if (obj != null)
                {
                    Scene  scene = obj as Scene;
                    string name  = obj.Name;
                    int    p     = name.IndexOf('.');

                    if (p > 0)
                    {
                        name = name.Substring(0, p);
                    }
                    if (scene != null)
                    {
                        if (scene.Models != null)
                        {
                            OnSceneLoad(world, scene, fname);
                        }
                        else if (scene.Engines != null)
                        {
                            RaiseAnimLoadEvent(name, fname);
                        }
                        return;
                    }
                    if (((obj as Skeleton) != null) || ((obj as MeshAnimator) != null))
                    {
                        RaiseAnimLoadEvent(name, fname);
                    }
                }
                return;
            }
            if (code == Event.LOAD_TEXT)
            {
                LoadTextEvent le = ev as LoadTextEvent;

                OnLoadText(le.FileName, le.Text);
                return;
            }
            if (code == Event.SCENE_CHANGE)
            {
                SceneEvent se = ev as SceneEvent;
                OnSceneChange(world, se.Target as Scene);
                return;
            }
            if (code == Event.ERROR)
            {
                ErrorEvent err = ev as ErrorEvent;
                RaiseErrorEvent(err.ErrString, err.ErrLevel);
                return;
            }
        }
示例#4
0
        /*!
         * Loads a Maya geometry cache for cloth presimulation.
         * @param	g			Garment which is being simulated by the cache
         * @param	url			URL or path to the cache description file (XML)
         * @param	text		if not null, this parameter is used as the XML cache description
         * @param	scriptor	Scriptor object to add this animation to
         *
         * @returns true if cache successfully loaded and connected, else false
         */
        public static bool LoadMayaCache(Garment g, String url, String text, Scriptor scriptor)
        {
            dynamic d = g;

            if (g == null)
            {
                return(false);
            }
            if ((g.ClothSim == null) || !g.ClothSim.IsClass((uint)SerialID.VX_MeshAnimator))
            {
                return(false);
            }

            LoadSceneEvent loadevent;
            string         name     = Path.GetFileNameWithoutExtension(url);
            MeshAnimator   clothsim = g.ClothSim.Clone() as MeshAnimator;
            Animator       anim;

            MayaIO.MayaCacheFile import = new MayaIO.MayaCacheFile(clothsim);
            String engname = d.name + ".meshanim";
            String animname;

            /*
             * Make a MeshAnimator to control the cloth vertices in the cloth mesh.
             * The mesh sequence will be loaded into this engine.
             */
            clothsim.Name = name;
            if (clothsim.Target == null)
            {
                clothsim.Target = g.ClothMesh;
            }

            /*
             * Make an Animator to control the mesh animation we are loading.
             * It is attached to the Scriptor that should control it.
             */
            name    += "." + engname;
            animname = name + ".anim";
            anim     = scriptor.MakeAnim(name, g.ClothMesh, false);
            anim.SetEngineName(engname);
            anim.SetFileName(url);
            SharedWorld.Get().Observe(Event.LOAD_SCENE, anim);

            /*
             * Make a load event to signal the mesh animation has been loaded.
             * The event will come from the Animator and will contain the
             * MeshAnimator with the mesh sequences loaded.
             */
            loadevent        = new LoadSceneEvent(Event.LOAD_SCENE);
            loadevent.Sender = anim;
            if (loadevent.Sender == null)
            {
                loadevent.Sender = clothsim;
            }
            loadevent.Object   = clothsim;
            loadevent.FileName = url;

            /*
             * Start the import of the Maya me4sh sequence.
             * This occurs asynchronously in a separate thread.
             */
            if (text != null)
            {
                import.FileName = url;
                import.LoadString(text, loadevent);
            }
            else
            {
                import.LoadFile(url, loadevent);
            }
            return(true);
        }
示例#5
0
        /*!
         * @param ev	Vixen event to handle.
         * @param world	current world
         * Handles vixen events - content loading and animation.
         * This function also calls event handlers for AvatarEvents.
         */
        protected override void OnVixen(VixenEventArgs vargs)
        {
            Event ev   = vargs.VixEvent;
            int   code = ev.Code;

            if (code == Event.STOP)
            {
                if (StopEvent != null)
                {
                    StopEvent(ev.Sender.Name);
                }
            }
            else if (code == Event.LOAD_SCENE)
            {
                try
                {
                    LoadSceneEvent le    = ev as LoadSceneEvent;
                    String         fname = le.FileName;
                    SharedObj      obj   = le.Object;

                    if (obj != null)
                    {
                        string name = obj.Name;
                        int    p    = name.IndexOf('.');

                        if (p > 0)
                        {
                            name = name.Substring(0, p);
                        }
                        if (obj.IsClass((uint)SerialID.VX_Scene))
                        {
                            Scene scene = obj as Scene;
                            OnSceneLoad(scene, fname);
                            if (LoadSceneEvent != null)
                            {
                                LoadSceneEvent(name, fname);
                            }
                        }
                        else if (obj.IsClass((uint)SerialID.VX_Skeleton))
                        {
                            if (LoadAnimEvent != null)
                            {
                                LoadAnimEvent(name, fname);
                            }
                        }
                    }
                }
                catch (Exception) { }
            }
            else if (code == Event.SCENE_CHANGE)
            {
                try
                {
                    SceneEvent se = ev as SceneEvent;
                    if (SetSceneEvent != null)
                    {
                        string name = se.Target.Name;
                        int    p    = name.IndexOf('.');

                        if (p > 0)
                        {
                            name = name.Substring(0, p);
                        }
                        SetSceneEvent(name);
                    }
                }
                catch (Exception) { }
            }
        }
示例#6
0
 public void LogLoadScene(LoadSceneEvent e, Node node)
 {
     this.WriteToLog(e.SceneName + " scene  start async loading");
 }