CityGenerator v0.80523
----------------------------------------------------------------------
by The_sLideR :: paoloemilioselva@gmail.com :: slidertime.blogspot.com
----------------------------------------------------------------------

###########################################
#           PACKAGE CONTENT               #
###########################################

+---------+
| BITMAPS |
+---------+
a folder with the thumbnails for the UNITS(objs)

+--------+
| IMAGES |
+--------+
Sample city map with elevation map

+-----------+
| MAXSCRIPT |
+-----------+
3dsmax scene with original OBJs to export and a MAXScript file to export all the objects in the scene

+------+
| OBJS |
+------+
The UNITS files

+---------+
| SCRIPTS |
+---------+
>> sliUtils.js
A scripted plugin for XSI with some usefull functions

>> CreateBuilding.dll
BuildingGenerator plugin for XSI

>> getBlobs.dll
BlobDetection plugin for XSI

+----------------------------+
| CITYGENERATOR_INTERFACE.JS |
+----------------------------+
The interface to use the CityGenerator (BuildingsGenerator + blobDetection).

+------------+
| README.TXT |
+------------+
This file

################################
#           INSTALL            #
################################
Create a folder named "builder" into your Softimage-users folder to have a path like
"C:\users\yourusername\Softimage\Softimage-version\builder"
Extract all the package content into this folder to have a path for the citygenerator_interface script file like this:
"C:\users\yourusername\Softimage\Softimage-version\builder\citygenerator_interface.js"

This is the final folder structure for builder:
"C:\users\yourusername\Softimage\Softimage-version\builder\bitmaps"
"C:\users\yourusername\Softimage\Softimage-version\builder\images"
"C:\users\yourusername\Softimage\Softimage-version\builder\maxscripts"
"C:\users\yourusername\Softimage\Softimage-version\builder\objs"
"C:\users\yourusername\Softimage\Softimage-version\builder\scripts"
"C:\users\yourusername\Softimage\Softimage-version\builder\citygenerator_interface.js"
"C:\users\yourusername\Softimage\Softimage-version\builder\readme.txt"


#########################################
#           HOW TO USE IT               #
#########################################

1. Open XSI and load the citygenerator_interface.js in a script editor then run it.

2. Choose an image (sample image in IMAGES folder).
Note: image should be at 320x240 pixels in BMP format

3. If an elevation map exists, check "with elevation map" checkbox.
Note: take a look at the city map example in the images folder

4. Choose the color to track in RGB or LUMINANCE mode

5. Click on PREVIEW to see the generated blobs-detected image

6. change the "min blob size" if you want to remove the smaller blobs

7. choose your "max units" values. A unit is the smaller part of a building (a window or a door, anyway an OBJ), and the "max units" per width and length is the max number of units per 320pixel (width) or 240pixel(height or lenght). It means that if you choose a value of 320 for "max units per width" you have a pixel per unit, so if a blob has a dimension of 100x80, the assigned building has 100units (windows) x 80units (windows) per floor.

8. take a look at the preview in the output box on the right. if it sounds good go to 9 otherwise change the values and click again on the preview button.

9. Choose a building-root name for all the buildings with the detected blobs

10. choose a unit-type
Note: 1,2 and 3 are faster then the fourth type, that could be very slow

11. click on creation button and wait...

GENERAL NOTES: the interface is very rough, I'm sorry about it, but I'm working on ;)

Take a look at the video for more info:
http://slidertime.blogspot.com/2008/05/city-generator-blobdetection.html

#########################################
#           BLOB DETECTION              #
#########################################

This plugin add a command to XSI: getBlobs
with some arguments:
- filepath: complete path for the image file (string)
- imagename: imagefile without BMP extension (string)
- minblobsize: min blob size (int)
- useRGB: to change between RGB or LUMINANCE mode (RGB=true, LUMINANCE=false) (boolean)
- REDchannel: RED channel value for the color to detect in RGB mode (float)
- GREENchannel: GREEN channel value for the color to detect in RGB mode (float)
- BLUEchannel: BLUE channel value for the color to detect in RGB mode (float)
- REDthreshold: threashold value for RED channel (float)
- GREENthreshold: threshold value for GREEN channel (float)
- BLUEthreshold: threshold value for BLUE channel (float)
- LUMINANCEvalue: LUMINANCE value (auto-detected when choose a color by a three-channel mix balanced with difference weight for each channel) (float)
- LUMINANCEthreshold: threashold value for the LUMINANCE (float)
useElevationMap: true or false to use elevation or not (boolean)

This function returns a string with all blobs separated by a # and each blob values separated by a comma with this order: blobnum,xcenterpos,ycenterpos,dimx,dimy,elevation

example: track RED color (R=1, G=0, B=0) on an image in "C:\\myimages" named "myimage.bmp" with a minblobsize of 20pixels (min amount of pixels in a blob to be detected) without an elevation map (we don't have an image named "myimage_elevation.bmp" in grey-level, so all the elevations will be 1) using RGB (we want to track the RED color) without thresholds per channel (we want to detect exaclty the RGB values of 1,0,0).

var myblobs = getBlobs("C:\\myimages", "myimage", 20, true, 1,0,0, 0,0,0, 0,0, false);
logmessage(myblobs); // to print the output to console

if "myimage.bmp" is an image with two red squares on a black or different-to-red color for the background, the output of this calling will be:

0,X0,Y0,DX0,DY0,1#1,X1,Y1,DX1,DY1,1#

where X0 and Y0 are the coords for the firt blob and X1 and Y1 are the coords for the second blob, and DX0 and DY0 are the dimension of the first blob and DX1 and DY1 are the dimension of the second blob. Both of the two blobs has the elevation to 1 because we didn't use an elevation map.

#########################################
#         BUILDINGS GENERATOR           #
#########################################

This plugin add a command to XSI to create a building: CreateBuilding
with these arguments:
- name: the building name (string)
- floors: how many floors for this building (int)
- unitswidth: how many units per width (int)
- unitslength: how many units per length (int)
- type: unit-type. actually I made 4 different units: 01, 02, 03 and 04, and each unit has to have a BMP file (ex: 01.bmp), and differents OBJ files per different building-parts like as: angle01, angleroof01, floor01, floor01close, ground01, ground01close, ground01door and roof01. Take a look into OBJS folder. (string)
- facewithentrance: which is the face of building with the entrance (a,B,C,D)
- entranceposition: where to put the entrance on the selected face (0=left,1=center,2=right,3=random) (int)

so, if we want to create a building named "Vittoriano" with 5 floors and 10units(windows) on the width and 8units(windows) on the length, with the unit-type 02 and the entrance on left side of the face A (front). we have to write:

CreateBuilding("Vittoriano", 5, 10, 8, "01", "D", 0);

There are also 8 more arguments to change windows per face, balcony per face, and other stuff, not yet used in this version.
These are used in the buildings stand alone generator (http://slidertime.blogspot.com/2008/05/buildings-generator-v10-output-video.html)

###########################
#       CONCLUSION        #
###########################

You can use this tool without restrictions, just send me an email with some feedbacks to make this tool as perfect as possible.
You can change the interface as your pleasure.
If you want to change the units, you can add others by changing the interface and creating other OBJS with the 3dsmax scene base dimension.
You can start from the type 01 and add stuff on that type, for example.

Please, send me an email with your feedback at paoloemilioselva@gmail.com.

Thanks

----------------------------------------------------------------------
by The_sLideR :: paoloemilioselva@gmail.com :: slidertime.blogspot.com
----------------------------------------------------------------------
