Exemple #1
0
        public static void ImportSceneObjects(string dirPath)
        {
            // clear
            foreach (SceneObject obj in ShowSceneObjects)
            {
                obj.Clear();
            }

            ShowSceneObjects.Clear();

            SceneUnderstandingObjects SceneObj = new SceneUnderstandingObjects(dirPath);

            if (SceneObj.GetNElement() < 1)
            {
                Debug.Log("Scene object data in " + dirPath + " is empty.");
                return;
            }

            #region Set scene object data
            for (int objType = 0; objType < (int)SceneUnderstandingObjectType.NumOfTypes; objType++)
            {
                foreach (SceneUnderstandingObjects.Element element in SceneObj.GetElements(objType))
                {
                    SceneObject scene_obj = new SceneObject();
                    scene_obj.BoundingBoxGameObj = new List <GameObject>();
                    scene_obj.IconGameObj        = new List <GameObject>();
                    scene_obj.objTypeID          = (SceneUnderstandingObjectType)objType;
                    scene_obj.objID       = element.id;
                    scene_obj.objFileName = element.objfilename;
                    scene_obj.cldFileName = element.cldfilename;
                    scene_obj.forward     = element.forward;
                    scene_obj.positions   = element.position;
                    SceneObj.GetElementsBoundingBoxMeshes(objType, element, ref scene_obj.BoundingBoxGameObj);
                    SceneObj.GetElementsIcons(objType, element, ref scene_obj.IconGameObj);
                    ShowSceneObjects.Add(scene_obj);
                }
            }
            #endregion
        }
Exemple #2
0
        public static void ImportSceneObjectsByType(string dirPath, SceneUnderstandingObjectType objType)
        {
            SceneUnderstandingObjects SceneObj = new SceneUnderstandingObjects(dirPath);

            foreach (SceneObject ssobj in ShowSceneObjects)
            {
                if (ssobj.objTypeID == objType)
                {
                    foreach (GameObject obj in ssobj.BoundingBoxGameObj)
                    {
                        if (obj != null)
                        {
                            GameObject.Destroy(obj);
                        }
                    }
                }
            }
            if (SceneObj.GetNElement() < 1)
            {
                Debug.Log("Scene semantic [" + SceneObj.GetElementName((int)objType) + "] data is empty");
                return;
            }
            //Comment in ViveSR
            //else
            //{
            //    foreach (SceneUnderstandingObjects.Element each in SceneObj.GetElements(objType))
            //    {
            //        Debug.Log("id[" + each.id + "] tag[" + each.tag + "]");

            //        Debug.Log("objfilename = " + each.objfilename);
            //        Debug.Log("cldfilename = " + each.cldfilename);
            //        Debug.Log("pos num = " + each.position.Count);
            //        foreach (var pos in each.position)
            //        {
            //            Debug.Log("pos idx = " + each.position.IndexOf(pos));
            //            Debug.Log("pos.x = " + pos.x);
            //            Debug.Log("pos.y = " + pos.y);
            //            Debug.Log("pos.z = " + pos.z);
            //        }
            //        //Debug.Log("forward = " + each.forward);
            //        Debug.Log("bBoxMinPoint = " + each.bBoxMinPoint);
            //        Debug.Log("bBoxMaxPoint = " + each.bBoxMaxPoint);
            //    }
            //}

            #region Get Object Bounding Box
            foreach (SceneUnderstandingObjects.Element element in SceneObj.GetElements((int)objType))
            {
                SceneObject scene_obj = new SceneObject();
                scene_obj.BoundingBoxGameObj = new List <GameObject>();
                scene_obj.IconGameObj        = new List <GameObject>();
                scene_obj.objTypeID          = (SceneUnderstandingObjectType)objType;
                scene_obj.objID       = element.id;
                scene_obj.objFileName = element.objfilename;
                scene_obj.cldFileName = element.cldfilename;
                scene_obj.forward     = element.forward;
                scene_obj.positions   = element.position;
                SceneObj.GetElementsBoundingBoxMeshes((int)objType, element, ref scene_obj.BoundingBoxGameObj);
                SceneObj.GetElementsIcons((int)objType, element, ref scene_obj.IconGameObj);
                ShowSceneObjects.Add(scene_obj);
            }
            #endregion
        }