class Measurement3D { //in this branchgroup measurements will be done private BranchGroup a_oMeasurementSceneGraphRoot = null; //pick tool for measurements protected PickTool a_oMeasurementPicker = null; /** * constructor */ protected Measurement3D() { //create branchgroup for materialmeasurement a_oMeasurementSceneGraphRoot = new BranchGroup(); //create picker and initialize a_oMeasurementPicker = new PickTool(a_oMeasurementSceneGraphRoot); a_oMeasurementPicker.setMode(PickTool.GEOMETRY_INTERSECT_INFO); //set capabilities for measure group a_oMeasurementSceneGraphRoot.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND); a_oMeasurementSceneGraphRoot.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE); a_oMeasurementSceneGraphRoot.setCapability(BranchGroup.ALLOW_CHILDREN_READ); a_oMeasurementSceneGraphRoot.setCapability(BranchGroup.ALLOW_DETACH); //add the measure group to a singleton universe (all material measurements use the same //universe and canvas3D, because of better memory usage VirtualMeasurementUniverse.getUniverse().addBranchGraph(a_oMeasurementSceneGraphRoot); } /** * add an object for material measurement * @param p_oMeasurementObject a BranchGroup containing a material object */ protected void addMeasurementObject(BranchGroup p_oMeasurementObject) { a_oMeasurementSceneGraphRoot.addChild(p_oMeasurementObject); } /** * remove a specific object from material measurement * @param p_oMeasurementObject materialobject to remove */ protected void removeMeasurementObject(BranchGroup p_oMeasurementObject) { a_oMeasurementSceneGraphRoot.removeChild(p_oMeasurementObject); } /** * remove all material objects */ protected void removeMeasurementObjects() { a_oMeasurementSceneGraphRoot.removeAllChildren(); } /** * tidy up j3d stuff */ @Override protected void finalize() throws Throwable { a_oMeasurementSceneGraphRoot.detach(); VirtualMeasurementUniverse.getUniverse().getLocale().removeBranchGraph(a_oMeasurementSceneGraphRoot); ViewInfo.clear(); super.finalize(); } }