當前位置: 首頁>>代碼示例>>Python>>正文


Python Surface.deserialise方法代碼示例

本文整理匯總了Python中surface.Surface.deserialise方法的典型用法代碼示例。如果您正苦於以下問題:Python Surface.deserialise方法的具體用法?Python Surface.deserialise怎麽用?Python Surface.deserialise使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在surface.Surface的用法示例。


在下文中一共展示了Surface.deserialise方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: Application

# 需要導入模塊: from surface import Surface [as 別名]
# 或者: from surface.Surface import deserialise [as 別名]

#.........這裏部分代碼省略.........
        # If HEAD
        else:
            self._positioner = self._positioner_on_head
            self._selector   = self._select_right_hand_on_head

        # Last time saved
        self._auto_save_time = self._origo[PROP_TEXT_TIMER]


    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
    def reset_view(self):
        orientation = Matrix(((1.0, 0.0, 0.0),
                              (0.0, 1.0, 0.0),
                              (0.0, 0.0, 1.0)))
        self._armature_control.worldOrientation = orientation
        self._armature.worldOrientation = orientation
        self._vertex_origo.worldScale = 1, 1, 1
        self._surface.update()


    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
    def save(self):
        # Save created mesh
        file_path = INT_TEMP_SAVE_FILE.format(datetime.now())
        save_to_file(path=file_path, data=self._surface.serialise())
        print('[OKAY] file has been saved to:', file_path)


    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
    def load(self):
        try:
            file_path = join(INT_TEMP_SAVE_FOLDER,
                             next(reversed(sorted(listdir(INT_TEMP_SAVE_FOLDER)))))
            self._surface.deserialise(load_from_file(file_path))
            print('[OKAY] file has been loaded from:', file_path)
        except StopIteration:
            print('[FAIL] there is no file in:', INT_TEMP_SAVE_FOLDER)


    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
    def auto_save(self):
        current_time = self._origo[PROP_TEXT_TIMER]
        if self._auto_save_time + INT_AUTO_SAVE_INTERVAL <= current_time:
            # Update last-time checked value
            self._auto_save_time = current_time
            # Save created mesh
            save_to_file(path=INT_AUTO_SAVE_FILE,
                         data=self._surface.serialise())
            print('[OKAY] file has been auto-saved to:', INT_AUTO_SAVE_FILE)


    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
    def recover_from_auto_save(self):
        self._auto_save_time = self._origo[PROP_TEXT_TIMER]
        self._surface.deserialise(load_from_file(INT_AUTO_SAVE_FILE))
        print('[OKAY] file has been recovered from:', INT_AUTO_SAVE_FILE)


    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
    def __call__(self):
        # HACK: The ugliest hack I've ever done...
        if self._preprocess:
            try:
                # Set HUD scene
                self._blender_overlay_scene = bge.logic.getSceneList()[1]
                # Stop preprocessing loops
開發者ID:kitchenbudapest,項目名稱:vr,代碼行數:70,代碼來源:app.py


注:本文中的surface.Surface.deserialise方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。