Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Open Unity
  2. File->New Project
  3. Copy the vhAssetsPackage.unitypackage file to this new project. YouYou need 2 Unity Packages to start with.  You'll find it all packages here: <VHToolkit> <VHToolkit>\bin\vhtoolkitUnity\vhAssetsPackage.unitypackage. Copy this file .  Copy them to <your project>\Assets
  4. In Unity, in the 'Project' column, double click on the vhAssetsPackage file
  5. You now have a Unity project containing all of the VHToolkit code needed to create your own virtual human.

Creating a Virtual Human using the VHToolkit Unity Package (simple)

  1. Open Unity
  2. Copy bin/vhtoolkitUnity/vhAssetsPackage.unityPackage and bin/vhtoolkitUnity/vhAssetsTestScenePackage.unityPackage into <your project>\Assets
  3. Double click vhAssetsPackage in the project view and import
  4. Double click vhAssetsTestScenePackage in the project view and import
  5. Open vhAssetsTextScene

Creating a Virtual Human using the VHToolkit Unity Package (detailed)

  1. First, is the vhAssets package.  This contains common scripts and libraries used in various Virtual Humans applications.  There is a different .unitypackage file for each platform.  
    1. vhAssetsPackage.unityPackage    (Windows)
    2. vhAssetsPackageOSX.unityPackage
    3. vhAssetsPackageIOS.unityPackage
    4. vhAssetsPackageAndroid.unityPackage
  2. Second, is the vhAssets Test Scene.  This contains assets and scripts that will initialize a very basic test scene environment.  This file is:  vhAssetsTestScenePackage.unityPackage
  3. Copy the 2 Unity Packages to this new project.
  4. In Unity, in the 'Project' column, double click on the 2 Unity Packages.
  5. Open Scenes->vhAssetsTestScene
  6. Click Play.  The virtual human should be animating in an idle pose.  Hit 'C' to show a debug menu.  You should be able to control him via the buttons on the debug menu.

 These steps assume you have virtual human art assets.

These instructions are for both Unity Pro and Unity Free. When there are specific instructions for a particular version, they have been marked as such.

There are differences because Unity Pro uses an .dll version of smartbody, and runs within the process. For Unity Free, Smartbody is launched as a separate process and communicates to Unity via network traffic.

Steps:

  1. Follow the steps above to get the VHToolkit Unity Package in your project
  2. Copy your art assets to your Unity Project. You can use the assets in VHToolkit if you wish. Copy these files to <your project>\Assets\Resources:
    1. <VHToolkit>\core\vhtoolkitUnity\Assets\Resources\art\characters\Brad.fbx
    2. <VHToolkit>\core\vhtoolkitUnity\Assets\Resources\art\textures\Brad_Face_2048.jpg
    3. <VHToolkit>\core\vhtoolkitUnity\Assets\Resources\art\textures\Brad_Hand.jpg
    4. <VHToolkit>\core\vhtoolkitUnity\Assets\Resources\art\textures\Brad_Pants.jpg
    5. <VHToolkit>\core\vhtoolkitUnity\Assets\Resources\art\textures\Brad_Shirt.tif
    You now have to match up the Materials with the textures:
    In Unity, in the Project pane, click to open the Resources folder, then click to open the Materials folder.
  3. Click on Brad-Brad_SkinRig_Brad_Hands
  4. In the Inspector, in the Texture2D square, click the Select.
  5. In the dialog that pops up, select the Brad_Hand texture
  6. Repeat these steps for the Head, Pants, and Shirt materials.
  7. To test to see if the character is imported correctly, select Brad in the Project column, and drag it to the Scene view. You should see the character, fully textured. Click delete to remove him from the scene when done.
  8. You now have to create a Prefab for the character.
    1. In the Project column, click Create -> Prefab
    2. Drag 'New Prefab' to the Resources folder
    3. Click on 'New Prefab' to rename it to 'BradPrefab'
    4. Drag 'Brad' onto 'BradPrefab' to create a prefab of Brad
    5. Still in the Project column, open up vhAssets\sbm
    6. Drag UnitySmartbodyCharacter to BradPrefab
    7. Create a SoundNode for the character:
      1. Go to GameObject->Create Empty
      2. In the Hierarchy, rename GameObject to SoundNode
      3. With SoundNode selected, go to Component->Audio->Audio Source
      4. In the Project column, drag BradPrefab to the Hierarchy
      5. Drag SoundNode to BradPrefab in the Hierarchy. A dialog will pop up saying that this will lose the prefab connection. Click Continue.
      6. In the Hierarchy, drag BradPrefab onto the BradPrefab in the Project column.
      7. Remove BradPrefab from Hierarchy
      8. <todo> <set the position of the SoundNode to the character's mouth>
    8. Select BradPrefab. In the Inspector, change 'Bone Parent Name' to CharacterRoot1/AccumulationRoot since that's how the hierarchy is set up in our current character. That points to the 'top' of the skeleton hierarchy.
    9. Still in the Inspector, select the checkbox 'Is Face Bone Driven'. Turn that on.
  9. Now you need to add the components to the scene.
    1. In the Project column, open up vhAssets\Resources
    2. Drag VHBehaviourManager to the Hierarchy column
    3. Drag DebugConsole to the Hierarchy column https://jira.ict.usc.edu/browse/VH-232
    4. Drag Fps Counter to the Hierarchy column https://jira.ict.usc.edu/browse/VH-231
    5. Drag FreeMouseLookCamera to the Hierarchy column. In the Hierarchy column, select 'Main Camera' and delete it.
    6. Drag VHMsgManager to the Hierarchy column
    7. (Unity Pro) Drag SmartbodyManager to the Hierarchy column.
    8. (Unity Free) Drag SmartbodyManagerBonebus to the Hierarchy column.
  10. Now you need to configure and initialize SmartbodyManager
    1. (Unity Pro) In the Hierarchy, select SmartbodyManager
    2. (Unity Free) - In the Hierarchy, select SmartbodyManagerBonebus.
    3. Change Position Scale to 0.01 since Brad's data is in centimeters. This is unnecessary if all your data is in meters.
    4. (Unity Pro) In the Project column, go to Create C Sharp script
    5. (Unity Pro) Select NewBehaviourScript and click Edit in the Inspector
    6. (Unity Pro) Add the following code to the Start() function:

`

Panel

// Use this for initialization
void Start()
{
}

static bool once = false;

Panel

// Update is called once per frame
void Update()
{
if (!once)
{
once = true;

SmartbodyManager.Get().SetMediaPath("Assets"); // https://jira.ict.usc.edu/browse/VH-235

Panel

VHMsgManager vhmsg = VHMsgManager.Get();
vhmsg.SendVHMsg(@"sbm path seq sbm-common\scripts");
vhmsg.SendVHMsg(@"sbm path ME sbm-common/common-sk");
vhmsg.SendVHMsg(@"sbm load motions -R sbm-common/common-sk");
vhmsg.SendVHMsg(@"sbm load poses -R sbm-common/common-sk");
vhmsg.SendVHMsg(@"sbm seq init-common-face");
vhmsg.SendVHMsg(@"sbm load motions -R sbm-toolkit/common-sk");
vhmsg.SendVHMsg(@"sbm load poses -R sbm-toolkit/common-sk");
vhmsg.SendVHMsg(@"sbm char brad init common.sk BradPrefab");
vhmsg.SendVHMsg(@"sbm bml character brad noecho posture HandsAtSide_Motex_Softened");
vhmsg.SendVHMsg(@"sbm set character brad world_offset x 0 y 0 z 0");
vhmsg.SendVHMsg(@"sbm set character brad voice audiofile data/sounds/.");
vhmsg.SendVHMsg(@"sbm set character brad voicebackup remote BradVoice");

FreeMouseLook camera = (FreeMouseLook)Component.FindObjectOfType(typeof(FreeMouseLook));

Panel

camera.transform.position = new Vector3(0, 0, 2);
camera.transform.rotation = Quaternion.Euler(0, 175, 0);
}
}

`

 

 

 

  1. Now
    1. (Unity Pro) Go to GameObject->Create Empty.
    2. (Unity Pro) Drag NewBehaviourScript to GameObject in the Hierarchy
    3. (Unity Pro) Copy sbm-common folder to get Smartbody assets. Copy <VHToolkit>\data\sbm-common to <your project>\Assets\sbm-common
    4. <todo> Add simple lighting
  2. Now we are ready to test
    1. In Unity, hit Play button
    2. (Unity Free) Launch Smartbody as a separate process. Run <VHToolkit>\tools\launch-scripts\run-toolkit-sbm.bat
    3. Brad should appear and animating with his idle animation.
    4. Try and play an animation
    5. Open the Unity debug console by hitting tilde (~)
    6. Type the following command: vhmsg sbm bml char brad anim HandsAtSide_Arms_Chop

Creating your own Virtual Human

 

Using the Console

Hit the ~ key to bring up the console. Here you can see some debug information. Type 'help' for all available commands.

...