MdPt:
PROC[v0, v1, v2: VertexInfo, r, s, t:
REAL]
RETURNS[VertexInfo] ~ {
shape: REF ShapeInstance ← NARROW[ Atom.GetPropFromList[v0.props, $Shape] ];
lerpProc: VertexInfoProc ← IF shape # NIL THEN shape.shadingClass.lerpVtxAux ELSE NIL;
v: VertexInfo;
v.coord.sx ← r * v0.coord.sx + s * v1.coord.sx + t * v2.coord.sx; -- for position on screen
v.coord.sy ← r * v0.coord.sy + s * v1.coord.sy + t * v2.coord.sy;
v.coord.sz ← r * v0.coord.sz + s * v1.coord.sz + t * v2.coord.sz;
v.coord.ex ← r * v0.coord.ex + s * v1.coord.ex + t * v2.coord.ex; -- for nml-vector shading
v.coord.ey ← r * v0.coord.ey + s * v1.coord.ey + t * v2.coord.ey;
v.coord.ez ← r * v0.coord.ez + s * v1.coord.ez + t * v2.coord.ez;
v.shade.r ← r * v0.shade.r + s * v1.shade.r + t * v2.shade.r; -- clr/vtx (could be avoided)
v.shade.g ← r * v0.shade.g + s * v1.shade.g + t * v2.shade.g;
v.shade.b ← r * v0.shade.b + s * v1.shade.b + t * v2.shade.b;
IF shape.shadingClass.texture #
NIL
THEN {
v.coord.x ← r * v0.coord.x + s * v1.coord.x + t * v2.coord.x;
v.coord.y ← r * v0.coord.y + s * v1.coord.y + t * v2.coord.y;
v.coord.z ← r * v0.coord.z + s * v1.coord.z + t * v2.coord.z;
};
IF lerpProc #
NIL
THEN {
-- get auxiliary info from supplied proc
data: LORA ← LIST[ v0.aux, v1.aux, NEW[REAL ← r], NEW[REAL ← s] ];
v ← lerpProc[ NIL, v, data];
data ← LIST[ v.aux, v2.aux, NEW[REAL ← r+s], NEW[REAL ← t] ];
v ← lerpProc[ NIL, v, data];
}
ELSE v.aux ← v0.aux;
v.props ← v0.props;
RETURN[v];
};
EvalTriangle:
PROC[p:
REF Patch, r, s, t:
REAL]
RETURNS[VertexInfo] ~ {
[Artwork node; type 'Artwork on' to command tool]
p1: ARRAY[0..6) OF VertexInfo;
p2: ARRAY[0..3) OF VertexInfo;
p3: VertexInfo;
p1[0] ← MdPt[p[1], p[8], p[0], r,s,t]; -- p1[0,0,2] ← r*p[1,0,2] + s*p[0,1,2] + t*p[0,0,3];
p1[2] ← MdPt[p[3], p[4], p[2], r,s,t]; -- p1[2,0,0] ← r*p[3,0,0] + s*p[2,1,0] + t*p[2,0,1];
p1[4] ← MdPt[p[5], p[6], p[7], r,s,t]; -- p1[0,2,0] ← r*p[1,2,0] + s*p[0,3,0] + t*p[0,2,1];
p1[1] ← MdPt[p[2], p[9], p[1], r,s,t]; -- p1[1,0,1] ← r*p[2,0,1] + s*p[1,1,1] + t*p[1,0,2];
p1[3] ← MdPt[p[4], p[5], p[9], r,s,t]; -- p1[1,1,0] ← r*p[2,1,0] + s*p[1,2,0] + t*p[1,1,1];
p1[5] ← MdPt[p[9], p[7], p[8], r,s,t]; -- p1[0,1,1] ← r*p[1,1,1] + s*p[0,2,1] + t*p[0,1,2];
p2[0] ← MdPt[p1[1], p1[5], p1[0], r,s,t]; -- p2[0,0,1] ← r*p[1,0,1] + s*p[0,1,1] + t*p[0,0,2];
p2[1] ← MdPt[p1[2], p1[3], p1[1], r,s,t]; -- p2[1,0,0] ← r*p[2,0,0] + s*p[1,1,0] + t*p[1,0,1];
p2[2] ← MdPt[p1[3], p1[4], p1[5], r,s,t]; -- p2[0,1,0] ← r*p[1,1,0] + s*p[0,2,0] + t*p[0,1,1];
p3 ← MdPt[p2[1], p2[2], p2[0], r,s,t]; -- p3[0,0,0] ← r*p[1,0,0] + s*p[0,1,0] + t*p[0,0,1];
RETURN[p3];
};