This Post has been really fun to research and what a sense of satisfaction I had when I found out how to do it but I apologise to all that follow as it has taken all my time up dedicated to this one issue so lets crack on as I am so excited.
So what did I want to prove?
- I wanted to prove that you could Geospatial model straight from a game engine like Unity or Armory3D
- This could be done for free without having to hard code – spreadsheet is fine as most that read this will be able to use basic spreadsheets but few will be able to go off writing Translation programs so it had to be a solution for all.
- No Proprietry Lock in to a platform.
- It also has to be able to make the Modelling program geospatial so you can tie the world together.
Where Did I start?
First I wanted to see what was possible with what I had, a FARO S70 Laserscan, FARO SCENE LT 2019 (yes its free and meshes point clouds beautifully if you have the hardware), Blender 2.8, Meshlab.
I will first say that the Laserscan I had was Geolocated as a project, If you are inserting a non geolocated laserscan, you can adjust the geolocation in the properties section. Even still, this is not a problem as I will also explain how to geolocate a standard mesh too so you don’t need a laserscan, its just this software makes it a cleaner process.
So I meshed out the laserscan in FARO SCENE and exported as OBJ,PLY,STL etc but none of the formats could show up in the viewport. With so much saying about Blender 2.8 Bugs at the moment, I just dismissed this as an option so I opened up in Meshlab and voila, it was there, a lovely Laserscan of the building. So I saved it and made a new OBJ file which was almost twice the size of the first and imported into UNITY which on completion was nowhere to be seen.
After much faffing with this and that and trying this, standing on one leg with fingers crossed and arms – anyway you get the picture, while exporting or clinching at any last notes from the net, I thought OBJ – its an old format, I wonder if I can open it in Notepad.
Sure enough it is a text file format and the first thing I recognised was that the X,Y,Z looked an aweful lot like Decimal Degree co-ordinates for the area but out of range.
Now while researching GNSS Systems I had to get familiar with different Historical systems of mapping in use and origins as well as the Technical aspects to the satellites themselves – Good Times :-), The point is that I was reminded of not looking at the world as a globe but as a flat paper map. Flat Land Maps, not Naval Charts, Used to be and often are still in a system using Cartesian Co-ordinates commonly known as Eastings and Northings.
So I went to the Ordnance Survey Site and inserted the
- X value in the Eastings Field,
- Y value in Northings Field,
- Z value in the Height Field.
BINGO exactly where the scan was Taken
So if it is here then why cant I work on it in my modelling suite, i.e. 3DS or Blender. Thats simple now, we know Eastings and Northings are in meters like Blender and 3DS so an Eastings of 583947.75m would be 583.94775KM East of the 0 point on the X axis, a little way away so of course you will see nothing.
In Blender, you can correct this easily by first Selecting the Imported Object in the Heirachy, Move the Cursor over the Viewport and Right Click. This will give you a menu where you can select ‘Set Origin’ which opens a sub menu and select ‘Set Origin To Geometry’.
You should now see the Transform Component have a huge number in X and Y but Z hopefully will be the Altitude so much smaller.
MAKE A COPY of THIS AS YOU WILL NEED TO PUT IT BACK.
OK now go into Edit Mode (push tab) and set the Local Median co-ordinates to 0 ( it will not allow Zero and will go to some smallish number). This only sets the centre of the model to 0 or in the middle ish but close enough for this as it is all relative from now on.
Go Back into object mode and hopefully your Transform component numbers have not changed, now set them to Zero. Your model should now be there.
Do your modelling and once finished, put the old Transform co-ordinates that you copied, back into the Transform Component to Re-locate the Model back into its Geolocated Space.
The link between the XYZ to Eastings and Northings is really powerful when we now import our model into a Game Engine like Unity or Armory3D as we can use a simple script to read the player or model current xyz and convert it into a Global Decimal Degree which can be linked out into all mapping systems, Smart Phones and everything Geolocatable thus creating the link between Virtual World and Real World.
This New XYZ can also become an Assets Identifier.
Ok but I have a non Geolocated model, How can I merge this into the GeoSpaced Game.
Idealy you would have GNSS Equipment Like SPECTRA SP20 GNSS Device for BIM or one of their other High Accuracy units but if you are at home, you could use a web map to derive a Rough location (still might be better than your phone) Google Maps (Left Double click Location to drop a pin, Click on the decimal degree output at the bottom pop up, Copy and paste from the left hand sidebar) or Bing Maps (Right click location, select copy below the decimal degree co-ordinates, pres CTRL + C)
Put these co-ordinates in the Transform Tool Decimal Degrees section at Ordnance Survey (If using maps, you will only get Lat and Long without a height value, set Elipsoid Height to 45.734 to pin on the ground at 0m height) which will give you an easting and Northing.
Ok This is your reference position. We can simply enter them in the Global Transform Component (Object Mode) after setting the Local Median (Edit Mode) to the location of the object that is to locate at that geolocation.
If not using Blender, then at worst case to apply your vertex points we need them in a spreadsheet for editing.
Open the OBJ file in Notepad (rightclick -> open with other apps -> select notepad)
We need to copy all lines beginning with a ‘v’ and there might be a few thousand. Each line has six values, position x,y,z and colour x,y,z(the colour is ranged from 0-1).
Select the first line and scroll to the end of the ‘v’ lines and hold shift and click at the end of the last line which will select everything inbetween.
Open your spreadsheet editor and paste. You need to chop and divide the text into seperate columns, there are lots of youtube videos on how to do this, and you can use the space to identify the place to seperate.
Once you have seperated the values into seperate cells, write a formula to add the reference easting to the first value, reference northing to the second value and reference height to the third value. Then copy cell all the way down for it to autopopulate the new figures.
Now concatenate (join) the values back into one single line of text with the spacings and colours added back in. Again lots of youtube videos on how to do this.
Copy the new data into the OBJ notepad file replacing the old ‘v’ values and save as a new OBJ. If the file extension is not available, select saveAs, type the filename followed by ‘.obj’ without the quotes.
now this obj will open in its new geolocation in eastings and northings, sorry I mean XYZ, co-ordinates.
Just to conclude that now we can write a script that tracks the xyz of anything we require to track either its movement in the virtual or even be effected by the movement of something in the real world to give a truly real time virtual simulator.
Imagine if a bridge was raised prematurely, you could not only see a visualisation of what is happening but also use AI to aleviate the problems as it can read and control the virtual easier than the Real but with full control of the Real by Proxy.
VIRTUAL WORLD IS POSSIBLE EASILY, CHEAPLY AND RELIABLY
Please Share and Like as I do not have a virtual Billboard, That will be the next big thing, Immersive Advertising – I can Hear George Carling now.