Parking1
========
:source-highlighter: highlight.js

Keywords: geometry material populations 

== Summary ==
This example shows how a parking lot can be filled with cars using
a small set of base geometries (different car models) and materials
(different paints) to automatically generate a population of car
variants.  In addition, this demo also leverages some of the tools
to the position cars generation from that population within the lot
and place shopping carts between them.

== Details ==
This scene demonstrates built-in tools that can be used to distribute
geometry in a scene either in specific spots (potentially with a random
fill percentage) or based on a density map

== Important Files ==
This section highlights key files important to the simulation.

=== Vehicle GLIST File ===
There are multiple versions of the geometry in this demo. The first
uses OBJ geometry files, the second uses FBX geometry files and the
third uses a mix of OBJ, FBX, DAE and GLTF files.  The 3rd scene
featuring the mix of file formats leverages geometry import support
provided by the open-source "Asset Importer"
(https://github.com/assimp/assimp[assimp]) library.  In additon to
DAE and GLTF, `assimp` supports a wide variety of common 3D file
formats (look
https://github.com/assimp/assimp/blob/master/doc/Fileformats.md[here] for
a complete list).

These scenes are captured as a specific scene file and a specific
sub-folder that contains the geometry:

* `demo_obj.scene` and the `geometry/obj` sub-folder.
* `demo_fbx.scene` and the `geometry/fbx` sub-folder.
* `demo_assimp.scene` and the `geometry/assimp` sub-folder.

The details of how the scene is assembled (described below) are the same
for both all three variants of the scene.  The primary difference are 
paths to the source geometry.

The `geometry/xxx/spots.glist` (where `xxx` is specific to the scene
geometry variant) file populates *all* the parking spots using a
combination of random base geometry, random material variations on
that geometry and randomly populated locations in the scene.  Even
though the file describes a single `<object>`, it is responsible
for all the vehicles in the scene.

.The `geometry/obj/spots.glist` GLIST file.
[source,xml]
----
include::geometry/obj/spots.glist[]
----

The `<object>` contains a set of `<basegeometry`> elements that
each load a a unique vehicle geometry file.  The `weight` for each
base geometry is used to define the weight for that geometry.  The
weights for all geometry are summed and then normalized.

NOTE: The `toyota_corolla` geometry has a weight of `0`, which means
      it will not appear in the scene.

Each car GLIST file attributes the corresponding vehicle geometry
(described by an OBJ file). The main body for all the vehicles is 
assigned material label `500`.  The `<population>` defines how that
`500` will be randomly replaced when the object is instanced based
on a set of variant material labels and weights.  Since the same 
base label is shared across all the vehicles, this will change the
paint color for every car when it is instanced.

.The `geometry/obj/generic_pickup.glist` GLIST file.
----
include::geometry/obj/generic_pickup.glist[]
----

The final component of efficiently populating this parking lot is
the utilizing a random fill to populate the parking spot locations
defined in `spots.txt`.  Each parking spot is either populated or
not based on the `fillpercent`.  If a spot it going to get a car,
it gets a car driven by the geometry and material variant populations
in the first part of `<object>` decription. See the GLIST
http://www.dirsig.org/docs/new/glist.html#_the_anchor_list[anchor list]
documentation for more information about this setup.

  
== Setup ==
This section includes any step-by-step instructions for running and
visualizing the simulation.

To run the simulation, perform the following steps:

. Run the DIRSIG `demo_obj.sim` or `demo_fbx.sim` file
. Load the resulting `demo.img` radiance file in the image viewer.


== Results ==

.Output image using 2% scaling.
image::images/demo.png[]
