我已经找到了如何在WorldWind中呈现视线的示例:http://patmurris.blogspot.com/2008/04/ray-casting-and-line-of-sight-for-wwj.html (其中a有点旧,但似乎仍然有效).这是示例中使用的类(下面稍微修改过代码以使用WorldWind 2.0).看起来代码也使用RayCastingSupport(Javadoc和Code)来实现其魔力.
我想弄清楚的是,如果这个代码/示例使用地球的曲率/和/或地平线的距离作为其逻辑的一部分.只看代码,我不确定我完全理解它在做什么.
例如,如果我试图找出地球上方200米处的人可以"看到"的地形,是否会考虑到地平线的距离?
修改代码以考虑到地平线的距离/地球的曲率(如果还没有),需要做些什么?
package gov.nasa.worldwindx.examples;
import gov.nasa.worldwind.util.RayCastingSupport;
import gov.nasa.worldwind.view.orbit.OrbitView;
import gov.nasa.worldwind.geom.Angle;
import gov.nasa.worldwind.geom.Position;
import gov.nasa.worldwind.geom.Sector;
import gov.nasa.worldwind.geom.Vec4;
import gov.nasa.worldwind.globes.Globe;
import gov.nasa.worldwind.layers.CrosshairLayer;
import gov.nasa.worldwind.layers.RenderableLayer;
import gov.nasa.worldwind.render.*;
import javax.swing.*;
import javax.swing.border.CompoundBorder;
import javax.swing.border.TitledBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
public class LineOfSight extends ApplicationTemplate
{
public static class AppFrame extends ApplicationTemplate.AppFrame
{
private double samplingLength = 30; // Ray casting sample length
private int centerOffset = 100; // meters …
Run Code Online (Sandbox Code Playgroud) 我试图在一段时间内围绕网络世界风地球"移动"可渲染物.为了说明我遇到的问题,我做了一个小例子.
这有效(但效率低下):
var myVar = setInterval(myTimer, 5000);
function myTimer() {
shapesLayer.removeRenderable(shape);
shape = new WorldWind.SurfaceCircle(new WorldWind.Location(shape.center.latitude+1, shape.center.longitude), 200e3, attributes);
shapesLayer.addRenderable(shape);
console.log(" new pos "+shape.center.latitude + " "+shape.center.longitude);
wwd.redraw();
}
Run Code Online (Sandbox Code Playgroud)
这是我想做的,但形状不动:
var myVar = setInterval(myTimer, 5000);
function myTimer() {
shape.center = new WorldWind.Location(shape.center.latitude+1, shape.center.longitude);
console.log(" new pos "+shape.center.latitude + " "+shape.center.longitude);
wwd.redraw();
}
Run Code Online (Sandbox Code Playgroud)
我需要在渲染上设置一个标志以使其刷新吗?
下面是完整的SurfaceShapes.js文件我一直在玩(在此基础上http://worldwindserver.net/webworldwind/examples/SurfaceShapes.html):
/*
* Copyright (C) 2014 United States Government as represented by the Administrator of the
* National Aeronautics and Space Administration. All Rights Reserved. …
Run Code Online (Sandbox Code Playgroud) 我想把它WorldWindowGLJPanel
放入一个窗格,我想让它可以调整大小,但我不能,即使我打电话resize
或setSize
方法.
这是我正在做的事情:
wwd = new WorldWindowGLJPanel();
wwd.setPreferredSize(new java.awt.Dimension(300, 300));
wwd.setModel(new BasicModel());
swingNode = new SwingNode();
swingNode.setContent(wwd);
wwdPane = new Pane();
wwdPane.getChildren().add(swingNode);
Run Code Online (Sandbox Code Playgroud)
然后我用它wwdPane
来显示World Wind.
我希望我world wind panel
的窗格大小包含它,我想让它可以world wind panel
调整大小.
我想过给大小我world wind panel
我的pane
了setSize(PaneDimenson)
,然后我worldwindpanel的大小与我的窗格中结合,但setSize
功能不工作.
编辑:我通过不使用窗格找到了替代解决方案,但直接使用swingNode,调整大小现在是自动的.但是如果你想使用一个窗格仍然存在问题,那么你就强迫使用一个组.
我正在阅读本教程
每当我的鼠标悬停在使用此代码创建的立方体上时(我的版本如下),大气和星星就会消失.
这是它通常看起来的样子:
这就是我将鼠标悬停在立方体上时的样子(看大气层):
我不确定这里发生了什么.
/*
* Copyright (C) 2012 United States Government as represented by the Administrator of the
* National Aeronautics and Space Administration.
* All Rights Reserved.
*/
package gov.nasa.worldwindx.examples.tutorial;
import gov.nasa.worldwind.Configuration;
import gov.nasa.worldwind.avlist.AVKey;
import gov.nasa.worldwind.geom.*;
import gov.nasa.worldwind.layers.RenderableLayer;
import gov.nasa.worldwind.pick.PickSupport;
import gov.nasa.worldwind.render.*;
import gov.nasa.worldwind.util.OGLUtil;
import gov.nasa.worldwindx.examples.ApplicationTemplate;
import javax.media.opengl.*;
import java.awt.*;
/**
* Example of a custom {@link Renderable} that draws a cube at a geographic position. This class shows the simplest
* possible example …
Run Code Online (Sandbox Code Playgroud) 在NASA WorldWind中,可以为Milstd-2525符号指定"行进方向"速度引导者.然而,这个速度领先者是黑色的,因此很难看到深蓝色的海洋背景.我已经尝试在TacticalSymbolAttributes中更改内部颜色材质,但这似乎没有效果(对任何东西).遗憾的是,文档没有提供有关如何更改线条颜色的任何线索.
是否有可能在Worldwind中改变Milstd-2525 Tactical Symbol的速度领导线的颜色,如果是这样,怎么样?
我为NASA Worldwind创建了一个输入处理程序,我正在尝试复制Google Earth,就像缩放一样.
我正在尝试缩放鼠标光标,而不是屏幕中心(就像默认情况下那样).
我有点工作 - 除了它不会一直缩放到光标下的纬度/长度,它似乎漂移得太远了.我想要发生的是在缩放期间光标下面保持相同的纬度/经度.因此,例如,如果您将光标悬停在特定地标(如水体)上,则当滚轮滚动时,它将保持在光标下方.
我正在使用的代码基于以下内容:https: //forum.worldwindcentral.com/forum/world-wind-java-forums/development-help/11977-zoom-at-mouse-cursor?p = 104793# post104793
这是我的输入处理程序:
import java.awt.event.MouseWheelEvent;
import gov.nasa.worldwind.awt.AbstractViewInputHandler;
import gov.nasa.worldwind.awt.ViewInputAttributes;
import gov.nasa.worldwind.geom.Position;
import gov.nasa.worldwind.geom.Vec4;
import gov.nasa.worldwind.view.orbit.BasicOrbitView;
import gov.nasa.worldwind.view.orbit.OrbitViewInputHandler;
public class ZoomToCursorViewInputHandler extends OrbitViewInputHandler {
protected class ZoomActionHandler extends VertTransMouseWheelActionListener {
@Override
public boolean inputActionPerformed(AbstractViewInputHandler inputHandler, MouseWheelEvent mouseWheelEvent,
ViewInputAttributes.ActionAttributes viewAction) {
double zoomInput = mouseWheelEvent.getWheelRotation();
Position position = getView().computePositionFromScreenPoint(mousePoint.x, mousePoint.y);
// Zoom toward the cursor if we're zooming in. Move straight out when zooming
// out.
if (zoomInput < 0 …
Run Code Online (Sandbox Code Playgroud) 我知道在WorldWind Java中你可以找到高程和特定位置,如下所示:
public Double getPositionElevationMeters(Double lat, Double lon) {
double elevation = getWorldWindCanvas().getModel().getGlobe()
.getElevation(Angle.fromDegrees(lat), Angle.fromDegrees(lon));
return elevation;
}
Run Code Online (Sandbox Code Playgroud)
有没有办法弄清楚这个纬度/经度是否实际上是一个主要的水体或土地?我采取了一种"盲目"的方法,只考虑低于0的高度是水,但这显然不是理想的.
我甚至会使用另一个能够提供这些信息的图书馆; 我只需要它离线工作.
我试图想出一种方法来以编程方式获取用户点击WorldWind AnalyticSurface的点的视觉颜色(而不是拾取颜色).
看看AnalyticSurface和PickedObjectList我不确定我需要串起来执行此操作的API调用,或者甚至可能.
我的任务是使用WorldWind API创建应用程序,为了熟悉API,我尝试运行"HelloWorldWind"示例应用程序.当我这样做时,我得到以下错误堆栈:
Exception in thread "main" java.lang.AbstractMethodError: javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V
at gov.nasa.worldwind.util.WWXML.createDocumentBuilder(WWXML.java:61)
at gov.nasa.worldwind.util.WWXML.openDocumentStream(WWXML.java:236)
at gov.nasa.worldwind.util.WWXML.openDocumentStream(WWXML.java:223)
at gov.nasa.worldwind.util.WWXML.openDocumentFile(WWXML.java:175)
at gov.nasa.worldwind.util.WWXML.openDocument(WWXML.java:148)
at gov.nasa.worldwind.Configuration.loadConfigDoc(Configuration.java:131)
at gov.nasa.worldwind.Configuration.<init>(Configuration.java:108)
at gov.nasa.worldwind.Configuration.<clinit>(Configuration.java:76)
at gov.nasa.worldwindx.examples.HelloWorldWind.main(HelloWorldWind.java:
Run Code Online (Sandbox Code Playgroud)
WWXML.createDocumentBuilder
如下:
public static DocumentBuilder createDocumentBuilder(boolean isNamespaceAware)
{
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
docBuilderFactory.setNamespaceAware(isNamespaceAware);
if (Configuration.getJavaVersion() >= 1.6)
{
try
{
docBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd",
false); // Not getting past here
}
catch (ParserConfigurationException e)
{ // Note it and continue on. Some Java5 parsers don't support the feature.
String message = Logging.getMessage("XML.NonvalidatingNotSupported");
Logging.logger().finest(message);
}
}
...
Run Code Online (Sandbox Code Playgroud)
Worldwind的Point PlaceMark可渲染具有通过调用setLineEnabled从地标到地形的一条线,如下截图所示:
我正在尝试做的是添加一条这样的线,它也适用于可渲染的战术符号.我的第一个想法是从PointPlacemark可渲染中借用逻辑来执行此操作,并将其添加到AbstractTacticalSymbol可渲染.我试过了,到目前为止我还没有成功.
这是我到目前为止所做的:
将此添加到OrderedSymbol类:
public Vec4 terrainPoint;
Run Code Online (Sandbox Code Playgroud)更新了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() …
Run Code Online (Sandbox Code Playgroud)worldwind ×10
java ×8
gis ×3
jogl ×2
opengl ×2
awt ×1
google-earth ×1
javafx ×1
javascript ×1
math ×1
resize ×1
swing ×1
webworldwind ×1