縦断勾配の確認等でポリラインをXY、またはXZ平面へ投影する。
YZ平面
//
// ポリラインをYZ平面に投影する
// RunOver: Primitives
//
int pts[] = primpoints(0, @primnum);
float sum = 0;
for(int i = 0; i < len(pts); i++)
{
vector pos = point(0, "P", pts[i]);
if(i == 0)
{
setpointattrib(0, "P", pts[i], set(0, pos.y, 0));
}
else
{
vector prev = point(0, "P", pts[i-1]);
vector diff = pos - prev;
sum += length(set(diff.x, 0, diff.z));
setpointattrib(0, "P", pts[i], set(0, pos.y, sum));
}
}
XY平面
//
// ポリラインをXY平面に投影する
// RunOver: Primitives
//
int pts[] = primpoints(0, @primnum);
float sum = 0;
for(int i = 0; i < len(pts); i++)
{
vector pos = point(0, "P", pts[i]);
if(i == 0)
{
setpointattrib(0, "P", pts[i], set(0, pos.y, 0));
}
else
{
vector prev = point(0, "P", pts[i-1]);
vector diff = pos - prev;
sum += length(set(diff.x, 0, diff.z));
setpointattrib(0, "P", pts[i], set(sum, pos.y, 0));
}
}