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(); }
protected Camera lookAtToCamera(Globe globe, LookAt lookAt, Camera result) { this.lookAtToViewingTransform(globe, lookAt, this.modelview); this.modelview.extractEyePoint(this.originPoint); globe.cartesianToGeographic(this.originPoint.x, this.originPoint.y, this.originPoint.z, this.originPos); globe.cartesianToLocalTransform(this.originPoint.x, this.originPoint.y, this.originPoint.z, this.origin); this.modelview.multiplyByMatrix(this.origin); result.latitude = this.originPos.latitude; result.longitude = this.originPos.longitude; result.altitude = this.originPos.altitude; result.heading = this.modelview.extractHeading(lookAt.roll); // disambiguate heading and roll result.tilt = this.modelview.extractTilt(); result.roll = lookAt.roll; // roll passes straight through return result; }
protected void makeDrawable(RenderContext rc) { // Obtain a pooled drawable and configure it to draw the sightline's coverage. Pool<DrawableSightline> pool = rc.getDrawablePool(DrawableSightline.class); DrawableSightline drawable = DrawableSightline.obtain(pool); // Compute the transform from sightline local coordinates to world coordinates. drawable.centerTransform = rc.globe.cartesianToLocalTransform(this.centerPoint.x, this.centerPoint.y, this.centerPoint.z, drawable.centerTransform); drawable.range = (float) WWMath.clamp(this.range, 0, Float.MAX_VALUE); // Configure the drawable colors according to the current attributes. When picking use a unique color associated // with the picked object ID. Null attributes indicate that nothing is drawn. if (this.activeAttributes != null) { drawable.visibleColor.set(rc.pickMode ? this.pickColor : this.activeAttributes.interiorColor); } if (this.occludeAttributes != null) { drawable.occludedColor.set(rc.pickMode ? this.pickColor : this.occludeAttributes.interiorColor); } // Use the sightline GLSL program to draw the coverage. drawable.program = (SightlineProgram) rc.getShaderProgram(SightlineProgram.KEY); if (drawable.program == null) { drawable.program = (SightlineProgram) rc.putShaderProgram(SightlineProgram.KEY, new SightlineProgram(rc.resources)); } // Enqueue a drawable for processing on the OpenGL thread. rc.offerSurfaceDrawable(drawable, 0 /*z-order*/); } }
protected LookAt cameraToLookAt(Globe globe, Camera camera, LookAt result) { this.cameraToViewingMatrix(globe, camera, this.modelview); this.modelview.extractEyePoint(this.forwardRay.origin); this.modelview.extractForwardVector(this.forwardRay.direction); if (!globe.intersect(this.forwardRay, this.originPoint)) { double horizon = globe.horizonDistance(camera.altitude); this.forwardRay.pointAt(horizon, this.originPoint); } globe.cartesianToGeographic(this.originPoint.x, this.originPoint.y, this.originPoint.z, this.originPos); globe.cartesianToLocalTransform(this.originPoint.x, this.originPoint.y, this.originPoint.z, this.origin); this.modelview.multiplyByMatrix(this.origin); result.latitude = this.originPos.latitude; result.longitude = this.originPos.longitude; result.altitude = this.originPos.altitude; result.range = -this.modelview.m[11]; result.heading = this.modelview.extractHeading(camera.roll); // disambiguate heading and roll result.tilt = this.modelview.extractTilt(); result.roll = camera.roll; // roll passes straight through return result; }