sop geo position shift

   3562   5   1
User Avatar
Member
4 posts
Joined: Aug. 2006
Offline
hdk noobie here,
I'm trying to write a sop that will take two geos, shift their positions by a given value, then blend the two to get a new position.
Question is, what do I shift?
Would something like this work? (I haven't had the chance to try it yet because I'm not sure how to assign pos back to the vertex)
pseudocode:

p = prim->getVertex(i).getPos();
newP = p * shiftVal;


*edit*
Another question is, is that a good way to go about the problem?
Or should I be calculating the difference of two geos ‘then’ apply the shiftVal to the difference?
User Avatar
Member
4 posts
Joined: Aug. 2006
Offline
well, little update;
So I tried this

(*prim).getVertex(j).getPos().assign(p, p*shiftVal, p*shiftVal, p*shiftVal);

And the result looks horrible! didn't exactly work as I wanted.
I found GEO_Delta intersting, only problem is I don't know how/what it does..
User Avatar
Member
44 posts
Joined: July 2005
Offline
getPos in the vertex class returns a reference to the position, so you should be able to just assign it:


UT_Vector4 newPos = ….;
prim->getVertex(i).getPos() = newPos;


or as in your example, use .assign() (note - you're multiplying the y,z, and w components in your example, but leaving the x untouched)

As far as order of operations, I'd blend the vectors first, then shift the result (1 interpolation and 1 shift as opposed to 2 shifts and 1 interpolation)
User Avatar
Member
4 posts
Joined: Aug. 2006
Offline
Thanks mondi,
Didn't know about xyzw for the vector.
Will try current method and if it doesn't work I'll have to find out if there's anything in the api that can help.

* basically, I need to extrapolate a new position from last valid frames.
ie. take the difference in positions of frames 39-40, and get the position for frame 50.
User Avatar
Member
7735 posts
Joined: July 2005
Offline
Why do this in the HDK? I think that using a VOP SOP would be the most efficient way to accomplish this. To get the previous frames, you can use the TimeShift SOP.
User Avatar
Member
4 posts
Joined: Aug. 2006
Offline
Well, I managed to do it just with points; didn't deal with primitives or vertices.
I grabbed the points of the two geos, got their positions with getPos(), calculated the difference and just applied it to one of the geos.
Way too simpler than I expected so even though it's working, I'm still unsure. oh well.
  • Quick Links