Пример #1
0
 public BranchGroup addSphere(geom3d.Point3d p, double radius, Color3f color) {
   BranchGroup bgSphere = new BranchGroup();
   bgSphere.setCapability(BranchGroup.ALLOW_DETACH);
   Appearance ap = new Appearance();
   ap.setColoringAttributes(new ColoringAttributes(color, ColoringAttributes.NICEST));
   ap.setTransparencyAttributes(new TransparencyAttributes(TransparencyAttributes.NICEST, 0.5f));
   Sphere sphere = new Sphere(new Float(radius), ap);
   Transform3D tr = new Transform3D();
   tr.setTranslation(new javax.vecmath.Vector3d(p.getX(), p.getY(), p.getZ()));
   TransformGroup tgSphere = new TransformGroup(tr);
   tgSphere.addChild(sphere);
   bgSphere.addChild(tgSphere);
   spin.addChild(bgSphere);
   return bgSphere;
 }
Пример #2
0
 public void addSphere(Simplex simplex, double radius, Color3f color) {
   geom3d.Point3d p = (Point3d) complex.getPoints().get(simplex.getPoints()[0]);
   BranchGroup bgSphere = new BranchGroup();
   bgSphere.setCapability(BranchGroup.ALLOW_DETACH);
   Appearance ap = new Appearance();
   ap.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_READ);
   ap.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_WRITE);
   ap.setColoringAttributes(new ColoringAttributes(color, ColoringAttributes.NICEST));
   simplex.setSphere(new Sphere(new Float(radius), ap));
   simplex.getSphere().getShape().setCapability(Shape3D.ALLOW_APPEARANCE_READ);
   simplex.getSphere().getShape().setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
   Transform3D tr = new Transform3D();
   tr.setTranslation(new javax.vecmath.Vector3d(p.getX(), p.getY(), p.getZ()));
   TransformGroup tgSphere = new TransformGroup(tr);
   tgSphere.addChild(simplex.getSphere());
   bgSphere.addChild(tgSphere);
   spin.addChild(bgSphere);
 }