Exemplo n.º 1
0
 /*
  * (non-Javadoc)
  * @see rajawali.scenegraph.A_nAABBTree#split()
  */
 @Override
 protected void split() {
   RajLog.d("[" + this.getClass().getName() + "] Spliting node: " + this);
   // Populate child array
   for (int i = 0; i < CHILD_COUNT; ++i) {
     if (mChildren[i] == null) {
       mChildren[i] =
           new Octree(
               this, mMergeThreshold, mSplitThreshold, mShrinkThreshold, mGrowThreshold, mOverlap);
     }
     mChildren[i].setBoundingColor(COLORS[i]);
     mChildren[i].setChildRegion(i, mChildLengths);
   }
   super.split();
 }
Exemplo n.º 2
0
 /*
  * (non-Javadoc)
  * @see rajawali.scenegraph.A_nAABBTree#setChildRegion(int, rajawali.math.Number3D)
  */
 @Override
 protected void setChildRegion(int octant, Vector3 side_lengths) {
   mChildRegion = octant;
   Vector3 min = mParent.getMin();
   Vector3 max = mParent.getMax();
   switch (mChildRegion) {
     case 0: // +X/+Y/+Z
       mMax.setAllFrom(mParent.getMax());
       mMin.setAllFrom(Vector3.subtract(mMax, side_lengths));
       break;
     case 1: // -X/+Y/+Z
       mMax.x = min.x + side_lengths.x;
       mMax.y = max.y;
       mMax.z = max.z;
       mMin.x = min.x;
       mMin.y = max.y - side_lengths.y;
       mMin.z = max.z - side_lengths.z;
       break;
     case 2: // -X/-Y/+Z
       mMax.x = min.x + side_lengths.x;
       mMax.y = min.y + side_lengths.y;
       mMax.z = max.z;
       mMin.x = min.x;
       mMin.y = min.y;
       mMin.z = max.z - side_lengths.z;
       break;
     case 3: // +X/-Y/+Z
       mMax.x = max.x;
       mMax.y = min.y + side_lengths.y;
       mMax.z = max.z;
       mMin.x = max.x - side_lengths.x;
       mMin.y = min.y;
       mMin.z = max.z - side_lengths.z;
       break;
     case 4: // +X/+Y/-Z
       mMax.x = max.x;
       mMax.y = max.y;
       mMax.z = min.z + side_lengths.z;
       mMin.x = max.x - side_lengths.x;
       mMin.y = max.y - side_lengths.y;
       mMin.z = min.z;
       break;
     case 5: // -X/+Y/-Z
       mMax.x = min.x + side_lengths.x;
       mMax.y = max.y;
       mMax.z = min.z + side_lengths.z;
       mMin.x = min.x;
       mMin.y = max.y - side_lengths.y;
       mMin.z = min.z;
       break;
     case 6: // -X/-Y/-Z
       mMin.setAllFrom(min);
       mMax.setAllFrom(Vector3.add(mMin, side_lengths));
       break;
     case 7: // +X/-Y/-Z
       mMax.x = max.x;
       mMax.y = min.y + side_lengths.y;
       mMax.z = min.z + side_lengths.z;
       mMin.x = max.x - side_lengths.x;
       mMin.y = min.y;
       mMin.z = min.z;
       break;
     default:
       return;
   }
   super.setChildRegion(octant, side_lengths);
 }