Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/fix/placemark-pitch' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
EMaksymenko committed Feb 20, 2022
2 parents 6ed9d5b + 843d22f commit 7000d5a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 35 deletions.
69 changes: 34 additions & 35 deletions src/gov/nasa/worldwind/render/PointPlacemark.java
Original file line number Diff line number Diff line change
Expand Up @@ -999,9 +999,26 @@ protected void doDrawOrderedRenderable(DrawContext dc, PickSupport pickCandidate
(byte) color.getAlpha());
}

// Compute the scale
double xscale;
Double scale = this.getActiveAttributes().getScale();
if (scale != null)
xscale = scale * this.activeTexture.getWidth(dc);
else
xscale = this.activeTexture.getWidth(dc);

double yscale;
if (scale != null)
yscale = scale * this.activeTexture.getHeight(dc);
else
yscale = this.activeTexture.getHeight(dc);

// Calculate maximum possible depth value in case of rectangle is tilted on 90 degree and rotated on 45
double maxDepth = Math.max(xscale, yscale) * 1.42;

// The image is drawn using a parallel projection.
osh.pushProjectionIdentity(gl);
gl.glOrtho(0d, dc.getView().getViewport().width, 0d, dc.getView().getViewport().height, -1d, 1d);
gl.glOrtho(0d, dc.getView().getViewport().width, 0d, dc.getView().getViewport().height, -maxDepth, maxDepth);

// Apply the depth buffer but don't change it (for screen-space shapes).
if ((!dc.isDeepPickingEnabled()))
Expand All @@ -1014,52 +1031,34 @@ protected void doDrawOrderedRenderable(DrawContext dc, PickSupport pickCandidate

// Adjust depth of image to bring it slightly forward
double depth = opm.screenPoint.z - (8d * 0.00048875809d);
depth = depth < 0d ? 0d : (depth > 1d ? 1d : depth);
depth = depth < 0d ? 0d : Math.min(depth, 1d);
gl.glDepthFunc(GL.GL_LESS);
gl.glDepthRange(depth, depth);

// The image is drawn using a translated and scaled unit quad.
// Translate to screen point and adjust to align hot spot.
osh.pushModelviewIdentity(gl);
gl.glTranslated(opm.screenPoint.x + this.dx, opm.screenPoint.y + this.dy, 0);

// Compute the scale
double xscale;
Double scale = this.getActiveAttributes().getScale();
if (scale != null)
xscale = scale * this.activeTexture.getWidth(dc);
else
xscale = this.activeTexture.getWidth(dc);

double yscale;
if (scale != null)
yscale = scale * this.activeTexture.getHeight(dc);
else
yscale = this.activeTexture.getHeight(dc);
// Translate to screen point.
gl.glTranslated(opm.screenPoint.x, opm.screenPoint.y, 0);

Double heading = getActiveAttributes().getHeading();
// Apply the pitch if specified.
Double pitch = getActiveAttributes().getPitch();

// Adjust heading to be relative to globe or screen
if (heading != null)
{
if (AVKey.RELATIVE_TO_GLOBE.equals(this.getActiveAttributes().getHeadingReference()))
heading = dc.getView().getHeading().degrees - heading;
else
heading = -heading;
if (pitch != null) {
gl.glRotated(pitch, 1, 0, 0);
}

// Apply the heading and pitch if specified.
if (heading != null || pitch != null)
{
gl.glTranslated(xscale / 2, yscale / 2, 0);
if (pitch != null)
gl.glRotated(pitch, 1, 0, 0);
if (heading != null)
gl.glRotated(heading, 0, 0, 1);
gl.glTranslated(-xscale / 2, -yscale / 2, 0);
// Apply the heading if specified.
Double heading = getActiveAttributes().getHeading();
if (heading != null) {
// Adjust heading to be relative to globe or screen
heading = AVKey.RELATIVE_TO_GLOBE.equals(this.getActiveAttributes().getHeadingReference())
? dc.getView().getHeading().degrees - heading : -heading;
gl.glRotated(heading, 0, 0, 1);
}

// Adjust to align hot spot.
gl.glTranslated(this.dx, this.dy, 0);

// Scale the unit quad
gl.glScaled(xscale, yscale, 1);

Expand Down
1 change: 1 addition & 0 deletions src/gov/nasa/worldwindx/examples/Placemarks.java
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ public void run()
// Create and assign the placemark attributes.
PointPlacemarkAttributes attrs = new PointPlacemarkAttributes();
attrs.setImage(symbolImage);
attrs.setImageOffset(new Offset(0.5, 0.5, AVKey.FRACTION, AVKey.FRACTION));
attrs.setImageColor(new Color(1f, 1f, 1f, 1f));
attrs.setLabelOffset(new Offset(0.9d, 0.6d, AVKey.FRACTION, AVKey.FRACTION));
attrs.setScale(0.5);
Expand Down

0 comments on commit 7000d5a

Please sign in to comment.