|
public class cLinker extends Composite
|
{
|
static final long serialVersionUID = 2676790134285089534L;
|
|
cLinker()
|
{
|
super("Linker");
|
|
count = 4;
|
|
height = 1;
|
depth = 0;
|
}
|
|
Object3D deepCopy()
|
{
|
cLinker t = new cLinker();
|
deepCopySelf(t);
|
return t;
|
}
|
|
void createEditWindow(GroupEditor callee, boolean newWindow)
|
{
|
if (newWindow)
|
objectUI = new LinkerEditor(this, deepCopy(), callee);
|
else
|
objectUI = new LinkerEditor(this, callee);
|
editWindow = objectUI.GetEditor();
|
}
|
|
void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
|
{
|
//if(count <= 0)
|
// return;
|
|
if(display.DrawMode() == display.SELECTION || display.IsDebugSelection())
|
{
|
super.draw(display, root, selected, blocked);
|
return;
|
}
|
|
//System.out.println("cLinker = " + this);
|
//new Exception().printStackTrace();
|
|
stack.push(cStatic.getVector()); // new cVector());
|
|
if(stack.size() > 1)
|
{
|
cStatic.point7.set(stack.peek());
|
/**/
|
//javax.media.opengl.GL gl = display.GetGL();
|
|
//gl.glBegin(gl.GL_LINES);
|
//gl.glVertex3d(stack.peek().x, stack.peek().y, stack.peek().z);
|
//System.out.println("line = " + stack.peek());
|
cVector keep = stack.pop();
|
//System.out.println("to = " + stack.peek());
|
cStatic.point7.sub(stack.peek());
|
//gl.glVertex3d(stack.peek().x, stack.peek().y, stack.peek().z);
|
//gl.glEnd();
|
/**/
|
|
stack.push(keep);
|
|
cStatic.point8.set(0,-1,0);
|
|
int size = 12;
|
|
if(cStatic.cone == null)
|
{
|
cStatic.box = new Box();
|
cStatic.cone = new Cone[size];
|
cStatic.sphere = new Sphere[size];
|
|
for (int i=0; i<size; i++)
|
{
|
cStatic.cone[i] = new Cone();
|
cStatic.cone[i].uDivs = 4 + i; // 8
|
cStatic.cone[i].vDivs = 1;
|
cStatic.cone[i].endcaps = false;
|
cStatic.cone[i].baseRadius = cStatic.cone[i].apexRadius = 1; // 0.125;
|
cStatic.cone[i].mode = 1;
|
cStatic.cone[i].retile();
|
cStatic.cone[i].recalculate();
|
|
cStatic.sphere[i] = new Sphere();
|
cStatic.sphere[i].uDivs = cStatic.cone[i].uDivs;
|
cStatic.sphere[i].vDivs = (cStatic.sphere[i].uDivs+1)/2;
|
cStatic.sphere[i].endcaps = false;
|
// cStatic.sphere[i].radius = 1; // 0.125;
|
cStatic.sphere[i].mode = 1;
|
cStatic.sphere[i].retile();
|
cStatic.sphere[i].recalculate();
|
}
|
}
|
|
int d = size - stack.size();
|
|
if (d < 0)
|
d = 0;
|
|
//LA.matPrint(cStatic.cone1.toParent);
|
|
/**/
|
double h = cStatic.point7.length(); ///2;
|
if(depth < 0)
|
depth = 0;
|
//System.out.println("h = " + h);
|
LA.matIdentity(cStatic.matrix1);
|
if(height < 0)
|
{
|
// Box mode
|
LA.matRotate(cStatic.box.fromParent, cStatic.point8, cStatic.point7);
|
LA.matRotate(cStatic.box.toParent, cStatic.point7, cStatic.point8);
|
//System.out.println("height = " + height);
|
LA.matScale(cStatic.matrix1, -height/8,h,-height/8);
|
cStatic.matrix1[1][3] = -depth/10/h;
|
LA.matConcat(cStatic.matrix1, cStatic.box.toParent, cStatic.box.toParent);
|
//LA.matIdentity(cStatic.matrix1);
|
//LA.matScale(cStatic.matrix1, -8/height,1/h,-8/height);
|
LA.matInvert(cStatic.matrix1, cStatic.matrix2);
|
LA.matConcat(cStatic.box.fromParent, cStatic.matrix2, cStatic.box.fromParent);
|
cStatic.box.draw(display, root, selected, blocked);
|
}
|
else
|
{
|
LA.matRotate(cStatic.cone[d].toParent, cStatic.point7, cStatic.point8);
|
LA.matRotate(cStatic.sphere[d].toParent, cStatic.point7, cStatic.point8);
|
|
LA.matScale(cStatic.matrix1, height/8,h,height/8);
|
cStatic.matrix1[1][3] = -depth/10/h;
|
//System.out.println("h = " + h);
|
//System.out.println("point = " + cStatic.point7);
|
LA.matConcat(cStatic.matrix1, cStatic.cone[d].toParent, cStatic.cone[d].toParent);
|
|
if (false) // TODO display.matrixdepth >= display.MAXSTACK)
|
{
|
LA.matRotate(cStatic.cone[d].fromParent, cStatic.point8, cStatic.point7);
|
LA.matRotate(cStatic.sphere[d].fromParent, cStatic.point8, cStatic.point7);
|
|
LA.matInvert(cStatic.matrix1, cStatic.matrix2);
|
//LA.matIdentity(cStatic.matrix1);
|
//LA.matScale(cStatic.matrix1, 8/height,1/h,8/height);
|
LA.matConcat(cStatic.cone[d].fromParent, cStatic.matrix2, cStatic.cone[d].fromParent);
|
|
LA.matIdentity(cStatic.matrix1);
|
LA.matScale(cStatic.matrix1, 8/height,8/height,8/height);
|
LA.matConcat(cStatic.sphere[d].fromParent, cStatic.matrix1, cStatic.sphere[d].fromParent);
|
}
|
|
LA.matIdentity(cStatic.matrix1);
|
LA.matScale(cStatic.matrix1, height/8,height/8,height/8);
|
LA.matConcat(cStatic.matrix1, cStatic.sphere[d].toParent, cStatic.sphere[d].toParent);
|
|
cStatic.cone[d].draw(display, root, selected, blocked);
|
cStatic.sphere[d].draw(display, root, selected, blocked);
|
}
|
}
|
|
super.draw(display, root, selected, blocked);
|
|
// keep cache
|
cStatic.vectors.add(stack.peek());
|
|
stack.pop();
|
}
|
|
static java.util.Stack<cVector> stack = new java.util.Stack<cVector>();
|
}
|