timeseries

   1447   3   1
User Avatar
Member
5 posts
Joined: July 2021
Offline
I have a simulation that i've done on a set of points outside of houdini which gives the x,y,z position of each of the points at each time step.

How do I set the position of each point with those values for each frame corresponding to a timestep within the external sim?
User Avatar
Member
406 posts
Joined: April 2017
Offline
This depends entirely on how you can encode the data you've created outside Houdini. You didn't really provide any details.

Assuming you can't export a standard geometry format, if you can encode your point position data as CSV, you could use the Table Import SOP to read that data into Houdini.
MOPs (Motion Operators for Houdini): http://www.motionoperators.com [www.motionoperators.com]
User Avatar
Member
9417 posts
Joined: July 2007
Offline
in case none of know formats or csv works for you, you can always use Python SOP to read it to Houdini, whether your data is in ascii or binary form, encrypted or whatever, as long as you know the structure you can load it in
but as toadstorm said, for specific answer its helpful to provide specific details
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
5 posts
Joined: July 2021
Offline
Sorry about the lack of detail!

I built a python SOP which generates an array for the time series x position values and time series y position values (see attached image)

I was trying to iterate through frames from python using hou.setFrame() and then looping over each point to the position like so:

allpts = geo.points()
for i, (x_t, y_t, pt) in tqdm(enumerate(zip(pred_x_ts, pred_y_ts, allpts)), total=num_epochs):
for frame in range(0, num_epochs):
hou.setFrame(frame)
pt.setPosition(hou.Vector3(float(x_t), 0.0, float(y_t)))


that didn't work so I tried creating an array to do it on the vex side like so:

geo.addArrayAttrib(type=hou.attribType.Point, name="ts_x", data_type=hou.attribData.Float, tuple_size=num_epochs)
geo.addArrayAttrib(type=hou.attribType.Point, name="ts_y", data_type=hou.attribData.Float, tuple_size=num_epochs)

for i, (x_t, y_t, pt) in tqdm(enumerate(zip(pred_x_ts, pred_y_ts, allpts)), total=num_epochs):
pt.setAttribValue('ts_x', x_t.squeeze().tolist())
pt.setAttribValue('ts_y', y_t.squeeze().tolist())

and then the vex inside a solver:

vector activeDir;

for(int i=0;i<len(f@ts_x);i++)
{
if(@Frame == i)
{
float x_pos = f@ts_x;
float y_pos = f@ts_y;

// printf("%f\n", x_pos);

vector targetPos = set(x_pos, 0.0, y_pos);
vector currentPos = @P;

// printf("%f", targetPos);
// printf("%f\n", currentPos);

activeDir = normalize(targetPos - currentPos);

// currentPos += activeDir * ch("speed");
currentPos += activeDir;

@P = currentPos;
}
}

which also doesn't seem to work although the points do move around

Attachments:
positions.png (114.9 KB)

  • Quick Links