Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        //dependant on the message defintion:


        msg = new CombinedInfo(lin, ang, rota);
        rosObj.GetComponent <ROSInitializer>().ros.Publish(
            CombinedInfo_pub.GetMessageTopic(), msg
            );
    }
    //檢查亭的交界情況
    List <CombinedInfo> CheckConnectedInfo(List <BuildingObj> BuildingsList)
    {
        List <CombinedInfo> combinedInfos = new List <CombinedInfo>();

        for (int i = 0; i < BuildingsList.Count; i++)
        {
            CombinedInfo combinedInfo = new CombinedInfo();
            combinedInfos.Add(combinedInfo);
        }
        for (int i = 0; i < BuildingsList.Count; i++)
        {
            Dictionary <int, List <int> > info = new Dictionary <int, List <int> >();
            BuildingObj LTing = BuildingsList[i];
            for (int j = BuildingsList.Count - 1; j >= 0; j--)
            {
                if (i == j)
                {
                    continue;
                }
                BuildingObj RTing = BuildingsList[j];
                if (isNeedCombine(LTing, RTing))
                {
                    //Debug.Log(i + "&" + j + " Nedd to be combined");
                    //檐柱
                    List <Vector3> LEaveColPosList = LTing.bodyController.GetColumnStructBottomPosList(LTing.bodyController.eaveCornerColumnList);
                    List <Vector3> REaveColPosList = RTing.bodyController.GetColumnStructBottomPosList(RTing.bodyController.eaveCornerColumnList);
                    //中心點位置
                    Vector3 LTingCenter = LTing.platformCenter;
                    Vector3 RTingCenter = RTing.platformCenter;
                    //交平面
                    Plane midPlan = new Plane((LTingCenter - RTingCenter).normalized, (LTingCenter + RTingCenter) / 2);
                    //i亭交j亭的交界點
                    List <int> LIntersectionIndexList = new List <int>(FindOtherSideIndex(LEaveColPosList, RTingCenter, midPlan));
                    //與j亭交LIntersectionIndexList
                    info.Add(j, LIntersectionIndexList);
                }
            }
            combinedInfos[i].Info = info;
        }

        /**
         * 紀錄所有柱子個別交了多少亭
         */
        for (int i = 0; i < BuildingsList.Count; i++)
        {
            List <int> colStates = new List <int>();
            for (int j = 0; j < BuildingsList[i].bodyController.eaveCornerColumnList.Count; j++)
            {
                colStates.Add(0);
            }
            foreach (KeyValuePair <int, List <int> > kvp in combinedInfos[i].Info)
            {
                List <int> value = kvp.Value;
                for (int j = 0; j < value.Count; j++)
                {
                    colStates[value[j]]++;
                }
            }
            combinedInfos[i].colStates = colStates;
            //檢查是否有cycle
            for (int j = 0; j < combinedInfos[i].colStates.Count; j++)
            {
                if (combinedInfos[i].colStates[j] == 3)                //為內部點
                {
                    combinedInfos[i].count++;
                    combinedInfos[i].startCount++;
                }
            }
        }
        for (int i = 0; i < combinedInfos.Count; i++)
        {
            combinedInfos[i].init_Count = combinedInfos[i].count;
        }
        return(combinedInfos);
    }
Exemplo n.º 3
0
 public static string ToYAMLString(CombinedInfo msg)
 {
     return(msg.ToYAMLString());
 }
Exemplo n.º 4
0
 public new static void CallBack(CombinedInfo msg)
 {
     int [] temp;
     temp = msg.GetData_linear_acceleration();
     Debug.Log("Hello Hello !" + temp);
 }