AddAxes:
PUBLIC
PROC [
context3d: Context3d,
origin: Triple ¬ [0, 0, 0],
size: REAL ¬ 1.0,
scale: Triple ¬ [1, 1, 1],
nReticles: NAT ¬ 20]
~ {};
Don't create shapes, just transform axes endpoints and draw smooth lines to Imager context3d?
AddAxis: PROC [name: ROPE, p, v0, v1: Triple] ~ {
AddName: PROC [name: ROPE, position: Triple] ~ {
s: Shape ← ShapeFromRope[name, name, "white"];
s.position ← position;
AddShape[context3d, s];
};
SetRect: PROC [id, n0, n1, n2, n3: NAT] ~ {
poly: G3dBasic.Surface ← s.surfaces[id] ← [NIL, NEW[G3dBasic.NatSequenceRep[4]]];
poly.vertices.length ← 4;
poly.vertices[0] ← n0;
poly.vertices[1] ← n1;
poly.vertices[2] ← n2;
poly.vertices[3] ← n3;
};
SetVertex: PROC [id: NAT, p: Triple] ~ {s.vertices[id] ← NEW[VertexRep ← [point: p]]};
s: Shape ← NEW[ShapeRep ← [name: Rope.Cat[name, "-axis"], matrix: G3dMatrix.Identity[]]];
SetRenderStyle[s, lines];
s.surfaces ← NEW[G3dBasic.SurfaceSequenceRep[4]]; s.surfaces.length ← 4;
s.vertices ← NEW[VertexSequenceRep[8]]; s.vertices.length ← 8;
SetVertex[0, origin];
SetVertex[1, G3dVector.Add[origin, v0]];
SetVertex[2, G3dVector.Add[G3dVector.Add[origin, v0], v1]];
SetVertex[3, G3dVector.Add[origin, v1]];
SetVertex[4, p];
SetVertex[5, G3dVector.Add[p, v0]];
SetVertex[6, G3dVector.Add[G3dVector.Add[p, v0], v1]];
SetVertex[7, G3dVector.Add[p, v1]];
SetRect[0, 0, 1, 5, 4];
SetRect[1, 1, 2, 6, 5];
SetRect[2, 2, 3, 7, 6];
SetRect[3, 3, 0, 4, 7];
FOR n: NAT IN [0..nReticles) DO
p1: Triple ← G3dVector.Interp[REAL[n]/REAL[nReticles], origin, direction];
p2: Triple ← G3dVector.Add[p1, offset];
s.vertices[2*n] ← NEW[VertexRep ← [point: p1]];
s.vertices[2*n+1] ← NEW[VertexRep ← [point: p2]];
s.surfaces[n].vertices ← NewPoly[2*n, 2*n+1];
ENDLOOP;
SetRenderStyle[s, lines];
AddShape[context3d, s];
AddName[name, direction];
};
AddAxis["X", [origin.x+size, origin.y, origin.z], [0.0, 0.01, 0.0], [0.0, 0.0, 0.01]];
AddAxis["Y", [origin.x, origin.y+size, origin.z], [0.0, 0.0, 0.01], [0.01, 0.0, 0.0]];
AddAxis["Z", [origin.x, origin.y, origin.z+size], [0.01, 0.0, 0.0], [0.0, 0.01, 0.0]];
};