|
|
Makes a triangle-mesh graph of Y=fn(X,Z) for unpatched POV. Probably are
better ways to do it, this eats memory and time.
#declare XMIN = -5; //bounds of graph area
#declare ZMIN = -5;
#declare XMAX = 5;
#declare ZMAX = 5;
#declare XSTEPS = 150; //resolution
#declare ZSTEPS = 150;
#declare points = array[XSTEPS+1][ZSTEPS+1]
#declare Z = ZMIN;
#declare Zctr = 0;
#while (Zctr < ZSTEPS+1)
#declare X = XMIN;
#declare Xctr = 0;
#while (Xctr < XSTEPS+1)
#declare points[Xctr][Zctr] = //place your function here
#declare Xctr=Xctr+1;
#declare X=X+(XMAX-XMIN)/(XSTEPS);
#end
#declare Zctr=Zctr+1;
#declare Z=Z+(ZMAX-ZMIN)/(ZSTEPS);
#end
#declare FunctionGraph = mesh {
#local Z = ZMIN;
#local Zctr = 0;
#while (Zctr < ZSTEPS)
#local X = XMIN;
#local Xctr = 0;
#while (Xctr < XSTEPS)
#if (mod((Xctr+Zctr),2)=1)
triangle { <XMIN+((XMAX-XMIN)/XSTEPS)*Xctr,
points[Xctr][Zctr], ZMIN+((ZMAX-ZMIN)/ZSTEPS)*Zctr>,
<XMIN+((XMAX-XMIN)/XSTEPS)*(Xctr+1),points[Xctr+1][Zctr],
ZMIN+((ZMAX-ZMIN)/ZSTEPS)*Zctr>,
<XMIN+((XMAX-XMIN)/XSTEPS)*Xctr,
points[Xctr][Zctr+1], ZMIN+((ZMAX-ZMIN)/ZSTEPS)*(Zctr+1)> }
triangle {
<XMIN+((XMAX-XMIN)/XSTEPS)*(Xctr+1),points[Xctr+1][Zctr],
ZMIN+((ZMAX-ZMIN)/ZSTEPS)*Zctr>,
<XMIN+((XMAX-XMIN)/XSTEPS)*Xctr,
points[Xctr][Zctr+1], ZMIN+((ZMAX-ZMIN)/ZSTEPS)*(Zctr+1)>,
<XMIN+((XMAX-XMIN)/XSTEPS)*(Xctr+1),points[Xctr+1][Zctr+1],ZMIN+((ZMAX-ZMIN)/ZSTEPS)*(Zctr+1)>
}
#else
triangle { <XMIN+((XMAX-XMIN)/XSTEPS)*Xctr,
points[Xctr][Zctr], ZMIN+((ZMAX-ZMIN)/ZSTEPS)*Zctr>,
<XMIN+((XMAX-XMIN)/XSTEPS)*(Xctr+1),points[Xctr+1][Zctr],
ZMIN+((ZMAX-ZMIN)/ZSTEPS)*Zctr>,
<XMIN+((XMAX-XMIN)/XSTEPS)*(Xctr+1),points[Xctr+1][Zctr+1],ZMIN+((ZMAX-ZMIN)/ZSTEPS)*(Zctr+1)>
}
triangle { <XMIN+((XMAX-XMIN)/XSTEPS)*Xctr,
points[Xctr][Zctr], ZMIN+((ZMAX-ZMIN)/ZSTEPS)*Zctr>,
<XMIN+((XMAX-XMIN)/XSTEPS)*Xctr,
points[Xctr][Zctr+1], ZMIN+((ZMAX-ZMIN)/ZSTEPS)*(Zctr+1)>,
<XMIN+((XMAX-XMIN)/XSTEPS)*(Xctr+1),points[Xctr+1][Zctr+1],ZMIN+((ZMAX-ZMIN)/ZSTEPS)*(Zctr+1)>
}
#end
#declare Xctr=Xctr+1;
#declare X=X+(XMAX-XMIN)/XSTEPS;
#end
#declare Zctr=Zctr+1;
#declare Z=Z+(ZMAX-ZMIN)/ZSTEPS;
#end
}
object { FunctionGraph }
Post a reply to this message
|
|