Hi,
I made a cactus with its thorns. The thorns created with particles, and an instancer. With Your (Joojaa) much helps, I managed to create the scipts, but I can't use :), because maya closes at particle generation time. Could you check it?
This is the create script:
//here is the normal vector:
float $pos[] = ParticleShape1.position;
setAttr closestPointOnSurface1.inPosition $pos[0] $pos[1] $pos[2];
vector $normalV = getAttr pointOnSurfaceInfo1.normal;
ParticleShape1.normalDir = $normalV;
//the rndVectorGen function generates a vector, which is not parallel with the normal vector
proc vector rndVectorGen(vector $nrmV) {
vector $rndV=unit(sphrand(10));
if (dot($nrmV,$rndV)==0) {
$rndV=rndVectorGen($nrmV);
}
return $rndV;
}
//
vector $normalUnitV=unit($normalV);
vector $rndV=rndVectorGen($normalV);
float $dotFloat=dot($normalUnitV,$rndV);
vector $projectedV=$dotFloat*$normalUnitV;
vector $upAxes=$rndV-$projectedV;
ParticleShape1.upAxesCustom=$upAxes;
the instancer aimDir is the ParticleShape1.normalDir, and the upAxes is the ParticleShape1.upAxesCustom.
Any advice is apprechiated!
Thank you very much...