prekabreki Posted November 11, 2019 Share Posted November 11, 2019 (edited) I'm trying to create a pipe HDA for Unreal Engine 4 that either calls upon a straight piece or a corner piece and then orients each piece accordingly. I feel like I'm going about it all wrong, but the result I have is so close! As you can see in the first picture, it's KIND OF working, but I think it might fall apart very easily. I've attached a hip file any help would be greatly appreciated. pipeorient.hip Edited November 11, 2019 by prekabreki Quote Link to comment Share on other sites More sharing options...
flcc Posted November 11, 2019 Share Posted November 11, 2019 Look at this Entagma tutorial : Quote Link to comment Share on other sites More sharing options...
ThomasPara Posted November 12, 2019 Share Posted November 12, 2019 int primpts[] = primpoints(0,@primnum); matrix3 m = ident(); //here you could use your own base matrix foreach(int index;int i;primpts){ //create direction vector, can be replaced by a predefined vector int forward = 1; if(index == len(primpts)-1){ forward = -1; } vector this_pos = point(0,"P",i); vector next_pos = point(0,"P",primpts[index]+forward); vector dir = normalize(next_pos-this_pos)*forward; setpointattrib(0,"dir",i,dir,"set"); //align matrix vector matrix_z = set(getcomp(m,2,0),getcomp(m,2,1),getcomp(m,2,2)); matrix_z = normalize(matrix_z); float angle = acos(dot(matrix_z,dir)); vector axis = normalize(cross(matrix_z,dir)); rotate(m,angle,axis); //convert to orient vector4 orient = quaternion(m); setpointattrib(0,"orient",i,orient,"set"); } Put this code in a primitive wrangle and you will have parallel transport, you can evolve this into a bigger asset. Quote Link to comment Share on other sites More sharing options...
prekabreki Posted November 14, 2019 Author Share Posted November 14, 2019 Thanks for the help so far, this seems like a much more sensible and stable way to do things, even if it is a bit over my head. I'm afraid I'm still having issues though when it comes to orienting the corner pieces. My latest hip is below if someone wants to take a look, you can see my problem in the attached image. pipesorient02.hip Quote Link to comment Share on other sites More sharing options...
Aizatulin Posted November 14, 2019 Share Posted November 14, 2019 Hi, parallel transport cannot handle this issue alone, because the (red)object has to invert its orientation, if you have a "right/left" corner. I would prefer a parallel transport implementation, which sets the v@up and v@N attributes for each point, because the "copy to points" node can use these attributes aswell and it will be easier to modify vectors. To determine the type of the corners you can use the average of the neighbour points and compare the direction to it with v@N value (using the dot product). If the product < 0, you can multiply v@N with -1, but note, that you destroy the parallel transport frame. There are probably other solutions out there ... pipesorient02.hipnc Quote Link to comment Share on other sites More sharing options...
prekabreki Posted November 14, 2019 Author Share Posted November 14, 2019 1 hour ago, Aizatulin said: Hi, parallel transport cannot handle this issue alone, because the (red)object has to invert its orientation, if you have a "right/left" corner. I would prefer a parallel transport implementation, which sets the v@up and v@N attributes for each point, because the "copy to points" node can use these attributes aswell and it will be easier to modify vectors. To determine the type of the corners you can use the average of the neighbour points and compare the direction to it with v@N value (using the dot product). If the product < 0, you can multiply v@N with -1, but note, that you destroy the parallel transport frame. There are probably other solutions out there ... pipesorient02.hipnc Thanks so much Aizatulin, that's exacly what I was looking for. All this orientation math is a big weakspot of mine. I wanted to ask if you had a quick solution if I wanted to change the elevation of the curve like in the picture below? Quote Link to comment Share on other sites More sharing options...
Aizatulin Posted November 14, 2019 Share Posted November 14, 2019 you can set v@N directly to dir, which is a more general solution, but the corner should be rectangular, if your pipe is rectangular aswell. pipesorient02A.hipnc Quote Link to comment Share on other sites More sharing options...
prekabreki Posted November 14, 2019 Author Share Posted November 14, 2019 8 minutes ago, Aizatulin said: you can set v@N directly to dir, which is a more general solution, but the corner should be rectangular, if your pipe is rectangular aswell. pipesorient02A.hipnc You've saved my ass, thanks so much for your help! (Also, neat path deformer!) 1 Quote Link to comment Share on other sites More sharing options...
Aizatulin Posted November 14, 2019 Share Posted November 14, 2019 By the way, here is a quick and dirty approach using the path deformer (combined with a point bevel/round this should work for any angle). It was just an idea ... pipesorient02B.hipnc 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.