public void ReadPositionsString(string positions) { this.ClearCells(); string[] strArray = positions.Split(';'); if (strArray.Length == 0) { throw new UnityException("invalid input positions data :" + positions); } for (int index = 0; index < strArray.Length; ++index) { this.AddCell(MetaballCellCluster.ParseVector3(strArray[index]), 0.0f, new float?(), (string)null); } }
private void ConstructCellCluster( MetaballCellCluster cluster, Transform parentNode, Matrix4x4 toLocalMtx, Transform meshTrans) { for (int index = 0; index < parentNode.get_childCount(); ++index) { Transform child = parentNode.GetChild(index); MetaballNode component = (MetaballNode)((Component)child).GetComponent <MetaballNode>(); if (Object.op_Inequality((Object)component, (Object)null)) { this._cellCluster.AddCell(meshTrans.InverseTransformPoint(child.get_position()), 0.0f, new float?(component.Radius), ((Object)((Component)child).get_gameObject()).get_name()).density = component.Density; } this.ConstructCellCluster(cluster, child, toLocalMtx, meshTrans); } }
void ConstructCellCluster(MetaballCellCluster cluster, Transform parentNode, Matrix4x4 toLocalMtx) { for (int i = 0; i < parentNode.childCount; ++i) { Transform c = parentNode.GetChild(i); MetaballNode n = c.GetComponent <MetaballNode>(); if (n != null) { MetaballCell cell = _cellCluster.AddCell(toLocalMtx * (c.position - transform.position), 0.0f, n.Radius, c.gameObject.name); cell.density = n.Density; } ConstructCellCluster(cluster, c, toLocalMtx); } }
public override void CreateMesh() { CleanupBoneRoot(); _cellCluster = new MetaballCellCluster(); Matrix4x4 toLocalMtx = meshFilter.transform.worldToLocalMatrix; ConstructCellCluster(_cellCluster, sourceRoot.transform, toLocalMtx); Mesh mesh; Vector3 uDir; Vector3 vDir; Vector3 uvOffset; GetUVBaseVector(out uDir, out vDir, out uvOffset); Bounds?bounds = null; if (bUseFixedBounds) { bounds = fixedBounds; } _errorMsg = MetaballBuilder.Instance.CreateMesh(_cellCluster, boneRoot.transform, powerThreshold, GridSize, uDir, vDir, uvOffset, out mesh, cellObjPrefab, bReverse, bounds, bAutoGridSize, autoGridQuarity); if (!string.IsNullOrEmpty(_errorMsg)) { Debug.LogError("MetaballError : " + _errorMsg); return; } mesh.RecalculateBounds(); meshFilter.sharedMesh = mesh; EnumBoneNodes(); }