Initially intended to create only some greeble-like structures to populate the scene and make simple geometry looking more complex, QTown grew with the idea to also be able to make the shapes look more like buildings. The most noted missing feature was the lack of proper texture coordinates, which seemed like a much too challenging task at the time.
Eventually I came up with a solution to this problem and this was the starting point to re-work some features for the new version. This time the script is heading further away from the greeble idea but evolving to be a tool for building city landscapes, skylines and everything in between.
Some of the new features are:
- automatically generated uv coordinates, organized in different uv sets for independent tiling
- every building is created as a separate structure with the option to keep it this way, to be able to move the buildings later for a more custom placement
- better performance, as the used memory is automatically released after the building process (can be turned off), because building hundreds of houses with uv mapping can be quite heavy on the memory
- included shader generation and texture linking for ready to render scenes
- city districts (only available with Maya 2012 and up) to produce a larger variety of house placements and easier assignment of different structures
- build-in presets with the ability to save custom presets
- all non-preset functions are stored in the user preferences
- editable file node names prior shader setup
- no limit to planar surfaces anymore. Detailed base geometry featuring hills and valleys (not too steep though) are considered valid. The placement of the buildings is based on the lowest bounding box extension of each polygon and makes building on landscapes much easier.
I also took out some unnecessary features, such as the curved option to work with curved surfaces, as I found that I hardly ever used this functionality.
In order to get started with QTown I prepared a demo which shows all the features as well as the general workflow for building your own cities.
Just copy the script and the presets text file to any script directory that is accessed via maya. Run the script by executing “icQTown” (without quotes) in the script editor. You may as well build a shelf button with the supplied icon (which should go to the icons directory in the maya preferences folder).
All parameters are setup with tooltips. Just move your mouse over the label of a parameter and wait for the description to pop-up.
Create Dropout Locator: Places randomly up to four locators on the faces that are skipped in the building process due to the Dropout percentage. These locators can be later used to mark the positioning for custom objects such as trees. The locators are just assigned a random position with the rotation and scale left at their defaults. Since the use for the dropout locators can be widely spread, the randomization for the rotation and scale is left to the user.
Creates mapping coordinates for each building during the construction process. Disable this option when you are testing various values and settings, as the construction process is a lot faster without UV creation.
Select the shader you want to use for your buildings. Mental Ray and VRay materials are only available when the plugins are loaded.
Creates all needed shaders based on the shader selection. The material names are drawn from the presets file that comes with the script. If you want the script to use different names as the ones that are supplied you have to edit this file and change the name between <filetex> and </filetex>.
Defines the path the script uses to link the file texture nodes. The default is the projects sourceimages directory. You can also set an alternative path here if the file textures are in a different location.
This adjusts the tiling of all textures and can be set interactively after the script has been run for easier adjusting of the tiling. If you need to only adjust certain file nodes you still have to do it through the common workflow.
Defines which file type the textures are. This is necessary to generate the correct name for the file texture nodes.
Add sRGB Correction:
This option places a gamma node between the file texture and the shader, set to 0.454 to allow for a proper linear workflow. When the VRay material is selected, the only the VRay gamma attribute is added to the file texture node.
Create File Textures:
Creates and connects the file textures to the existent shaders. The file texture nodes have to be existent in the scene if you want to enable the automatic texturing of the buildings, as the uv set assignment is dependent on these nodes.
Select any preset to adjust the parameters accordingly. You can also save your own presets, that are then stored along with the default ones in the presets file. The first presets are designed to work with the planar mesh function, the districts presets are optimized for the district based geometry. All values and the achieved results depend on the size of the base mesh.
This allows for selecting multiple base meshes to apply the same settings to.
Replace Dropout Locator With Selection:
Takes the position of each dropout locator and replaces it with a copy of the currently selected object. No randomization is applied during this process.
Flush Cache After Build:
On by default, this option ensures that the used memory for the building process is cleared after each construct sequence. This clears the undo queue. If you need to undo your building action simply delete your generated geometry.
Manual option to clear the memory if the automatic cache flushing is disabled.
Remove Progress Bar:
Emergency function. If the script encounters an error during the construction the progress bar will be still visible. This removes the progress bar, eliminating the need of restarting Maya.
Tools (only available with Maya 2012 and later)
Generates some random base structure for creating differently oriented and randomly shaped base meshes. If the result doesn't suit your needs, undo the action and create a new layout. No result matches any other.
Create District Geometry:
Takes the result from the above step and uses it to generate the base meshes. If the contained polySplit function produces an error, simply delete the source plane (the large plane that hasn't been cut properly). The result should be still usable.
Select the district group from the previous step and run this function to create an array of nine groups which are randomly rotated to cover a larger area.
Randomize Vertices On Selection:
Takes the selected mesh and offsets the vertices slightly to build a base mesh that results in a more scattered looking distribution of buildings.
Have fun using the script!
Also, please remember that QTown is a free script and that quite some time has gone into the development. It's not perfect, regarding the aspect that is lacks detail for any close-ups. These requests have been made in the past but i have no intention in including more detailed geometry such as windows, doors and other accessories. This is also true for the lack of any streets. This might change for future versions but is not planned at the current state. Yet, the first version of the script didn't even contain textures and here we are ;)
As a last note I would like to encourage you to drop me a note when you have found this script useful for any production or did some stunning work with it. Thanks.
Introduction to integrating mel scripts in maya