Jump to content

Orient object along it's velocity


Recommended Posts

i guess technically the easiest solution would be to make your object a packed prim and use that to drive your unpacked geometry with copy_to_points_SOP, while velocity used as N. a bit odd in terms of workflow but hey, it's easy (easier than it sounds :)) and it works. see the attachment for hip file. you can also build a quaternion orient attribute to make it more flexible and to allow continuous rotations without axis flipping. 

orient_along_vector.hiplc

  • Like 1
Link to comment
Share on other sites

The cube animates but the vector changes it's orientation as it moves, which is understandable; but I want to orient the cube, which is sorta difficult to do with a cube, but anyhow; I want to orient the cube so the front face, a face to which you don't see in the screen capture; orients to the path which is key-framed by means of the transform SOP.

vectorsphere.png

Link to comment
Share on other sites

Here's my take to it :
cinnamonMetal_orientToVel.hip

Unfortunately, I haven't been able to keep the first animation frame to pop and to keep the final position/orientation. Instead I used a time warp with the anim duration to keep it from popping.

Is this (almost) what you wanted ?

Edited by Alain2131
Link to comment
Share on other sites

18 minutes ago, CinnamonMetal said:

@Alain2131 Yes, although do you mean the popping at frame 49; when the Time Shift SOP is enabled ? 

The popping happens at frame 13 and 49 (or anytime the cube transitions from/to not moving) - but the timewarp should fix that, thanks to the Pre/Post-Hold.
But as mentioned, that's a hacky way to fix that

As for getting the matrix transformation of the cube, this is pretty much what I do using maketransform

But because it's based on the velocity vector to construct it, when the velocity is 0 the matrix gets squashed down. I decided that when the velocity was 0, to not do anything - thus the snapping.
A way to fix that would be to find the closest velocity vector that is not 0 and use it. But I don't know how to get an attribute at another frame than the current one. There would probably be a way to do it in Python.

You mentioned "[...] have the cube vectors orient along it's path."
Not sure what that means. What vectors ? Do you mean the cube orientation vector ?

Link to comment
Share on other sites

7 hours ago, Alain2131 said:

Do you mean the cube orientation vector ?

Yes. :) 

Quote

A way to fix that would be to find the closest velocity vector that is not 0 and use it. But I don't know how to get an attribute at another frame than the current one. There would probably be a way to do it in Python.

Hrm, I'll look although if you find the method in Python ? :)  

I couldn't find anything; unless, maybe picking a frame and trying to grab the attribute from that frame, for example; Frame1 ?

Edited by CinnamonMetal
Link to comment
Share on other sites

Well, as for the "cube orientation vector", it doesn't exist as a rotation would exist in another package, say Maya. Not in that context.
It exist only at the /Obj level (or any object subnet)

As for finding the closest non-zero value for the velocity with Python, that's exactly it !
Get current value, if 0 get value at next frame until the value is not 0.
.. In theory, but I can't get the geometry to recook when the frame is changed. It always give me the initial frame's attribute value. Or so I think, it keeps throwing my timeslider to astronomical values.

So that didn't work. Instead, I've done something horrible. It works, but it's horrible.
cinnamonMetal_orientToVel_v2.hip
Since that "orientation vector" only existed at the /Obj, that's exactly what I did.

Does that hack work out for you ?

PleaseForgiveMeIKnowIDidSomethingHorrible

Edited by Alain2131
Link to comment
Share on other sites

On 1/10/2019 at 12:07 PM, CinnamonMetal said:

The cube animates but the vector changes it's orientation as it moves, which is understandable; but I want to orient the cube, which is sorta difficult to do with a cube, but anyhow; I want to orient the cube so the front face, a face to which you don't see in the screen capture; orients to the path which is key-framed by means of the transform SOP.

vectorsphere.png

well, yeah, so what's the issue? copy to points works like a charm... see the animated gif bellow.

 

orient_along_vector.thumb.gif.6de4fbbe42ff03765f86450ca79d4e63.gif

Edited by davpe
Link to comment
Share on other sites

@davpe Your previous scene doesn't demonstrate what is seen in the GIF above; rather, sliders are controlling the three vectors then you are setting the velocity on the normals.  Rather then, if the object has an animation from a transform SOP. 

If you add a transform sop after the pack sop; animate it's transforms; how is the pig head to orient to the direction and by which direction ?

@Alain2131 The subnet ObjNet1 really throws me though a loop, not that I don't understand, but it's buried so deep :) It's quite a hack, although it does work.

Edited by CinnamonMetal
Link to comment
Share on other sites

when animation stops, then velocity = 0, so is the orientation. you'd have to make up a logic for that situation, based on what do you want to happen if the object is not moving (or limit the velocity to some minimal value that appears to be zero but it's not - so you'll still get the orientation vector)

velocity distance is: 

@vdist = length(@v);

Edited by davpe
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...