예제 #1
0
 private void SetCurrentEffect(NutcrackerEffects.Effects selectedEffect)
 {
     Data.CurrentEffect = selectedEffect;
     ConfigureMainEditorOptions(selectedEffect);
     effect.SetNextState(true);
     SetCurrentTab(selectedEffect.ToString());
 }
예제 #2
0
파일: Nutcracker.cs 프로젝트: stewmc/vixen
        // renders the given node to the internal ElementData dictionary. If the given node is
        // not a element, will recursively descend until we render its elements.
        private void RenderNode(ElementNode node)
        {
            int wid;
            int ht;

            if (_data.NutcrackerData.StringOrienation == NutcrackerEffects.StringOrientations.Horizontal)
            {
                wid = MaxPixelsPerString;
                ht  = StringCount;
            }
            else
            {
                wid = StringCount;
                ht  = MaxPixelsPerString;
            }
            int nFrames = (int)(TimeSpan.TotalMilliseconds / frameMs);

            if (nFrames <= 0)
            {
                return;
            }
            var nccore = new NutcrackerEffects(_data.NutcrackerData)
            {
                Duration = TimeSpan
            };

            nccore.InitBuffer(wid, ht);
            int numElements = node.Count();

            TimeSpan startTime = TimeSpan.Zero;

            // OK, we're gonna create 1 intent per element
            // that intent will hold framesToRender Color values
            // that it will parcel out as intent states are called for...

            // set up arrays to hold the generated colors
            var pixels = new RGBValue[numElements][];

            for (int eidx = 0; eidx < numElements; eidx++)
            {
                pixels[eidx] = new RGBValue[nFrames];
            }
            // generate all the pixels
            for (int frameNum = 0; frameNum < nFrames; frameNum++)
            {
                nccore.RenderNextEffect(_data.NutcrackerData.CurrentEffect);
                // peel off this frames pixels...
                if (_data.NutcrackerData.StringOrienation == NutcrackerEffects.StringOrientations.Horizontal)
                {
                    int i = 0;
                    for (int y = 0; y < ht; y++)
                    {
                        for (int x = 0; x < _stringPixelCounts[y]; x++)
                        {
                            pixels[i][frameNum] = new RGBValue(nccore.GetPixel(x, y));
                            i++;
                        }
                    }
                }
                else
                {
                    int i = 0;
                    for (int x = 0; x < wid; x++)
                    {
                        for (int y = 0; y < _stringPixelCounts[x]; y++)
                        {
                            pixels[i][frameNum] = new RGBValue(nccore.GetPixel(x, y));
                            i++;
                        }
                    }
                }
            }
            ;

            // create the intents
            var            frameTs  = new TimeSpan(0, 0, 0, 0, frameMs);
            List <Element> elements = node.ToList();

            for (int eidx = 0; eidx < numElements; eidx++)
            {
                IIntent intent = new StaticArrayIntent <RGBValue>(frameTs, pixels[eidx], TimeSpan);
                _elementData.AddIntentForElement(elements[eidx].Id, intent, startTime);
            }

            nccore.Dispose();
        }
예제 #3
0
        private void ConfigureMainEditorOptions(NutcrackerEffects.Effects selectedEffect)
        {
            //This logic placement is crappy, but it prevents an error for now.
            //Will fix better when each one gets factored out into it's own effect.
            if (selectedEffect == NutcrackerEffects.Effects.Snowflakes)
            {
                if (StringCount == 1)
                {
                    radioButtonHorizontal.Enabled = false;
                }
            }
            else
            {
                radioButtonHorizontal.Enabled = true;
            }

            chkFitToTime.Enabled = selectedEffect == NutcrackerEffects.Effects.Curtain;
        }
예제 #4
0
        // renders the given node to the internal ElementData dictionary. If the given node is
        // not a element, will recursively descend until we render its elements.
        private void RenderNode(ElementNode node)
        {
            int wid;
            int ht;
            if (_data.NutcrackerData.StringOrienation == NutcrackerEffects.StringOrientations.Horizontal)
            {
                wid = MaxPixelsPerString;
                ht = StringCount;
            }
            else
            {
                wid = StringCount;
                ht = MaxPixelsPerString;
            }
            int nFrames = (int)(TimeSpan.TotalMilliseconds / frameMs);
            var nccore = new NutcrackerEffects(_data.NutcrackerData) {Duration = TimeSpan};
            nccore.InitBuffer( wid, ht);
            int numElements = node.Count();

            TimeSpan startTime = TimeSpan.Zero;

            // OK, we're gonna create 1 intent per element
            // that intent will hold framesToRender Color values
            // that it will parcel out as intent states are called for...

            // set up arrays to hold the generated colors
            var pixels = new RGBValue[numElements][];
            for (int eidx = 0; eidx < numElements; eidx++)
                pixels[eidx] = new RGBValue[nFrames];
            List<ElementNode> nodes = FindLeafParents().ToList();
            // generate all the pixels
            for (int frameNum = 0; frameNum < nFrames; frameNum++)
            {
                nccore.RenderNextEffect(_data.NutcrackerData.CurrentEffect);
                // peel off this frames pixels...
                if (_data.NutcrackerData.StringOrienation == NutcrackerEffects.StringOrientations.Horizontal)
                {
                    int i = 0;
                    for (int y = 0; y < ht; y++)
                    {
                        for (int x = 0; x < _stringPixelCounts[y]; x++)
                        {
                            pixels[i][frameNum] = new RGBValue(nccore.GetPixel(x, y));
                            i++;
                        }
                    }
                }
                else
                {
                    int i = 0;
                    for (int x = 0; x < wid; x++)
                    {
                        for (int y = 0; y < _stringPixelCounts[x]; y++)
                        {
                            pixels[i][frameNum] = new RGBValue(nccore.GetPixel(x, y));
                            i++;
                        }
                    }
                }
            };

            // create the intents
            var frameTs = new TimeSpan(0, 0, 0, 0, frameMs);
            List<Element> elements = node.ToList();
            for (int eidx = 0; eidx < numElements; eidx++)
            {
                IIntent intent = new StaticArrayIntent<RGBValue>(frameTs, pixels[eidx], TimeSpan);
                _elementData.AddIntentForElement(elements[eidx].Id, intent, startTime);
            }

            nccore.Dispose();
        }
예제 #5
0
        // renders the given node to the internal ElementData dictionary. If the given node is
        // not a element, will recursively descend until we render its elements.
        private void RenderNode(ElementNode node)
        {
            int wid = 0;
            int ht  = 0;

            if (_data.NutcrackerData.StringOrienation == NutcrackerEffects.StringOrientations.Horizontal)
            {
                wid = PixelsPerString();
                ht  = StringCount;
            }
            else
            {
                wid = StringCount;
                ht  = PixelsPerString();
            }
            int nFrames = (int)(TimeSpan.TotalMilliseconds / frameMs);
            NutcrackerEffects nccore = new NutcrackerEffects(_data.NutcrackerData);

            nccore.InitBuffer(wid, ht);
            int totalPixels = nccore.PixelCount();

            if (totalPixels != wid * ht)
            {
                throw new Exception("bad pixel count");
            }
            int numElements = node.Count();

            if (numElements != totalPixels)
            {
                Logging.Warn("numEle " + numElements + " != totalPixels " + totalPixels);
            }

            TimeSpan startTime = TimeSpan.Zero;
            //TimeSpan ms50 = new TimeSpan(0, 0, 0, 0, frameMs);
            Stopwatch timer = new Stopwatch();

            timer.Start();

            // OK, we're gonna create 1 intent per element
            // that intent will hold framesToRender Color values
            // that it will parcel out as intent states are called for...

            // set up arrays to hold the generated colors
            var pixels = new RGBValue[numElements][];

            for (int eidx = 0; eidx < numElements; eidx++)
            {
                pixels[eidx] = new RGBValue[nFrames];
            }

            // generate all the pixels
            int pps = PixelsPerString();
            int sc  = StringCount;

            for (int frameNum = 0; frameNum < nFrames; frameNum++)
            {
                nccore.RenderNextEffect(_data.NutcrackerData.CurrentEffect);
                // peel off this frames pixels...
                if (_data.NutcrackerData.StringOrienation == NutcrackerEffects.StringOrientations.Horizontal)
                {
                    int i = 0;
                    for (int y = 0; y < sc; y++)
                    {
                        for (int x = 0; x < pps; x++)
                        {
                            pixels[i][frameNum] = new RGBValue(nccore.GetPixel(x, y));
                            i++;
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < numElements; i++)
                    {
                        pixels[i][frameNum] = new RGBValue(nccore.GetPixel(i));
                    }
                }
            }
            ;

            // create the intents
            var            frameTs  = new TimeSpan(0, 0, 0, 0, frameMs);
            List <Element> elements = node.ToList();

            for (int eidx = 0; eidx < numElements; eidx++)
            {
                IIntent intent = new StaticArrayIntent <RGBValue>(frameTs, pixels[eidx], TimeSpan);
                _elementData.AddIntentForElement(elements[eidx].Id, intent, startTime);
            }

            timer.Stop();
            Logging.Debug(" {0}ms, Frames: {1}, wid: {2}, ht: {3},  pix: {4}, intents: {5}",
                          timer.ElapsedMilliseconds, nFrames, wid, ht, totalPixels, _elementData.Count());
        }
예제 #6
0
 private void SetCurrentEffect(NutcrackerEffects.Effects selectedEffect)
 {
     Data.CurrentEffect = selectedEffect;
     effect.SetNextState(true);
     SetCurrentTab(selectedEffect.ToString());
 }
예제 #7
0
        // renders the given node to the internal ElementData dictionary. If the given node is
        // not a element, will recursively descend until we render its elements.
        private void RenderNode(ElementNode node)
        {
            int wid = 0;
            int ht = 0;
            if (_data.NutcrackerData.StringOrienation == NutcrackerEffects.StringOrientations.Horizontal)
            {
                wid = PixelsPerString();
                ht = StringCount;
            }
            else
            {
                wid = StringCount;
                ht = PixelsPerString();
            }
            int nFrames = (int)(TimeSpan.TotalMilliseconds / frameMs);
            NutcrackerEffects nccore = new NutcrackerEffects(_data.NutcrackerData);
            nccore.InitBuffer( wid, ht);
            int totalPixels = nccore.PixelCount();
            if( totalPixels != wid * ht)
                throw new Exception("bad pixel count");
            int numElements = node.Count();
            if (numElements != totalPixels)
                Logging.Warn( "numEle " + numElements + " != totalPixels " + totalPixels);

            TimeSpan startTime = TimeSpan.Zero;
            //TimeSpan ms50 = new TimeSpan(0, 0, 0, 0, frameMs);
            Stopwatch timer = new Stopwatch();
            timer.Start();

            // OK, we're gonna create 1 intent per element
            // that intent will hold framesToRender Color values
            // that it will parcel out as intent states are called for...

            // set up arrays to hold the generated colors
            var pixels = new RGBValue[numElements][];
            for (int eidx = 0; eidx < numElements; eidx++)
                pixels[eidx] = new RGBValue[nFrames];

            // generate all the pixels
            int pps = PixelsPerString();
            int sc = StringCount;
            for (int frameNum = 0; frameNum < nFrames; frameNum++)
            {
                nccore.RenderNextEffect(_data.NutcrackerData.CurrentEffect);
                // peel off this frames pixels...
                if (_data.NutcrackerData.StringOrienation == NutcrackerEffects.StringOrientations.Horizontal)
                {
                    int i = 0;
                    for (int y = 0; y < sc; y++)
                    {
                        for (int x = 0; x < pps; x++)
                        {
                            pixels[i][frameNum] = new RGBValue(nccore.GetPixel(x, y));
                            i++;
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < numElements; i++)
                    {
                        pixels[i][frameNum] = new RGBValue(nccore.GetPixel(i));
                    }
                }
            };

            // create the intents
            var frameTs = new TimeSpan(0, 0, 0, 0, frameMs);
            List<Element> elements = node.ToList();
            for (int eidx = 0; eidx < numElements; eidx++)
            {
                IIntent intent = new StaticArrayIntent<RGBValue>(frameTs, pixels[eidx], TimeSpan);
                _elementData.AddIntentForElement(elements[eidx].Id, intent, startTime);
            }

            timer.Stop();
            Logging.Debug(" {0}ms, Frames: {1}, wid: {2}, ht: {3},  pix: {4}, intents: {5}",
                            timer.ElapsedMilliseconds, nFrames, wid, ht, totalPixels, _elementData.Count());
        }