I’ve been a 3d visualisation specialist for many years and yet I’m still new to real-time technology. I was curious to test the limits of Stingray with a very large scale model. Can Stingray import an InfraWorks model of the streets surrounding the Autodesk Montreal office? Let’s find out!
InfraWorks is mainly used for transportation planning and design by civil engineers. It’s a powerful tool to generate road, bridge and drainage proposals. There is also an interesting tool called Model Builder, which generates 3d models of a city (building, roads, terrain…). Stingray can be used to see an InfraWorks project
in a real-time game engine, or maybe the Model Builder capabilities could be used to generate a surrounding around an architectural project.
InfraWorks Model Builder
I’ve generated a city block around the office using the InfraWorks Model Builder. The maximum area you can generate in Model Builder is 200 km2, but I used a smaller area for testing purposes. It’s possible to do this even in InfraWork’s trial mode.
InfraWorks generates models using data from Open Street Map in a cloud service; it’s fully automated. When the model was ready, I got an email notification. The terrain’s topology was quite good, some buildings needed more detail, but overall it still gave me a good idea of the surroundings. Some cities may have more accurate results than others, it really depends on the Open Street Map data.
Then it was time to export the geometry. Since my goal was to have terrain and buildings, I turned off some layers. Open Street Map generated 3d models of all the information available in its database. Roads and railways added a lot of polys and may be a problem later in Stingray. Actually, the roads themselves don’t cause problems, it’s the sidewalks, pavement markings, barriers, etc. While it is possible to import all that geometry, whether you do or not depends on the project’s purpose.
It’s a good idea to export the 3d model in multiple files (ground and buildings) to better to manage the project. I exported two files: ground.fbx and building.fbx.
Optimization is the key
In 3ds Max, I imported the ground.fbx file first. It was useful that all the water surfaces were combined, as I could easily put them in a layer. The terrain, however, was divided in segments of 420 m x 420 m. This left me with more than 300 objects with their own materials—definitely problematic, as it’s important to have minimal objects and materials to achieve the best possible performance in a real-time game engine. Also, the mesh were quite dense. This meant I needed to attach all the segments and optimize the geometry.
My first reflex was to attach all the mesh and use the ProOptimizer modifier. I tried and it failed, there were far too many polygons to process them all at the same time. Then I tried it the other way around. I optimized them first in batches of 40-60 objects, and then attached them together using the Editable Mesh – Attach tool. That worked flawlessly!
Note: You might want to chose the "Exclude Borders" option during the optimization process, this will make a more precise mesh but on the other-hand the mesh will be heavier.
Then it was time to fix the material issue, since I couldn’t have 300 different textures for the terrain. I made a top view rendering of the entire terrain in 3ds Max and used the render as a texture. It was a big terrain so the render had to be big too, mine was 10 k x 10 k pixels. I defined the render’s output size by first selecting the top view (keyboard shortcut t), and then opening the Render Setup dialog (keyboard shortcut F10).
I saved the image in PNG file format with transparency so I could crop the image in an image editing software; I used Adobe Photoshop. Once the render image opened in Photoshop, I selected the layer transparency (Select – Load Selection, Channel Layer 0 Transparency). I cropped the image so it would fit perfectly on the terrain in 3ds Max. I also added a black layer under the terrain texture in Photoshop to avoid possible white edges in the final texture. Then I saved the image as a JPG.
Back in 3ds Max, I created a new material and used the terrain texture in the Diffuse Color slot. I applied a UVW Map on the terrain object, chose Planar and pressed Fit. The texture fit perfectly on the terrain. I then had 1 object with 1 material and a single texture, definitely more real-time friendly!
Once I had the terrain fixed up, it was time to bring in the buildings. When I imported building.fbx, there were 47 objects. This was an acceptable number, and their being separated by material was helpful for scene management. What wasn’t very helpful was all the objects being named Mesh and all the materials being named Material. Most of the materials had only a diffuse channel. Another problem was that the textures were from the Autodesk Material Library, some with special characters in their file name. Special characters such as dots aren’t supported in Stingray and result in question marks (? / missing texture).
For example, the file slate.roof.grey.jpg can’t be imported in Stingray results in something similar to the following image.
This meant that I had to rename and relink the textures. This could have been a time-consuming process, but luckily my very talented colleague Martin Ashton created a MAXScript to automate the process. I ran the script “stingray_bitmap_sanitizer.ms Click here to download“ and all the problematic texture files were renamed (“.” to “_”) and re-linked properly.
Once finished, I sent the objects to Stingray using the Live link between 3ds Max and Stingray. Generally, it’s a good idea to be selective about what is sent, to control the amount of unit in Stingray–I sent only the terrain, water and buildings.
In Stingray, I dropped each unit in the Level Viewport, selected all the units, and then set the transform coordinates to 0.0.0 to light them properly.
I then changed the sun orientation (transform - rotation) to match the terrain texture shadows. At the same time, I changed a few settings in the Shading Environment, as the default settings for the Fog and the Depth of Field component weren’t appropriate for the project scale.
Voil ! The city of Montreal in Stingray (well a part of it!).
Stay tuned for more tutorial on using real-time technologies for design vizualization.