Пример #1
0
        static protected void ParseDataAsync(object input)
        {
            ArrayList queue = input as ArrayList;

            while ((queue.Count > 0) && !MayaCacheFile.RaiseError)
            {
                MayaCacheFile cache = null;

                lock (queue)
                {
                    cache = queue[0] as MayaCacheFile;
                    queue.Remove(cache);
                }
                try
                {
                    cache.ParseData();
                }
                catch (Exception)
                {
                    ErrorEvent ev = new ErrorEvent();

                    MayaCacheFile.RaiseError = true;
                    ev.ErrString             = "FILE OPEN FAILED ";
                    ev.ErrString            += cache.BaseName;
                    ev.ErrLevel = 2;
                    ev.Log();
                }
            }
            _loadthread = null;
        }
Пример #2
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);
        }