Advanced Placement - Unity-Technologies/com.unity.cv.synthetichumans GitHub Wiki
Synthetic comes with an extensible framework for placing humans in Scenes realistically, while respecting the collisions between them and the Scene and ensuring that they are placed within the camera's frustum.
The advanced placement system in Palette comprises of a few parts. The entryway into the system is the the NavMesh Placement Randomizer (NavMeshPlacementRandomizer.cs
). This Randomizer can use several placement methods, called Palette Placers (which utilizes Palette Placers (PalettePlacer.cs
), to situate the humans in the Scene. The choice of which Placer to use is controlled by the user and is mapped to the animation of the generated human at the time of placement. These mappings are defined in Animation Placement Groups. Thus, any Randomizer that randomizes the animations of generated humans needs to be executed before the NavMesh Placement Randomizer. For example, if a generated human has a seated animation, the code responsible for placing this human needs to use the SittingPlacer
algorithm and position the human on surfaces that are marked to be compatible with this Placer.
Required Scene Setup Regardless of Placers Used
- The NavMesh Placement Randomizer.
- One or more cameras added to the list of cameras in the above Randomizer.
A Primer on Placers
Palette Placers decide how humans are placed on surfaces and how they are guaranteed to be in the camera's frustum. The Palette package comes with a variety of Placers, and facilitates the creation of custom Placers through extensible APIs.
Some of the Placers included in Palette are the Bound-based Ground Placer, the Ray-based Ground Placer, and the Sitting Placer. These utilize Unity's navigation and physics systems to place humans.
Placers require a single NavMeshSurface component in the Scene that has its Collect Objects property set to All, which makes it encompass all meshes in the scene and not just the children of the NavMeshSurface object.
All the three Placers mentioned above place humans only in the frustum of at least one of the camera's added to NavMesh Placement Randomizer. The Placers are different in the way they choose positions for placement. If the appropriate Placer is not used, you may get into situations where the Placer is unable to place any humans (or the requested number of humans) in the camera's view.
Bound-based Ground Placer
This Placer chooses placement positions in the volume created by the intersection of the camera's frustum and the bounds of the NavMeshSurface. Humans are placed at these positions. Then, humans that are not within the camera's view are deactivated.
With this Placer, positions may be chosen anywhere on the NavMesh. If the NavMesh encompass multiple rooms, positions will be chosen randomly from all rooms.
An example usage of this Placer:
Position of the camera in the example above:
Requirements for Bound-based Ground Placer
- A single NavMeshSurface component anywhere in the Scene, with the Collect Objects property set to All.
- The Palette Animation Randomizer Tag component on the humans, and a random animation assigned to this tag by the Palette Animation Randomizer.
- The NavMesh Placement Randomizer Tag component on the humans, with an Animation Placement Group added, which assigns the Bound Based Ground Placer to one or more animations that the target humans may have at runtime.
- Components required on surfaces on which humans should be placed
- The Ground Placer Tag component with the Area field set to NavMesh Modifier.
- The NavMesh Modifier component with the Override Area option enabled and Area Type set to Walkable.
Ray-based Ground Placer
This placer randomly chooses a ray cast direction from the camera and then selects a random position to place the human between the camera and the first wall the ray hits. This position is also on the NavMesh.
Since higher priority is given to the camera, the selected positions are always in the camera's view.
An example usage of this Placer:
Position of the camera in the example above:
Requirements for Ray-based Ground Placer
- A single NavMeshSurface component anywhere in the Scene, with the Collect Objects property set to All.
- The Palette Animation Randomizer Tag component on the humans, and a random animation assigned to this tag by the Palette Animation Randomizer.
- The NavMesh Placement Randomizer Tag component on the humans, with an Animation Placement Group added, which assigns the Ray Based Ground Placer to one or more animations that the target humans may have at runtime.
- Components required on surfaces on which humans should be placed
- The Ground Placer Tag component with the Area field set to NavMesh Modifier.
- The NavMesh Modifier component with the Override Area option enabled and Area Type set to Walkable.
- The Ray Based Ground Placer Tag on all walls in the Scene.
Sitting Placer
This Placer first chooses the position of placement in a similar manner to the Bound-based Ground Placer. It selects an object to sit on in the volume created by the intersection of the camera's frustum and the bounds of the NavMeshSurface. This object must have a Sitting Placer Tag component attached, and the tag uses polar coordinates to define the possible edges of the object where humans are going to be placed.
Then, the Sitting Placer samples a placement position at the edge of the NavMesh on the chosen object and places the human in this position. The algorithm also makes sure that the upper leg joints of the Palette human are on the edge of the seat object.
An example usage of the Sitting Placer Tag:
An example usage of this the Sitting Placer:
Position of the camera in this example:
Requirements for Sitting Placer
- A single NavMeshSurface component anywhere in the Scene, with the Collect Objects property set to All.
- The Palette Animation Randomizer Tag component on the humans, and a random animation assigned to this tag by the Palette Animation Randomizer
- The NavMesh Placement Randomizer Tag component on the humans, with an Animation Placement Group added which assigns the Sitting Placer to one or more animations that the target humans may have at runtime.
- Components required on the surface on which humans should be placed
- The Sitting Placer Tag component with the Area field set to NavMesh Modifier
- The NavMesh Modifier component with the Override Area option enabled and Area Type set to a custom navigation area, e.g. "Sitting". Navigation areas are defined in Window->AI->Navigation->Areas. The area type must be different from the Ground Placers' Walkable area if both ground and sitting placers are used.