Пример #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);
        }
Пример #2
0
 public void Dispose()
 {
     m_vertices  = null;
     m_uvsFront  = null;
     m_uvsBack   = null;
     m_normals   = null;
     m_triangles = null;
     m_face      = null;
 }
Пример #3
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public SkpFaceMesh(SkpFace p_face)
 {
     m_face      = p_face;
     m_vertices  = new SUPoint3D[0];
     m_uvsFront  = new SUPoint3D[0];
     m_uvsBack   = new SUPoint3D[0];
     m_normals   = new SUVector3D[0];
     m_triangles = new int[0];
 }
Пример #4
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);
        }
Пример #5
0
        public static Dictionary <string, SkpFace> GetEntityFaces(SUEntitiesRef p_suEntitiesRef, SkpModel p_model)
        {
            Dictionary <string, SkpFace> surfaces = new Dictionary <string, SkpFace>(200);

            long faceCount = 0;

            SKPCExport.SUEntitiesGetNumFaces(p_suEntitiesRef, ref faceCount);

            if (faceCount > 0)
            {
                SUFaceRef[] faces = new SUFaceRef[faceCount];
                SKPCExport.SUEntitiesGetFaces(p_suEntitiesRef, faceCount, faces, ref faceCount);

                for (long i = 0; i < faceCount; i++)
                {
                    SkpFace surface = new SkpFace(p_model);
                    surface.Load(faces[i]);
                    surfaces.Add(surface.Identity, surface);
                }
            }

            return(surfaces);
        }
Пример #6
0
        public static Task <Dictionary <string, SkpFace> > GetEntityFacesAsync(SUEntitiesRef p_suEntitiesRef, SkpModel p_model)
        {
            TaskCompletionSource <Dictionary <string, SkpFace> > tcs = new TaskCompletionSource <Dictionary <string, SkpFace> >();
            long faceCount = 0;

            SKPCExport.SUEntitiesGetNumFaces(p_suEntitiesRef, ref faceCount);

            if (faceCount > 0)
            {
                SUFaceRef[] faces = new SUFaceRef[faceCount];
                SKPCExport.SUEntitiesGetFaces(p_suEntitiesRef, faceCount, faces, ref faceCount);

                TaskExcutor.Run <SkpFace, SUFaceRef>(faces, f =>
                {
                    SkpFace surface = new SkpFace(p_model);
                    surface.Load(f);
                    return(surface);
                }).ContinueWith(t =>
                {
                    if (t.IsFaulted)
                    {
                        tcs.TrySetException(t.Exception);
                    }
                    else
                    {
                        tcs.TrySetResult(t.Result.ToDictionary(p => p.Identity, p => p));
                    }
                });
            }
            else
            {
                tcs.TrySetResult(new Dictionary <string, SkpFace>());
            }

            return(tcs.Task);
        }