The SmartBody distribution includes an application called OgreViewer which contains an example of how to run SmartBody either embedded in-process or via a network protocol (BoneBus).
SmartBody characters are constructed and connected to their Ogre counterparts. SmartBody then controls the Ogre characters directly. Note that a custom Ogre interface can be constructed by using the SmartBody API. The OgreViewer application is used as one possible example of how SmartBody and Ogre can communicate together.
For SmartBody characters to appear in OgreViewer, an Ogre mesh and Ogre skeleton needs to be present that matches the character type when the character is created:
mycharacter = scene.createCharacter("myname", type)
myskeleton = scene.createSkeleton(skeletonname)
mycharacter.setSkeleton(myskeleton)
here 'type' is the name of an Ogre mesh file that exists in smartbody/core/ogre-viewer/media. For example, if the 'type' is 'brad', then the file brad.mesh and brad.skeleton will be retrieved from the Ogre media directory. Note that the skeleton used for the SmartBody character ('skeletonname') must match the skeleton used by Ogre. If no Ogre mesh is available for the particular character type, then the default mesh (Brad.mesh) will be used, although doing so will likely result in mismatches between the SmartBody skeleton and the Ogre skeleton.
The OgreViewer will run in embedded mode automatically if no command line parameters are entered. By contrast, In BoneBus mode, the OgreViewer application will connect to a running SmartBody process and render characters if a matching Ogre-compatible mesh is available.
If command line options are added to OgreViewer, then SmartBody will be run in-process by setting the following command line options:
Argument | Description |
---|---|
-config | Use a configuration file that contains startup instructions. Here is an example of the valid contents:
[GENERAL] UseBoneBus=False ScriptPath=../../../../data/sbm-common/scripts DefaultPyFile=default-init.py MediaPath=. Scene=vh_basic_level.mesh Where 'UseBoneBus' can be 'True' or 'False' 'ScriptPath' is the location of the startup script. 'DefaultPyFile' is the name of the script that will be run on startup. It must be located in the 'ScriptPath' directory. 'MediaPath' is the prefix attached to all asset queries. 'Scene' is an Ogre .mesh file that contains the initial scene geometry
|
-mediapath | Media path for the application. The media path determines the prefix by which all subsequents paths are added. For example, if the media path is: /my/application, then specifying a relative directory for some file parameter, such as 'myfiles', results in the mediapath being added to it. In other words, the final path will be: /my/application/myfiles |
-scriptpath | Path containing scripts to be initially loaded |
-script | Initial script to run. If not specified, runs default.py. |
-scene | The default mesh that will be loaded into the scene. The mesh must be placed in the Ogre media path. |
-help | Prints the help message then exits the application. |
Controlling the Camera in Ogre
Key | Behavior |
---|---|
1,2,3,4 | Toggles between the default scenes: 1 = default scene as specified on the command line or via configuration file 2 = world scene in feet 3 = world scene in centimeters 4 = scene with rectangular plane and shadows |
J | Toggle the camera rotation via mouse off and on |
P | Display the camera details |
A,D | Move the camera left or right |
W,S | Move the camera forward or backward |
Q,E | Move the camera up or down |
N | Toggle solid, wireframe or points mode |
Controlling Characters in Ogre
If the OgreViewer is being run in BoneBus mode (out-of-process), then commands can be sent directly to the SmartBody process, and the characters actions will be seen in the Ogre window. Please see the documentation on running the SmartBody standalone program. The OgreViewer itself has no interactive controls, and thus any interactive commands either need to be embedded within the C++ code or sent through via a VHMessage through ActiveMQ. This can be done, for example, via the elsender application that is part of the SmartBody distribution. Please see the section on sending VH Messages for more details.
Creating Models and Skeletons for SmartBody and Ogre
We recommend exporting an Ogre mesh and skeleton from your modeling tool in a T- or A- pose. We have had success using the OgreMax exporter (www.ogremax.com/downloads). Additionally, you will need to export the Ogre skeleton into a format that SmartBody understands, such as a COLLADA, bvh, asf or fbx. This skeleton file must be places in one of SmartBody's asset paths (for example, /path/to/smartbody/data/sbm-common/common-sk).
Additionally, any skeleton that doesn't use the standard SmartBody naming convention would need to use a joint mapping (please see the section on Using Custom Skeletons and Animations) before use. Additionally, to use any existing animations in the SmartBody distribution, motions for that skeleton would need to be retargeted (please see the section on Retargetting).
Examples
To run SmartBody using a configuration file, make sure a config.ini file is located in the same directory as the OgreViewer executable containing parameters such as the following:
[GENERAL]
UseBoneBus=False
ScriptPath=../../../../data/sbm-common/scripts
DefaultPyFile=default-init.py
MediaPath=.
Scene=vh_basic_level.mesh
To run SmartBody in the OgreViewer process, enter a script path, script and optionally a media path:
OgreViewer -mediapath /path/to/smartbody/trunk/data -scriptpath sbm-common/scripts -script default-init.py
To run SmartBody in a separate process that connects to the OgreViewer (BoneBus mode), first run the OgreViewer:
OgreViewer
then run sbgui with the appropriate parameters:
sbgui -mediapath /path/to/smartbody/trunk/data -scriptpath sbmcommon/scripts -script default-init.py