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.
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:
setupProjection(0, scope.xz, Scale_X, Scale_Z)
texture ("assets/Image_Textures/" + layerName + ".png")
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
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.
Head of 3D Technologies
Garsdale Design Limited