Exemplo n.º 1
0
    def PrintModelInfo(self, root=None):
        if root == None:
            root = scene.getRoot()

        n_triangles = scene.getPolygonCount([root], True, False, False)
        n_vertices = scene.getVertexCount([root], False, False, False)
        part_occurrences = scene.getPartOccurrences(root)
        n_parts = len(part_occurrences)
        n_prototypes = self.GetPrototypePartsCount(part_occurrences)
        logging.warning(
            f"=====> Model Info \t{self.message} \t-> Triangles: {n_triangles} \tVertices: {n_vertices} \tGeometry Parts: {n_parts} \tUnique Geometry Parts: {n_prototypes}"
        )
Exemplo n.º 2
0
    def StartExport(self):
        Logger().Warning(
            "=====> Model processing has been started, please wait processing..."
        )
        self.ApplyCustomInformations(self.root)
        originalTriangleCount = scene.getPolygonCount([self.root], True)

        if len(self.lod_decimations) <= 0:
            self.lod_decimations = [-1]

        for current_lod_level in range(len(self.lod_decimations)):
            file_name = "C:/tmp/lod-" + str(current_lod_level)
            if current_lod_level == 0:
                ExportScene((file_name + ".fbx")).Run()
                ExportScene((file_name + ".gltf")).Run()
            else:
                self.ApplyDecimateAlgorithms(originalTriangleCount,
                                             current_lod_level)
                ExportScene((file_name + ".fbx")).Run()
                ExportScene((file_name + ".gltf")).Run()
Exemplo n.º 3
0
    def ApplyDecimateAlgorithms(self, originalTriangleCount,
                                current_lod_level):
        targetTriangleCount = originalTriangleCount
        lod_decimation_value = self.lod_decimations[current_lod_level]

        if type(lod_decimation_value) is list:
            if len(lod_decimation_value) == 3:
                Logger().Warning(
                    f"=====> Applying DecimateToQuality algorithm to LOD{current_lod_level}..."
                )
                PixyzAlgorithms(verbose=True).Decimate([],
                                                       lod_decimation_value[0],
                                                       lod_decimation_value[1],
                                                       lod_decimation_value[2])
            elif len(lod_decimation_value) == 4:
                Logger().Warning(
                    f"=====> Applying Decimate algorithm to LOD{current_lod_level}..."
                )
                targetTriangleCount = math.ceil(
                    originalTriangleCount * (lod_decimation_value[3] / 100.0))
                PixyzAlgorithms(verbose=True).Decimate([],
                                                       lod_decimation_value[0],
                                                       lod_decimation_value[1],
                                                       lod_decimation_value[2])
            else:
                Logger().Error(
                    f"Wrong LOD information for LOD{current_lod_level}, please to be sure it is a list and contains 3 or 4 elements for decimateToQuality or HiddenRemoval algorithms."
                )
        else:
            Logger().Warning(
                f"=====> Applying DecimateTarget algorithm with {self.decimate_target_strategy}:{lod_decimation_value} parameters to LOD{current_lod_level}..."
            )
            PixyzAlgorithms(verbose=True).DecimateTarget(
                [], [self.decimate_target_strategy, lod_decimation_value])

        currentTriangleCount = scene.getPolygonCount([self.root], True)
        if currentTriangleCount > targetTriangleCount:
            Logger().Warning("=====> Doing decimate to target...")
            PixyzAlgorithms(verbose=True).DecimateTarget(
                [], ["triangleCount", targetTriangleCount])
        PixyzAlgorithms(verbose=False).DeletePatches()
Exemplo n.º 4
0
 def PrintOccurrenceInfo(self, occurrences):
     n_triangles = scene.getPolygonCount(occurrences, True, False, False)
     n_vertices = scene.getVertexCount(occurrences, False, False, False)
     logging.warning(
         f"=====> Occurrence Info \t{self.message} \t-> Triangles: {n_triangles} \tVertices: {n_vertices}"
     )
Exemplo n.º 5
0
    def Start(self):
        Logger().Warning(
            "=====> Model processing has been started, please wait processing..."
        )
        self.ApplyCustomInformations(self.root)
        originalTriangleCount = scene.getPolygonCount([self.root], True)

        if len(self.lod_decimations) <= 0:
            self.lod_decimations = [-1]

        for current_lod_level in range(len(self.lod_decimations)):
            if self.PreLodFunc is not None:
                self.PreLodFunc(current_lod_level)

            #Cull objects by current level threshold size. Simple select by size and delete
            scene.clearSelection()
            scene.selectByMaximumSize(
                self.small_object_threshold[current_lod_level], -1)
            scene.deleteSelection()

            if current_lod_level == 0:
                self.ApplyDecimateAlgorithms(originalTriangleCount,
                                             current_lod_level)
                originalTriangleCount = scene.getPolygonCount([self.root],
                                                              True)

                if self.exportFile == "":
                    self.UpdatePartInformation()
                    self.CreateWorkerItems(self.root, '18446744069414584320')
            else:
                self.ApplyDecimateAlgorithms(originalTriangleCount,
                                             current_lod_level)
                if self.exportFile == "":
                    self.UpdatePartInformation()
                    self.CreateWorkerItemsOnlyGeometry()

            if current_lod_level > 0 and self.exportFile == "":
                syncing = False
                while (syncing != True):
                    syncing = CheckStatusCode(
                        check_url="http://127.0.0.1:8081/healthcheck").Run()

            if self.PostLodFunc is not None:
                self.PostLodFunc(current_lod_level)

            if self.exportFile != "":
                file_name = self.exportFile + str(current_lod_level)
                ExportScene((file_name + ".gltf")).Run()

                self.redis_client.CustomPublish(
                    "Info", f"Exported - {file_name}.gltf")
                self.redis_client.CustomPublish("PixyzLodsProcessed",
                                                f"{current_lod_level+1}")
                self.redis_client.CustomPublish(
                    "PixyzTotalLods", f"{len(self.lod_decimations)}")
                self.redis_client.CustomPublish(
                    "PixyzLastLodTriangleCount",
                    f"{scene.getPolygonCount([self.root],True)}")
                self.redis_client.CustomPublish("PixyzOriginalTriangles",
                                                f"{originalTriangleCount}")

            else:
                self.StartProcess(current_lod_level)

                self.redis_client.Done()

                ending_process = False
                while (ending_process != True):
                    ending_process = CheckStatusCode(
                        check_url="http://127.0.0.1:8081/endprocess").Run()