Skip to content

Information Flow, Architecture, and Animal Manager System

Jasmine Mai edited this page Aug 31, 2020 · 13 revisions

Information Flow

Imgur

Link to Flow Chart in Figma

Components

The primary components involved in the animal switch system are:

Animal Manager

The Animal Manager prefab keeps track of all of the animals and their specific vision and movement parameters. The prefab has the AnimalManager.cs script on it. The script exposes two events: VisionSwitch and AnimalSwitch that other scripts can subscribe to:

  • VisionSwitch: any function that takes in a VisionParameters object can be subscribed to this
  • AnimalSwitch: any function that takes in a Animal enum can be subscribed to this

AnimalManager.cs has a function SwitchAnimal that takes in an Animal enum as a parameter and an optional boolean setAsNewAnimal (which is by default true). setAsNewAnimal, if true, sets the animal passed in as the new animal that is being explored, so that on button press, it will switch automatically between that animal and human. The SwitchAnimal function can be called by another script whenever the animal needs to be switched. When it is called, SwitchAnimal searches through its list of animals then invokes the VisionSwitch and AnimalSwitch events, passing in the appropriate VisionParameters and Animal parameters respectively.

VisionParameters is a class containing vision parameters/information and movement parameters/information, respectively. VisionParameters.cs can be found under Assets > Scripts > Vision.

Main Scripts

  • AnimalManager.cs

Usage

Through the inspector, drag in animal prefabs (prefabs with the AnimalController.cs script on them) into the Animal Controllers list of AnimalManager.cs

Animal Prefabs

These are per-animal prefabs that contain the vision and movement information for each specific animal.

Main Scripts

  • AnimalController.cs
  • AnimalVision.cs

Usage

Add the AnimalController.cs script onto a game object. The required AnimalVision.cs script will be added automatically. Set the parameters on the AnimalVision.cs script that are appropriate for that animal. Don't forget to set the animal type in AnimalController.cs.

Then, drag in all of your animal prefabs into the Animal Controllers list of the AnimalManager.cs script.

World Objects

Sometimes, the vision effects you wish to apply should differ per object (e.g. UV is a per-object effect because the amount of UV light emitted is dependent on the object). These effects are material effects. To use material effects, you need a MaterialController.cs on every object whose material you wish to change on animal switch.

Main Scripts

  • MaterialController.cs
  • Any material effects you wish to apply:
    • MaterialSwap.cs
    • UV.cs

Usage

Add MaterialController.cs on each world object that you wish to change the material of. Then add the material effects that you want to apply.

Skybox Manager

Controls the skybox materials.

Main Scripts

  • SkyboxController.cs
  • Any skybox effects you wish to apply:
    • SkyboxSwap.cs

Renderer Manager

Controls the addition and deletion of renderer effects to the custom render pipeline.
To use a renderer effect in a scene, its corresponding script must be added to the scene's Renderer Manager.

Main Scripts

  • RendererController.cs
  • Any renderer effects you wish to apply:
    • RendererEffect.cs: The template for renderer effects. Custom renderer effects inherit from this script.
    • BlitEffect.cs: A general purpose renderer effect for creating blit effects. It can be used on its own, or as a template for more specific blit effects
    • ColorblindEffect.cs: The script for the colorblind renderer effect.

Environment Controllers

Controls the environment based on animal switch. Connected to animal manager's AnimalSwitch event.

Main Scripts

  • SoundController.cs: controls an audio source's settings
  • LightController.cs: controls a light source's settings

Usage

Attach the script on the relevant component. For example, attach SoundController.cs to a game object with an audio source, LightController.cs to a game object with a light. Add the settings associated with each animal as needed. If an animal is not provided, it will default to the original settings found on the source.

Architecture

Script Summaries

Link to Diagram in Figma

Managers and Controllers

  • AnimalManager.cs: Manages animal switching and notifying other scripts of animal switching
  • AnimalController.cs: Per-animal controller. Synthesizes information from an animal's AnimalVision.cs script so that the Animal Manager can access this information more easily.
  • MaterialController.cs: In charge of applying material changes to objects when animal has been switched
  • RendererController.cs: In charge of applying renderer effects to the render pipeline when animal has been switched.
  • SkyboxController.cs: In charge of applying material changes to skybox materials
  • SoundController.cs: In charge of switching sound settings on the assigned audio source
  • LightController.cs: In charge of switching light settings on the assigned light source

Base/Information Classes:

  • MaterialEffect.cs: Inherited by all vision effects that affect a renderer's materials.
  • RendererEffect.cs: Inherited by all vision effects that are applied to the render pipeline and affect the camera.
  • SkyboxEffect.cs: Inherited by all vision effects that affect a skybox's materials.
  • VisionParameters.cs: class that holds all of an animal's vision information so that scripts can access that information on animal switch.

Vision Effects:

  • UV.cs: A material effect. Inherits from MaterialEffect.cs. Applies UV false color to a renderer's materials by getting rid of a material's red channel, switching the green channel to the material's red channel, the blue channel to the green channel, and applying a UV amount to the blue channel.
  • MaterialSwap.cs: A material effect. Inherits from MaterialEffect.cs. Swaps out materials for the appropriate one based on animal type.
  • SparkleShaderIntensity.cs: A material effect. Used to control the sparkle shader.
  • SkyboxSwap.cs: A skybox effect. Inherits from SkyboxEffec.cs. Swaps out skybox materials.
  • ColorblindEffect.cs: A renderer effect. Applies the specified colorblindness to the render pipeline/camera.