/** * Returns the ViewPlatformBehavior at the specified index */ ViewPlatformBehavior getViewPlatformBehavior(int index) { return (ViewPlatformBehavior)behaviors.getChild(index); }
/** * Returns the avatarRoot child number of the ViewerAvatar object. * All the children of the avatarRoot are compared with the passed * in ViewerAvatar. If a match is found, the index is returned. * * @param avatar The ViewerAvatar object to look for in the avatarRoot's * child nodes. * @return The index of the child that corresponds to the ViewerAvatar. * If the avatarRoot does not contain the ViewerAvatar -1 is returned. */ private int findAvatarChild(ViewerAvatar avatar) { // Search the avatarRoot for the ViewerAvatar associated with // with the Viewer object for (int i = 0; i < avatarRoot.numChildren(); i++) { if (((ViewerAvatar)avatarRoot.getChild(i)) == avatar) return i; } // Should never get here. System.err.println("ViewingPlatform.findAvatarChild:Child not found."); return -1; }
/** * Sets the ViewPlatformBehavior which will operate on the ViewPlatform * transform (the TransformGroup returned by * ViewingPlatform.getViewPlatformTransform()). The ViewPlatformBehavior * may be set after the ViewingPlatform is setLive(). * If a behavior is already present, it will be detached and it's * setViewingPlatform method will be called with a parameter of null. * @param behavior The ViewPlatformBehavior to add to the ViewingPlatform. * null will remove the ViewingPlatform behavior. * @since Java 3D 1.2.1 */ public void setViewPlatformBehavior(ViewPlatformBehavior behavior) { if (behaviors != null) { removeViewPlatformBehavior((ViewPlatformBehavior)behaviors.getChild(0)); } if (behavior != null) { addViewPlatformBehavior(behavior); } }
/** * Update the position of the child at the specified index. * * @param i * @param pos */ private void updatePositionInGeometry(final int i, final Point3d pos) { final BranchGroup bg = (BranchGroup) getChild(i); final TransformGroup tg = (TransformGroup) bg.getChild(0); v3f.x = (float) pos.x; v3f.y = (float) pos.y; v3f.z = (float) pos.z; t3d.set(v3f); tg.setTransform(t3d); }
public void displayCase(Image3DUniverse univ, int caseNo) { System.out.println("Case no " + caseNo); int threshold = 120; BranchGroup scene = univ.getScene(); for(int i = scene.numChildren()-1; i >= 1 ; i--) { if (scene.getChild(i) instanceof BranchGroup) if (scene.getChild(i).getCapability(BranchGroup.ALLOW_DETACH)) scene.removeChild(i); } System.out.println("Nr. of contents:" + univ.getContents().size()); univ.removeAllContents(); createCase(caseNo); Volume volume = new Volume(image); List l = MCCube.getTriangles(volume, threshold); univ.addTriangleMesh(l, RED, "case" + caseNo); for(int z = 0; z < data.length; z++) { for(int y = 0; y < 2; y++) { for(int x = 0; x < 2; x++) { if(((int)data[z][y*2+x]&0xff)>=threshold) { addVertex(univ, RED, x, y, z); } else { addVertex(univ, GREY, x, y, z); } } } } }
/** * @see PointList.PointListListener#highlighted */ @Override public void highlighted(final BenesNamedPoint p) { final int i = points.indexOf(p); final BranchGroup bg = (BranchGroup) getChild(i); final TransformGroup tg = (TransformGroup) bg.getChild(0); final ScaleInterpolator si = (ScaleInterpolator) tg.getChild(1); final Alpha a = si.getAlpha(); si.setEnable(true); a.resume(); try { Thread.sleep(600); } catch (final Exception e) {} a.pause(); si.setEnable(false); }
/** * Removes the specified ViewPlatformBehavior */ void removeViewPlatformBehavior(ViewPlatformBehavior behavior) { // remove from the behaviors branch group if (behaviors != null) { behaviors.detach(); for (int i = 0; i < behaviors.numChildren(); i++) { if (behaviors.getChild(i) == behavior) { behavior.setViewingPlatform( null ); behaviors.removeChild(i); break; } } if (behaviors.numChildren() == 0) behaviors = null; else this.addChild(behaviors); } }
/** * Set the radius of the points. * * @param r */ public void setRadius(final float r) { this.radius = r; final Transform3D t3d = new Transform3D(); for (int i = 0; i < numChildren(); i++) { final BranchGroup bg = (BranchGroup) getChild(i); final TransformGroup tg = (TransformGroup) bg.getChild(0); final ScaleInterpolator si = (ScaleInterpolator) tg.getChild(1); if (si != null) { si.setMaximumScale(5 * radius); si.setMinimumScale(radius); } final TransformGroup sig = (TransformGroup) tg.getChild(0); sig.getTransform(t3d); t3d.setScale(radius); sig.setTransform(t3d); } }
final BranchGroup bg = (BranchGroup) getChild(i); final TransformGroup tg = (TransformGroup) ((Group) bg.getChild(0)).getChild(0); final Sphere s = (Sphere) tg.getChild(0); s.setAppearance(appearance); Group gr = (Group) bg.getChild(0); gr = (Group) gr.getChild(2); final OrientedShape3D os = (OrientedShape3D) gr.getChild(0);