/
Cloth Cache With First Stack Order
Cloth Cache With First Stack Order
Welcome to this new blog post!
Today we are going to have a look at how you can use cloth caches with the First stack order mode.
Here is a script for randomizing your cloth caches.
import AtomsCore import AtomsUtils import AtomsMath import os import sys import random #agents ids to randomize agents_ids = range(0,5) #random time offset range time_offset = 30 #input cache cache_path = "E:/Atoms_files/atoms/deformed_cache/deform_anim.clothcache" cache_folder = os.path.dirname(cache_path) cache_name = os.path.basename(cache_path).split('.clothcache')[0] #output cache out_cache_folder = cache_folder out_cache_name = cache_name+"_new" #open the header to get the start and end frame ark = AtomsCore.Archive() ark.readFromFile(cache_path) cache_header = AtomsCore.MapMetadata() cache_header.deserialise(ark) start = cache_header['startFrame'].value() end = cache_header['endFrame'].value() #load all the frames of the * entry in memory all_frame_data = {} for i in range(start, end+1): curr_file = "%s/%s.%04d.clothcache" % (cache_folder, cache_name, i) ark_frame = AtomsCore.Archive() ark_frame.readFromFile(curr_file) cache_frame = AtomsCore.MapMetadata() cache_frame.deserialise(ark_frame) if not '*' in cache_frame: continue frame_data = cache_frame['*'] all_frame_data[i] = frame_data.clone() #randomize time offset agents_ids_time_offset = [0 for i in agents_ids] for i in range(len(agents_ids_time_offset)): agents_ids_time_offset[i] = random.randint(-time_offset,time_offset) #rebuild the new random cache for f in range(start, end+1): frame_data = AtomsCore.MapMetadata() for i in range(len(agents_ids)): curr_frame = agents_ids_time_offset[i] % (end - start) + start agents_ids_time_offset[i] = agents_ids_time_offset[i] + 1 frame_data[str(agents_ids[i])] = all_frame_data[curr_frame] frame_data['*'] = all_frame_data[f] frame_data['boundingBox'] = AtomsCore.Box3Metadata(AtomsMath.Box3d()) ark_frame = AtomsCore.Archive(frame_data.memSize()) frame_data.serialise(ark_frame) curr_file = "%s/%s.%04d.clothcache" % (out_cache_folder, out_cache_name, f) print curr_file ark_frame.writeToFile(curr_file) #copy the header ark_header = AtomsCore.Archive(cache_header.memSize()) cache_header.serialise(ark_header) header_file = "%s/%s.clothcache" % (out_cache_folder, out_cache_name) ark_frame.writeToFile(header_file)
, multiple selections available,
Related content
Reading an Atoms Cache
Reading an Atoms Cache
More like this
Arnold procedural parameters
Arnold procedural parameters
More like this
VRay procedural parameters
VRay procedural parameters
More like this
Renderman procedural parameters
Renderman procedural parameters
More like this
Read/Write an Atoms cache
Read/Write an Atoms cache
More like this
Atoms cache actor (AtomsUnreal)
Atoms cache actor (AtomsUnreal)
More like this
Copyright © 2017, Toolchefs LTD.