Esempio n. 1
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="groupRef"></param>
        public void Load(SUGroupRef groupRef)
        {
            SUDrawingElementRef drawingRef = SKPCExport.SUGroupToDrawingElement(groupRef);
            SUEntityRef         entityRef  = SKPCExport.SUDrawingElementToEntity(drawingRef);

            m_identity = SkpEntityCache.GetIdentity(entityRef);
            m_defaultMaterialIdentity = SkpEntityCache.GetMaterialDefault(drawingRef);

            SUEntitiesRef entities = default;

            SKPCExport.SUGroupGetEntities(groupRef, ref entities);

            m_faces     = SkpFace.GetEntityFaces(entities, Model);
            m_instances = SkpInstance.GetEntityInstances(entities, Model);
            m_groups    = SkpGroup.GetEntityGroups(entities, Model);

            SUTransformation transform = default;

            SKPCExport.SUGroupGetTransform(groupRef, ref transform);
            m_transform = new SkpTransform(transform);

            SUStringRef groupName = default(SUStringRef);

            SKPCExport.SUStringCreate(ref groupName);
            SKPCExport.SUGroupGetName(groupRef, ref groupName);
            m_name = Utilities.GetString(groupName);
            SKPCExport.SUStringRelease(ref groupName);

            m_clusters = SkpFaceCluster.Load(m_faces.Values, m_model);
        }
Esempio n. 2
0
        public void Load(SUComponentDefinitionRef p_suComponentRef)
        {
            SUDrawingElementRef drawingRef = SKPCExport.SUComponentDefinitionToDrawingElement(p_suComponentRef);
            SUEntityRef         entityRef  = SKPCExport.SUDrawingElementToEntity(drawingRef);

            m_identity = SkpEntityCache.GetIdentity(entityRef);
            m_defaultMaterialIdentity = SkpEntityCache.GetMaterialDefault(drawingRef);

            SUEntitiesRef entities = default(SUEntitiesRef);

            SKPCExport.SUComponentDefinitionGetEntities(p_suComponentRef, ref entities);
            m_instances = SkpInstance.GetEntityInstances(entities, Model);
            m_groups    = SkpGroup.GetEntityGroups(entities, Model);
            m_faces     = SkpFace.GetEntityFaces(entities, Model);
            m_clusters  = SkpFaceCluster.Load(m_faces.Values, m_model);
        }
Esempio n. 3
0
        public static Dictionary <string, SkpFaceCluster> Load(IEnumerable <SkpFace> p_faces, SkpModel p_model)
        {
            if (p_faces == null || p_faces.Count() == 0)
            {
                return(new Dictionary <string, SkpFaceCluster>());
            }

            Dictionary <string, Tuple <List <Tuple <Vector3[], Vector2[], Vector3[], int[]> >, List <Tuple <SkpFace, bool> > > > objectDatas = new Dictionary <string, Tuple <List <Tuple <Vector3[], Vector2[], Vector3[], int[]> >, List <Tuple <SkpFace, bool> > > >();

            foreach (var item in p_faces)
            {
                string frontMaterialIdentity = string.IsNullOrEmpty(item.FrontMaterialIdentity) ? p_model.DefaultMaterialName: item.FrontMaterialIdentity;
                Tuple <Vector3[], Vector2[], Vector3[], int[]> frontMeshdata = item.FaceMesh.GenerateFrontMeshData();
                if (!objectDatas.ContainsKey(frontMaterialIdentity))
                {
                    objectDatas[frontMaterialIdentity] = new Tuple <List <Tuple <Vector3[], Vector2[], Vector3[], int[]> >, List <Tuple <SkpFace, bool> > >(new List <Tuple <Vector3[], Vector2[], Vector3[], int[]> >(), new List <Tuple <SkpFace, bool> >());
                }
                objectDatas[frontMaterialIdentity].Item1.Add(frontMeshdata);
                objectDatas[frontMaterialIdentity].Item2.Add(new Tuple <SkpFace, bool>(item, true));

                string backMaterialIdentity = string.IsNullOrEmpty(item.BackMaterialIdentity) ? p_model.DefaultMaterialName : item.BackMaterialIdentity;
                Tuple <Vector3[], Vector2[], Vector3[], int[]> backMeshdata = item.FaceMesh.GenerateBackMeshData();
                if (!objectDatas.ContainsKey(backMaterialIdentity))
                {
                    objectDatas[backMaterialIdentity] = new Tuple <List <Tuple <Vector3[], Vector2[], Vector3[], int[]> >, List <Tuple <SkpFace, bool> > >(new List <Tuple <Vector3[], Vector2[], Vector3[], int[]> >(), new List <Tuple <SkpFace, bool> >());
                }
                objectDatas[backMaterialIdentity].Item1.Add(backMeshdata);
                objectDatas[backMaterialIdentity].Item2.Add(new Tuple <SkpFace, bool>(item, false));
            }

            Dictionary <string, SkpFaceCluster> clusters = new Dictionary <string, SkpFaceCluster>();

            foreach (var materialIdentity in objectDatas.Keys)
            {
                List <Tuple <Vector3[], Vector2[], Vector3[], int[]> > meshDatas = objectDatas[materialIdentity].Item1;
                List <Tuple <SkpFace, bool> > faces = objectDatas[materialIdentity].Item2;

                SkpFaceCluster cluster = new SkpFaceCluster(faces, materialIdentity, meshDatas, p_model);
                clusters.Add(cluster.m_clusterID, cluster);
            }

            return(clusters);
        }