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 05-22-2007, 07:27 PM   #1
patmurris
WWJ Consultant
 
patmurris's Avatar
 
Join Date: Jun 2005
Location: Saint-Paul de Vence, Alpes Maritimes, France
Posts: 3,412
Question Adding the Sky Gradient to WWJ

Following on my first try at a renderable layer for WWJ, i'm in the process of porting the Sky Gradient code too... but am having some kind of 'reference center' problem (not seen in the screenshot though).



The code renders a sphere portion centered on the eye (camera) so that it intersect the globe exactly at the horizon. It is constructed at the origine, rotated to account for the camera position latitude and longitude, and then translated toward the camera.

This code worked in WW and WW2DPlusOne and it works too in WWJ except the 'sky' sphere position seems to be 'shifted' by some amount and doesnt render in the right position. It gets better when the camera comes close to the ground.

I'm wrondering if there is some sort of 'floating reference center' that should be accounted for at some point ? tag ?

Note: i'm expecting some problems with the ellipsoidal globe since the sky geometry is a regular sphere here. I will deal with it after it falls in the right place first.
__________________
My World Wind Java Blog & WW.net Plugins page

Last edited by patmurris; 05-22-2007 at 08:34 PM.
patmurris is offline   Reply With Quote
Old 05-22-2007, 08:24 PM   #2
fabrizio.giudici
Senior Member
 
Join Date: May 2007
Location: Milan, Genoa (Italy)
Posts: 112
Default

First of all, thank you for your posts! Using the previous one I was able to understand a lot about how to add "things" to the scenario.

I'm experiencing too some positioning problems. I'm exercising by writing a layer that draw parallels and meridians. I just modified your code and replaced the stars with a mesh. Now I managed to render a spherical grid, but:

1. the sphere is not centered with the Earth;
2. I had to use equatorialRadius() * 1.5 to roughly match the Earth radius

Now I'll try to attach a screenshot.
__________________
--
Fabrizio Giudici, Ph.D. - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
weblogs.java.net/blog/fabriziogiudici - www.tidalwave.it/blog
Fabrizio.Giudici@tidalwave.it - mobile: +39 348.150.6941

Last edited by fabrizio.giudici; 05-22-2007 at 08:28 PM.
fabrizio.giudici is offline   Reply With Quote
Old 05-22-2007, 08:28 PM   #3
fabrizio.giudici
Senior Member
 
Join Date: May 2007
Location: Milan, Genoa (Italy)
Posts: 112
Default

Here it is:

__________________
--
Fabrizio Giudici, Ph.D. - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
weblogs.java.net/blog/fabriziogiudici - www.tidalwave.it/blog
Fabrizio.Giudici@tidalwave.it - mobile: +39 348.150.6941
fabrizio.giudici is offline   Reply With Quote
Old 05-22-2007, 08:31 PM   #4
patmurris
WWJ Consultant
 
patmurris's Avatar
 
Join Date: Jun 2005
Location: Saint-Paul de Vence, Alpes Maritimes, France
Posts: 3,412
Default

I'm glad you could get started with the StarsLayer code
Does your grid position shift when the camera moves or tilt ?
__________________
My World Wind Java Blog & WW.net Plugins page

Last edited by patmurris; 05-22-2007 at 08:35 PM.
patmurris is offline   Reply With Quote
Old 05-22-2007, 08:42 PM   #5
fabrizio.giudici
Senior Member
 
Join Date: May 2007
Location: Milan, Genoa (Italy)
Posts: 112
Default

Quote:
Originally Posted by patmurris View Post
I'm glad you could get started with the StarsLayer code
Does your grid position shift when the camera moves or tilt ?
I don't know. Indeed it was my very first impression, but then you made me discover that its shifted. So it could be a perspective thing. Now I'll try to manually recenter it and let's see.
__________________
--
Fabrizio Giudici, Ph.D. - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
weblogs.java.net/blog/fabriziogiudici - www.tidalwave.it/blog
Fabrizio.Giudici@tidalwave.it - mobile: +39 348.150.6941
fabrizio.giudici is offline   Reply With Quote
Old 05-22-2007, 10:17 PM   #6
fabrizio.giudici
Senior Member
 
Join Date: May 2007
Location: Milan, Genoa (Italy)
Posts: 112
Default

I've found this method:

Code:
Point pos = dc.getGlobe().computePointFromPosition(Angle.fromDegreesLatitude(lat), Angle.fromDegreesLongitude(lon), h);
which centers correctly the stuff. Strangely enough, I had to set h = 3400000 to fit the Earth size - I expected 0 if it referred to the ASL, or 6349etc if to the center of the planet.

But there are problems still. Rotating the Earth, the meridians "slide" over the terrain ; if I tilt the view by means of shift+up/down, the grid completely detaches from the Earth
__________________
--
Fabrizio Giudici, Ph.D. - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
weblogs.java.net/blog/fabriziogiudici - www.tidalwave.it/blog
Fabrizio.Giudici@tidalwave.it - mobile: +39 348.150.6941
fabrizio.giudici is offline   Reply With Quote
Old 05-22-2007, 11:11 PM   #7
patmurris
WWJ Consultant
 
patmurris's Avatar
 
Join Date: Jun 2005
Location: Saint-Paul de Vence, Alpes Maritimes, France
Posts: 3,412
Default

Quote:
Originally Posted by fabrizio.giudici View Post
Rotating the Earth, the meridians "slide" over the terrain ; if I tilt the view by means of shift+up/down, the grid completely detaches from the Earth
thats what i was refering to by 'floating reference center'...
We need tag advise here...
__________________
My World Wind Java Blog & WW.net Plugins page
patmurris is offline   Reply With Quote
Old 05-28-2007, 09:15 PM   #8
patmurris
WWJ Consultant
 
patmurris's Avatar
 
Join Date: Jun 2005
Location: Saint-Paul de Vence, Alpes Maritimes, France
Posts: 3,412
Default

Check the Polyline class in geom. It draw GL lines according to points positions (lat/lon/elevation). Cartesian corrdinates are computed with

Code:
dc.getGlobe().computePointFromPosition(p.getLatitude(), 
    p.getLongitude(), p.getElevation());
It computes a local reference center that is substracted from all vertices coordinates when building the geometry and then is 'pushed' during rendering :

Code:
dc.getView().pushReferenceCenter(dc, this.referenceCenter);
__________________
My World Wind Java Blog & WW.net Plugins page
patmurris is offline   Reply With Quote
Old 06-01-2007, 12:36 AM   #9
tag
WWJ Technical Manager
 
Join Date: May 2007
Location: Seattle
Posts: 459
Default

Please post your graticule code and we'll try to help.

In order to achieve precision over great distances, most geometry is calculated relative to a local origin. But code that doesn't need to worry about very fine precision doesn't need to concern itself with that. At least we thought we designed it that way.

A caution: A graticule is a lot more than lines around the globe. If you simply use lines some distance above the surface, the lines shift relative to the ground as you move. For me, the equator should touch the same ground no matter how I view it. Lines also pierce the terrain unless they're so far off the surface as to miss Mt. Everest, or they follow the terrain, which we implemented but decided was still unacceptable. We know what to do; we just haven't done it yet.
tag is offline   Reply With Quote
Old 06-01-2007, 05:31 AM   #10
patmurris
WWJ Consultant
 
patmurris's Avatar
 
Join Date: Jun 2005
Location: Saint-Paul de Vence, Alpes Maritimes, France
Posts: 3,412
Default

Here is my actual version of the sky gradient (zip 3k).
I guess the way i compute cartesian coordinates and 'move' the geometry before drawing has something wrong. Maybe i dont use the right values from the current view... see comments in the source.

If you can have a look. Thanks.
__________________
My World Wind Java Blog & WW.net Plugins page
patmurris 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
WWJ Early Access Release 0.2.0 now available tag WWJ Release Announcements 48 09-19-2007 09:52 PM
Adding a star background layer to WWJ patmurris Development Help 1 05-20-2007 11:18 PM
Add elevation color gradient to terrain mapped textures. HalOlson Developers' Corner 3 04-10-2007 06:26 PM
Partial sky globe? Help Unregistered Technical Support 2 06-04-2006 04:35 PM
Sky Gradient plug-in patmurris Add-ons & Scripts 4 05-12-2006 05:53 AM


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


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