Keywords: bundles, sources
Summary
In this night scenario, a "suspect" car is stationary in a parking lot and a police car approaches (with headlights and spinning lights) and stops. This demo utilizes the "bundled object" approach that allows objects to be encapsulated into folders that contain all geometry, material properties and maps (material, texture, etc.).
Related Materials
The following demos, manuals and tutorials can provide additional information about the topics at the focus of this demo:
-
Related Demos
-
The BundledObject1 demo
-
-
Related Manuals
-
The GLIST file manual
-
The Generic Motion model manual
-
The Flexible Motion model manual
-
The User-Defined Sources manual
-
-
Related Tutorials
-
The Bundling Objects tutorial
-
Details
The focus of this demo is to show that bundled objects can also contain user-defined sources and those sources can have dynamic motion localized to the object. In this case, the "police" car has a pair of headlights and a spinning blue/red "gumball" light on the roof. Since these lights are part of the bundle, they automatically move with the bundle when a motion model is applied to it.
This setup will outline how the sources are configured in the bundled geometry and demonstrate how those sources move with the bundle in the scene.
Important Files
This section highlights key files important to the simulation.
Scene Geometry
This scene is composed from three bundles, which are located in the
geometry/bundles
subfolder:
-
The parking lot,
-
The "suspect" car, and
-
The "police" car.
The Parking Lot Bundle
The parking lot bundle uses a simple 1 x 1 meter OBJ "panel" that is scaled
to about 45 x 30 meters. The material file includes a material map to
define asphalt vs. parking lines and texture within the asphalt. Below is
the top-level GLIST file for this bundle (see
geometry/bundles/parking_lot/parking_lot.glist
).
<geometrylist> <object search_paths="local"> <localmaterials>parking_lot.mat</localmaterials> <basegeometry> <obj swapyz="false"> <filename>1x1.obj</filename> <assign id="1">panel</assign> </obj> </basegeometry> <staticinstance> <scale> <cartesiantriple><x>44.65</x><y>30.14</y><z>1.0</z></cartesiantriple> </scale> </staticinstance> </object> </geometrylist>
The Suspect Car Bundle
The "suspect car" bundle (see geometry/bundles/suspect_car/suspect_car.glist
)
imports a Nissan Fairlady OBJ file and then uses the GLIST <assign>
mechanism to associate DIRSIG materials with the materials in the
OBJ (via the usemtl
). Using our preferred method the car OBJ is
centered in XY about the local origin to make inserting it into the
scene easier. This car does not have headlights but it does have
an interior dome light. That dome light is modeled as an additional
<object>
using the
GDB method
to geometrically describe the source location and direction. The
GDB source (see geometry/bundles/suspect_car/dome_light.gdb
) has
an explicitly defined normal that points the source down (Z = -1)
and it is statically placed inside the car by an instance that adds
1.3
meters of +Z translation to position it just below the interior
roof line.
<geometrylist> <object search_paths="local"> <localmaterials>suspect_car.mat</localmaterials> <basegeometry> <obj swapyz="false"> <filename>nissan_fairlady.obj</filename> <assign name="paint" id="504">default</assign> <assign name="paint" id="504">body-color</assign> <assign id="510">glass2</assign> <assign id="511">metal3</assign> <assign id="511">metal</assign> <assign id="512">Black</assign> <assign id="512">tire</assign> <assign id="513">leather</assign> <assign id="514">plt1</assign> </obj> </basegeometry> <staticinstance/> </object> <object search_paths="local"> <localmaterials>suspect_car.mat</localmaterials> <basegeometry> <gdb><filename>dome_light.gdb</filename></gdb> </basegeometry> <staticinstance> <translation> <point><x>0</x><y>0</y><z>1.3</z></point> </translation> </staticinstance> </object> </geometrylist>
Important
|
Note that the GLIST method for describing a source geometrically is preferred over the GDB method used in this case. |
The Police Car Bundle
The "police car" bundle (see geometry/bundles/police_car/police_car.glist)
imports a Nissan March OBJ file and then uses the GLIST `<assign>
mechanism to associate DIRSIG materials with the materials in the
OBJ (via the usemtl
). This vehicle is then bundled with multiple
sources.
The 2nd <object>
in the GLIST is the point source used for the
headlights. This source is described in the GLIST using a single
<basesource>
that is instanced twice — once for the driver side
and once for the passenger side. The source direction vector is
defined to point along the +Y axis (0,1,0), which corresponds to
the forward direction of an object in DIRSIG. The instances for
the two headlights include 0.66
meter +/- X translation,
1.6
meter +Y translation, and 0.7
meter +Z translation for
the left and right (driver and passenger) locations.
- How were these translations determined?
-
There is not an easy way to find the 3D location of a single vertex or facet in most 3D content creation tools. Instead they were estimated from the bounds of the car geometry. These bounds can be easily extracted using the DIRSIG
object_tool
(as shown below). The various XYZ translations were chosen to make sure the point sources were in front (+Y) of the car at about 80% of the width and 40% of the height.
$ object_tool geometry/bundles/police_car/nissan_march.obj
Reading input OBJ file ...
Reading in geometry file: geometry/bundles/police_car/nissan_march.obj
Part count = 183
Facet count = 36273
Vertex count = 21701
Geometry summary tool:
Triangle count = 36273
Vertex count = 21701
Group Count = 183
Minimum = -0.930, -1.847, 0.000
Mid = 0.000, 0.000, 0.910
Maximum = 0.930, 1.847, 1.820
Size = 1.861 x 3.694 x 1.820 [m]
The 3rd and 4th <object>
elements in the GLIST define the spinning
blue and red "gumball" light on the roof:
-
The 3rd object describes a source with material
blue_light
and a direction vector of (-1,0,0) and -
The 4th object describes a source with material
red_light
and a direction vector of (+1,0,0).
NOTE The direction vectors for the blue and red lights are opposite in sign, so they are pointing in opposite directions.
Both lights have the same dynamic instance setup, which uses the Flexible Motion model to translate the lights to the roof and then spin them as a function of time.
The entire police car bundle GLIST is shown below, including the base vehicle geometry, the static headlights and the spinning blue/red roof lights.
<geometrylist>
<object search_paths="local">
<localmaterials>police_car.mat</localmaterials>
<basegeometry>
<obj swapyz="false">
<filename>nissan_march.obj</filename>
<assign name="paint" id="500">default</assign>
<assign name="paint" id="500">body-color</assign>
<assign id="510">glass2</assign>
<assign id="511">metal3</assign>
<assign id="511">metal</assign>
<assign id="512">Black</assign>
<assign id="512">tire</assign>
<assign id="513">leather</assign>
<assign id="514">plt1</assign>
</obj>
</basegeometry>
<staticinstance/>
</object>
<object search_paths="local">
<localmaterials>police_car.mat</localmaterials>
<basesource>
<pointsource matid="headlight">
<pointing><vector><x>0.0</x><y>1.0</y><z>0.0</z></vector></pointing>
</pointsource>
</basesource>
<staticinstance>
<translation>
<point><x>-0.66</x><y>1.6</y><z>0.7</z></point>
</translation>
</staticinstance>
<staticinstance>
<translation>
<point><x>+0.66</x><y>1.6</y><z>0.7</z></point>
</translation>
</staticinstance>
</object>
<object search_paths="local">
<localmaterials>police_car.mat</localmaterials>
<basesource>
<pointsource matid="blue_light">
<pointing><vector><x>-1.0</x><y>0.0</y><z>0.0</z></vector></pointing>
</pointsource>
</basesource>
<dynamicinstance>
<motion type="flexible">
<locationengine type="fixed">
<location frame="scene">
<x>0.0</x><y>0.0</y><z>1.7</z>
</location>
</locationengine>
<orientationengine type="euler">
<data source="external" datetime="relative" frame="scene" order="xyz" delimiter=" " loop="true">
<filename>spin_euler.txt</filename>
</data>
</orientationengine>
</motion>
</dynamicinstance>
</object>
<object search_paths="local">
<localmaterials>police_car.mat</localmaterials>
<basesource>
<pointsource matid="red_light">
<pointing><vector><x>+1.0</x><y>0.0</y><z>0.0</z></vector></pointing>
</pointsource>
</basesource>
<dynamicinstance>
<motion type="flexible">
<locationengine type="fixed">
<location frame="scene">
<x>0.0</x><y>0.0</y><z>1.7</z>
</location>
</locationengine>
<orientationengine type="euler">
<data source="external" datetime="relative" frame="scene" order="xyz" delimiter=" " loop="true">
<filename>spin_euler.txt</filename>
</data>
</orientationengine>
</motion>
</dynamicinstance>
</object>
</geometrylist>
Scene Assembly
The geometry/demo.glist
file instantiates these three bundled
objects into the scene. The parking lot and "suspect" car are
statically instanced and the "police" car is dynamically instanced
using the Generic Motion
model.
<geometrylist>
<object enabled="true">
<basegeometry>
<glist>
<filename>bundles/parking_lot/parking_lot.glist</filename>
</glist>
</basegeometry>
<staticinstance name="lot"/>
</object>
<object enabled="true">
<basegeometry>
<glist>
<filename>bundles/suspect_car/suspect_car.glist</filename>
</glist>
</basegeometry>
<staticinstance name="suspect_car1">
<translation>
<point><x>-2.6</x><y>6.0</y><z>0.0</z></point>
</translation>
<rotation units="degrees" rotationorder="xyz">
<cartesiantriple><x>0</x><y>0</y><z>-90</z></cartesiantriple>
</rotation>
</staticinstance>
</object>
<object enabled="true">
<basegeometry>
<glist>
<filename>bundles/police_car/police_car.glist</filename>
</glist>
</basegeometry>
<dynamicinstance name="police_car1">
<motion type="generic">
<filename>$SCENE_DIR/geometry/police_car.ppd</filename>
</motion>
</dynamicinstance>
</object>
</geometrylist>
Simulations and Results
The Single-Frame Simulation
Run the single-frame demo.sim
file using DIRSIG4:
$ dirsig4 demo.sim
or using DIRSIG5 with a higher convergence setup to account for the lower radiance overall levels:
$ dirsig5 --convergence=30,250,1e-12 demo.sim
Load the resulting demo-t0000-c000.img
radiance file in the DIRSIG
image viewer and display the RGB bands using one of the high dynamic
range scaling options (e.g., "two sigma" or "two percent" scaling).
Alternatively, the image_tool
provides the non-linear "gamma" scaling
option, which can be used to directly produce a PNG with the following
syntax:
$ image_tool convert --percent=2 --gamma=3.0 demo-t0000-c0000.img
The Multi-Frame Simulation
Run the single-frame demo.sim
file using DIRSIG4:
$ dirsig4 video.sim
or using DIRSIG5 with a higher convergence setup to account for the lower radiance overall levels:
$ dirsig5 --convergence=30,250,1e-12 video.sim
All the frames produced by the multi-frame simulation can be scaled in a
single execution of the image_tool
by using the appropriate wildcards
for the image filename:
$ image_tool convert --percent=2 --gamma=3.0 demo-t0000-c*.img