How Does CityEngine Generate Vertex Positions from OSM Data?

4388
18
06-28-2013 03:21 PM
MichaelGharbharan
New Contributor
I'm assuming CityEngine is projecting the WGS84 latitude and longitude values from the .osm file to another coordinate system.

Does anyone what coordinate system CityEngine is converting the latitude and longitude to?
Also if you know the math or have the code to perform this transformation, I'd really appreciate you sharing it with me.

Thanks.
Tags (2)
0 Kudos
18 Replies
MatthiasBuehler1
Frequent Contributor
Hi !

The lat/long values are projected to CityEngine's cartesian coordinate system, thus the high vertex coordinate values. CityEngine stores all the vertex positions in cartesian coordinates.

The projection is done with a library, but I'm not sure how, but I'm pretty sure we can not share this. I'd recommend you google how to do this if you need the code.

Let me know if this is ok or if you need more info.

Matt
0 Kudos
MichaelGharbharan
New Contributor
Thanks for your response,

Let me give you some background on what I'm trying to do. I want to use CityEngine to generate a 3D model from an OSM file then I want to import that model into Unity, parse the OSM file myself (in Unity) and do a little bit of math to position the nodes from the OSM in the correct place on the model generated from CityEngine.

However in order for me to do that, I need to know about the projection CityEngine does so I can ensure the nodes are put in the correct space.

If you cannot share CityEngine's secret recipe with me, I can think of one other solution, but I'm not sure if its possible:

Writing an exporter for CityEngine to output the node data (see image) to a file, this way I could just load the node positions from file rather than projecting them myself.

[ATTACH=CONFIG]25624[/ATTACH]

Is it possible to export the data in the image above? If so can you give me some direction?

Thanks.
0 Kudos
MatthiasBuehler1
Frequent Contributor
Something tells me you want to go in this direction .. 😉

http://forums.arcgis.com/threads/64088-Vehicle-placement-on-CityEngine-generated-streets.
0 Kudos
MichaelGharbharan
New Contributor
Something tells me you want to go in this direction .. 😉

http://forums.arcgis.com/threads/64088-Vehicle-placement-on-CityEngine-generated-streets.


That is definitely the direction I want to go in!

http://forums.arcgis.com/threads/64088-Vehicle-placement-on-CityEngine-generated-streets.?p=225535&v...

That post you made seems like it would be a great starting step for me but I have a couple of questions:

Where do I put the code for the marker creation and position reports?
What format will the data exported by the markerInstances.py script be in?

Thanks.
0 Kudos
MatthiasBuehler1
Frequent Contributor
Hi !

the marker reporting is in the CGA rule which creates the street geometries. In the example in the other thread I used the 'Modern Streets' example, which you can download.

The format to export is basically just a text list. E.g. you can write this into a text file. Since you're creating the text on your own, you can compose directly any other ascii file format. very flexible.

Makes sense ?
0 Kudos
MichaelGharbharan
New Contributor
Hello,

Thanks for all your help, I was able to generate the markers. I've exported the city as in FBX and imported it into Unity. I am now trying to spawn objects on the marker positions but the positions are off (see image below).

[ATTACH=CONFIG]25986[/ATTACH]

Referring to your post:
http://forums.arcgis.com/threads/64088-Vehicle-placement-on-CityEngine-generated-streets.?p=225246&v...

I am offsetting the marker positions using the values given from the FBX exporter (see image below)

[ATTACH=CONFIG]25985[/ATTACH]

I am subtracting the offsets from the marker position in the markerInstances.py script (see image below)

[ATTACH=CONFIG]25988[/ATTACH]

Do you have any ideas why my object placement positions are off? I've been trying to figure out the method CityEngine uses to calculate its offsets but I've been unable to recreate the same offsets.
0 Kudos
MatthiasBuehler1
Frequent Contributor
hey man,


short fix :
ignore the difference and just use the point marker geometries in Unity. Write a js or cs script to extract the data in Unity instead of CE.


long fix :
not sure what could cause this.. weird. it seems the data is also rotated.. could it be you have somehow inverted some axes, e.g. x = -123456 instead of 123456 ?

try to track this down on a very simple 1 meter wide / 10 meter long street, so you can precisely control all point marker vertices.


I've done a similar thing some time ago in Maya and it did fit spot-on.

lemme know.

matt
0 Kudos
MichaelGharbharan
New Contributor
Hello,

The exported model is indeed rotated, not sure why this is but I was able to place objects on the marker positions by writing a script in Unity which places the objects based on the marker's vertices.

Now I've got another question for you 🙂

I need a way to be able to only export the markers and the shape they are parented to. I realize my wording to describe what I want to might be a little confusing, so I have made some diagrams to try and explain:

The image below shows how the imported city appears in Unity.
[ATTACH=CONFIG]26072[/ATTACH]

The image below shows what I am trying to get imported into Unity.
[ATTACH=CONFIG]26073[/ATTACH]

Is this even possible? Please let me know if you have any thoughts.

Thanks.

EDIT: Forgot to mention, I had the thought of editing the rule file so that it only generates what I want, but I'm inexperienced with writing rule files and not sure if this is plausible.
0 Kudos
MatthiasBuehler1
Frequent Contributor
hi,

I'd add an attr :

@Range("streets", "markers")
attr exportWhat = "streets"

then on each of the leaf shapes which actually create geometry, NIL them accorsing to that new attr.

e.g. if you only want to export the streets, NIL the markers.

if you have that setup, export TWICE. once for the street geo, once for the markers.

m.
0 Kudos