Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by xPoposx · Jun 06, 2016 at 01:38 PM · unity 5blenderandroidplugingpsgis

How to georeference model in Unity3d?

Hello everyone, I wonder if there is a possibility to assign GPS coordinates to a 3D model (.fpx), because, in part of my project, I have a shp file in which I have GIS data and to import file into Unity3d I had to go through the blender to convert the shapefile to .fpx model, but by doing this, I lose information about GPS coordinates. Would you have any ideas for me ?, any suggestion will be welcome.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by rich2020 · Sep 06, 2016 at 10:43 AM

Hi, I don't know what it is that you are trying to do, so what I'm about to say may not be relevant and for that, I apologise.

Anyway, I am looking at mapping objects with lat and lon coordinates to the surface of a sphere. I took the coordinates from various places around the world from this site (http://www.latlong.net/) so that I could place the objects and see if their positions matched with the texture of the sphere (earth texture).

Note: Unity mesh is not suitable for this... you must get a mesh from blender with the UVs or download one from the web. I used this one: http://tf3dm.com/3d-model/planet-earth-99065.html.

Import the mesh into Unity, and download a texture: http://visibleearth.nasa.gov/view_cat.php?categoryID=1484 I used this one: http://eoimages.gsfc.nasa.gov/images/imagerecords/73000/73909/world.topo.bathy.200412.3x5400x2700.png

To map from Polar (lat lon) coordinates to Cartesian (xyz), you can use this function:

  private Vector3 PolarToCartesian(LatLon polar, float radius)
     {
         var latitude = DegreeToRadian(polar.Latitude);
         var longitude = DegreeToRadian(polar.Longitude);
 
         latitude = 1.570795765134f - latitude; // subtract 90 degrees (in radians)
 
         return new Vector3
         {
             x = (radius)*Mathf.Sin(latitude)*Mathf.Cos(longitude),
             y = (radius)*Mathf.Cos(latitude),
             z = (radius)*Mathf.Sin(latitude)*Mathf.Sin(longitude)
         };
     }

Radius is the radius of the sphere onto which I map the objects.

LatLon is just...

 public class LatLon
 {
     public float Latitude { get; set; }
     public float Longitude { get; set; }
 }

and you need to convert your degrees to Radians:

   private float DegreeToRadian(float input)
     {
         return Mathf.PI * input / 180;
     }

So, for example, you have a sphere with radius 10 and you want to place a game object at based on the coordinates of London: 51.500083, -0.126182.

You can create a new game object like such:

  GameObject item = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
  Vector3 itemPosition = (PolarToCartesian(new LatLon {Latitude = lat,Longitude=  lon},RadiusOfParentSphere));
  item.transform.Translate(itemPosition );
  item.gameObject.GetComponent<Renderer>().material.color = color;

Everything here is based off the fantastic work done by mgear: http://unitycoder.com/blog/2016/03/01/latitude-longitude-position-on-3d-sphere-v2

Note: you may need to rotate your sphere a bit to get the mapped object to align with the texture.

Hope this helps!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to georeference model in Unity3d? 1 Answer

Do I have to create the texture atlas in Unity or Blender? 0 Answers

How to load android app when the button clicked in unity scene? 4 Answers

Imported Blender Animations not Working 2 Answers

Unity Ads can not show more than 1 time after install game 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges