Jump to content

trying to roate pieces of my burger randomly


Recommended Posts

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 :(

Capture.thumb.JPG.8e119052581bc9ac9cf7e9d54f7e4add.JPG

Link to comment
Share on other sites

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 by 3dome
  • Like 1
Link to comment
Share on other sites

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?

 

Link to comment
Share on other sites

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 by 3dome
  • Like 1
Link to comment
Share on other sites

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.


 

Link to comment
Share on other sites

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 by 3dome
Link to comment
Share on other sites

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 by anthonymcgrath
found it!
Link to comment
Share on other sites

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.

cap.thumb.JPG.1fc2221db47fe4a79bee45b7523bc082.JPG

Link to comment
Share on other sites

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?

Capture.thumb.JPG.4ee6557d4fad242082e5129c30254329.JPG

 

 

Link to comment
Share on other sites

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 by ThomasPara
typo
  • Like 2
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...