def generate_quake_motion_path(args): trace_file = args[0] #input trace file output_filename = _get_option_or_default(args, 1, 'quake.txt') xoffset = int(_get_option_or_default(args, 2, 0)) # uniform x translation yoffset = int(_get_option_or_default(args, 3, 0)) # uniform y translation trace = ObjectPathTrace(trace_file) trace.fill_parents(report=True) pb = ProgressBar(len(trace.roots())) obj_sizes = trace.aggregate_sizes() fout = open(output_filename, 'w') trace_subsets = trace.clusters() subtraces = trace.subset_traces(trace_subsets) obj_count = 0 for subtrace in subtraces: subtrace_roots = subtrace.roots() for objid, mots in subtrace.sim_motions_iter(subtrace_roots): # above the actual output to ensure it gets updated obj_count += 1 pb.update(obj_count) pb.report() idx = 0 for mot in mots: num_updates = sum([len(mot) for mot in mots]) mot.squeeze(fudge=.05) #if num_updates <= 1: continue for t, pos in mot: # note that we flip y and z to go from SL coords -> meru coords bbox = obj_sizes[objid] bbox_rad = vec3.dist(bbox[0], bbox[1]) / 2.0 line = "%s: %f, %f, %f, %d, %f" % ( str(objid), xoffset + pos[0], yoffset + pos[1], pos[2], int(t * 1000), bbox_rad) print >> fout, line idx += 1 fout.close() pb.finish() return 0
def generate_quake_motion_path(args): trace_file = args[0] #input trace file output_filename = _get_option_or_default(args, 1, 'quake.txt') xoffset = int(_get_option_or_default(args, 2, 0)) # uniform x translation yoffset = int(_get_option_or_default(args, 3, 0)) # uniform y translation trace = ObjectPathTrace(trace_file) trace.fill_parents(report=True) pb = ProgressBar(len(trace.roots())) obj_sizes = trace.aggregate_sizes() fout = open(output_filename,'w') trace_subsets = trace.clusters() subtraces = trace.subset_traces(trace_subsets) obj_count = 0 for subtrace in subtraces: subtrace_roots = subtrace.roots() for objid,mots in subtrace.sim_motions_iter(subtrace_roots): # above the actual output to ensure it gets updated obj_count += 1 pb.update(obj_count) pb.report() idx = 0 for mot in mots: num_updates = sum( [ len(mot) for mot in mots ] ) mot.squeeze(fudge=.05) #if num_updates <= 1: continue for t,pos in mot: # note that we flip y and z to go from SL coords -> meru coords bbox = obj_sizes[objid] bbox_rad = vec3.dist(bbox[0], bbox[1])/2.0 line = "%s: %f, %f, %f, %d, %f" % (str(objid), xoffset+pos[0], yoffset+pos[1], pos[2], int(t*1000), bbox_rad) print >>fout, line idx += 1 fout.close() pb.finish() return 0
def sizes(self): """ Extract the sizes of each prim in the trace, returning a dict of UUID -> (bbox_min_vec, bbox_max_vec), where both are 3-tuples representing Vector3s. The bounding box will be transformed by object transformations (scale, rotate) but will not be in world-space (not translated w.r.t. the parent). """ objids = self.objects() obj_sizes = {} for size_evt in self.size_events(): size_id = UUID(size_evt['id']) if size_id not in objids: continue if size_id in obj_sizes: continue # only use the first size value bbox_scale = parse_vec3(size_evt['scale']) bbox_min = vec3.mult(parse_vec3(size_evt['min']), bbox_scale) bbox_max = vec3.mult(parse_vec3(size_evt['max']), bbox_scale) r = vec3.dist(bbox_min, bbox_max) * 0.5 obj_sizes[size_id] = (bbox_min, bbox_max) return obj_sizes