本文整理汇总了Python中surface.Surface.serialise方法的典型用法代码示例。如果您正苦于以下问题:Python Surface.serialise方法的具体用法?Python Surface.serialise怎么用?Python Surface.serialise使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类surface.Surface
的用法示例。
在下文中一共展示了Surface.serialise方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Application
# 需要导入模块: from surface import Surface [as 别名]
# 或者: from surface.Surface import serialise [as 别名]
#.........这里部分代码省略.........
self._armature = blender_scene.objects[OBJ_ARMATURE]
self._geometry = blender_scene.objects[OBJ_GEOMETRY]
# EXPERIMENTAL
# Set position setter
# If DESK
if mounted_on_desk:
self._positioner = self._positioner_on_desk
self._selector = self._select_right_hand_on_desk
# 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)