World Wind Forums

Go Back   World Wind Forums > WorldWind JAVA forums > Development Help

Development Help Help for building applications or diagnosing problems with WWJ

Reply
 
Thread Tools Display Modes
Old 07-26-2012, 04:29 PM   #11
KurtZachary
Junior Member
 
Join Date: Apr 2012
Posts: 20
KurtZachary is on a distinguished road
Default the alignment is working the way you stated

I just set used .setHeading(null); and it is producing the desired results. Now I need to figure out how to make it so the image is centered on the lat/lon.
KurtZachary is offline   Reply With Quote
Old 07-26-2012, 04:45 PM   #12
KurtZachary
Junior Member
 
Join Date: Apr 2012
Posts: 20
KurtZachary is on a distinguished road
Default this is working perfectly

Thanks for the offset code, it worked perfectly!

Is there a way to turn off the functionality where the image enlarges on mouse over?

I have no idea if my uses will love it or hate it so I'm just curious if it is easy to turn on/off.
KurtZachary is offline   Reply With Quote
Old 07-26-2012, 04:50 PM   #13
tag
WWJ Technical Manager
 
Join Date: May 2007
Location: Seattle
Posts: 1,027
tag is on a distinguished road
Default

I just tried the Placemarks example, setting the heading of Placemark B to 45 and the heading reference to RELATIVE_TO_SCREEN and it worked as expected. Also works with a heading of 90.
tag is offline   Reply With Quote
Old 07-26-2012, 05:02 PM   #14
tag
WWJ Technical Manager
 
Join Date: May 2007
Location: Seattle
Posts: 1,027
tag is on a distinguished road
Default

Set the PointPlacemark's highlight attributes to be the same as its normal attributes.
tag is offline   Reply With Quote
Old 07-26-2012, 05:49 PM   #15
KurtZachary
Junior Member
 
Join Date: Apr 2012
Posts: 20
KurtZachary is on a distinguished road
Default I see, I didn't realize there were 2 attribute objects

That is very easy, thanks!
KurtZachary is offline   Reply With Quote
Old 08-06-2012, 04:30 PM   #16
incubus
Member
 
Join Date: Nov 2011
Posts: 32
incubus is on a distinguished road
Default

Hi, I know this is a bit of a late reply but I wanted to do the exact same thing and achieved it by using a custom icon renderer and using it in my IconLayer. Doing it this way allows you to still use the UserFacingIcon should you wish to keep it. See code below:


Code:
import com.sun.opengl.util.texture.TextureCoords;
import gov.nasa.worldwind.geom.Vec4;
import gov.nasa.worldwind.layers.IconLayer;
import gov.nasa.worldwind.render.DrawContext;
import gov.nasa.worldwind.render.IconRenderer;
import gov.nasa.worldwind.render.WWIcon;
import gov.nasa.worldwind.util.Logging;
import java.awt.Dimension;
import java.awt.Rectangle;
import javax.media.opengl.GL;

public class ContactLayer extends IconLayer{
    
    public ContactLayer(){
        this.iconRenderer = new CenteredIconRenderer();
    }
    
    // Code copied from gov.nasa.worldwind.render.IconRenderer with modifications
    // to the centre icon spot.
    private class CenteredIconRenderer extends IconRenderer{

        @Override
        protected Vec4 drawIcon(DrawContext dc, OrderedIcon uIcon) {
            Vec4 iconPoint = uIcon.getPoint();
            if (iconPoint == null)
            {
                String msg = Logging.getMessage("nullValue.PointIsNull");
                Logging.logger().severe(msg);

                // Record feedback data for this WWIcon if feedback is enabled.
                if (uIcon.getIcon() != null)
                    this.recordFeedback(dc, uIcon.getIcon(), null, null);

                return null;
            }

            WWIcon icon = uIcon.getIcon();
            if (dc.getView().getFrustumInModelCoordinates().getNear().distanceTo(iconPoint) < 0)
            {
                // Record feedback data for this WWIcon if feedback is enabled.
                this.recordFeedback(dc, icon, iconPoint, null);

                return null;
            }

            final Vec4 screenPoint = dc.getView().project(iconPoint);
            if (screenPoint == null)
            {
                // Record feedback data for this WWIcon if feedback is enabled.
                this.recordFeedback(dc, icon, iconPoint, null);

                return null;
            }

            double pedestalScale;
            double pedestalSpacing;
            if (this.pedestal != null)
            {
                pedestalScale = this.pedestal.getScale();
                pedestalSpacing = pedestal.getSpacingPixels();
            }
            else
            {
                pedestalScale = 0d;
                pedestalSpacing = 0d;
            }

            javax.media.opengl.GL gl = dc.getGL();

            this.setDepthFunc(dc, uIcon, screenPoint);

            gl.glMatrixMode(GL.GL_MODELVIEW);
            gl.glLoadIdentity();

            Dimension size = icon.getSize();
            double width = size != null ? size.getWidth() : icon.getImageTexture().getWidth(dc);
            double height = size != null ? size.getHeight() : icon.getImageTexture().getHeight(dc);
            //gl.glTranslated(screenPoint.x - width / 2, screenPoint.y + (pedestalScale * height) + pedestalSpacing, 0d);
            gl.glTranslated(screenPoint.x - width / 2, screenPoint.y - height / 2 + (pedestalScale * height) + pedestalSpacing, 0d);

            if (icon.isHighlighted())
            {
                double heightDelta = this.pedestal != null ? 0 : height / 2; // expand only above the pedestal
                gl.glTranslated(width / 2, heightDelta, 0);
                gl.glScaled(icon.getHighlightScale(), icon.getHighlightScale(), icon.getHighlightScale());
                gl.glTranslated(-width / 2, -heightDelta, 0);
            }

            //Rectangle rect = new Rectangle((int) (screenPoint.x - width / 2), (int) (screenPoint.y), (int) width, (int) (height + (pedestalScale * height) + pedestalSpacing));
            Rectangle rect = new Rectangle((int) (screenPoint.x - width / 2), (int) (screenPoint.y - height / 2), (int) width, (int) (height + (pedestalScale * height) + pedestalSpacing));
            
            if (dc.isPickingMode())
            {
                //If in picking mode and pick clipping is enabled, check to see if the icon is within the pick volume.
                if (this.isPickFrustumClippingEnabled() && !dc.getPickFrustums().intersectsAny(rect))
                {
                    // Record feedback data for this WWIcon if feedback is enabled.
                    this.recordFeedback(dc, icon, iconPoint, rect);

                    return screenPoint;
                }
                else
                {
                    java.awt.Color color = dc.getUniquePickColor();
                    int colorCode = color.getRGB();
                    this.pickSupport.addPickableObject(colorCode, icon, uIcon.getPosition(), false);
                    gl.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
                }
            }

            if (icon.getBackgroundTexture() != null)
                this.applyBackground(dc, icon, screenPoint, width, height, pedestalSpacing, pedestalScale);

            if (icon.getImageTexture().bind(dc))
            {
                TextureCoords texCoords = icon.getImageTexture().getTexCoords();
                gl.glScaled(width, height, 1d);
                dc.drawUnitQuad(texCoords);
            }

            if (this.pedestal != null && this.pedestal.getImageTexture() != null)
            {
                gl.glLoadIdentity();
                gl.glTranslated(screenPoint.x - (pedestalScale * (width / 2)), screenPoint.y, 0d);
                gl.glScaled(width * pedestalScale, height * pedestalScale, 1d);

                if (this.pedestal.getImageTexture().bind(dc))
                {
                    TextureCoords texCoords = this.pedestal.getImageTexture().getTexCoords();
                    dc.drawUnitQuad(texCoords);
                }
            }

            // Record feedback data for this WWIcon if feedback is enabled.
            this.recordFeedback(dc, icon, iconPoint, rect);

            return screenPoint;
        }
    }
}
John.
incubus is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ScreenAnnotation vertical alignment Anthra Development Help 2 06-26-2012 10:40 PM
Object placement and AltitudeMode GeoMaster Suggestion Box 1 09-27-2011 10:29 AM
My UserFacingIcons disappear nirenit Development Help 5 05-25-2011 10:25 PM
Efficiency with thousands of UserFacingIcons QA_2 Development Help 16 03-15-2010 04:34 PM
problem using UserFacingIcons and packaged icon images - solved nick Development Help 0 08-19-2009 03:16 AM


All times are GMT +1. The time now is 04:01 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.