CityEngine to FBX Co-ordinate translation

6883
2
12-15-2014 01:10 PM
JakeBarter
New Contributor

Hi,

I am a student working on a game as a college project. I have created a Cityengine model from UK mapping data using the 27700 co-ordinate system. This has then been imported into the Unity game engine using FBX export.

Can you tell me how I can convert co-ordinates to/from 27700/Unity? I am not sure how CityEngine does this as I guess the shapefile imports are converted into an internal cartesian format.

My goal is to write a function that can take a Unity x/y/z and convert to EPSG:27700 and visa versa.

Thanks for any help you can offer. And thanks to ESRI for the student license.

Tags (1)
0 Kudos
2 Replies
BrooksPatrick
Esri Contributor

Hi Jake,

CityEngine (as your I’m sure aware) exports to many different 3D formats that are compatible with Unity3D. This would best be served with the FBX format however both OBJ and DAE (Collada) will also import directly to Unity3D. There is a distinct difference between CityEngine and Unity 3D file format interoperability and the implementation of the SDK inside of Unity to apply CGA rules.

Some key points to remember when going from CityEngine to Unity :

·        Real-world Terrain / Imagery needs to be tiled for highest resolution 4000dpi max resolution in Unity.

·        Unity recognizes files in centimeters but in CityEngine we use meters. Once the files are imported to Unity, the scale factor on the FBX can be changed before adding it to the scene.

·        Keep X,Y, Z center values the same on export in order to have all exported layers with the same spatial reference. This can also be set to center on your selected model in CityEngine

·        Create doorways in CGA Rule in order to apply collision mesh to only the outside of the building, this will allow entry to the building.

·        A slight 10cm offset might be needed in order to reduce the shape clash between street polygons and the terrain mesh.

·        If LOD (level of detail) is set up in a rule then separate LODs can be exported and then merged into an LOD group in Unity. This will allow control over the detail as it relates to player location.

·        In order to export all models (regardless of layers) as one FBX file from CityEngine, it will be important to set up the naming scheme inside the rule itself. This highlighted example from below will then name all corresponding generated models correctly in Unity when the “merge meshes by material” is selected on export from CityEngine. In the case below we were able to string together object attributes which could be anything.

CityEngine rule snippet:

Texture -->

      setupProjection(0, scope.xz, Scale_X, Scale_Z)

      texture ("assets/Image_Textures/" + layerName + ".png")

      projectUV (0)

      rotateUV (0, Rotate_Angle)

      ....

      set(material.name, layerName + "_" + "string" + moreattributes)

     

A good FBX tutorial can be found here as well: How to Import CityEngine Scene into Unity3D Tutorial | 3Decide

MatthiasBuehler
Regular Contributor

Hi Jake,

The difference between polar (georeferenced) and cartesian coordinates are basically a huge offset in the XZ plane. CityEngine stores all georeferenced data in cartesian coordinates, with high precision.

Usually, going from CityEngine to Unity, it's a one way process and there's no need to go back to CityEngine with data from Unity. So going that way, what you need is to export with the 'center near the origin' button in the export settings. This will calculate the offset so all geometries are nicely placed near the origin. I usually round this value to a precise number I can remember.

So importing something back to a georeferenced position is basically moving the thing by negative this offset.

I hope that makes sense.

Let me know if there's more questions.

Matt

Matthias Buehler

Head of 3D Technologies

twitter: @MattB3D

----------------------------------------

Garsdale Design Limited

matthias.buehler@garsdaledesign.co.uk

www.garsdaledesign.co.uk

0 Kudos