public static void Mirror(this Curve2 curve, float mirrorError, Curve2 origin = null) { var axis = 0.5f;//mirrorAxis var append = new List <Key2>(); foreach (var k in curve) { if (Mathf.Abs(k.time - axis) < mirrorError)//points on mirror axis { if (origin != null) { var key = origin[curve.IndexOf(k)]; key.SetVector(new Vector2(axis, k.value)); //key.outMode = key.inMode; //key.outMode = KeyMode.None; } k.SetVector(new Vector2(axis, k.value)); k.outTan = k.inTan.MirrorX(axis); k.outMode = k.inMode; } else { var n = k.Clone(); ComTool.Swap(ref n.inTan, ref n.outTan);//先把切线翻转 n.inTan = n.inTan.MirrorX(n.time); n.outTan = n.outTan.MirrorX(n.time); n.SetVector(n.vector.MirrorX(axis)); // 然后SetVector一起拉过去 ComTool.Swap(ref n.inMode, ref n.outMode); append.Add(n); } } curve.keys.AddRange(append); curve.Sort(); }
private void CutAbove() { foreach (var unit in o.gridTerrain.units) { if (unit.pos.y > cutAboveNum) { ComTool.DestroyAuto(unit.go); unit.go = null; unit.id = -1; } } }
public void EmptyGrid(Vector3Int pos) { var unit = gridTerrain[pos]; if (unit != null) { lastPos = pos; lastPos.y--; gridTerrain.Remove(pos); ComTool.DestroyAuto(unit.go); } }
void Replace() { foreach (var unit in o.gridTerrain.units) { if (unit.id == from) { ComTool.DestroyAuto(unit.go); unit.id = to; unit.go = Instantiate(o.prefabs[to].go, o.poolGrid, true); } } o.gridTerrain.Arrange(); }
public static void CreateRig(RigData info, Transform rig, out Transform[] bones) { ComTool.ClearChildren(rig); float totalLength = 0; var ls = new float[info.bonesCount]; float len; for (int i = 0; i < info.bonesCount; i++) { len = info.curveBoneLength.Evaluate1D(i / (float)info.bonesCount); totalLength += len; ls[i] = len; } var ratio = info.length / totalLength; Transform p = null; for (int i = 0; i < info.bonesCount; i++) { var bone = new GameObject("bone " + i.ToString()).transform; bone.parent = p == null ? rig : p; p = bone; if (i == 0) { bone.SetLocalPosY(0); } else { bone.SetLocalPosY(ls[i - 1] * ratio); } } bones = rig.GetTransforms().ToArray(); var tail = new GameObject("bone tail"); tail.SetParent(rig); tail.SetLocalPosY(info.length); tail.SetParent(p, true); // flat bones foreach (var bone in bones) { bone.parent = rig; } }
public void FillGrid(Vector3Int pos, int id, bool replace) { var unit = gridTerrain[pos]; if (unit == null) { if (id >= prefabs.Count) { UpdateList(); } if (id >= prefabs.Count) { print("Invalid Tile id."); return; } gridTerrain.Add(newGrid(id, pos)); } else if (replace) { ComTool.DestroyAuto(unit.go); unit.id = id; unit.go = Instantiate(prefabs[id].go, poolGrid, true); } }
//public Vector3 normal; //public Vector3 na, nb, nc, nd; public static Quad ToReverse(Quad quad) { ComTool.Swap(ref quad.a, ref quad.d); return(quad); }