anthonymcgrath Posted June 25, 2018 Share Posted June 25, 2018 hi all i'm trying to add a way to rotate each of my pieces of my burger randomly - but i cannot suss it for love nor money can anyone help please? @mestela - i found a simple wrangle from you to shift all the pieces upwards (burger exported from maya!) ... now i just want to add a little rotation but i cant figure this out tried primitive wrangles and pasting expressions into transform nodes - no idea Quote Link to comment Share on other sites More sharing options...
3dome Posted June 25, 2018 Share Posted June 25, 2018 (edited) if every piece is a packed alembic you can loop through them. use a meta import to get random seed for a simple expression (like fit01(rand(detail("../metaThing", "iteration", 0)), -125, 235) ) in a transform SOP (on there maybe set pivot to $CEX,$CEY,$CEZ) if they are not packed, just use connectivity as in your picture and then loop Edited June 25, 2018 by 3dome 1 Quote Link to comment Share on other sites More sharing options...
anthonymcgrath Posted June 25, 2018 Author Share Posted June 25, 2018 20 minutes ago, 3dome said: if every piece is a packed alembic you can loop through them. use a meta import to get random seed for a simple expression (like fit01(rand(detail("../metaThing", "iteration", 0)), -125, 235) ) in a transform SOP (on there maybe set pivot to $CEX,$CEY,$CEZ) if they are not packed, just use connectivity as in your picture and then loop hmmm not sure now - how do i know if my alembic is packed or not? Quote Link to comment Share on other sites More sharing options...
3dome Posted June 25, 2018 Share Posted June 25, 2018 (edited) they usually are. you can see that by middle mouse click it and then it says packed alembics and you only have like 25 points/prims or so EDIT: but there's nothing wrong with converting them to polys and then run connectivity before the loop Edited June 25, 2018 by 3dome 1 Quote Link to comment Share on other sites More sharing options...
anthonymcgrath Posted June 25, 2018 Author Share Posted June 25, 2018 2 minutes ago, 3dome said: they usually are. you can see that by middle mouse click it and then it says packed alembics and you only have like 25 points/prims or so EDIT: but there's nothing wrong with converting them to polys and then run connectivity before the loop ah yes thankyou! yeah they are/were packed. I run a convert (to polys), transform to scale it down, drop in a normal sop and then i ran my connectivity/partition combo to get groups of primitives (are they called "details" ?) so: 400 primitives in _0 800 primitives in _1 962 primitives in _2 etc It would be great if i could just simply random rotate those primitive groups there. Quote Link to comment Share on other sites More sharing options...
3dome Posted June 25, 2018 Share Posted June 25, 2018 (edited) there's no need to create groups with a partition SOP as the connectivity gives you an attribute (called class by default) identifying which prim belongs to which piece. so just run the loop as I mentioned in the first post (you can even do For-Each Connected Piece loop which sets up the loop to work with connectivity) EDIT: just make sure to set connectivity to Primitive so the attrib gets created on them instead of the default point level (the Connected Piece loop does all that for you if you're unfamiliar with that stuff) Edited June 25, 2018 by 3dome Quote Link to comment Share on other sites More sharing options...
Noobini Posted June 25, 2018 Share Posted June 25, 2018 pretty simple would have thought... rotateBurger.hipnc Quote Link to comment Share on other sites More sharing options...
anthonymcgrath Posted June 26, 2018 Author Share Posted June 26, 2018 (edited) 9 hours ago, Noobini said: pretty simple would have thought... rotateBurger.hipnc hey @Noobini thanks - this makes sense - but how did you add that seed and spare input parameter to the transform node? I was able to do edit intterface but cant find a spare parameter option or seed? edit - never mind - just did edit interface on your transform node in your scene and was able to find out what they were heh! Edited June 26, 2018 by anthonymcgrath found it! Quote Link to comment Share on other sites More sharing options...
anthonymcgrath Posted June 26, 2018 Author Share Posted June 26, 2018 was having some probs - my entire burger bun was rotating as one piece... keeps giving me an issue with the use of "-1" in that expression in the rotation channel. anyway just tried the exact same thing in H16 and it works fine... weird. Quote Link to comment Share on other sites More sharing options...
anthonymcgrath Posted June 26, 2018 Author Share Posted June 26, 2018 okay managed to get it sorted - seems to be something H16 is happy to do but 15.5 (which i was using) doesn't want to play ball. I also was given this cool tut by @Farmfield - cheers good sir! Quote Link to comment Share on other sites More sharing options...
ThomasPara Posted June 26, 2018 Share Posted June 26, 2018 matrix3 m = ident(); vector axis = set(0,1,0); float angle = radians(rand(i@class)*360); rotate(m,angle,axis); @P *= m; Write that in a pointwrangle after a connectivity node set to points. 2 Quote Link to comment Share on other sites More sharing options...
anthonymcgrath Posted June 26, 2018 Author Share Posted June 26, 2018 55 minutes ago, ThomasPara said: matrix3 m = ident(); vector axis = set(0,1,0); float angle = radians(rand(i@class)*360); rotate(m,angle,axis); @P *= m; Write that in a pointwrangle after a connectivity node set to points. hey thanks for the reply - this works and is quite fast... but the pivots for all the pieces seem to be at the bottom. i added a slider in to control the amount of rotation... you can see in this pic below that the pieces rotate from the origin. Anyway to centre the pivots on these pieces? Quote Link to comment Share on other sites More sharing options...
Atom Posted June 26, 2018 Share Posted June 26, 2018 What about something like this... matrix3 m = ident(); vector axis = set(0,1,0); float angle = radians(rand(i@class)*360); rotate(m,angle,axis); @orient = quaternion(m); Quote Link to comment Share on other sites More sharing options...
kiryha Posted June 26, 2018 Share Posted June 26, 2018 Rotate around Y should be fine, but if you need all axes... You can move each piece to the origin, then rotate, then move back. Here is an example: inverse_transform_example.hip. But I was not able to get bbox of each piece without a loop. Quote Link to comment Share on other sites More sharing options...
ThomasPara Posted June 26, 2018 Share Posted June 26, 2018 (edited) You can also just pack them first, that will give you the pivots. Use assemble. Or connectivity. If you use connectivity you need to assign the name on the primitives yourself. //primitive wrangle with class as primitive attribute s@name = "piece"+itoa(i@class); Then pack by name attribute. Now you can rotate the packed primitives //pointwrangle matrix3 m = primintrinsic(0,"transform",@ptnum); vector axis_y = set(0,1,0); //if you want axis to be aligned with packed transform axis_y *= m; float angle = radians(rand(@ptnum)*360); rotate(m,angle,axis_y); setprimintrinsic(0,"transform",@ptnum,m,"set"); Edited June 26, 2018 by ThomasPara typo 2 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.