예제 #1
0
    /// <summary>
    /// 获取新生对象
    /// </summary>
    /// <returns></returns>
    private GameObject GetNewGameObject(PairedIndex <OrganIndex> pairedOrganIndex)
    {
        GameObject cloneObject = GameObject.Instantiate(pairedOrganIndex.CurIndex.Belong);

        /*
         * 因枝干顶点已经调整完毕
         * 故可用后一关键帧中枝干所指的顶点索引确定前一关键帧顶点的位置
         */
        Vector3 position = TreeModel.GetBranchTopCenter(m_PreGameObjects[0], pairedOrganIndex.CurIndex.From);

        foreach (GameObject _subObject in GameObjectOperation.GetGameObjects(cloneObject))
        {
            if (!GameObjectValidate.HavaVertices(_subObject))
            {
                continue;
            }

            Vector3[] vertices = GameObjectOperation.GetVertices(_subObject);

            //该对象所有顶点均为该位置
            CopyVertices(_subObject.transform.InverseTransformPoint(position), vertices);
            GameObjectOperation.UpdateMeshInfo(_subObject, vertices);
        }

        //设置阈值为0
        GameObjectOperation.SetThreshold(cloneObject, 0);

        return(cloneObject);
    }