Skip to content

Quick start

Brice Donval edited this page Jul 22, 2020 · 1 revision

Communication between Greta and Unity player

When you want to run a Unity scene that includes a Greta agent, you must first run Greta and load a configuration file that includes the following Thrift modules:

  • Thrift Command Receiver
  • Thrift Audio Sender
  • Thrift FAP Sender
  • Thrift BAP Sender

drawing

The "Thrift Command Receiver" is the main module which allows us to synchronize agents, objects and events on them from Unity to Greta. The Audio, FAP (Facial Animation Parameters) and BAP (Body Animation Parameters) Senders are modules which send voice and animations from the Greta engine to the Unity player.

This kind of Greta configuration can be found in the folder <GRETA_DIR>/bin/Configurations/GretaUnity/.

After that, you can play a Unity scene that includes one or more GretaUnity agent(s). A GretaUnity agent is provided as a Prefab element for Unity, which includes the essential scripts to synchronize and animate it. Especially it includes the following scripts:

  • Greta Character Animator (GretaCharacterAnimator.cs)
  • Greta Character Synchronizer (GretaCharacterSynchronizer.cs)
  • Greta Object Tracker (GretaObjectTracker.cs)
  • Animation Command Sender Tester (AnimationCommandSenderTester.cs)

drawing

The "Greta Character Animator" is the main script which allows us to respond to the Thrift modules of Greta and play the corresponding animations. Indeed it contains this four elements:

  • A Thrift command sender
  • A Thrift audio receiver
  • A Thrift FAP receiver
  • A Thrift BAP receiver

The corresponding Thrift senders/receivers from Greta and Unity connect to each other with a specific host and port for each category of information. By default in GretaUnity, these four ports are used:

drawing

The "Greta Character Animator" is also in charge to transform the character from the "T position" used by our characters to the "N position" used by Greta.

drawing

drawing

The "Greta Character Synchronizer" script is in charge to send characters position, rotations and scale from Unity to Greta. It also sends its following members:

  • its head
  • its left eye
  • its right eye
  • its mouth
  • its left hand
  • its right hand
  • its left foot
  • its right foot

The "Greta Object Tracker" script is a way to track an object in the scene. It takes an object to follow in parameter, and allows us to indicate which influence of gaze we want between five values: EYES, HEAD, SHOULDER, TORSO, WHOLE.

The "Animation Command Sender Tester" script allows us to send an "Animation ID" (a FML file path without the .xml extension) in order to test GretaUnity capabilities.

On the Unity side, when the T key is pressed, the path to this FML file is sent to Greta which read it and execute it. Internally, "Animation Command Sender Tester" asks "Greta Character Animator" to send this file path, which itself asks "Thrift Command Sender" to do so. In "Thrift Command Sender", a message with the type "animID" and with the file path is created. Then it is sent through the Thrift channel (port 9912 for messages).

On the Greta side, the "Thrift Command Receiver" module receives this message. It first looks at its type, then when it sees that it corresponds to "animID" it starts processing this file: read the FML file at the given location and propagate it content inside the Greta's internal system (from FML to Signals, from Signals to Keyframes and from Keyframes to FAP frames, BAP frames and Audio frames) to be executed by the virtual agent and be finally played by the Unity player after receiving corresponding animation parameters through the tree other Thrift channels.