Hello,
i have a question maybe someone could help with.
I basically have an object already at a specific position in space, where its actual pivot lay at origin (0,0,0).
Using $CEX,$CEY,$CEZ is fine in a transform node to get the pivot to the middle of the object, but the pivot rotate is still using the default rotation values (thus not following the object local axis), i need to orient the pivot to match the "bounding box" of the object. And I'm not too sure how to achieve this, I just want the pivot of the object to match the object bounding box.
I hope this make sense
thanks for the help
Transfer a bounding box pivot orientation to another object
1932 3 1- symbi
- Member
- 1 posts
- Joined: Oct. 2021
- Offline
- BabaJ
- Member
- 2042 posts
- Joined: Sept. 2015
- Offline
- paulbrownv
- Member
- 3 posts
- Joined: July 2015
- Offline
Hi!
I have the same question. Using $CEX, etc does translate the pivot but you don't get the rotation of that object from that.
If we use a BOUND node, we can activate "Oriented Bounding Box" and you get exactly that, but then how can we use that operation for a pivot? It says you can export xform and radii as attributes, but how to access them? (if that's where the information we need is stored)
Can someone help figure this out?
I'm a Houdini beginner too ;-)
Thanks!
I have the same question. Using $CEX, etc does translate the pivot but you don't get the rotation of that object from that.
If we use a BOUND node, we can activate "Oriented Bounding Box" and you get exactly that, but then how can we use that operation for a pivot? It says you can export xform and radii as attributes, but how to access them? (if that's where the information we need is stored)
Can someone help figure this out?
I'm a Houdini beginner too ;-)
Thanks!
- cncverkstad
- Member
- 117 posts
- Joined: Aug. 2017
- Online
Rabbit
other
with 2
int dotranslate = chi("dotranslate"); int dotrotate = chi("dotrotate"); int doscale = chi("doscale"); int uniformscale = chi("uniformscale"); vector min0,max0,min1,max1; getbbox(0,min0,max0); getbbox(1,min1,max1); vector size0 = max0-min0; vector center0 = (max0+min0)/2; vector size1 = max1 -min1; vector center1 = (max1+min1)/2; matrix T = 1 ; matrix R = 1 ; matrix S = 1 ; if ( dotranslate){ vector t = center1 -center0; translate(T,t); } if (dotrotate){ float size0_array[]= set(size0); float size1_array[]= set(size1); int size0_argsort[]= argsort(size0_array); int size1_argsort[]= argsort(size1_array); vector newsize = size0; vector mr[]; for(int i;i<3; i++){ vector axis; axis[size1_argsort[i] ]=1; mr[size0_argsort[i] ]=axis; newsize[size0_argsort[i]]= size0[size0_argsort[i]]; } size0 = newsize; //mr[2]= cross(mr[0],mr[1]); R = set(mr); } if(doscale){ //@P = fit(@P,min0,max0,min1,max1); vector s = size1/size0; if (uniformscale){ s = min(s); } scale(S,s); } vector p = center0;matrix X = 1;translate(X,p); matrix xform = invert(X)*R*S*T*X; string prim_type_name = primintrinsic(0,"typename",@primnum); if(match('Packed*',prim_type_name)){ matrix xform0 = getpackedtransform(0,@primnum); setpackedtransform(0,@primnum,xform0*xform); }else{ @P *= xform; }
other
node = hou.pwd() geo = node.geometry() obb = geo.orientedBoundingBox() t = obb.center() size = obb.sizevec() rotation = obb.rotation().inverted() r = rotation.extractRotates() box = hou.sopNodeTypeCategory().nodeVerb('box') box.setParms({'size':size,'r':r,'t':t}); geo1 = hou.Geometry() box.execute(geo1,[]) geo.merge(geo1) obb_min = t-size/2 obb_max = t+size/2 geo.addAttrib(hou.attribType.Global,'obb_min',hou.Vector3(),0,0) geo.addAttrib(hou.attribType.Global,'obb_max',hou.Vector3(),0,0) geo.addAttrib(hou.attribType.Global,'obb_rot',hou.Vector3(),0,0) geo.setGlobalAttribValue('obb_min',obb_min) geo.setGlobalAttribValue('obb_max',obb_min) geo.setGlobalAttribValue('obb_rot',r)
with 2
int dotranslate = chi("dotranslate"); int dotrotate = chi("dotrotate"); int doscale = chi("doscale"); int uniformscale = chi("uniformscale"); vector min0 = detail(0,'obb_min'); vector max0 = detail(0,'obb_max'); vector rot0= radians(detail(0,'obb_rot')); vector min1= detail(1,'obb_max'); vector max1 = detail(1,'obb_max'); vector rot1= radians(detail(1,'obb_rot')); vector size0 = max0-min0; vector center0 = (max0+min0)/2; vector size1 = max1 -min1; vector center1 = (max1+min1)/2; matrix T = 1 ; matrix R = 1 ; matrix S = 1 ; if ( dotranslate){ vector t = center1 -center0; translate(T,t); } if (dotrotate){ float size0_array[]= set(size0); float size1_array[]= set(size1); int size0_argsort[]= argsort(size0_array); int size1_argsort[]= argsort(size1_array); vector newsize = size0; vector mr[]; for(int i;i<3; i++){ vector axis; axis[size1_argsort[i] ]=1; mr[size0_argsort[i] ]=axis; newsize[size0_argsort[i]]= size0[size0_argsort[i]]; } size0 = newsize; //mr[2]= cross(mr[0],mr[1]); R = set(mr); } if(doscale){ //@P = fit(@P,min0,max0,min1,max1); vector s = size1/size0; if (uniformscale){ s = min(s); } scale(S,s); } vector p = center0;matrix X = 1;translate(X,p); matrix R0 = 1;rotate(R0,rot0,0); matrix R1 = 1;rotate(R1,rot1,0); matrix xform = invert(X)*invert(R0)*R*S*R1*T*X; string prim_type_name = primintrinsic(0,"typename",@primnum); if(match('Packed*',prim_type_name)){ matrix xform0 = getpackedtransform(0,@primnum); setpackedtransform(0,@primnum,xform0*xform); }else{ @P *= xform; }
Edited by cncverkstad - Oct. 3, 2023 07:10:26
Conservation of Momentum
-
- Quick Links