# 3D Modelling Log

Modelling and scripting using Maya, Houdini and other 3D software of the kind

# Shape Fitting 0.2.0

Shape Fitting is a simple SketchUp plugin that finds a simpler shape with fewer vertices from an input shape with many vertices. Plugin originates from one functionality of Park Generator, which was employed when the initial input region had to be mapped to a quad somehow before Grid rule can be applied to it. The quad area should match the area of the input polygon in the best possible way, and that does not necessarily mean minimal differences in areas . Rather, the quad should act as a template for the Grid rule – we should bear in mind that the ultimate goal is for the resulting park to look good. Park content is bounded (practically speaking – clipped) by the input region.

The plugin is available at the Extensions Warehouse store. Widgets are created with the SKUI library.

Currently, the plugin uses three methods to find this quad, and these are grouped into two classes below.

### Bounding Boxes Methods

AABB (Axis Aligned Bounding Box) and OBB (Oriented Bounding Box)  enclose the entire input polygon. While AABB aligned to x and y (world) coordinate axes, as the name suggests, OBB is rotated – to find the rectangle with the minimal area that contains the entire input polygon. The plugin uses GTE library to compute OBB, which implements rotating callipers algorithm [1].

Axes Corners method uses x- and y-axes as the name suggests. If OBB is chosen from the Box type parameter – axes are mapped to the local coordinates of the oriented box. Algorithm works as follows: from the centre of the polygon rays are cast to the corners of the box (‘corners of axes’) and resulting edge intersections make up the quad vertices. It is worth noting that the fitted polygon (quad) vertices lay on the boundary of the input, which (for the most time) do not coincide with those of the input polygon.

### Angle Thresholding Methods

A Naive angle thresholding method filters input vertices by an angle threshold between adjacent edges. For instance, if the dot product of the adjacent edges is less than a certain value (e.g. 0.5) then the vertex angle is sharp enough for this vertex to be classified as a corner. However, depending on the input shape, for a  given threshold value  there could be an arbitrary number of corners detected! Next method, an improvement of this one, fixes this.

Adaptive thresholding method tries to search for the optimal threshold that delivers specified number of corners (4 in a case of a quad). The algorithms takes the initial cosine range of [-1, 1],  picks a threshold somewhere in the middle, and, until the threshold produces the correct number of corners – iteratively searches in one of the subranges – either below (to get fewer corners) or above (to get more corners) the threshold. Currently, for “somewhere in the middle” the plugin picks a value exactly in the middle (e.g. 0.5 for [0, 1] range), although other picks could possibly be tried too to make convergence faster! This algorithm, however, does not terminate for every case, such as when all angles are equal (a poly-circle). To solve this, the total number of iterations is limited, and if no threshold found algorithms returns an empty polygon.

# SketchUp plugin: Disperse Components

For the lack of the available plugins (extensions) such that would randomly place (sample) objects within a given polygon I have decided to take a few days to write a plugin for SketchUp.  It uses Poisson disk sampling method as described by Bridson. Plugin uses C++ library built on the code I wrote for my Masters project.

Using the plugin is just a 2-operation process:

1. Select Component instances as objects you wish to scatter and Faces where you want those objects to be placed.
2. In SketchUp menu select Plugins -> Disperse Components, optionally entering distribution parameters, and press OK. After a short while you should see the components dispersed copies.

Not to forget the link to the mv_disperse_extension plugin (SU 2014/2015 SU for windows only currently)!

NOTE: currently in alpha stage so might not work as expected.

# Tower Factory

I have started working on a tower factory script. However I found reimplementing standard procedural modelling functionality. The next step is to employ existing framework or other code.

tower_factory

# Experiment with City Streets

Experiment with distribution of varying building heights along the street. Real life streets do not simply have uniform random building heights, but height variance between adjacent buildings is lower than those between any two random buildings along the street.

street scripts

# Modelling a Pipe Junction

This is one of my first Python scripts in Maya. The bolt count as well as dimensions of the elements of the pipework can be changed parametrically.

pipes1.py