Hello guys

I have a scene with a chocolate bar with lot of peanuts, caramel pieces and other things on top of the chocolate bar. I have fractured the chocolate bar and used RBD packed object in DOP network to simulate breaking the chocolate bar. I have used the same voronoi fracture settings for the peanuts, caramel pieces etc. scattered over the surface of the bar. So far so good - everything is fractured at the correct way.
But here is the question. When I place all the pieces including the peanuts, caramels and so on into one DOP network it gets heavy because there are hundreds of peanuts pieces and secondly all the peanuts, caramel pieces fall down from the fractured chocolate pieces. How can I stick-constraint hundreds of peanuts on the correct chocolate piece – there are about 20 fractured chocolate pieces and hundreds peanuts and other stuff. Any help would be great.

I have achieved to follow the position, but the rotation doesn't work with this code.

float maxdist = 0.03;
int closeprim;
vector prim_uv;

float dist = xyzdist(1, @P, closeprim, prim_uv, maxdist);

vector pos = primuv(2, “P”, closeprim, prim_uv);

vector norm_dirorig = normalize(primuv(1, “N”, closeprim, prim_uv));
vector norm_dir = normalize(primuv(2, “N”, closeprim, prim_uv));

vector origPos = @P;

@P = pos + (norm_dir * dist);

vector movePos = @P;
///////////////////////////////////////////////////////////

i@primpoints = primpoints(1, closeprim);


vector primpointposorig_0 = point(1, “P”, @primpoints);
vector primpointposorig_1 = point(1, “P”, @primpoints);

vector x_dirorig = normalize(primpointposorig_0 - primpointposorig_1);
vector z_dirorig = norm_dirorig;
vector y_dirorig = normalize(cross(x_dirorig, z_dirorig));

matrix origmatrix = maketransform(z_dirorig, x_dirorig, origPos);


vector primpointposfinal_0 = point(2, “P”, @primpoints);
vector primpointposfinal_1 = point(2, “P”, @primpoints);

vector x_dir = normalize(primpointposfinal_0 - primpointposfinal_1);
vector z_dir = norm_dir;
vector y_dir = normalize(cross(x_dir, z_dir));

matrix finalmatrix = maketransform(z_dir, x_dir, movePos);

@P = @P * invert(origmatrix);
@P *= finalmatrix;

attach]FollowPosition.jpg


Many thanks