首页 > 代码库 > frost_vex_01

frost_vex_01

int inc = 0;

//整数inc等于0

while(inc < 6){

//inc在小于6的范围内递增

    if(rand(@ptnum + inc + ch("seed")) < ch("variance")){

            inc++;

//如果随机数小于variance,产生递增值

            continue;

    }

    

    float angle = radians(60 * inc);

//angle的值等于(1-5之间的递增值)*60度

    vector axis = @N;

//旋转轴向等于点的法线属性

    matrix rot = ident();

//定义矩阵rot

    rotate(rot, angle, axis);

    vector dir = v@dir * rot;

//dir的值等于原始dir乘以旋转度数

    

    vector step = @P + dir * ch("step");

//step等于原始位置+(base中dir的随机的方向*长度)

    

    vector rp, ruv;

    int ray = intersect(2, @P + dir * 0.015, dir, rp, ruv);

//输出与边界框(端口2)相交处的坐标与uv坐标rp和ruv

    if(ray == -1){

//如果不相交

        int handle = pcopen(1, "P", step, ch("rad"), 1);

//pcopen打开点云查询查询范围是“rad”,查询点的个数是1

        vector naxis = pcfilter(handle, "N");

//定义矢量属性naxis,是查询点的处的N属性

        vector ndir = pcfilter(handle, "dir");

//定义矢量属性ndir,是查询点处的dir属性

        pcclose(handle);

//pcclose这个函数用来关闭与pcopen相关的handle

        int prim = addprim(0, "polyline");

//在0号端口处添加图元(polyline),为prim

        int pt0 = addpoint(0, @P);

//在0号端口的@P处添加点,为pt0

        int pt1 = addpoint(0, step);

//在0号端口的step处添加点,为pt1

        addvertex(0, prim, pt0);

//在pt0处,图元名为prim的位置添加顶点

        addvertex(0, prim, pt1);

//在pt1处,图元名为prim的位置添加顶点

        

        setpointattrib(0, "end", pt1, 1);

//在pt1处设置end属性,值为1

        setpointattrib(0, "N", pt1, naxis);

//在pt1处设置N属性,值为naxis

        setpointattrib(0, "dir", pt1, ndir);

    }

    inc++;

}

i@base = 0;

i@start = 0;

frost_vex_01