public DX11FileTexturePoolElement(DX11RenderContext context, string path, bool mips, bool async = false)
        {
            this.FileName = path;
            this.DoMips   = mips;
            this.refcount = 1;


            if (async)
            {
                this.m_task           = new FileTexture2dLoadTask(context, path, mips);
                m_task.StatusChanged += task_StatusChanged;

                context.ResourceScheduler.AddTask(m_task);
            }
            else
            {
                try
                {
                    ImageLoadInformation info = ImageLoadInformation.FromDefaults();
                    if (!this.DoMips)
                    {
                        info.MipLevels = 1;
                    }

                    this.Texture = DX11Texture2D.FromFile(context, path, info);
                    this.Status  = eDX11SheduleTaskStatus.Completed;
                }
                catch
                {
                    this.Status = eDX11SheduleTaskStatus.Error;
                }
            }
        }
Beispiel #2
0
            public void SetPosition(DX11RenderContext ctx, int frame)
            {
                int frameindex = frame - this.CurrentFrame;

                frameindex = frameindex < 0 ? 0 : frameindex;
                frameindex = frameindex > Data.FileCount - 1 ? Data.FileCount - 1 : frameindex;

                if (frameindex != CurrentFrame)
                {
                    if (this.Texture == null)
                    {
                        this.Texture.Dispose();
                    }

                    ImageLoadInformation info = ImageLoadInformation.FromDefaults();
                    info.MipLevels = 1;
                    this.Texture   = DX11Texture2D.FromFile(ctx, Data.FilePath[frameindex], info);
                    CurrentFrame   = frameindex;
                }
            }
Beispiel #3
0
        public void Evaluate(int SpreadMax)
        {
            if (this.FInPath.IsChanged)
            {
                this.directories.Clear();
                string path = this.FInPath[0];

                try
                {
                    var subdirs = Directory.GetDirectories(path).ToList();

                    subdirs.ForEach(sd => this.directories.Add(new DirectoryData(sd)));
                    this.outdircount.SliceCount = subdirs.Count;
                    for (int i = 0; i < this.directories.Count; i++)
                    {
                        this.outdircount[i] = this.directories[i].FileCount;
                    }
                }
                catch
                {
                    this.directories.Clear();
                    this.outdircount.SliceCount = 0;
                }
            }

            if (this.outdircount.SliceCount == 0)
            {
                return;
            }

            if (this.FSpawn[0] && this.FSpawnIndex.SliceCount > 0)
            {
                for (int i = 0; i < this.FSpawnIndex.SliceCount; i++)
                {
                    int idx = this.FSpawnIndex[i];

                    if (this.spawners.Any(s => s.Index == idx))
                    {
                        //Emit animation
                        Spawner sp = new Spawner();
                        sp.Index        = idx;
                        sp.InitialFrame = this.FFrameIndex[0];
                        sp.CurrentFrame = 0;
                        sp.Data         = this.directories[idx];
                        sp.Texture      = DX11Texture2D.FromFile(ctx, sp.Data.FilePath[0]);

                        this.spawners.Add(sp);
                    }
                }
            }

            spawners.Where(s => s.CurrentFrame >= s.Data.FileCount).ToList().ForEach(s => { s.Dispose(); this.spawners.Remove(s); });

            this.outidx.SliceCount = spawners.Count;
            this.outpos.SliceCount = spawners.Count;
            this.outtex.SliceCount = spawners.Count;

            for (int i = 0; i < this.spawners.Count; i++)
            {
                Spawner s = this.spawners[i];
                this.outidx[i] = s.Index;
                this.outpos[i] = (double)s.CurrentFrame / (double)s.Data.FileCount;
                this.outtex[i] = new DX11Resource <DX11Texture2D>();
            }
        }