/// <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); }
/// <summary> /// 获取唯一标记 /// </summary> /// <param name="suEntity"></param> /// <param name="p_indentityDefault"></param> /// <returns></returns> public static string GetIdentity(SUEntityRef suEntity) { if (suEntity.ptr == IntPtr.Zero) { return(null); } long persistentID = default; SKPCExport.SUEntityGetPersistentID(suEntity, ref persistentID); if (persistentID != 0) { string identityStr = persistentID.ToString(); return(identityStr); } if (GetAttribute(suEntity, "Sandu", "Identity", out string identitySandu)) { return(identitySandu); } int entityID = default; SKPCExport.SUEntityGetID(suEntity, ref entityID); string identityID = entityID.ToString(); return(identityID); }
/// <summary> /// 获取属性值 /// </summary> /// <param name="suEntityRef"></param> /// <param name="attributeName"></param> /// <param name="propertyName"></param> /// <returns></returns> public static bool GetAttribute(SUEntityRef suEntityRef, string attributeName, string propertyName, out string defaultValue) { if (suEntityRef.ptr == IntPtr.Zero) { defaultValue = null; return(false); } SUAttributeDictionaryRef dictionaryRef = default(SUAttributeDictionaryRef); if (SKPCExport.SUEntityGetAttributeDictionary(suEntityRef, attributeName, ref dictionaryRef) == SUResult.SU_ERROR_NONE) { SUTypedValueRef propertyValueRef = default(SUTypedValueRef); if (SKPCExport.SUAttributeDictionaryGetValue(dictionaryRef, attributeName, ref propertyValueRef) == SUResult.SU_ERROR_NONE) { SUStringRef temp = default; SKPCExport.SUStringCreate(ref temp); SKPCExport.SUTypedValueGetString(propertyValueRef, ref temp); defaultValue = Utilities.GetString(temp); SKPCExport.SUStringRelease(ref temp); return(true); } } defaultValue = null; return(false); }
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); }
public void Load(SUFaceRef p_suFaceRef) { SUDrawingElementRef drawingRef = SKPCExport.SUFaceToDrawingElement(p_suFaceRef); SUEntityRef entityRef = SKPCExport.SUDrawingElementToEntity(drawingRef); m_identity = SkpEntityCache.GetIdentity(entityRef); SUMaterialRef suFrontMaterialRef = default(SUMaterialRef); SKPCExport.SUFaceGetFrontMaterial(p_suFaceRef, ref suFrontMaterialRef); m_frontMaterialIdentity = SkpEntityCache.GetIdentity(SKPCExport.SUMaterialToEntity(suFrontMaterialRef)); SUMaterialRef suBackMaterialRef = default(SUMaterialRef); SKPCExport.SUFaceGetBackMaterial(p_suFaceRef, ref suBackMaterialRef); m_backMaterialIdentity = SkpEntityCache.GetIdentity(SKPCExport.SUMaterialToEntity(suBackMaterialRef)); m_faceMesh = new SkpFaceMesh(this); m_faceMesh.Load(p_suFaceRef); }