public override void Read(PackFileDeserializer des, BinaryReaderEx br) { base.Read(des, br); m_duration = br.ReadSingle(); m_toGeneratorStartTimeFraction = br.ReadSingle(); m_flags = br.ReadUInt16(); m_endMode = (EndMode)br.ReadSByte(); m_blendCurve = (BlendCurve)br.ReadSByte(); m_alignmentBone = br.ReadInt16(); br.ReadUInt64(); br.ReadUInt64(); br.ReadUInt64(); br.ReadUInt64(); br.ReadUInt64(); br.ReadUInt64(); br.ReadUInt64(); br.ReadUInt64(); br.ReadUInt64(); br.ReadUInt64(); br.ReadUInt64(); br.ReadUInt64(); br.ReadUInt64(); br.ReadUInt64(); br.ReadUInt64(); br.ReadUInt64(); br.ReadUInt64(); br.ReadUInt16(); }
public override void Read(PackFileDeserializer des, BinaryReaderEx br) { base.Read(des, br); m_hands = des.ReadClassArray <hkbHandIkDriverInfoHand>(br); m_fadeInOutCurve = (BlendCurve)br.ReadSByte(); br.ReadUInt32(); br.ReadUInt16(); br.ReadByte(); }
public void UpdateFromProjectorData(ProjectorData projectorData) { MaxBlend = projectorData.BlendData.MaxBlend; BlacklevelOffset = projectorData.BlendData.BlacklevelOffset; Blacklevel2Offset = projectorData.BlendData.Blacklevel2Offset; BlendCurve.InitFromConfig(projectorData.BlendData.CurvePoints); var controlPoints = projectorData.ControlPoints; if (controlPoints != null) { for (var i = 0; i < ControlPoints.Count; i++) { ControlPoints[i].X = controlPoints[i].X; ControlPoints[i].Y = controlPoints[i].Y; if (controlPoints[i].ControlPointType == ControlPointType.IsFix) { ControlPoints[i].ControlPointType = ControlPointType.IsFix; } } } var blacklevelControlPoints = projectorData.BlacklevelControlPoints; if (blacklevelControlPoints != null) { for (var i = 0; i < BlacklevelControlPoints.Count; i++) { BlacklevelControlPoints[i].X = blacklevelControlPoints[i].X; BlacklevelControlPoints[i].Y = blacklevelControlPoints[i].Y; } } var blacklevel2ControlPoints = projectorData.Blacklevel2ControlPoints; if (blacklevel2ControlPoints != null) { for (var i = 0; i < Blacklevel2ControlPoints.Count; i++) { Blacklevel2ControlPoints[i].X = blacklevel2ControlPoints[i].X; Blacklevel2ControlPoints[i].Y = blacklevel2ControlPoints[i].Y; } } var blendRegionControlPoints = projectorData.BlendRegionControlPoints; if (blendRegionControlPoints != null) { for (var i = 0; i < BlendRegionControlPoints.Count; i++) { BlendRegionControlPoints[i].X = blendRegionControlPoints[i].X; BlendRegionControlPoints[i].Y = blendRegionControlPoints[i].Y; } } }
public ProjectorData GetProjectorData() { return(new ProjectorData { BlendData = new BlendSettings { MaxBlend = MaxBlend, BlacklevelOffset = BlacklevelOffset, Blacklevel2Offset = Blacklevel2Offset, CurvePoints = BlendCurve.GetCurvePoints() }, ControlPoints = ControlPoints.ToArray(), BlendRegionControlPoints = BlendRegionControlPoints.ToArray(), BlacklevelControlPoints = BlacklevelControlPoints.ToArray(), Blacklevel2ControlPoints = Blacklevel2ControlPoints.ToArray() }); }
protected override void RenderEffect(int frame, IPixelFrameBuffer frameBuffer) { double level = LevelCurve.GetValue(GetEffectTimeIntervalPosition(frame) * 100) / 100; double blendLevel = BlendCurve.GetValue(GetEffectTimeIntervalPosition(frame) * 100) / 100; double backgroundLevelCurve = BackgroundLevelCurve.GetValue(GetEffectTimeIntervalPosition(frame) * 100) / 100; int x, y, mod, b; float V; int cycleLen = frame * Speed; int pixelsPerBranch = (int)(0.5 + (double)BufferHt / Branches); if (pixelsPerBranch == 0) { pixelsPerBranch = 1; } if (frame == _xLimit) { _treeWidth = 0; _xLimit += BufferWi; } _treeWidth++; for (y = 0; y < BufferHt; y++) { for (x = 0; x < BufferWi; x++) { mod = y % pixelsPerBranch; if (mod == 0) { mod = pixelsPerBranch; } V = ToggleBlend //Fade between branches ? (float)(1 - (1.0 * mod / pixelsPerBranch) * (1 - blendLevel)) : (float)((1.0 * mod / pixelsPerBranch) * (blendLevel)); HSV hsv = HSV.FromRGB(BackgroundColor.GetColorAt((GetEffectTimeIntervalPosition(frame) * 100) / 100)); hsv.V = backgroundLevelCurve * V; // we have now set the color for the background tree // $orig_rgbval=$rgb_val; Branch = (int)((y - 1) / pixelsPerBranch); if (_branchColor >= Colors.Count || Branch == 0) { _branchColor = 0; } _row = pixelsPerBranch - mod; // now row=0 is bottom of branch, row=1 is one above bottom // mod = which pixel we are in the branch // mod=1,row=pixels_per_branch-1 top picrl in branch // mod=2, second pixel down into branch // mod=pixels_per_branch,row=0 last pixel in branch // // row = 0, the $p is in the bottom row of tree // row =1, the $p is in second row from bottom b = (int)((cycleLen) / BufferWi) % Branches; // what branch we are on based on frame # // // b = 0, we are on bottomow row of tree during frames 1 to BufferWi // b = 1, we are on second row from bottom, frames = BufferWi+1 to 2*BufferWi // b = 2, we are on third row from bottome, frames - 2*BufferWi+1 to 3*BufferWi M = (x % 6); // m=0, 1sr strand // m=1, 2nd strand // m=5, last strand in 6 strand pattern switch (ColorType) { case TreeColorType.Twinkle: _colorIdx = _random.Next(0, Colors.Count); break; case TreeColorType.AlternatePixel: _colorIdx = (x % Colors.Count); break; case TreeColorType.Static: _colorIdx = _branchColor; break; case TreeColorType.Alternate: break; } switch (BranchDirection) { case TreeBranchDirection.UpRight: case TreeBranchDirection.DownRight: case TreeBranchDirection.UpLeft: case TreeBranchDirection.DownLeft: if (Branch <= b && x <= _treeWidth && (((_row == 3 && (M == 0 || M == 5)) || ((_row == 2 && (M == 1 || M == 4)) || ((_row == 1 && (M == 2 || M == 3))))))) { hsv = HSV.FromRGB(Colors[_colorIdx].GetColorAt((GetEffectTimeIntervalPosition(frame) * 100) / 100)); } break; case TreeBranchDirection.Up: case TreeBranchDirection.Down: if (Branch <= b && (((_row == 3 && (M == 0 || M == 5)) || ((_row == 2 && (M == 1 || M == 4)) || ((_row == 1 && (M == 2 || M == 3))))))) { hsv = HSV.FromRGB(Colors[_colorIdx].GetColorAt((GetEffectTimeIntervalPosition(frame) * 100) / 100)); } break; case TreeBranchDirection.Left: if ((BufferWi - x) <= _treeWidth && (((_row == 3 && (M == 0 || M == 5)) || ((_row == 2 && (M == 1 || M == 4)) || ((_row == 1 && (M == 2 || M == 3))))))) { hsv = HSV.FromRGB(Colors[_colorIdx].GetColorAt((GetEffectTimeIntervalPosition(frame) * 100) / 100)); } break; case TreeBranchDirection.Alternate: if (Branch % 2 != 0) { if ((BufferWi - x) <= _treeWidth && (((_row == 3 && (M == 0 || M == 5)) || ((_row == 2 && (M == 1 || M == 4)) || ((_row == 1 && (M == 2 || M == 3))))))) { hsv = HSV.FromRGB(Colors[_colorIdx].GetColorAt((GetEffectTimeIntervalPosition(frame) * 100) / 100)); } } else { if (x <= _treeWidth && (((_row == 3 && (M == 0 || M == 5)) || ((_row == 2 && (M == 1 || M == 4)) || ((_row == 1 && (M == 2 || M == 3))))))) { hsv = HSV.FromRGB(Colors[_colorIdx].GetColorAt((GetEffectTimeIntervalPosition(frame) * 100) / 100)); } } break; case TreeBranchDirection.Right: if (x <= _treeWidth && (((_row == 3 && (M == 0 || M == 5)) || ((_row == 2 && (M == 1 || M == 4)) || ((_row == 1 && (M == 2 || M == 3))))))) { hsv = HSV.FromRGB(Colors[_colorIdx].GetColorAt((GetEffectTimeIntervalPosition(frame) * 100) / 100)); } break; case TreeBranchDirection.None: if (((((_row == 3 && (M == 0 || M == 5)) || ((_row == 2 && (M == 1 || M == 4)) || ((_row == 1 && (M == 2 || M == 3)))))))) { hsv = HSV.FromRGB(Colors[_colorIdx].GetColorAt((GetEffectTimeIntervalPosition(frame) * 100) / 100)); } break; } hsv.V = hsv.V * level; //adjusts overall intensity switch (BranchDirection) { case TreeBranchDirection.Down: case TreeBranchDirection.DownRight: frameBuffer.SetPixel(x, BufferHt - y, hsv); break; case TreeBranchDirection.UpLeft: frameBuffer.SetPixel(BufferWi - x, y, hsv); break; case TreeBranchDirection.DownLeft: frameBuffer.SetPixel(BufferWi - x, BufferHt - y, hsv); break; default: frameBuffer.SetPixel(x, y, hsv); break; } } _colorIdx = (Branch % Colors.Count); } }
public float[] GetBlendData() { var maxBlend = (float)MaxBlend; var blend3 = new float[_resolution.Width * _resolution.Height * 3]; Helpers.ArrayFill(blend3, maxBlend); var blendXList = new List <int>(); var blendYList = new List <int>(); foreach (var i in BlendRegionIndexes) { blendXList.Add(BlendRegionControlPoints[i].X); blendYList.Add(BlendRegionControlPoints[i].Y); } var blendx = blendXList.ToArray(); var blendy = blendYList.ToArray(); var bmp = new Bitmap(_resolution.Width, _resolution.Height); var g = Graphics.FromImage(bmp); var points = new System.Drawing.Point[blendx.Length]; for (var i = 0; i < blendx.Length; i++) { points[i] = new System.Drawing.Point(blendx[i], blendy[i]); } g.FillPolygon(Brushes.Black, points, System.Drawing.Drawing2D.FillMode.Winding); var bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, bmp.PixelFormat); var data = new byte[bmp.Height * bmpData.Stride]; Marshal.Copy(bmpData.Scan0, data, 0, data.Length); bmp.UnlockBits(bmpData); var f = bmpData.Stride / bmp.Width; double ox = -1; int w = -1; for (int y = 0; y < _resolution.Height; y++) { var yf = y * _resolution.Width * f; for (int x = 0; x < _resolution.Width; x++) { if (data[x * f + yf + 3] > 0) { if (w == -1) { w = CalcWidth(data, f, _resolution.Width, x, y); ox = x; } var value = maxBlend; if (w > 0) { var x2 = 1d / w * (x - ox); if (Index == 1) { x2 = 1d - x2; } value = (float)(BlendCurve.GetY(x2) * maxBlend); } blend3[(x + y * _resolution.Width) * 3 + 0] = value; blend3[(x + y * _resolution.Width) * 3 + 1] = value; blend3[(x + y * _resolution.Width) * 3 + 2] = value; } else { w = -1; } } } return(blend3.ToArray()); }