private Arc[] createArcs( ByteBuffer arcsBuffer ) { Arc[] arcs = new Arc[arcsBuffer.capacity() / Arc.SIZE]; for ( int i = 0; i < arcs.length; i++ ) { arcs[i] = new Arc( this, i, arcsBuffer, i * Arc.SIZE ); } return arcs; }
/** * Returns the bounding box of the region that this arc represents. * * @return the bounding box */ public float[][] getBBox() { float[][] bbox = new float[2][3]; bbox[0][0] = mt.fragments[lowestPatch].bbox[0][0]; bbox[0][1] = mt.fragments[lowestPatch].bbox[0][1]; bbox[0][2] = mt.fragments[lowestPatch].bbox[0][2]; bbox[1][0] = mt.fragments[lowestPatch].bbox[1][0]; bbox[1][1] = mt.fragments[lowestPatch].bbox[1][1]; bbox[1][2] = mt.fragments[lowestPatch].bbox[1][2]; for ( int patchId = lowestPatch + 1; patchId <= highestPatch; patchId++ ) { enlargeBBox( bbox, mt.fragments[patchId].bbox ); } return bbox; }
/** * Initializes the cut, so it is just below the root node. */ private void initializeCut() { lod = new HashSet<Arc>(); applied = new boolean[mt.nodes.length]; Node root = mt.nodes[0]; int[] outgoingArcs = new int[root.highestOutgoingArc - root.lowestOutgoingArc + 1]; for ( int i = 0; i < outgoingArcs.length; i++ ) { Arc arc = mt.arcs[i + root.lowestOutgoingArc]; if ( arc.interferes( roi, zScale ) ) { lod.add( arc ); } } applied[0] = true; }
private boolean isInViewVolume( Arc arc ) { float[][] scaledBBox = arc.getBBox(); scaledBBox[0][2] *= zScale; scaledBBox[1][2] *= zScale; return viewRegion.intersects( scaledBBox ); }
void append(ByteBuffer buffer) { org.deegree.rendering.r3d.multiresolution.Arc.store(buffer, sourceNode, destinationNode, lowestPatch, highestPatch, nextArcWithSameDestination, error); } }
/** * Checks whether all fragments denoted by the given {@link Arc} are texturable with respect to the max texture size * and texture resolutions. * * @param arc * @return true, if all are texturable, false otherwise (at least one is not texturable) */ private boolean isTexturable( Arc arc ) { if ( textureManagers.length == 0 ) { return true; } for ( MeshFragment fragment : arc.getFragments() ) { if ( !isTexturable( fragment ) ) { return false; } } return true; }
/** * Determines if this arc interferes with the given {@link Geometry}. * * @param roi * geometry that is tested for interference * @param zScale * scaling factor applied to z values of the mesh geometry (and bounding boxes) * @return true, if the arc interferes with the geometry, false otherwise */ public boolean interferes( ViewFrustum roi, float zScale ) { float[][] nodeBBox = getBBox(); nodeBBox[0][2] *= zScale; nodeBBox[1][2] *= zScale; return roi.intersects( nodeBBox ); }
/** * Checks whether the screen-space error (after perspective projection) introduced by the fragments of the * {@link Arc} is acceptable. * * @param arc * @return true, if all fragments are fine */ private boolean isScreenSpaceErrorAcceptable( Arc arc ) { float[][] scaledBBox = arc.getBBox(); scaledBBox[0][2] *= zScale; scaledBBox[1][2] *= zScale; float[] eyePos = new float[3]; eyePos[0] = (float) viewRegion.getEyePos().x; eyePos[1] = (float) viewRegion.getEyePos().y; eyePos[2] = (float) viewRegion.getEyePos().z; float dist = VectorUtils.getDistance( scaledBBox, eyePos ); double projectionFactor = viewParams.estimatePixelSizeForSpaceUnit( dist ); double screenError = projectionFactor * arc.geometricError; // System.out.println ("error: " + arc.geometryError); // System.out.println ("screen error: " + screenError); return screenError <= maxPixelError; }
private void forceRefinement( Arc region, List<Arc> toDo ) { Node modification = mt.nodes[region.sourceNode]; int incomingArc = modification.lowestIncomingArc; while ( incomingArc != -1 ) { if ( applied[mt.arcs[incomingArc].sourceNode] ) { lod.remove( mt.arcs[incomingArc] ); } else { forceRefinement( mt.arcs[incomingArc], toDo ); } incomingArc = mt.arcs[incomingArc].nextArcWithSameDestination; } for ( int arcId = modification.lowestOutgoingArc; arcId <= modification.highestOutgoingArc; arcId++ ) { if ( arcId != region.id ) { Arc arc2 = mt.arcs[arcId]; if ( arc2.interferes( roi, zScale ) ) { lod.add( arc2 ); toDo.add( arc2 ); } } } applied[modification.id] = true; } }
for ( int arcId = modification.lowestOutgoingArc; arcId <= modification.highestOutgoingArc; arcId++ ) { Arc arc = mt.arcs[arcId]; if ( arc.interferes( roi, zScale ) ) { lod.add( arc ); toDo.add( arc );