public void Process(RemapLineInfo _info, float _size) { info = _info; size = _size; info.pts [0].pcg = 0; info.pts [info.pts.Count - 1].pcg = 1; float len = 0; //step 1:Cal Point Pcg for (int i = 0; i < info.pts.Count - 1; i++) { len += Vector2.Distance(info.pts[i].uv, info.pts[i + 1].uv); } for (int i = 1; i < info.pts.Count - 1; i++) { float dis = Vector2.Distance(info.pts[i].uv, info.pts[i - 1].uv); info.pts [i].pcg = info.pts [i - 1].pcg + dis / len; } //step 2:before after pcg center for (int k = 0; k < info.pts.Count; k++) { var p0 = info.pts [SWTextureProcess.LoopID(k - 1, info.pts.Count)].uv; var p1 = info.pts [SWTextureProcess.LoopID(k, info.pts.Count)].uv; var p2 = info.pts [SWTextureProcess.LoopID(k + 1, info.pts.Count)].uv; float angle = Vector2.Angle(p2 - p1, p0 - p1); float x = 90 - angle * 0.5f; float width = size * Mathf.Tan(x * Mathf.Deg2Rad); info.pts[k].pre = p1 + (p0 - p1).normalized * width; info.pts[k].after = p1 + (p2 - p1).normalized * width; var me = info.pts [SWTextureProcess.LoopID(k, info.pts.Count)]; var item = info.pts [SWTextureProcess.LoopID(k - 1, info.pts.Count)]; float dis = Vector2.Distance(me.uv, item.uv); info.pts [k].prePcg = me.pcg + (item.pcg - me.pcg) * width / dis; item = info.pts [SWTextureProcess.LoopID(k + 1, info.pts.Count)]; dis = Vector2.Distance(me.uv, item.uv); info.pts [k].afterPcg = me.pcg + (item.pcg - me.pcg) * width / dis; float angleSigned = SWCommon.AngleSigned(p2 - p1, p1 - p0, new Vector3(0, 0, 1)); Vector2 vv = p1 - p0; Matrix4x4 m = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0, 0, Mathf.Sign(angleSigned) * -90), Vector3.one); vv = m.MultiplyVector(vv); info.pts[k].center = info.pts[k].pre + vv.normalized * size; } Process(); }
public static void ProcessRemap_Line(SWTexture2DEx tex, RemapLineInfo info, float size) { SWUndo.RegisterCompleteObjectUndo(tex); if (info.stitch) { ProcessRemap_LineStitch(tex, info, size); } else { ProcessRemap_LineNormal(tex, info, size); } }
public static void ProcessRemap_Line(SWTexture2DEx tex, RemapLineInfo info, float size) { SWUndo.RegisterCompleteObjectUndo(tex); //if (info.stitch) if (SWWindowDrawRemap.Instance.rData.l.st) { ProcessRemap_LineStitch(tex, info, size); } else { ProcessRemap_LineNormal(tex, info, size); } }
public override void Init(SWDataNode _data, SWWindowMain _window) { childPortSingleConnection = true; styleID = 2; base.Init(_data, _window); data.outputType.Add(SWDataType._UV); data.inputType.Add(SWDataType._Color); if (textureEx.IsNull) { ResetTex(); } lineInfo = ScriptableObject.CreateInstance <RemapLineInfo>(); }
public static void ProcessRemap_LineStitch(SWTexture2DEx tex, RemapLineInfo info, float size) { TexThread_RemapLineStitch t = new TexThread_RemapLineStitch(tex, null); t.Process(info, size); }
public void Init(SWNodeRemap _node) { node = _node; info = ScriptableObject.CreateInstance <RemapLineInfo>(); }