Logo Search packages:      
Sourcecode: earth3d version File versions  Download package

void MapTileTreeNode::generateBoundingSphere (  ) 

Generate the bounding sphere from the vertex data of the texture and the heightfield data.

Definition at line 441 of file mapTileTreeNode.cpp.

                                             {
  if (getCore(0)) {
    TextureTreeNodeCore *texcore = (TextureTreeNodeCore *) getCore(0);
    Point3D center;
    for(int i=0; i<4; i++) {
      center += *(texcore->getVertex(i));
    }
    center/=4;

    float radius=0, newradius;
    for(int i=0; i<4; i++) {
      newradius = (*(texcore->getVertex(i)) - center).length();
      if (newradius>radius) radius = newradius;
    }

    if (getCore(1)) {
      HeightfieldTreeNodeCore *hcore = (HeightfieldTreeNodeCore *) getCore(1);
      Point3D *vertexarray = hcore->vertexarray;
      for(int i=0; i<hcore->vertexcount; i++) {
      newradius = (vertexarray[i] - center).length();
      if (newradius>radius) radius = newradius;
      }
    }

    bs.center = center;
    bs.radius = radius;
  }
}


Generated by  Doxygen 1.6.0   Back to index