/* create the node. Use nodeRect for calculation of coordinates */
MapTileTreeNode newNode = new MapTileTreeNode(currentNode);
newNode.depth = depth;
Rect2D newNodeRect = getChildRect(childnr, nodeRect);
/* create texture core */
TextureTreeNodeCore newTextureCore = createTextureCore(currentNode.getMapTileTree(), currentNode, childnr, newNodeRect);
/* insert core */
newNode.setCore(0, newTextureCore);
/* create heightfield core */
HeightfieldTreeNodeCore newHeightfieldCore = createHeightfieldCore(currentNode, childnr, newNodeRect, newTextureCore.vertex, htree);
/* insert core */
newNode.setCore(1, newHeightfieldCore);
/* generate bounding sphere */
newNode.generateBoundingSphere();
// insert into parent node
currentNode.setChild(childnr, newNode);
// newNode.informNeighborNodes();
// request the nodes
if (newTextureCore.getRequestID()!=null) {
request(newTextureCore);
}
else {
newTextureCore.setGenerated(false);
newTextureCore.setDownloaded(true);
}
requestHeightfield(newHeightfieldCore);
// select currentNode for drawing or generate deeper node from known data
selectNode(newNode, selectedNodes, visible);
/* set interpolation value for the new node */
float newDistance = (float) getDistance(viewer, ((HeightfieldTreeNodeCore)(newNode.getCore(1))).getRect());
float newEdgeSize = (float) getMaxEdgeSize(viewer, ((TextureTreeNodeCore)(newNode.getCore(0))).vertex, newDistance);
if (newEdgeSize>Global.MAXTILESIZE_2) {
newNode.setInterpolationCounter(1-(newEdgeSize-Global.MAXTILESIZE_2)/Global.MAXTILESIZE_2);
}
else {
newNode.setInterpolationCounter(1);
}
}
else {
// printf("CHECKNODE FOUND CHILD\n");
/* the tile cannot be yet requested because the download of the parent
tile is not finished. The parent needs to be drawn */
selectNode(currentNode, selectedNodes, visible);
if (edgeSize>Global.MAXTILESIZE_2) {
currentNode.setInterpolationCounter(1-(edgeSize-Global.MAXTILESIZE_2)/Global.MAXTILESIZE_2);
}
else {
currentNode.setInterpolationCounter(1);
}
}
}
else {
/* Calculate angle rectangle of child node */
Rect2D newNodeRect = getChildRect(childnr, nodeRect);
/* Check this node */
checkNode(child, selectedNodes, viewer, virtualviewer, newNodeRect, projmodelmatrix, modelviewmatrix, depth+1, distsurface, direction, windowSize);
}
}