/** * Extracts the smallest LOD fragment that satisfies the given LOD criterion . * * @param crit * criterion that the LOD must satisfies * @param roi * @return smallest LOD that satisfies the given LOD criterion */ public List<MeshFragment> extractLODFragment( LODCriterion crit, ViewFrustum roi ) { return new SpatialSelection( this, crit, roi, 1.0f ).determineLODFragment(); }
/** * Determines the LOD fragment that corresponds to the associated {@link LODCriterion} and region of interest. * * @return PatchInfo objects of all patches that make up the LOD fragment */ public List<MeshFragment> determineLODFragment() { List<MeshFragment> fragments = new ArrayList<MeshFragment>(); adaptTopDown(); for ( Arc arc : lod ) { for ( int fragmentId = arc.lowestPatch; fragmentId <= arc.highestPatch; fragmentId++ ) { MeshFragment fragment = mt.fragments[fragmentId]; fragments.add( fragment ); } } return fragments; }
initializeCut(); lod.remove( mt.arcs[incomingArc] ); } else { forceRefinement( mt.arcs[incomingArc], toDo );
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; } }
/** * The new LOD is based on the current viewfrustum and the maximum size of any textures. * * @param glRenderContext * @param zScale * @param textureManagers */ private Set<RenderMeshFragment> getNewLOD( RenderContext glRenderContext, float zScale, TextureManager[] textureManagers ) { ViewParams params = glRenderContext.getViewParams(); ViewFrustum frustum = params.getViewFrustum(); ViewFrustumCrit crit = new ViewFrustumCrit( params, (float) maxPixelError, zScale, glRenderContext.getMaxTextureSize(), textureManagers, (float) maxProjectedTexelSize ); SpatialSelection lodAdaptor = new SpatialSelection( fragmentManager.getMultiresolutionMesh(), crit, frustum, zScale ); List<MeshFragment> fragments = lodAdaptor.determineLODFragment(); Set<RenderMeshFragment> fragmentIds = new HashSet<RenderMeshFragment>( fragments.size() ); for ( MeshFragment fragment : fragments ) { fragmentIds.add( fragmentManager.renderFragments[fragment.id] ); } return fragmentIds; }