import myGraphics.VectorGrafix.*; import myGraphics.Shape3d.*; import myGraphics.Perspective.*; import myGraphics.Kinematics.*; import java.applet.*; import java.awt.*; class MyCanvas extends Canvas { RobotFigure theFigure; Camera theCamera; Viewport theViewport; Image offScreenImage; Graphics offScreenGC; public MyCanvas(RobotFigure f, Camera c, Viewport v) { super(); theFigure = f; theCamera = c; theViewport = v; } public void update(Graphics g) { paint(g); } public void paint(Graphics g) { Color fg = g.getColor(); Color bg = Color.white; Dimension size = this.size(); offScreenImage = createImage(size.width, size.height); offScreenGC = offScreenImage.getGraphics(); offScreenGC.setColor(bg); offScreenGC.fillRect(0, 0, size.width, size.height); offScreenGC.setColor(fg); theFigure.renderFigure(offScreenGC, theCamera, theViewport); g.drawImage(offScreenImage, 0, 0, null); } } public class RobotApplet extends java.applet.Applet { MyCanvas theCanvas; Choice thePopup; Scrollbar xScroll, yScroll, zScroll; public RobotFigure Arnold; public Model selectedPart; public Viewport theViewport; public Camera theCamera; double stepSize, stepAngle; public int toDegrees(double theta) { return (int)(theta * 180 / Math.PI); } public double toRadians(int theta) { return (double) theta * Math.PI / 180.0; } public void init() { this.setLayout(new BorderLayout()); /* Setup Arnold */ Arnold = new RobotFigure(); selectedPart = Arnold.Head; /* Setup the Popup Menu */ thePopup = new Choice(); thePopup.addItem("Head"); thePopup.addItem("Torso"); thePopup.addItem("Right Shoulder"); thePopup.addItem("Right Upper Claw"); thePopup.addItem("Right Lower Claw"); thePopup.addItem("Left Shoulder"); thePopup.addItem("Left Upper Claw"); thePopup.addItem("Left Lower Claw"); thePopup.addItem("Pelvis"); thePopup.addItem("Right Upper Leg"); thePopup.addItem("Right Lower Leg"); thePopup.addItem("Right Foot"); thePopup.addItem("Left Upper Leg"); thePopup.addItem("Left Lower Leg"); thePopup.addItem("Left Foot"); thePopup.select("Head"); this.add("North", thePopup); /* Setup the Scrollbars */ xScroll = new Scrollbar(Scrollbar.VERTICAL, toDegrees(selectedPart.Rx), 10, toDegrees(selectedPart.minRot.x()), toDegrees(selectedPart.maxRot.x())); yScroll = new Scrollbar(Scrollbar.HORIZONTAL, toDegrees(selectedPart.Ry), 10, toDegrees(selectedPart.minRot.y()), toDegrees(selectedPart.maxRot.y())); zScroll = new Scrollbar(Scrollbar.VERTICAL, toDegrees(selectedPart.Rz), 10, toDegrees(selectedPart.minRot.z()), toDegrees(selectedPart.maxRot.z())); this.add("East", xScroll); this.add("South", yScroll); this.add("West", zScroll); /* Setup the Camera */ Vector3d e = new Vector3d(0.0, 0.0, 35.0); Vector3d a = new Vector3d(0.0, 0.0, 13.0); theCamera = new Camera(e, a, 0.0, 30.0, 30.0); /* Setup the Viewport */ theViewport = new Viewport(350, 350); theViewport.fitImagePlane(theCamera.imageWidth, theCamera.imageHeight); /* Setup the Canvas */ theCanvas = new MyCanvas(Arnold, theCamera, theViewport); this.add("Center", theCanvas); /* Configure the scale at which the applet responds to controls */ stepSize = 10.0 / theViewport.pixPerUnit; // equivalent of 10 pixels stepAngle = Math.PI / 90.0; // equivalent of 2 degrees /* Do some last minute housekeeping, and go! */ Path.BEZIER_STEPS = 5; // set resolution for drawing beziers in paths this.resize(theViewport.hPix, theViewport.vPix); this.requestFocus(); } public void update(Graphics g) { paint(g); } public void paint(Graphics g) { showStatus("Repainting applet..."); theCanvas.repaint(); showStatus("Done repainting."); } public boolean handleEvent(Event evt) { switch (evt.id) { case Event.SCROLL_LINE_DOWN: case Event.SCROLL_LINE_UP: case Event.SCROLL_PAGE_DOWN: case Event.SCROLL_PAGE_UP: case Event.SCROLL_ABSOLUTE: { return scroll(evt); } } return super.handleEvent(evt); } public boolean scroll(Event evt) { if (evt.target.equals(xScroll)) { selectedPart.Rx = toRadians(xScroll.getValue()); repaint(); return true; } else if (evt.target.equals(yScroll)) { selectedPart.Ry = toRadians(yScroll.getValue()); repaint(); return true; } else if (evt.target.equals(zScroll)) { selectedPart.Rz = toRadians(zScroll.getValue()); repaint(); return true; } else { return false; } } public boolean action(Event evt, Object what) { theCanvas.requestFocus(); if (evt.target instanceof Choice) { String theItem = new String(); theItem = thePopup.getSelectedItem(); if (theItem.equals("Head")) { selectedPart = Arnold.Head; } else if (theItem.equals("Torso")) { selectedPart = Arnold.Torso; } else if (theItem.equals("Right Shoulder")) { selectedPart = Arnold.RShoulder; } else if (theItem.equals("Right Upper Claw")) { selectedPart = Arnold.RUpperClaw; } else if (theItem.equals("Right Lower Claw")) { selectedPart = Arnold.RLowerClaw; } else if (theItem.equals("Left Shoulder")) { selectedPart = Arnold.LShoulder; } else if (theItem.equals("Left Upper Claw")) { selectedPart = Arnold.LUpperClaw; } else if (theItem.equals("Left Lower Claw")) { selectedPart = Arnold.LLowerClaw; } else if (theItem.equals("Pelvis")) { selectedPart = Arnold.Pelvis; } else if (theItem.equals("Right Upper Leg")) { selectedPart = Arnold.RUpperLeg; } else if (theItem.equals("Right Lower Leg")) { selectedPart = Arnold.RLowerLeg; } else if (theItem.equals("Right Foot")) { selectedPart = Arnold.RAnkle; } else if (theItem.equals("Left Upper Leg")) { selectedPart = Arnold.LUpperLeg; } else if (theItem.equals("Left Lower Leg")) { selectedPart = Arnold.LLowerLeg; } else if (theItem.equals("Left Foot")) { selectedPart = Arnold.LAnkle; } else { return false; } /* Setup scrollbars for values and constraints of selected part */ xScroll.setValues(toDegrees(selectedPart.Rx), 10, toDegrees(selectedPart.minRot.x()), toDegrees(selectedPart.maxRot.x())); yScroll.setValues(toDegrees(selectedPart.Ry), 10, toDegrees(selectedPart.minRot.y()), toDegrees(selectedPart.maxRot.y())); zScroll.setValues(toDegrees(selectedPart.Rz), 10, toDegrees(selectedPart.minRot.z()), toDegrees(selectedPart.maxRot.z())); return true; } else { return false; } } public boolean keyDown(Event evt, int key) { if (evt.shiftDown() && evt.controlDown()) { switch (key) { case Event.LEFT: theCamera.rotate(0.0, 0.0, stepAngle); theCanvas.repaint(); return true; case Event.RIGHT: theCamera.rotate(0.0, 0.0, -stepAngle); theCanvas.repaint(); return true; case Event.UP: theCamera.translate(0.0, stepSize, 0.0); theCanvas.repaint(); return true; case Event.DOWN: theCamera.translate(0.0, -stepSize, 0.0); theCanvas.repaint(); return true; default: return false; } } else if (evt.shiftDown()) { switch (key) { case Event.LEFT: theCamera.translate(-stepSize, 0.0, 0.0); theCanvas.repaint(); return true; case Event.RIGHT: theCamera.translate(stepSize, 0.0, 0.0); theCanvas.repaint(); return true; case Event.UP: theCamera.rotate(stepAngle, 0.0, 0.0); theCanvas.repaint(); return true; case Event.DOWN: theCamera.rotate(-stepAngle, 0.0, 0.0); theCanvas.repaint(); return true; default: return false; } } else { switch (key) { case Event.LEFT: theCamera.rotate(0.0, stepAngle, 0.0); theCanvas.repaint(); return true; case Event.RIGHT: theCamera.rotate(0.0, -stepAngle, 0.0); theCanvas.repaint(); return true; case Event.UP: theCamera.translate(0.0, 0.0, -stepSize); theCanvas.repaint(); return true; case Event.DOWN: theCamera.translate(0.0, 0.0, stepSize); theCanvas.repaint(); return true; default: return false; } } } public boolean mouseDrag(java.awt.Event evt, int x, int y) { theCanvas.requestFocus(); return false; } public boolean mouseDown(Event evt, int x, int y) { theCanvas.requestFocus(); return false; } public boolean mouseUp(Event evt, int x, int y) { theCanvas.requestFocus(); return false; } } class RobotFigure extends Figure { public Model Torso; public Model Head; public Model RShoulder, RUpperClaw, RLowerClaw; public Model LShoulder, LUpperClaw, LLowerClaw; public Model Pelvis; public Model RUpperLeg, RLowerLeg, RAnkle, RForeToe, RBackToe, RInToe, ROutToe; public Model LUpperLeg, LLowerLeg, LAnkle, LForeToe, LBackToe, LInToe, LOutToe; public static final double TWO_PI = 2.0 * Math.PI; public static final double PI_DIV_2 = Math.PI / 2.0; public static final double PI_DIV_4 = Math.PI / 4.0; public static final double PI_DIV_5 = Math.PI / 5.0; public static final double PI_DIV_6 = Math.PI / 6.0; public static final double LEG_ANGLE = Math.acos(0.8); public RobotFigure() { super(); initTorso(); initHead(); initRShoulder(); initRUpperClaw(); initRLowerClaw(); initLShoulder(); initLUpperClaw(); initLLowerClaw(); initPelvis(); initRUpperLeg(); initRLowerLeg(); initRAnkle(); initRForeToe(); initRBackToe(); initRInToe(); initROutToe(); initLUpperLeg(); initLLowerLeg(); initLAnkle(); initLForeToe(); initLBackToe(); initLInToe(); initLOutToe(); setRoot(Pelvis); Pelvis.attachChild(Torso, 0.0, 4.0, 0.0); Pelvis.attachChild(RUpperLeg, -5.0, 0.0, 0.0); Pelvis.attachChild(LUpperLeg, 5.0, 0.0, 0.0); Torso.attachChild(Head, 0.0, 2.0, 0.0); Torso.attachChild(RShoulder, -11.0, 0.0, 0.0); Torso.attachChild(LShoulder, 11.0, 0.0, 0.0); RShoulder.attachChild(RUpperClaw, 0.0, 0.0, 0.0); RShoulder.attachChild(RLowerClaw, 0.0, 0.0, 0.0); LShoulder.attachChild(LUpperClaw, 0.0, 0.0, 0.0); LShoulder.attachChild(LLowerClaw, 0.0, 0.0, 0.0); RUpperLeg.attachChild(RLowerLeg, -2.0, 0.0, -6.0); RLowerLeg.attachChild(RAnkle, 0.0, -8.0, 6.0); RAnkle.attachChild(RForeToe, 0.0, -2.0, 1.0); RAnkle.attachChild(RBackToe, 0.0, -2.0, -1.0); RAnkle.attachChild(RInToe, 1.0, -2.0, 0.0); RAnkle.attachChild(ROutToe, -1.0, -2.0, 0.0); LUpperLeg.attachChild(LLowerLeg, 2.0, 0.0, -6.0); LLowerLeg.attachChild(LAnkle, 0.0, -8.0, 6.0); LAnkle.attachChild(LForeToe, 0.0, -2.0, 1.0); LAnkle.attachChild(LBackToe, 0.0, -2.0, -1.0); LAnkle.attachChild(LInToe, -1.0, -2.0, 0.0); LAnkle.attachChild(LOutToe, 1.0, -2.0, 0.0); } protected void initHead(){ Transformation3d dtrans = new Transformation3d(); dtrans = dtrans.x_rotate(-PI_DIV_2); Head = new Model(dtrans); Head.crossSection.moveTo(1.0, 0.0); for (double f = 0.0; f <= TWO_PI; f += PI_DIV_6) { Head.crossSection.lineTo(Math.cos(f), Math.sin(f)); } Head.crossSection.lineTo(1.0, 0.0); Head.crossSection.terminatePath(); Head.profile.moveTo(6.0, 0.0); Head.profile.bezierTo(6.0, 4.0, 1.0, 10.0, 1.0, 6.0); Head.profile.lineTo(1.0, 1.0); Head.profile.lineTo(0.0, 1.0); Head.profile.terminatePath(); Head.setRConstraints(0.0, -TWO_PI, 0.0, 0.0, TWO_PI, 0.0); } protected void initTorso(){ Transformation3d dtrans = new Transformation3d(); dtrans = dtrans.x_rotate(-PI_DIV_2); Torso = new Model(dtrans); Torso.crossSection.moveTo(1.0, 0.0); for (double f = 0.0; f <= TWO_PI; f += PI_DIV_6) { Torso.crossSection.lineTo(Math.cos(f), Math.sin(f)); } Torso.crossSection.lineTo(1.0, 0.0); Torso.crossSection.terminatePath(); Torso.profile.moveTo(2.0, 8.0); Torso.profile.lineTo(1.0, 9.0); Torso.profile.lineTo(1.0, 10.0); Torso.profile.lineTo(-1.0, 10.0); Torso.profile.lineTo(-1.0, 9.0); Torso.profile.lineTo(-2.0, 8.0); Torso.profile.lineTo(-2.0, 1.0); Torso.profile.lineTo(-4.0, 1.0); Torso.profile.terminatePath(); Torso.setRConstraints(0.0, -TWO_PI, 0.0, 0.0, TWO_PI, 0.0); } protected void initRShoulder(){ Transformation3d dtrans = new Transformation3d(); dtrans = dtrans.y_rotate(-PI_DIV_2); RShoulder = new Model(dtrans); RShoulder.crossSection.moveTo(1.0, 0.0); for (double f = 0.0; f <= TWO_PI; f += PI_DIV_6) { RShoulder.crossSection.lineTo(Math.cos(f), Math.sin(f)); } RShoulder.crossSection.lineTo(1.0, 0.0); RShoulder.crossSection.terminatePath(); RShoulder.profile.moveTo(-1.0, 2.0); RShoulder.profile.lineTo(1.0, 2.0); RShoulder.profile.terminatePath(); RShoulder.setRConstraints(-TWO_PI, 0.0, 0.0, TWO_PI, 0.0, 0.0); } protected void initRUpperClaw(){ Transformation3d dtrans = new Transformation3d(); dtrans = dtrans.translate(0.0, -2.0, 0.0); dtrans = dtrans.x_rotate(-Math.PI / 20.0); RUpperClaw = new Model(dtrans); RUpperClaw.crossSection.moveTo(0.0, 4.0); RUpperClaw.crossSection.lineTo(-1.0, 6.0); RUpperClaw.crossSection.lineTo(1.0, 6.0); RUpperClaw.crossSection.lineTo(0.0, 4.0); RUpperClaw.crossSection.terminatePath(); RUpperClaw.profile.moveTo(0.0, 1.0); RUpperClaw.profile.bezierTo(8.0, 1.0, 13.0, 0.33, 13.0, 0.0); RUpperClaw.profile.terminatePath(); RUpperClaw.setRConstraints(-PI_DIV_5, 0.0, 0.0, 0.0, 0.0, 0.0); } protected void initRLowerClaw(){ Transformation3d dtrans = new Transformation3d(); dtrans = dtrans.translate(0.0, 2.0, 0.0); dtrans = dtrans.x_rotate(Math.PI / 20.0); RLowerClaw = new Model(dtrans); RLowerClaw.crossSection.moveTo(0.0, -4.0); RLowerClaw.crossSection.lineTo(-1.0, -6.0); RLowerClaw.crossSection.lineTo(1.0, -6.0); RLowerClaw.crossSection.lineTo(0.0, -4.0); RLowerClaw.crossSection.terminatePath(); RLowerClaw.profile.moveTo(0.0, 1.0); RLowerClaw.profile.bezierTo(8.0, 1.0, 13.0, 0.33, 13.0, 0.0); RLowerClaw.profile.terminatePath(); RLowerClaw.setRConstraints(0.0, 0.0, 0.0, PI_DIV_5, 0.0, 0.0); } protected void initLShoulder(){ Transformation3d dtrans = new Transformation3d(); dtrans = dtrans.y_rotate(PI_DIV_2); LShoulder = new Model(dtrans); LShoulder.crossSection.moveTo(1.0, 0.0); for (double f = 0.0; f <= TWO_PI; f += PI_DIV_6) { LShoulder.crossSection.lineTo(Math.cos(f), Math.sin(f)); } LShoulder.crossSection.lineTo(1.0, 0.0); LShoulder.crossSection.terminatePath(); LShoulder.profile.moveTo(-1.0, 2.0); LShoulder.profile.lineTo(1.0, 2.0); LShoulder.profile.terminatePath(); LShoulder.setRConstraints(-TWO_PI, 0.0, 0.0, TWO_PI, 0.0, 0.0); } protected void initLUpperClaw(){ Transformation3d dtrans = new Transformation3d(); dtrans = dtrans.translate(0.0, -2.0, 0.0); dtrans = dtrans.x_rotate(-Math.PI / 20.0); LUpperClaw = new Model(dtrans); LUpperClaw.crossSection.moveTo(0.0, 4.0); LUpperClaw.crossSection.lineTo(-1.0, 6.0); LUpperClaw.crossSection.lineTo(1.0, 6.0); LUpperClaw.crossSection.lineTo(0.0, 4.0); LUpperClaw.crossSection.terminatePath(); LUpperClaw.profile.moveTo(0.0, 1.0); LUpperClaw.profile.bezierTo(8.0, 1.0, 13.0, 0.33, 13.0, 0.0); LUpperClaw.profile.terminatePath(); LUpperClaw.setRConstraints(-PI_DIV_5, 0.0, 0.0, 0.0, 0.0, 0.0); } protected void initLLowerClaw(){ Transformation3d dtrans = new Transformation3d(); dtrans = dtrans.translate(0.0, 2.0, 0.0); dtrans = dtrans.x_rotate(Math.PI / 20.0); LLowerClaw = new Model(dtrans); LLowerClaw.crossSection.moveTo(0.0, -4.0); LLowerClaw.crossSection.lineTo(-1.0, -6.0); LLowerClaw.crossSection.lineTo(1.0, -6.0); LLowerClaw.crossSection.lineTo(0.0, -4.0); LLowerClaw.crossSection.terminatePath(); LLowerClaw.profile.moveTo(0.0, 1.0); LLowerClaw.profile.bezierTo(8.0, 1.0, 13.0, 0.33, 13.0, 0.0); LLowerClaw.profile.terminatePath(); LLowerClaw.setRConstraints(0.0, 0.0, 0.0, PI_DIV_5, 0.0, 0.0); } protected void initPelvis(){ Transformation3d dtrans = new Transformation3d(); dtrans = dtrans.x_rotate(-PI_DIV_2); Pelvis = new Model(dtrans); Pelvis.crossSection.moveTo(1.0, 0.0); for (double f = 0.0; f <= TWO_PI; f += PI_DIV_6) { Pelvis.crossSection.lineTo(Math.cos(f), Math.sin(f)); } Pelvis.crossSection.lineTo(1.0, 0.0); Pelvis.crossSection.terminatePath(); Pelvis.profile.moveTo(-1.0, 4.0); Pelvis.profile.lineTo(1.0, 4.0); Pelvis.profile.lineTo(1.0, 2.0); Pelvis.profile.lineTo(-1.0, 2.0); Pelvis.profile.lineTo(-1.0, 4.0); Pelvis.profile.terminatePath(); /* Use the default rotational constraints (i.e., none) */ } protected void initRUpperLeg(){ Transformation3d dtrans = new Transformation3d(); dtrans = dtrans.y_rotate(-PI_DIV_2); dtrans = dtrans.x_rotate(PI_DIV_2); RUpperLeg = new Model(dtrans); RUpperLeg.crossSection.moveTo(1.0, 0.0); for (double f = 0.0; f <= Math.PI; f += PI_DIV_6) { RUpperLeg.crossSection.lineTo(Math.cos(f), Math.sin(f)); } RUpperLeg.crossSection.lineTo(-1.0, 0.0); RUpperLeg.crossSection.lineTo(-1.0, -6.0); for (double f = Math.PI; f <= TWO_PI; f += PI_DIV_6) { RUpperLeg.crossSection.lineTo(Math.cos(f), Math.sin(f) - 6.0); } RUpperLeg.crossSection.lineTo(1.0, -6.0); RUpperLeg.crossSection.lineTo(1.0, 0.0); RUpperLeg.crossSection.terminatePath(); RUpperLeg.profile.moveTo(-1.0, 1.0); RUpperLeg.profile.lineTo(1.0, 1.0); RUpperLeg.profile.terminatePath(); RUpperLeg.setRConstraints(-TWO_PI, 0.0, 0.0, 0.0, 0.0, 0.0); } protected void initRLowerLeg(){ Transformation3d dtrans = new Transformation3d(); dtrans = dtrans.y_rotate(-PI_DIV_2); dtrans = dtrans.x_rotate(-Math.acos(0.8)); RLowerLeg = new Model(dtrans); RLowerLeg.crossSection.moveTo(1.0, 0.0); for (double f = 0.0; f <= Math.PI; f += PI_DIV_6) { RLowerLeg.crossSection.lineTo(Math.cos(f), Math.sin(f)); } RLowerLeg.crossSection.lineTo(-1.0, -10.0); for (double f = Math.PI; f <= TWO_PI; f += PI_DIV_6) { RLowerLeg.crossSection.lineTo(Math.cos(f), Math.sin(f) - 10.0); } RLowerLeg.crossSection.lineTo(1.0, 0.0); RLowerLeg.crossSection.terminatePath(); RLowerLeg.profile.moveTo(-1.0, 1.0); RLowerLeg.profile.lineTo(1.0, 1.0); RLowerLeg.profile.terminatePath(); RLowerLeg.setRConstraints(LEG_ANGLE - Math.PI, 0.0, 0.0, LEG_ANGLE, 0.0, 0.0); } protected void initRAnkle(){ Transformation3d dtrans = new Transformation3d(); dtrans = dtrans.translate(0.0, 0.0, -2.0); dtrans = dtrans.x_rotate(-PI_DIV_2); RAnkle = new Model(dtrans); RAnkle.crossSection.moveTo(1.0, 0.0); for (double f = 0.0; f <= TWO_PI; f += PI_DIV_6) { RAnkle.crossSection.lineTo(Math.cos(f), Math.sin(f)); } RAnkle.crossSection.lineTo(1.0, 0.0); RAnkle.crossSection.terminatePath(); RAnkle.profile.moveTo(-1.0, 2.0); RAnkle.profile.lineTo(1.0, 2.0); RAnkle.profile.terminatePath(); RAnkle.setRConstraints(-PI_DIV_4 - LEG_ANGLE, -TWO_PI, 0.0, LEG_ANGLE, TWO_PI, 0.0); } protected void initRForeToe(){ Transformation3d dtrans = new Transformation3d(); dtrans = dtrans.translate(0.0, -1.0, 0.0); RForeToe = new Model(dtrans); RForeToe.crossSection.moveTo(-1.0, 2.0); RForeToe.crossSection.lineTo(1.0, 2.0); RForeToe.crossSection.lineTo(1.0, 0.0); RForeToe.crossSection.lineTo(-1.0, 0.0); RForeToe.crossSection.lineTo(-1.0, 2.0); RForeToe.crossSection.terminatePath(); RForeToe.profile.moveTo(1.0, 1.0); RForeToe.profile.lineTo(5.0, 0.0); RForeToe.profile.terminatePath(); RForeToe.setRConstraints(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); } protected void initRBackToe(){ Transformation3d dtrans = new Transformation3d(); dtrans = dtrans.translate(0.0, -1.0, 0.0); dtrans = dtrans.y_rotate(Math.PI); RBackToe = new Model(dtrans); RBackToe.crossSection.moveTo(-1.0, 2.0); RBackToe.crossSection.lineTo(1.0, 2.0); RBackToe.crossSection.lineTo(1.0, 0.0); RBackToe.crossSection.lineTo(-1.0, 0.0); RBackToe.crossSection.lineTo(-1.0, 2.0); RBackToe.crossSection.terminatePath(); RBackToe.profile.moveTo(1.0, 1.0); RBackToe.profile.lineTo(5.0, 0.0); RBackToe.profile.terminatePath(); RBackToe.setRConstraints(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); } protected void initRInToe(){ Transformation3d dtrans = new Transformation3d(); dtrans = dtrans.translate(0.0, -1.0, 0.0); dtrans = dtrans.y_rotate(PI_DIV_2); RInToe = new Model(dtrans); RInToe.crossSection.moveTo(-1.0, 2.0); RInToe.crossSection.lineTo(1.0, 2.0); RInToe.crossSection.lineTo(1.0, 0.0); RInToe.crossSection.lineTo(-1.0, 0.0); RInToe.crossSection.lineTo(-1.0, 2.0); RInToe.crossSection.terminatePath(); RInToe.profile.moveTo(1.0, 1.0); RInToe.profile.lineTo(5.0, 0.0); RInToe.profile.terminatePath(); RInToe.setRConstraints(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); } protected void initROutToe(){ Transformation3d dtrans = new Transformation3d(); dtrans = dtrans.translate(0.0, -1.0, 0.0); dtrans = dtrans.y_rotate(-PI_DIV_2); ROutToe = new Model(dtrans); ROutToe.crossSection.moveTo(-1.0, 2.0); ROutToe.crossSection.lineTo(1.0, 2.0); ROutToe.crossSection.lineTo(1.0, 0.0); ROutToe.crossSection.lineTo(-1.0, 0.0); ROutToe.crossSection.lineTo(-1.0, 2.0); ROutToe.crossSection.terminatePath(); ROutToe.profile.moveTo(1.0, 1.0); ROutToe.profile.lineTo(5.0, 0.0); ROutToe.profile.terminatePath(); ROutToe.setRConstraints(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); } protected void initLUpperLeg(){ Transformation3d dtrans = new Transformation3d(); dtrans = dtrans.y_rotate(PI_DIV_2); dtrans = dtrans.x_rotate(PI_DIV_2); LUpperLeg = new Model(dtrans); LUpperLeg.crossSection.moveTo(1.0, 0.0); for (double f = 0.0; f <= Math.PI; f += PI_DIV_6) { LUpperLeg.crossSection.lineTo(Math.cos(f), Math.sin(f)); } LUpperLeg.crossSection.lineTo(-1.0, -6.0); for (double f = Math.PI; f <= TWO_PI; f += PI_DIV_6) { LUpperLeg.crossSection.lineTo(Math.cos(f), Math.sin(f) - 6.0); } LUpperLeg.crossSection.lineTo(1.0, 0.0); LUpperLeg.crossSection.terminatePath(); LUpperLeg.profile.moveTo(-1.0, 1.0); LUpperLeg.profile.lineTo(1.0, 1.0); LUpperLeg.profile.terminatePath(); LUpperLeg.setRConstraints(-TWO_PI, 0.0, 0.0, 0.0, 0.0, 0.0); } protected void initLLowerLeg(){ Transformation3d dtrans = new Transformation3d(); dtrans = dtrans.y_rotate(PI_DIV_2); dtrans = dtrans.x_rotate(-LEG_ANGLE); LLowerLeg = new Model(dtrans); LLowerLeg.crossSection.moveTo(1.0, 0.0); for (double f = 0.0; f <= Math.PI; f += PI_DIV_6) { LLowerLeg.crossSection.lineTo(Math.cos(f), Math.sin(f)); } LLowerLeg.crossSection.lineTo(-1.0, -10.0); for (double f = Math.PI; f <= TWO_PI; f += PI_DIV_6) { LLowerLeg.crossSection.lineTo(Math.cos(f), Math.sin(f) - 10.0); } LLowerLeg.crossSection.lineTo(1.0, 0.0); LLowerLeg.crossSection.terminatePath(); LLowerLeg.profile.moveTo(-1.0, 1.0); LLowerLeg.profile.lineTo(1.0, 1.0); LLowerLeg.profile.terminatePath(); LLowerLeg.setRConstraints(LEG_ANGLE - Math.PI, 0.0, 0.0, LEG_ANGLE, 0.0, 0.0); } protected void initLAnkle() { Transformation3d dtrans = new Transformation3d(); dtrans = dtrans.translate(0.0, 0.0, -2.0); dtrans = dtrans.x_rotate(-PI_DIV_2); LAnkle = new Model(dtrans); LAnkle.crossSection.moveTo(1.0, 0.0); for (double f = 0.0; f <= TWO_PI; f += PI_DIV_6) { LAnkle.crossSection.lineTo(Math.cos(f), Math.sin(f)); } LAnkle.crossSection.lineTo(1.0, 0.0); LAnkle.crossSection.terminatePath(); LAnkle.profile.moveTo(-1.0, 2.0); LAnkle.profile.lineTo(1.0, 2.0); LAnkle.profile.terminatePath(); LAnkle.setRConstraints(-PI_DIV_4 - LEG_ANGLE, -TWO_PI, 0.0, LEG_ANGLE, TWO_PI, 0.0); } protected void initLForeToe(){ Transformation3d dtrans = new Transformation3d(); dtrans = dtrans.translate(0.0, -1.0, 0.0); LForeToe = new Model(dtrans); LForeToe.crossSection.moveTo(-1.0, 2.0); LForeToe.crossSection.lineTo(1.0, 2.0); LForeToe.crossSection.lineTo(1.0, 0.0); LForeToe.crossSection.lineTo(-1.0, 0.0); LForeToe.crossSection.lineTo(-1.0, 2.0); LForeToe.crossSection.terminatePath(); LForeToe.profile.moveTo(1.0, 1.0); LForeToe.profile.lineTo(5.0, 0.0); LForeToe.profile.terminatePath(); LForeToe.setRConstraints(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); } protected void initLBackToe(){ Transformation3d dtrans = new Transformation3d(); dtrans = dtrans.translate(0.0, -1.0, 0.0); dtrans = dtrans.y_rotate(Math.PI); LBackToe = new Model(dtrans); LBackToe.crossSection.moveTo(-1.0, 2.0); LBackToe.crossSection.lineTo(1.0, 2.0); LBackToe.crossSection.lineTo(1.0, 0.0); LBackToe.crossSection.lineTo(-1.0, 0.0); LBackToe.crossSection.lineTo(-1.0, 2.0); LBackToe.crossSection.terminatePath(); LBackToe.profile.moveTo(1.0, 1.0); LBackToe.profile.lineTo(5.0, 0.0); LBackToe.profile.terminatePath(); LBackToe.setRConstraints(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); } protected void initLInToe(){ Transformation3d dtrans = new Transformation3d(); dtrans = dtrans.translate(0.0, -1.0, 0.0); dtrans = dtrans.y_rotate(-PI_DIV_2); LInToe = new Model(dtrans); LInToe.crossSection.moveTo(-1.0, 2.0); LInToe.crossSection.lineTo(1.0, 2.0); LInToe.crossSection.lineTo(1.0, 0.0); LInToe.crossSection.lineTo(-1.0, 0.0); LInToe.crossSection.lineTo(-1.0, 2.0); LInToe.crossSection.terminatePath(); LInToe.profile.moveTo(1.0, 1.0); LInToe.profile.lineTo(5.0, 0.0); LInToe.profile.terminatePath(); LInToe.setRConstraints(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); } protected void initLOutToe(){ Transformation3d dtrans = new Transformation3d(); dtrans = dtrans.translate(0.0, -1.0, 0.0); dtrans = dtrans.y_rotate(PI_DIV_2); LOutToe = new Model(dtrans); LOutToe.crossSection.moveTo(-1.0, 2.0); LOutToe.crossSection.lineTo(1.0, 2.0); LOutToe.crossSection.lineTo(1.0, 0.0); LOutToe.crossSection.lineTo(-1.0, 0.0); LOutToe.crossSection.lineTo(-1.0, 2.0); LOutToe.crossSection.terminatePath(); LOutToe.profile.moveTo(1.0, 1.0); LOutToe.profile.lineTo(5.0, 0.0); LOutToe.profile.terminatePath(); LOutToe.setRConstraints(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); } }