def addCut(self): itemFrom = QTableWidgetItem(str(self.__previousFrame + 1)) itemFrom.setFlags(itemFrom.flags() | Qt.ItemIsUserCheckable) itemFrom.setCheckState(Qt.Checked) itemTo = QTableWidgetItem(str(hou.intFrame())) targetRow = self.table.rowCount() self.table.insertRow(targetRow) self.table.setItem(targetRow, 0, itemFrom) self.table.setItem(targetRow, 1, itemTo) self.__previousFrame = hou.intFrame()
def playrange_to_precedent(): list_sf, list_f = sim_cache_framelists() index = sim_cache_precedent_index(hou.intFrame()) frame_start = list_f[index] frame_end = hou.playbar.playbackRange()[1] hou.playbar.setPlaybackRange(frame_start, frame_end)
def read_dataset_from_current_frame(working_dir, sop_name, prediction=False): frame_id = hou.intFrame() # Find the name of the current animation anim_type = hou.parm(sop_name + '/anim_types').evalAsString() clip_name = hou.parm(sop_name + '/' + anim_type).evalAsString() clip_name = clip_name.replace('.bclip', '') if prediction: clip_path = os.path.join(working_dir, 'prediction', clip_name + '.npz') else: clip_path = os.path.join(working_dir, 'dataset', clip_name + '.npz') if os.path.exists(clip_path): npzfile = np.load(clip_path) #bones = npzfile['bones'] #base_skinnings = npzfile['bases'] if prediction: smooth_skinnings = npzfile['predicted_smooths'] else: smooth_skinnings = npzfile['smooths'] #smooth_skinnings = npzfile['bases'] #bone = bones[frame_id-1] #base_skinning = base_skinnings[frame_id-1] smooth_skinning = smooth_skinnings[frame_id - 1] node = hou.pwd() geo = node.geometry() for i, point in enumerate(geo.points()): point.setPosition(smooth_skinning[i]) else: print('the file ', clip_path, ' doesnt exist')
def percent(node): frame_start = parm_check(node, 'f1') frame_end = parm_check(node, 'f2') frame_inc = parm_check(node, 'f3') if frame_start == frame_end and frame_start == frame_inc and frame_end == frame_inc: pc = 'Frame 1 (1 of 1, 100%) - ' + date + ' from: ' + str(node.path()) return pc if frame_inc == 1.0: if node.parm("frame"): frame = int(node.evalParm("frame")) else: frame = hou.intFrame() else: if node.parm("frame"): frame = float(node.evalParm("frame")) else: frame = hou.frame() padlen = len(str(abs(frame_end))) date = str(time.strftime("%X %p")) #Total Frame is (Beg Frame - End Frame + One Frame) / divisions frame_total = (frame_end - frame_start + 1) / frame_inc #Current Frame is if frame <= frame_start: frame_cur = 1 elif frame >= frame_end: frame_cur = frame_total else: frame_cur = (frame - frame_start + 1) #Percentage per = int(float(frame_cur) / float(frame_inc)) / float(frame_total) p = int(10000 * per) / 100 #Print Message pc = 'Frame ' + str(frame).zfill(padlen) + ' (' + str(frame_cur).zfill( padlen) + ' of ' + str(frame_total).zfill(padlen) + ', ' + str( p).zfill(2) + '%) - ' + date + ' from: ' + str(node.path()) return pc
def path_util(node, name, folder, ext, nameopt=None, component=None): path_var = "path_" + name path = node.evalParm(path_var) enable_var = "enable_" + name path_enable = node.evalParm(enable_var) if path_enable == 1 and path != "": path = path else: frame_tex = node.evalParm('frame_tex') method = node.evalParm('method') if nameopt: name_ext = nameopt else: name_ext = name if not component: component = pth.component(node) filelist = ['/', component, '_', name_ext, '_vat', ext] if ext is '.shader': filelist = ['/', component, '_vat', ext] if ext is 'texture': ext = node.evalParm("ext_texture") if ext == "": ext = '.exr' filelist = ['/', component, '_', name_ext, '_vat', ext] if frame_tex == 1 and method == 2: frame = '.' + str(hou.intFrame()).zfill(5) folder = "Resources/StreamingAssets/" + component filelist = ['/', name_ext, frame, ext] dirlist = [project(node), folder] path = pth.path_create(dirlist, filelist).replace("\\", '/') os.path.normpath(path) return path
def export_data_from_current_frame(working_dir, sop_name): max_frames = hou.evalParm(sop_name + '/nFrames') frame_id = hou.intFrame() if frame_id > max_frames or frame_id <= 0: print('do not write frame_id({}) because > max_frames({})'.format( frame_id, max_frames)) return # Find the name of the current animation anim_type = hou.parm(sop_name + '/anim_types').evalAsString() clip_name = hou.parm(sop_name + '/' + anim_type).evalAsString() clip_name = clip_name.replace('.bclip', '') # Export skeleton # The skeleton hierarchy is frame invariant => only write it once bone_names = get_bone_names(SMOOTH_SKINNING_INPUT_ID) skeleton_path = os.path.join(working_dir, DATASET_FOLDER, 'skeleton.txt') if not os.path.exists(skeleton_path): parent_names = get_bone_parents(sop_name, bone_names) with open(skeleton_path, 'w') as file_handler: for i, bone_name in enumerate(bone_names): file_handler.write(bone_name + ',' + parent_names[i]) file_handler.write('\n') # Export skinning # The skinning data is frame invariant => only write it once skinning_data = get_skinning_data(SMOOTH_SKINNING_INPUT_ID) skinning_path = os.path.join(working_dir, DATASET_FOLDER, 'skinning.npy') if not os.path.exists(skinning_path): np.save(skinning_path, skinning_data) # Export bone and geometry dataset bone = get_bone_data(sop_name, bone_names) base_skinning = get_vertices(BASE_SKINNING_INPUT_ID) smooth_skinning = get_vertices(SMOOTH_SKINNING_INPUT_ID) clip_path = os.path.join(working_dir, DATASET_FOLDER, clip_name + '.npz') bones, base_skinnings, smooth_skinnings = None, None, None if not os.path.exists(clip_path): bone_shape = ([max_frames] + list(bone.shape)) base_shape = ([max_frames] + list(base_skinning.shape)) smooth_shape = ([max_frames] + list(smooth_skinning.shape)) bones = np.empty(bone_shape, dtype=bone.dtype) base_skinnings = np.empty(base_shape, dtype=base_skinning.dtype) smooth_skinnings = np.empty(smooth_shape, dtype=smooth_skinning.dtype) else: npzfile = np.load(clip_path) bones = npzfile['bones'] base_skinnings = npzfile['bases'] smooth_skinnings = npzfile['smooths'] # Save data bones[frame_id - 1] = bone base_skinnings[frame_id - 1] = base_skinning smooth_skinnings[frame_id - 1] = smooth_skinning out_attributes = { 'bones': bones, 'bases': base_skinnings, 'smooths': smooth_skinnings } np.savez(clip_path, **out_attributes) print('writing frame {}/{} from animation into the file : {}'.format( frame_id, max_frames, clip_path))
def get_current_time(): return hou.intFrame()
def alembic_frame(): frame = str(hou.intFrame()).zfill(5) return frame