// 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) { bool altColor = false; bool startingColor = false; double intervals = 1; if (Enable) { //intervals = Math.DivRem((long)TimeSpan.TotalMilliseconds, (long)Interval, out rem); intervals = Math.Ceiling(TimeSpan.TotalMilliseconds / (double)Interval); } TimeSpan startTime = TimeSpan.Zero; for (int i = 0; i < intervals; i++) { altColor = startingColor; var intervalTime = intervals == 1 ? TimeSpan : TimeSpan.FromMilliseconds(Interval); LightingValue?lightingValue = null; int totalElements = node.Count(); int currentNode = 0; var nodes = node.GetLeafEnumerator(); while (currentNode < totalElements) { var elements = nodes.Skip(currentNode).Take(GroupEffect); currentNode += GroupEffect; int cNode = 0; elements.ToList().ForEach(element => { RenderElement(altColor, ref startTime, ref intervalTime, ref lightingValue, element); cNode++; }); altColor = !altColor; } startTime += intervalTime; startingColor = !startingColor; } }
// 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) { bool altColor = false; bool startingColor = false; double intervals = 1; if (Enable) { //intervals = Math.DivRem((long)TimeSpan.TotalMilliseconds, (long)Interval, out rem); intervals = Math.Ceiling(TimeSpan.TotalMilliseconds / (double)Interval); } TimeSpan startTime = TimeSpan.Zero; for (int i = 0; i < intervals; i++) { altColor = startingColor; var intervalTime = intervals == 1 ? TimeSpan : TimeSpan.FromMilliseconds(Interval); LightingValue? lightingValue = null; int totalElements = node.Count(); int currentNode = 0; var nodes = node.GetLeafEnumerator(); while (currentNode < totalElements) { var elements = nodes.Skip(currentNode).Take(GroupEffect); currentNode += GroupEffect; int cNode = 0; elements.ToList().ForEach(element => { RenderElement(altColor, ref startTime, ref intervalTime, ref lightingValue, element); cNode++; }); altColor = !altColor; } startTime += intervalTime; startingColor = !startingColor; } }
// 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(); }
protected EffectIntents RenderNode(ElementNode node) { EffectIntents effectIntents = new EffectIntents(); int nFrames = (int)(TimeSpan.TotalMilliseconds / FrameTime); if (nFrames <= 0) return effectIntents; var buffer = new PixelFrameBuffer(BufferWi, BufferHt, UseBaseColor?BaseColor:Color.Transparent); int bufferSize = StringPixelCounts.Sum(); TimeSpan startTime = TimeSpan.Zero; // set up arrays to hold the generated colors var pixels = new RGBValue[bufferSize][]; for (int eidx = 0; eidx < bufferSize; eidx++) pixels[eidx] = new RGBValue[nFrames]; // generate all the pixels for (int frameNum = 0; frameNum < nFrames; frameNum++) { if (UseBaseColor) { var level = BaseLevelCurve.GetValue(GetEffectTimeIntervalPosition(frameNum)*100)/100; buffer.ClearBuffer(level); } else { buffer.ClearBuffer(); } RenderEffect(frameNum, ref buffer); // peel off this frames pixels... if (StringOrientation == StringOrientation.Horizontal) { int i = 0; for (int y = 0; y < BufferHt; y++) { for (int x = 0; x < StringPixelCounts[y]; x++) { pixels[i][frameNum] = new RGBValue(buffer.GetColorAt(x,y)); i++; } } } else { int i = 0; for (int x = 0; x < BufferWi; x++) { for (int y = 0; y < StringPixelCounts[x]; y++) { pixels[i][frameNum] = new RGBValue(buffer.GetColorAt(x, y)); i++; } } } }; // create the intents var frameTs = new TimeSpan(0, 0, 0, 0, FrameTime); List<Element> elements = node.ToList(); int numElements = node.Count(); for (int eidx = 0; eidx < numElements; eidx++) { IIntent intent = new StaticArrayIntent<RGBValue>(frameTs, pixels[eidx], TimeSpan); effectIntents.AddIntentForElement(elements[eidx].Id, intent, startTime); } return effectIntents; }
private void CreateString() { if (Creating) { // There is no ElementNode selected in the tree if (inputElements == null) { StringCount++; } // We've got an ElementNode selected in the tree, now figure out what to do with it. else { int inputStringCount = 0; int inputPixelCount = 0; PreviewTools.CountPixelsAndStrings(inputElements, out inputPixelCount, out inputStringCount); int stringNum = _strings.Count(); // is this a single node with no children? if (inputPixelCount == 0 && inputStringCount == 0) { PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), 10, inputElements, ZoomLevel); line.Parent = this; _strings.Add(line); _stringCount = _strings.Count(); } // If we're here, we've got a group selected else { // Do we have multiple child strings in this group and no individual pixels selected? if (stringNum <= inputStringCount - 1 && inputPixelCount == 0) { StringType = StringTypes.Pixel; ElementNode child = null; if (inputStringCount > 0) { child = inputElements.Children.ToList()[stringNum]; } else { child = inputElements; } int pixelCount = child.Count(); PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), child.Count(), child, ZoomLevel); line.Parent = this; _strings.Add(line); _stringCount = _strings.Count(); } // If we're here, we have multiple pixels in a single string and no strings in our parent node else if (inputPixelCount > 2 && inputStringCount == 0 && stringNum == 0) { StringType = StringTypes.Pixel; PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), inputElements.Count(), inputElements, ZoomLevel); line.Parent = this; _strings.Add(line); _stringCount = _strings.Count(); } // If we get here, there is nothing valid selected so add a string and move on else { PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), 10, null, ZoomLevel); line.StringType = StringType; line.Parent = this; _strings.Add(line); _stringCount = _strings.Count(); } } } } }
// 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(); }
// 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()); }
protected EffectIntents RenderNode(ElementNode node) { EffectIntents effectIntents = new EffectIntents(); int nFrames = (int)(TimeSpan.TotalMilliseconds / FrameTime); if (nFrames <= 0) { return(effectIntents); } var buffer = new PixelFrameBuffer(BufferWi, BufferHt, UseBaseColor?BaseColor:Color.Transparent); int bufferSize = StringPixelCounts.Sum(); TimeSpan startTime = TimeSpan.Zero; // set up arrays to hold the generated colors var pixels = new RGBValue[bufferSize][]; for (int eidx = 0; eidx < bufferSize; eidx++) { pixels[eidx] = new RGBValue[nFrames]; } // generate all the pixels for (int frameNum = 0; frameNum < nFrames; frameNum++) { if (UseBaseColor) { var level = BaseLevelCurve.GetValue(GetEffectTimeIntervalPosition(frameNum) * 100) / 100; buffer.ClearBuffer(level); } else { buffer.ClearBuffer(); } RenderEffect(frameNum, ref buffer); // peel off this frames pixels... if (StringOrientation == StringOrientation.Horizontal) { int i = 0; for (int y = 0; y < BufferHt; y++) { for (int x = 0; x < StringPixelCounts[y]; x++) { pixels[i][frameNum] = new RGBValue(buffer.GetColorAt(x, y)); i++; } } } else { int i = 0; for (int x = 0; x < BufferWi; x++) { for (int y = 0; y < StringPixelCounts[x]; y++) { pixels[i][frameNum] = new RGBValue(buffer.GetColorAt(x, y)); i++; } } } } ; // create the intents var frameTs = new TimeSpan(0, 0, 0, 0, FrameTime); List <Element> elements = node.ToList(); int numElements = node.Count(); for (int eidx = 0; eidx < numElements; eidx++) { IIntent intent = new StaticArrayIntent <RGBValue>(frameTs, pixels[eidx], TimeSpan); effectIntents.AddIntentForElement(elements[eidx].Id, intent, startTime); } return(effectIntents); }
// 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()); }