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 12-04-2007, 04:22 AM   #1
bhughes
Member
 
Join Date: Nov 2007
Posts: 36
Default Rotating Icons

Hello,
I'm working on a simulation which will show an airplane flying a figure-8 flight pattern within a defined airspace. I plan on using an icon of the aircraft and moving it to the appropriate geolocation relative to time. I would like to align the aircraft icon so it is pointed in the right direction (i.e., the direction of flight). But I just can't seem to figure out how to rotate an icon (it's obviously possible, since the compass icon does it). BTW, in case someone is wondering, for the display I need it will be much better to rotate the airplane icon and not the earth. Can someone point me towards information on this?

Thank you.

P.S. I'm quite new to WWJ (not to mention java).
bhughes is offline   Reply With Quote
Old 12-04-2007, 04:36 AM
James_In_Utah
This message has been deleted by James_In_Utah. Reason: Wrong section
Old 12-04-2007, 10:45 PM   #2
patmurris
WWJ Consultant
 
patmurris's Avatar
 
Join Date: Jun 2005
Location: Saint-Paul de Vence, Alpes Maritimes, France
Posts: 3,412
Default

I dont think you can rotate an icon in the actual implementation. However, you can change its image.

Maybe you can have a set of images that have the plane pointing in a reasonable number of directions and alternate them - change the icon image source. This image set can be generated at run time from an initial icon by using j2d graphic methods and affine transforms.

Anyway, icons will only work with a vertical view.
__________________
My World Wind Java Blog & WW.net Plugins page
patmurris is offline   Reply With Quote
Old 12-04-2007, 11:42 PM   #3
toolshed
Senior Member
 
Join Date: Jun 2007
Posts: 109
Default

Quote:
Originally Posted by bhughes View Post
Hello,
I'm working on a simulation which will show an airplane flying a figure-8 flight pattern within a defined airspace. I plan on using an icon of the aircraft and moving it to the appropriate geolocation relative to time. I would like to align the aircraft icon so it is pointed in the right direction (i.e., the direction of flight). But I just can't seem to figure out how to rotate an icon (it's obviously possible, since the compass icon does it). BTW, in case someone is wondering, for the display I need it will be much better to rotate the airplane icon and not the earth. Can someone point me towards information on this?

Thank you.

P.S. I'm quite new to WWJ (not to mention java).
Here's an idea. Have a base renderer for all objects that is built on something like the Templete Design Pattern. In other words have a skeleton of an algorithm that defers some of the steps to subclasses. For example, subclass the ""draw" method of a basic renderer. This would allow bhughes to add a heading vector (or just simply use glRotate) to signify the heading of a airplane icon. You could take it a step further and subclass the "beginDraw" and "endDraw" methods as well. Thoughts?
toolshed is offline   Reply With Quote
Old 12-06-2007, 06:11 PM   #4
linnuxxy
Senior Member
 
Join Date: Nov 2007
Posts: 108
Default

I think the IconLayer and WWIcon need a lot of improvements to be useful.

A great new features would be

-the ability of rotating icons.
-the ability of making flashing icons.

And the implementation should be able to handle a large number of icons in small geographical area, should render it in a decent way even if it is viewed from hight altitudes!
linnuxxy is offline   Reply With Quote
Old 12-06-2007, 07:36 PM   #5
remleduff
Senior Member
 
Join Date: Jun 2007
Posts: 213
Default

I kind of agree that Icons/IconLayer leave a little to be desired.

Firstly, I don't think setImageSource(Object) is a great interface. The API would probably be better off with just a constructor that takes a BufferedImage, and *possibly* an overloaded one that takes a URL.

Highlighting icons isn't great, it doesn't use even the best rescaling algorithm that Java provides. Much better would be a separate "setHighlightedImage" function that allowed application specific (and higher quality) highlight.

There's no way to set an anchor point in the Icon, it's fixed at the (middlex, bottomy) point of your image. I think a better default would be centered in the image and it definitely needs to be overridable.

SelectEvent.getPickItems only returns one icon even if many are stacked on top of one another (due to the way rendering unique colors is used to choose the picked items). It would be great if it was easier to get all the picked icons for things like a UI to disambiguate mouse-clicks-- I'm planning on looking at using a real intersection test instead which I doubt will be very difficult.

Icons and Annotations both share the problem that there are some non-obvious assumptions around the rendering of OrderedRenderables, specifically they both use the same cryptic "setDepthFunc" method which has some magic constants in it and I'm not convinced works 100%.

With all these issues I list, it may sound like I'm unhappy, but nothing could be farther from the truth. I'm totally in love with how easy it is to do some amazing things with the API. I definitely should have brought these issues up earlier rather than dumping them all at once like this though.
remleduff is offline   Reply With Quote
Old 12-21-2007, 03:44 PM   #6
linnuxxy
Senior Member
 
Join Date: Nov 2007
Posts: 108
Default

I use this function for symbolizing and rotating of WWIcon

private BufferedImage getSymbol(Vehicle vehicle) {
String imagePath="/images/symbols/vobject.png";
if (vehicle.getType()!=null) {
imagePath=String.format("/images/symbols/%d.png",vehicle.getType());
}
InputStream iconStream = this.getClass().getResourceAsStream(imag ePath);

BufferedImage image = null;
try {
image = ImageIO.read(iconStream);
AffineTransform tx = new AffineTransform();
tx.rotate(Math.toRadians(vehicle.getLast Location().getHeading()), image.getWidth()/2, image.getHeight()/2);

AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR) ;
image = op.filter(image, null);
} catch (Exception e) {
e.printStackTrace();
}
return image;
}
linnuxxy is offline   Reply With Quote
Old 12-21-2007, 05:40 PM   #7
James_In_Utah
Super Member
 
James_In_Utah's Avatar
 
Join Date: Jan 2006
Location: Eden, Utah
Posts: 1,446
Default

Will the Java version of World Wind support importing KML? If so, will it also support the <heading> tag inside <IconStyle>? I use this in the .Net version and in GE to show directions of aircraft icons.
Thanks,
James
James_In_Utah is offline   Reply With Quote
Old 12-21-2007, 06:55 PM   #8
patmurris
WWJ Consultant
 
patmurris's Avatar
 
Join Date: Jun 2005
Location: Saint-Paul de Vence, Alpes Maritimes, France
Posts: 3,412
Default

There is a code contribution addressing KMLs but i dont know for the details regarding which tags are supported or when it may be incorporated.
__________________
My World Wind Java Blog & WW.net Plugins page
patmurris is offline   Reply With Quote
Old 12-21-2007, 09:07 PM   #9
linnuxxy
Senior Member
 
Join Date: Nov 2007
Posts: 108
Default

The code I posted seems to have a problem,

when I change the heading of the camera view, JWW does not rotate the icons to reflect the same direction!

how can I fix that?

Last edited by linnuxxy; 12-21-2007 at 09:10 PM.
linnuxxy is offline   Reply With Quote
Old 12-23-2007, 12:22 PM   #10
asantiago
WWJ aficionado
 
Join Date: Aug 2007
Posts: 134
Default

Hi all

if I understand well the first time I read the post, you would like to be possible rotating icons in the same way the compass rotates. Weel, I think I get it (see attached image).

The rotating code is a short peace of code to put in the IconRendered.drawIcon method. The only thing is your icons has a get-setHeading method to get the rotation angle of the icon. I've create a Rotable interface for this.

Quote:
gl.glTranslated(screenPoint.x, screenPoint.y + height / 2, 0d);
if (icon instanceof Rotable)
{
Angle heading = ((Rotable) icon).getHeading();
gl.glRotated(heading.getDegrees(), 0d, 0d, 1d);
}
gl.glTranslated(-width / 2, -height / 2, 0d);
I'll continue working on it, but please note the above code has implication with the pedestal position.

I hope to release the code for this tonight or tomorrow morning and also accompanied with a new icon class called AnnotatedIcon that allows to show an annotation pointing to the icon. The icon can represent some information and when it is selected you can show an annotation with more detailed info.

Bye.
Attached Images
File Type: jpg rotated_icons.jpg (75.6 KB, 235 views)
__________________
|---------------------------------------
| http://acuriousanimal.orggeo.net
|---------------------------------------
| http://acuriousanimal.blogspot.com
| http://theballoonproject.blogspot.com
|---------------------------------------
| _ __
| /_| ( _ _/'_ _
|( |. __)(//)//(/(/()
| _/
|---------------------------------------

Last edited by asantiago; 12-23-2007 at 12:32 PM.
asantiago 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
Plugin: My favorite Icons - Add Icons/Favorite canosso Add-ons & Scripts 26 03-02-2010 04:06 AM
Bright and dim icons caterpillar Technical Support 10 10-17-2007 07:06 PM
Overlapping Icons twf Development Help 9 06-07-2007 08:01 PM
Icons and Icon Updated Please Test! nigel_ht Developers' Corner 3 05-07-2007 08:33 PM
Rotating Icons nigel_ht Developers' Corner 3 12-29-2005 08:07 PM


All times are GMT +1. The time now is 05:18 PM.


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