VEXercise 1 – Group Mirror

This is part of a series of small exercises and experiments I am doing in Houdinis VEX language. There might be better ways to solve this and if I discover a better way I will update the post.

Mirrored Prim Grouos

During the process of building a rig I needed a quick way to mirror groups from one body part to the opposite and decided to make it into a vexercise.

Naturally, this only works on meshes that are symmetrical and in this example only in the YZ plane (but you can change that in the attribute mirror node).


The mirror is done in 3 steps.
1 – Mark all prims that belong to the group (attribwrangle1).

//Mark all prims from the source groups with mirror=1

string grpName = ch("../inGrpName");
i@mirror = inprimgroup(0, grpName, @primnum);

2 – Mirror all marked prims (attribmirror1).

3 – Put all the mirrored prims into a new group (attribwrangle2).
//put mirrored prims into a new group (name from string parameter)
string grpName = ch("../outGrpName");

int val;
if(grpName != "") {
    val = i@mirror - prim(1, "mirror", @primnum);
} else {
    //if not out name is given then use in name + mark all prims with mirror=1
    grpName = ch("../inGrpName");
    val = i@mirror;
}

setprimgroup(0, grpName, @primnum, val, "set");

Mirror Network

Done. Last step is a bit of cleaning up.

Leave a Reply

Your email address will not be published. Required fields are marked *