I have coordinates of vertices in datafiles ("frames") with filenames 000.txt
, 001.txt
, 002.txt
, …. The files have rows like this (vertex: ID, X, Y, Z):
15 2.525695e+00 -4.162952e+00 -2.020646e+00
I am not sure how to modify the answers here (which generate the coordinates within Python) for the case of reading in coordinates from "frame" files.
Here is how I import all the "frames"/files into one giant array data
:
import glob
def fileNameToData(filepath):
file = open(filepath,'r')
lines = file.readlines()
data=[]
for i in lines:
data.append(list(map(float,i.split())))
return data
files = glob.glob('*.txt')
files.sort()
data=[]
for f in files:
for i in fileNameToData(f):
data.append(i)
How could my data
be used to animate the vertices?
cf. ch. 7 and 8 of 3D Scientific Visualization with Blender