protected void determineModelToTexCoord(RenderContext rc) { Vec3 point = rc.geographicToCartesian(this.center.latitude, this.center.longitude, this.center.altitude, this.altitudeMode, scratchPoint); this.modelToTexCoord = rc.globe.cartesianToLocalTransform(point.x, point.y, point.z, this.modelToTexCoord); this.modelToTexCoord.invertOrthonormal(); }
protected void determineModelToTexCoord(RenderContext rc) { double mx = 0, my = 0, mz = 0; double numPoints = 0; for (int boundaryIdx = 0, boundaryCount = this.boundaries.size(); boundaryIdx < boundaryCount; boundaryIdx++) { List<Position> positions = this.boundaries.get(boundaryIdx); if (positions.isEmpty()) { continue; // no boundary positions } for (int idx = 0, len = positions.size(); idx < len; idx++) { Position pos = positions.get(idx); Vec3 point = rc.geographicToCartesian(pos.latitude, pos.longitude, pos.altitude, WorldWind.ABSOLUTE, this.point); mx += point.x; my += point.y; mz += point.z; numPoints++; } } mx /= numPoints; my /= numPoints; mz /= numPoints; this.modelToTexCoord = rc.globe.cartesianToLocalTransform(mx, my, mz, this.modelToTexCoord); this.modelToTexCoord.invertOrthonormal(); }
/** * Calculate the number of times to split the edges of the shape for geometry assembly. * * @param rc current RenderContext * * @return an even number of intervals */ protected int computeIntervals(RenderContext rc) { int intervals = MIN_INTERVALS; if (intervals >= this.maximumIntervals) { return intervals; // use at least the minimum number of intervals } Vec3 centerPoint = rc.geographicToCartesian(this.center.latitude, this.center.longitude, this.center.altitude, this.altitudeMode, scratchPoint); double maxRadius = Math.max(this.majorRadius, this.minorRadius); double cameraDistance = centerPoint.distanceTo(rc.cameraPoint) - maxRadius; if (cameraDistance <= 0) { return this.maximumIntervals; // use the maximum number of intervals when the camera is very close } double metersPerPixel = rc.pixelSizeAtDistance(cameraDistance); double circumferencePixels = this.computeCircumference() / metersPerPixel; double circumferenceIntervals = circumferencePixels / this.maximumPixelsPerInterval; double subdivisions = Math.log(circumferenceIntervals / intervals) / Math.log(2); int subdivisionCount = Math.max(0, (int) Math.ceil(subdivisions)); intervals <<= subdivisionCount; // subdivide the base intervals to achieve the desired number of intervals return Math.min(intervals, this.maximumIntervals); // don't exceed the maximum number of intervals }
protected void addVertex(RenderContext rc, double latitude, double longitude, double altitude, int offset, boolean isExtrudedSkirt) { int offsetVertexIndex = this.vertexIndex + offset; Vec3 point = rc.geographicToCartesian(latitude, longitude, altitude, this.altitudeMode, scratchPoint); Vec3 texCoord2d = this.texCoord2d.set(point).multiplyByMatrix(this.modelToTexCoord); point = rc.geographicToCartesian(latitude, longitude, 0, WorldWind.CLAMP_TO_GROUND, scratchPoint); this.vertexArray[offsetVertexIndex++] = (float) (point.x - this.vertexOrigin.x); this.vertexArray[offsetVertexIndex++] = (float) (point.y - this.vertexOrigin.y);
protected double cameraDistanceGeographic(RenderContext rc, Sector boundingSector) { double lat = WWMath.clamp(rc.camera.latitude, boundingSector.minLatitude(), boundingSector.maxLatitude()); double lon = WWMath.clamp(rc.camera.longitude, boundingSector.minLongitude(), boundingSector.maxLongitude()); Vec3 point = rc.geographicToCartesian(lat, lon, 0, WorldWind.CLAMP_TO_GROUND, this.scratchPoint); return point.distanceTo(rc.cameraPoint); }
this.vertexOrigin.set(this.center.longitude, this.center.latitude, this.center.altitude); } else { rc.geographicToCartesian(this.center.latitude, this.center.longitude, this.center.altitude, this.altitudeMode, scratchPoint); this.vertexOrigin.set(scratchPoint.x, scratchPoint.y, scratchPoint.z);
rc.geographicToCartesian(this.position.latitude, this.position.longitude, this.position.altitude, this.altitudeMode, renderData.placePoint);
/** * Calculates the distance from this tile to the camera point associated with the specified render context. * * @param rc the render context which provides the current camera point * * @return the distance in meters */ protected double distanceToCamera(RenderContext rc) { // determine the nearest latitude double nearestLat = WWMath.clamp(rc.camera.latitude, this.sector.minLatitude(), this.sector.maxLatitude()); // determine the nearest longitude and account for the antimeridian discontinuity double nearestLon; double lonDifference = rc.camera.longitude - this.sector.centroidLongitude(); if (lonDifference < -180.0) { nearestLon = this.sector.maxLongitude(); } else if (lonDifference > 180.0) { nearestLon = this.sector.minLongitude(); } else { nearestLon = WWMath.clamp(rc.camera.longitude, this.sector.minLongitude(), this.sector.maxLongitude()); } float minHeight = (float) (this.heightLimits[0] * rc.verticalExaggeration); rc.geographicToCartesian(nearestLat, nearestLon, minHeight, WorldWind.ABSOLUTE, this.nearestPoint); return rc.cameraPoint.distanceTo(this.nearestPoint); } }
protected void addVertex(RenderContext rc, double latitude, double longitude, double altitude, boolean intermediate) { int vertex = this.vertexArray.size() / VERTEX_STRIDE; Vec3 point = rc.geographicToCartesian(latitude, longitude, altitude, this.altitudeMode, this.point); point = rc.geographicToCartesian(latitude, longitude, 0, this.altitudeMode, this.point); this.vertexArray.add((float) (point.x - this.vertexOrigin.x)); this.vertexArray.add((float) (point.y - this.vertexOrigin.y));
protected void doRender(RenderContext rc) { rc.geographicToCartesian(this.position.latitude, this.position.longitude, this.position.altitude, this.altitudeMode, placePoint); rc.geographicToCartesian(this.position.latitude, this.position.longitude, 0, WorldWind.CLAMP_TO_GROUND, groundPoint);
protected int addVertex(RenderContext rc, double latitude, double longitude, double altitude, int type) { int vertex = this.vertexArray.size() / VERTEX_STRIDE; Vec3 point = rc.geographicToCartesian(latitude, longitude, altitude, this.altitudeMode, this.point); Vec3 texCoord2d = this.texCoord2d.set(point).multiplyByMatrix(this.modelToTexCoord); point = rc.geographicToCartesian(latitude, longitude, 0, WorldWind.CLAMP_TO_GROUND, this.point); this.vertexArray.add((float) (point.x - this.vertexOrigin.x)); this.vertexArray.add((float) (point.y - this.vertexOrigin.y));