9
2011
Latitude Longitude on 3D sphere
Testing sphere (earth), with latitude longitude positions.
(Texture is just thrown in there and sphere is rotated 197′ to get roughly correct positions,
tested atleast few cities)
Maybe could use this with GeoIP, News location plotting, Weather news plotter,
GPS data, Twitter, GoogleMaps api etc..?
*Code for the math stuff is taken from here:
http://www.actionscript.org/forums/s…957#post722957
Texture from nasa images (said to be public domain / no copyright)
Webplayer:
http://unitycoder.com/upload/demos/latlong1/
Demo location is set at London (lat 51.50015, long -0.1262362)
(mouse orbit)
Download source + webplayer scene:
latlong_1.unitypackage
20 Comments + Add Comment
Leave a comment
Recent posts
- [GreaseMonkey] Unity Forum Fixer
- UnityHub: Make Hub application background Translucent
- Customize SpriteShapeRenderer quality (but has issues)
- Editor tool: Copy selected gameobject’s names into clipboard as rows (for Excel)
- Editor tool: Replace string in selected gameobject’s names
- UnityHub: Enable built-in Login Dialog (no more browser login/logout issues!)
- Use TikTok-TTS in Unity (with WebRequest)
- Create Scene Thumbnail Image using OnSceneSaved & OnPreviewGUI
- webgl+javascript TTS
- Using Moonsharp (LUA) + Unity Webgl
- Using 3D gameobject prefabs with Unity Tilemap + NavMesh Surface
- Custom Unity Hub Project Template Preview Image/Video (using HTML+CSS in package description)
Recent Comments
- Vector3 maths for dummies! on
- UnityHub: Make Hub application background Translucent on
- UnityHub: Make Hub application background Translucent on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- [Asset Store] Point Cloud Viewer & Tools on
- [Asset Store] Point Cloud Viewer & Tools on
- ffmpeg stream raw video into Unity Texture2D on
GeographicDistance:
https://github.com/BiDuc/Oilmap-3D/blob/master/ASA/Assets/Scripts/CoordinateScripts/GeographicCoords.cs
distance:
http://codeflow.org/entries/2010/aug/27/geo-programming-with-python-and-javascript/
lat.long. distance calculation:
http://forum.unity3d.com/threads/vectrosity-fast-and-easy-line-drawing.270846/page-2#post-1822877
convert google maps lat/lng to pixel coordinates and vice versa:
https://gist.github.com/flarb/4980598
Hi, I’ve just tested your project in Unity 5 and the marker seems to be a bit off – it seems to put it in somewhere near Romania. Do you know if something has changed? I’ve been trying to get the markers to match the correct location, but am having a tough time.
Most likely the model is just wrong (its default unity sphere, with the default UV mapping which breaks at top and bottom), cant remember if I had to manually adjust the material UV starting position to match London horizontally..
Yeah, I have tried playing with the material and getting it into the right position, but no matter what, my two points (Newcastle, UK; London, UK) seem to always end up in France!
It’s driving me mad.
This is what I am using:
//Radius is 150… It is half the Scale of my sphere which is 300
private Vector3 convertSphericalToCartesian(float lat, float lon, float radius)
{
//Convert to radians first
lat = NormalizeRadian(DegreeToRadian (lat));
lon = DegreeToRadian (lon);
float x = radius * Mathf.Sin(lat) * Mathf.Cos(lon);
float z = radius * Mathf.Sin(lat) * Mathf.Sin(lon);
float y = radius * Mathf.Cos(lat);
return new Vector3(x,y,z);
}
private float DegreeToRadian(float input){
float output = 0.0f;
output = Mathf.PI * input / 180;
return output;
}
private float NormalizeRadian(float radian){
return radian – 1.570795765134f;
}
Any ideas?
tested with 4.6x and 5.1, and the sphere is different in 5.1 (texture is clearly in a different position), so that breaks the old demo at least..
Hey did you figure how to position the sphere so that it lines up correctly? or must i just make a couple of tests and get a the highest accuracy by looking? if i can get the position of the seem then it should work out.
anyway thanks for the example, at least i know in what direction to go
no, havent made further tests.. in the old version i think it was just a matter of manually rotating the sphere until most locations match, but that wont be accurate of course..
hey mGear
i finally got it right. i basically had to just give my sphere a y rotation of 180 and fix the uv mapping on it. oh and i had to convert the code to playmaker, this was a bitch to do.
anyway rock on!
How did you fix the UV mapping?
Hi, Thanks very much I tried your project and it works great. How ever in my project I want to use a cylinder instead of an sphere. I wanted to ask if you know any ways to also change the rotation of the cylinder so it always stand straight on the earth sphere.
Thanks very much
not sure if I understood, maybe image would help.. 🙂
Thanks, I was over complicating it, a simple lookAt solved my problem 🙂
Works great , Thanks buddy
Hi there, this is super useful but running your current demo in unity, the placement is not in the right place, has unity 5 broken something?
added some new info here,
http://unitycoder.com/blog/2016/03/01/latitude-longitude-position-on-3d-sphere-v2/
Thanks, you rock!!!
[…] 4)Globe asset:http://unitycoder.com/blog/2011/08/09/latitude-longitude-on-3d-sphere/ […]