|
|
i took teh liberty to change your code a bit:
#declare a=0;
#while (a<zdem)
#declare b=0;
#while (b<xdem)
#declare ep=vertices[a][b];
#declare av=<0,0,0>;
#declare c=0;
#while (c<8)
#declare svp=ep+(sp/2)*<int(sin(c*45)*(pi/180)), 10,
int(cos(c*45)*(pi/180))>;
#declare svt=trace(relief, svp, -y, norm);
#if (norm.x!=0 | norm.y!=0 | norm.z!=0)
#warning "OK!"
#declare av=av+norm;
#end
#declare c=c+1;
#end
#if (vlength(av)!=0)
#declare normals[a][b]=vnormalize(av);
#else
#declare normals[a][b]=<0,0,0>;
#end
#declare b=b+1;
#end
#declare a=a+1;
#end
- you don't need seperate x,y and zet av, (just use av.x when needed)
- the divide by number of normals is replaced by vnormalize()
- added check for <0,0,0> sum of normals.
- you seem to check wether the trace() function missed the object,
but normals like <0,0,1> and <0,1,0> are valid, so use something like:
#if (norm.x!=0 | norm.y!=0 | norm.z!=0)
or:
#if (vlength(norm)!=0)
or:
#if ((abs(norm.x)+abs(norm.y)+abs(norm.z))!=0)
jaap.
Post a reply to this message
|
|