예제 #1
0
 /**
  * Updates the position of vol so it is placed at orig. This method is used for fast repaints in
  * J3DScene
  */
 void updateVolumePosition(Volume3d vol, Volume3d orig) {
   switch (chainTree.volumeMode) {
     case OBB:
       Box3d box = (Box3d) vol;
       Box3d origBox = (Box3d) orig;
       box.setAnchor(origBox.getAnchor());
       box.setXDir(origBox.getXDir());
       box.setYDir(origBox.getYDir());
       box.setZDir(origBox.getZDir());
       return;
     case CAPSULE:
       Capsule3d caps = (Capsule3d) vol;
       Capsule3d origCaps = (Capsule3d) orig;
       caps.segment.setA(origCaps.segment.getA());
       caps.segment.setB(origCaps.segment.getB());
       caps.rad = origCaps.rad;
       return;
     case RSS:
       RSS3d rss = (RSS3d) vol;
       RSS3d origRSS = (RSS3d) orig;
       rss.rectangle.center.set(origRSS.rectangle.center);
       rss.rectangle.bases[0].set(origRSS.rectangle.bases[0]);
       rss.rectangle.bases[1].set(origRSS.rectangle.bases[1]);
       rss.radius = origRSS.radius;
       return;
     case PSS:
       Sphere3d sphere = (Sphere3d) vol;
       Sphere3d origSphere = (Sphere3d) orig;
       sphere.center.set(origSphere.center);
   }
   throw new Error("Unknown volume type chosen: " + chainTree.volumeMode);
 }
예제 #2
0
  /** Create a volume bounding all the points. Also extend the radius appropriately */
  Volume3d createEnclosingExtendedVolume(PointSet3d points, double extension) {
    switch (chainTree.volumeMode) {
      case OBB:
        Box3d retBox = Box3d.createBoundingBox_Covariance(points);
        retBox.extents[0] += extension;
        retBox.extents[1] += extension;
        retBox.extents[2] += extension;
        return retBox;
      case CAPSULE:
        Capsule3d ret = Capsule3d.createBoundingCapsule_CovarianceFit(points);
        ret.rad += extension;
        return ret;
      case RSS:
        RSS3d rss = RSS3d.createBoundingRSS_covariance(points);
        rss.radius += extension;

        return rss;
      case PSS:
        Sphere3d sphere = Sphere3d.getMinSphere(points);
        sphere.radius += extension;
        return sphere;
    }
    throw new Error("Unknown volume type chosen: " + chainTree.volumeMode);
  }