# Parking1

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" (assimp) library. In additon to DAE and GLTF, `assimp` supports a wide variety of common 3D file formats (look 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.

    <geometrylist>
      <object enabled="true">
        <basegeometry weight="2">
          <glist><filename>nissan_march.glist</filename></glist>
        </basegeometry>
        <basegeometry weight="2">
          <glist><filename>infiniti_g35.glist</filename></glist>
        </basegeometry>
        <basegeometry weight="1">
          <glist><filename>generic_pickup.glist</filename></glist>
        </basegeometry>
        <basegeometry weight="0">
          <glist><filename>toyota_corolla.glist</filename></glist>
        </basegeometry>
        <basegeometry weight="1">
          <glist><filename>nissan_primera.glist</filename></glist>
        </basegeometry>
        <basegeometry weight="1">
          <glist><filename>nissan_fairlady.glist</filename></glist>
        </basegeometry>
        <basegeometry weight="1">
          <glist><filename>nissan_skyline.glist</filename></glist>
        </basegeometry>

        <population>
          <materialvariant>
            <variantid>500</variantid>
            <distribution>
              <matid weight="2">501</matid>
              <matid weight="1">502</matid>
              <matid weight="1">503</matid>
              <matid weight="1">504</matid>
              <matid weight="2">505</matid>
              <matid weight="2">506</matid>
              <matid weight="2">507</matid>
            </distribution>
          </materialvariant>
        </population>
        <randomfill savefile="vehicle_instances.sav">
          <anchorlist>
            <filename>spots.txt</filename>
            <fillpercent>70</fillpercent>
            <reversepercent>30</reversepercent>
            <anchor>lot</anchor>
            <seed>33932194</seed>
            <posdev><point><x>0.02</x><y>0.4</y><z>0</z></point></posdev>
            <rotdev units="degrees"><point><x>0</x><y>0</y><z>3</z></point></rotdev>
          </anchorlist>
        </randomfill>
      </object>
    </geometrylist>

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.

    <geometrylist>
      <object>
        <basegeometry>
          <obj swapyz="false">
            <filename>generic_pickup.obj</filename>
            <assign name="paint" id="500">default</assign>
            <assign id="510">windows</assign>
            <assign id="512">tires</assign>
          </obj>
        </basegeometry>
        <staticinstance/>
      </object>
    </geometrylist>

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 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:

1. Run the DIRSIG `demo_obj.sim` or `demo_fbx.sim` file

2. Load the resulting `demo.img` radiance file in the image viewer.

## Results

Figure 1. Output image using 2% scaling.