Esempio n. 1
0
    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);
    }
Esempio n. 2
0
 private void ConstructTree(Transform node, SkinnedMetaballCell cell, Matrix4x4 toLocalMtx)
 {
     for (int index = 0; index < node.get_childCount(); ++index)
     {
         Transform    child     = node.GetChild(index);
         MetaballNode component = (MetaballNode)((Component)child).GetComponent <MetaballNode>();
         if (Object.op_Inequality((Object)component, (Object)null))
         {
             SkinnedMetaballCell cell1 = cell.AddChild(Vector4.op_Implicit(Matrix4x4.op_Multiply(toLocalMtx, Vector4.op_Implicit(Vector3.op_Subtraction(((Component)child).get_transform().get_position(), ((Component)this).get_transform().get_position())))), component.Radius, 0.0f);
             cell1.tag     = ((Object)((Component)child).get_gameObject()).get_name();
             cell1.density = component.Density;
             this.ConstructTree(child, cell1, toLocalMtx);
         }
     }
 }
Esempio n. 3
0
    void ConstructTree(Transform node, SkinnedMetaballCell cell, Matrix4x4 toLocalMtx)
    {
        for (int i = 0; i < node.childCount; ++i)
        {
            Transform    c = node.GetChild(i);
            MetaballNode n = c.GetComponent <MetaballNode>();

            if (n != null)
            {
                SkinnedMetaballCell childCell = cell.AddChild(toLocalMtx * (c.transform.position - transform.position), n.Radius, 0.0f);
                childCell.tag     = c.gameObject.name;
                childCell.density = n.Density;
                ConstructTree(c, childCell, toLocalMtx);
            }
        }
    }
    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);
    }