Worldwind의 포인트 장소의 렌더링 가능한이 스크린 샷으로 setLineEnabled를 호출하여 지형 아래로 위치 표시에서 선을 드롭 할 수있는 기능이 있습니다Worldwind 라인 지형
내가 노력하고있어를 Tactical Symbol 렌더링과 함께 작동하는 이와 같은 라인을 추가하십시오. 내 첫 번째 생각은 PointPlacemark 렌더링에서이 작업을 수행하는 로직을 빌려서 AbstractTacticalSymbol 렌더링 가능에 추가하는 것입니다. 나는 그것을 시도하고 나는 지금까지 성공적이지 못했다.
추가를 OrderedSymbol 클래스에이 :
public Vec4 terrainPoint;
업데이트 computeSymbolPoints이 terrainPoint
protected void computeSymbolPoints(DrawContext dc, OrderedSymbol osym) { osym.placePoint = null; osym.screenPoint = null; osym.terrainPoint = null; osym.eyeDistance = 0; Position pos = this.getPosition(); if (pos == null) return; if (this.altitudeMode == WorldWind.CLAMP_TO_GROUND || dc.is2DGlobe()) { osym.placePoint = dc.computeTerrainPoint(pos.getLatitude(), pos.getLongitude(), 0); } else if (this.altitudeMode == WorldWind.RELATIVE_TO_GROUND) { osym.placePoint = dc.computeTerrainPoint(pos.getLatitude(), pos.getLongitude(), pos.getAltitude()); } else // Default to ABSOLUTE { double height = pos.getElevation() * dc.getVerticalExaggeration(); osym.placePoint = dc.getGlobe().computePointFromPosition(pos.getLatitude(), pos.getLongitude(), height); } if (osym.placePoint == null) return; // Compute the symbol's screen location the distance between the eye point and the place point. osym.screenPoint = dc.getView().project(osym.placePoint); osym.eyeDistance = osym.placePoint.distanceTo3(dc.getView().getEyePoint()); // Compute a terrain point if needed. if (this.isLineEnabled() && this.altitudeMode != WorldWind.CLAMP_TO_GROUND && !dc.is2DGlobe()) osym.terrainPoint = dc.computeTerrainPoint(pos.getLatitude(), pos.getLongitude(), 0); }
추가 된이를 계산하기 위해 여기
내가 지금까지 한 일이다 논리 (PointPlacemark.java에서 가져 와서 준수하도록 업데이트 됨) ce to AbstractTacticalSymbol.java). lineEnabled를 true로 설정 했으므로 기본적으로 선을 그려야합니다.boolean lineEnabled = true; double lineWidth = 1; protected int linePickWidth = 10; Color lineColor = Color.white; /** * Indicates whether a line from the placemark point to the corresponding position on the terrain is drawn. * * @return true if the line is drawn, otherwise false. */ public boolean isLineEnabled() { return lineEnabled; } /** * Specifies whether a line from the placemark point to the corresponding position on the terrain is drawn. * * @param lineEnabled true if the line is drawn, otherwise false. */ public void setLineEnabled(boolean lineEnabled) { this.lineEnabled = lineEnabled; } /** * Determines whether the placemark's optional line should be drawn and whether it intersects the view frustum. * * @param dc the current draw context. * * @return true if the line should be drawn and it intersects the view frustum, otherwise false. */ protected boolean isDrawLine(DrawContext dc, OrderedSymbol opm) { if (!this.isLineEnabled() || dc.is2DGlobe() || this.getAltitudeMode() == WorldWind.CLAMP_TO_GROUND || opm.terrainPoint == null) return false; if (dc.isPickingMode()) return dc.getPickFrustums().intersectsAny(opm.placePoint, opm.terrainPoint); else return dc.getView().getFrustumInModelCoordinates().intersectsSegment(opm.placePoint, opm.terrainPoint); } /** * Draws the placemark's line. * * @param dc the current draw context. * @param pickCandidates the pick support object to use when adding this as a pick candidate. */ protected void drawLine(DrawContext dc, PickSupport pickCandidates, OrderedSymbol opm) { GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility. if ((!dc.isDeepPickingEnabled())) gl.glEnable(GL.GL_DEPTH_TEST); gl.glDepthFunc(GL.GL_LEQUAL); gl.glDepthMask(true); try { dc.getView().pushReferenceCenter(dc, opm.placePoint); // draw relative to the place point this.setLineWidth(dc); this.setLineColor(dc, pickCandidates); gl.glBegin(GL2.GL_LINE_STRIP); gl.glVertex3d(Vec4.ZERO.x, Vec4.ZERO.y, Vec4.ZERO.z); gl.glVertex3d(opm.terrainPoint.x - opm.placePoint.x, opm.terrainPoint.y - opm.placePoint.y, opm.terrainPoint.z - opm.placePoint.z); gl.glEnd(); } finally { dc.getView().popReferenceCenter(dc); } } /** * Sets the width of the placemark's line during rendering. * * @param dc the current draw context. */ protected void setLineWidth(DrawContext dc) { Double lineWidth = this.lineWidth; if (lineWidth != null) { GL gl = dc.getGL(); if (dc.isPickingMode()) { gl.glLineWidth(lineWidth.floatValue() + linePickWidth); } else gl.glLineWidth(lineWidth.floatValue()); if (!dc.isPickingMode()) { gl.glHint(GL.GL_LINE_SMOOTH_HINT, GL.GL_FASTEST); gl.glEnable(GL.GL_LINE_SMOOTH); } } } /** * Sets the color of the placemark's line during rendering. * * @param dc the current draw context. * @param pickCandidates the pick support object to use when adding this as a pick candidate. */ protected void setLineColor(DrawContext dc, PickSupport pickCandidates) { GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility. if (!dc.isPickingMode()) { Color color = this.lineColor; gl.glColor4ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue(), (byte) color.getAlpha()); } else { Color pickColor = dc.getUniquePickColor(); Object delegateOwner = this.getDelegateOwner(); pickCandidates.addPickableObject(pickColor.getRGB(), delegateOwner != null ? delegateOwner : this, this.getPosition()); gl.glColor3ub((byte) pickColor.getRed(), (byte) pickColor.getGreen(), (byte) pickColor.getBlue()); } }
추가 drawOrderedRenderable 방법의 시작이 호출 :
boolean drawLine = this.isDrawLine(dc, osym); if (drawLine) this.drawLine(dc, pickCandidates, osym);
나는이 밀접 PointPlacemark 지형 표시에 선을 얻기 위해 무엇을하고 있는지 반영 생각하지만, 이것은 무엇이다 변경 사항이 적용된 TacticalSymbols 예제를 실행하면 다음과 같이 표시됩니다.
감사합니다. 이것은 정확히 내가 뭘 찾고 있었는지 (스크린 샷) - 라인 너비와 색상을 제어하는 능력과 함께. 괜찮으 시다면 변경해야 할 사항을 설명해주십시오. – systemoutprintln
내 대답을 설명으로 업데이트했습니다. – TWT
그 설명은 대단히 도움이됩니다. 다시 감사합니다. – systemoutprintln