class OkuboTank extends Universe { vector laserPos = new vector(0,0,0); float laserWidth = 0.004; OkuboTank(float x, float y, float z, float wd, float ht, float dp) { super(x,y,z,wd,ht,dp); } void draw() { // draw the laser light. // not as general as the other code: assumes a straight-on x-z plot. vector laserScrPos = pos2scr(laserPos); for (int i=floor(origin.x); i0.01) { stroke(255,255,255,200*a); line(i, origin.y, i, origin.y+span.y); } } } } class Universe { // a coordinate system, maybe more. vector origin, span; // location and size on screen vector modelMin, modelMax; Universe(float x, float y, float z, float wd, float ht, float dp) { // location on screen origin = new vector(x,y,z); span = new vector(wd,ht,dp); // by default, all coordinates range -1..1 in model units modelMin = new vector(-1,-1,-1); modelMax = new vector(1,1,1); } vector pos2scr(vector pos) { // position in model units to screen position return origin.plus((pos.minus(modelMin)).dividedBy(modelMax.minus(modelMin)).times(span)); } vector scr2pos(vector scr) { // screen position to model position return modelMin.plus((scr.minus(origin)).dividedBy(span).times(modelMax.minus(modelMin))); } void draw() {} }