public static SkinnedMetaballCell ConstructFromString(string data, float radius) { string[] cells = data.Split(';'); if (cells.Length == 0) { throw new UnityException("invalid input data :" + data); } // first one is root SkinnedMetaballCell rootCell = new SkinnedMetaballCell(); rootCell.parent = null; //_rootCell.directionFromParent = -1; rootCell.modelPosition = ParseVector3(cells[0]); rootCell.radius = radius; // rootCell.resource = 100.0f; rootCell.baseColor = Vector3.zero; rootCell.CalcRotation(); for (int i = 1; i < cells.Length; ++i) { Vector3 pos; pos = ParseVector3(cells[i]); rootCell.AddChild(pos, radius, 0.0f); } return(rootCell); }
public static SkinnedMetaballCell ConstructFromString( string data, float radius) { string[] strArray = data.Split(';'); if (strArray.Length == 0) { throw new UnityException("invalid input data :" + data); } SkinnedMetaballCell skinnedMetaballCell = new SkinnedMetaballCell(); skinnedMetaballCell.parent = (SkinnedMetaballCell)null; skinnedMetaballCell.modelPosition = SkinnedMetaballCell.ParseVector3(strArray[0]); skinnedMetaballCell.radius = radius; skinnedMetaballCell.baseColor = Vector3.get_zero(); skinnedMetaballCell.CalcRotation(); for (int index = 1; index < strArray.Length; ++index) { Vector3 vector3 = SkinnedMetaballCell.ParseVector3(strArray[index]); skinnedMetaballCell.AddChild(vector3, radius, 0.0f); } return(skinnedMetaballCell); }
public SkinnedMetaballCell AddChild(Vector3 position, float in_radius, float minDistanceCoef = 1.0f) { SkinnedMetaballCell child = new SkinnedMetaballCell(); child.baseColor = baseColor; // child.resource = 0.0f; child.radius = in_radius; child.distanceFromRoot = distanceFromRoot + 1; child.modelPosition = position; child.parent = this; children.Add(child); // collision test bool bFail = false; Root.DoForeachSkinnedCell((c) => { if (c != child) { if ((child.modelPosition - c.modelPosition).sqrMagnitude < child.radius * child.radius * minDistanceCoef * minDistanceCoef) { bFail = true; } } }); if (bFail) { children.Remove(child); return(null); } child.CalcRotation(); return(child); }
public SkinnedMetaballCell AddChild( Vector3 position, float in_radius, float minDistanceCoef = 1f) { SkinnedMetaballCell child = new SkinnedMetaballCell(); child.baseColor = this.baseColor; child.radius = in_radius; child.distanceFromRoot = this.distanceFromRoot + 1; child.modelPosition = position; child.parent = this; this.children.Add(child); bool bFail = false; this.Root.DoForeachSkinnedCell((SkinnedMetaballCell.ForeachSkinnedCellDeleg)(c => { if (c == child) { return; } Vector3 vector3 = Vector3.op_Subtraction(child.modelPosition, c.modelPosition); if ((double)((Vector3) ref vector3).get_sqrMagnitude() >= (double)child.radius * (double)child.radius * (double)minDistanceCoef * (double)minDistanceCoef) { return; } bFail = true; })); if (bFail) { this.children.Remove(child); return((SkinnedMetaballCell)null); } child.CalcRotation(); return(child); }