Welcome, Guest! Log In | Create Account

BoneBus

From smartbody

Jump to: navigation, search

When Smartbody is used as a separate process, the BoneBus is the protocol that communicates between Smartbody and the renderer. It is implemented as a C++ library that uses TCP and UDP to transmit messages allowing Smartbody to be used in a distributed manner.

The primary purpose of the BoneBus is to transmit the bone positions and rotations of the characters to the renderer. The renderer receives these messages and adjusts the character accordingly. You could think of the Smartbody process as the puppeteer that is controlling the character inside the renderer.

These are the functions that the BoneBus provides:

  • Creation / Removal of Smartbody characters
  • Setting world positions and rotations of Smartbody characters
  • Setting bone positions and rotations of Smartbody characters’ bones.
  • Setting facial visemes

These are helper functions also provided by BoneBus that give outside processes greater control over the renderer:

  • Setting world positions and rotation of the camera
  • Playing / Stopping a sound
  • Executing an arbitrary renderer-specific script by name

The C++ library is designed to hide the details of the protocol. Indeed, there are changes that we would like to make. By using the library, it allows changes to occur without requiring changes to your implementation.

BoneBus is a high bandwidth protocol. Without optimization, bone data (rotation/position) for each bone in each character gets sent out every frame. At thirty frames per second, there is a lot of data to transmit. An initial pass at optimization has been implemented that reduces this quite a bit, and additional optimization techniques will be added in the future.

BoneBus uses regular socket connections, sending over TCP and UDP. UDP is being used for bone messages that don’t require reliability (ie, bone data). TCP is used for the rest.
For the TCP side, the renderer is used as the server, listening for the Smartbody process to connect to it.

Here’s a diagram:

Integrating BoneBus with your renderer involves using the BoneBus library. There are two examples you can use for reference. First, in lib/bonebus/samples/minimal, there is a sample server.cpp file that shows the most minimal steps needed to create a server, listen for connections, and receive data.

Looking at the sample, BoneBus is implemented through a set of callback functions that are used to pass data to the server. These callback functions are called in the library’s polling routine, BoneBusServer::Update().

The second example is a more complete implementation, using Ogre as the renderer. You can find this in core/smartbody/ogre-viewer/OgreTest.cpp. It will be perhaps harder to understand, but it will give examples of how to modify the bones inside of the callbacks.