CinnamonMetal Posted January 9, 2019 Share Posted January 9, 2019 (edited) How do I orient a object along it's velocity based on a primitives velocity ? And how do you calculate the distance of the velocity ? Edited January 9, 2019 by CinnamonMetal Quote Link to comment Share on other sites More sharing options...
davpe Posted January 10, 2019 Share Posted January 10, 2019 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 1 Quote Link to comment Share on other sites More sharing options...
CinnamonMetal Posted January 10, 2019 Author Share Posted January 10, 2019 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. Quote Link to comment Share on other sites More sharing options...
Alain2131 Posted January 10, 2019 Share Posted January 10, 2019 (edited) 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 January 10, 2019 by Alain2131 Quote Link to comment Share on other sites More sharing options...
CinnamonMetal Posted January 10, 2019 Author Share Posted January 10, 2019 (edited) @Alain2131 Yes, although do you mean the popping at frame 49; when the Time Shift SOP is enabled ? I was hoping there was a method to which I could get the matrix transformation of the cube then simple have the cube vectors orient along it's path. Edited January 10, 2019 by CinnamonMetal Quote Link to comment Share on other sites More sharing options...
Alain2131 Posted January 10, 2019 Share Posted January 10, 2019 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 ? Quote Link to comment Share on other sites More sharing options...
CinnamonMetal Posted January 10, 2019 Author Share Posted January 10, 2019 (edited) 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 January 10, 2019 by CinnamonMetal Quote Link to comment Share on other sites More sharing options...
Alain2131 Posted January 11, 2019 Share Posted January 11, 2019 (edited) 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 January 11, 2019 by Alain2131 Quote Link to comment Share on other sites More sharing options...
davpe Posted January 11, 2019 Share Posted January 11, 2019 (edited) 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. well, yeah, so what's the issue? copy to points works like a charm... see the animated gif bellow. Edited January 11, 2019 by davpe Quote Link to comment Share on other sites More sharing options...
CinnamonMetal Posted January 11, 2019 Author Share Posted January 11, 2019 (edited) @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 January 11, 2019 by CinnamonMetal Quote Link to comment Share on other sites More sharing options...
davpe Posted January 11, 2019 Share Posted January 11, 2019 well it doesn't make any difference whether the object is animated or not. i just added a transform SOP animation and Trail SOP to my setup. otherwise it's the same thing. look at the hip file attached. orient_along_vector.hiplc 1 Quote Link to comment Share on other sites More sharing options...
CinnamonMetal Posted January 11, 2019 Author Share Posted January 11, 2019 (edited) @davpe One problem, when the animation stops, the normal change direction ? How can I calculate the distance of the velocity ? Edited January 11, 2019 by CinnamonMetal Quote Link to comment Share on other sites More sharing options...
davpe Posted January 11, 2019 Share Posted January 11, 2019 (edited) 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 January 11, 2019 by davpe 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.