Adding Avatar Agents or NPCs

Avatar models can be brought in if they are in either the .fbx, .glTF or .cfg (cal3D) format

See ExampleScripts - Adding_NPC 

For more information on adding avatars, see this tutorial https://www.worldviz.com/post/avatar-workflow-tips-for-vizard 

or see the Vizard Documentation on avatars

For intelligent avatar agents, see this page

Included avatars with SightLab

You can find sample full body avatars in the sightlab_resources directory  C:\Program Files\WorldViz\Vizard<version>\resources\sightlab_resources\avatar\full_body

as well as a complete characters avatar in  C:\Program Files\WorldViz\Vizard<version>\resources\sightlab_resources\avatar\Complete Character

And head and hands avatars in  C:\Program Files\WorldViz\Vizard<version>\bin\lib\site-packages\sightlab_utils\resources\avatar

Replace <version> with either Vizard7 or Vizard8, depending on your installation 

See examples here

Avatar agents or NPCs (non-player characters) are avatars in the scene that don't represent an actual user, but rather an agent in the scene that is controlled by code or AI and can act out scenes or interact with users. 

Here are the steps on how to add one to your experiment

Open Inspector and open your environment model (or just click "Modify" and "Edit" to open your model if using the GUI)

Click "File-Add" and in the "sightlab_resources- objects" folder choose the standInAvatar.osgb (located in the Resources/scene_objects in this example or in C:\Program Files\WorldViz\Vizard<version>\resources\sightlab_resources\objects)

Click on the "avatarTransform" node in the scene graph and then use the translate and rotate tools to move and rotate where you want your NPC in the scene. When you are finished make sure to choose File-Save

Open the avatar you are going to use in Inspector separately and preview any animations that you have available under the "Animations" tab. 

Important Notes:

The avatarPlacer module is specifically designed to work with GEODE nodes in the scene graph. Always provide the name of the GEODE node you wish to target. Using other types of nodes may lead to unexpected behavior or errors.

Instructions to place in code:

Add the following code to your SightlabVR.py script for single user. For multi-user add it to both the client and server scripts.

Note: this code can also be found in the "example_scripts" folder under "Adding_NPCS.py", where "state(1)" refers to the idle animation that you wish to have the NPC/agent start with and "avatar =vizfx.addAvatar('vcc_male.cfg')" would be swapped out with the name and path to your avatar model.  There are also example scripts for the multi-user version. 


from sightlab_utils import avatarPlacerimport sightlab_utils.sightlab as slfrom sightlab_utils.settings import *
sightlab = sl.SightLab(gui = False)
env = vizfx.addChild('sightlab_resources/environments/ShowRoom_standin_avatar.osgb')sightlab.setEnvironment(env)
avatar =vizfx.addAvatar('sightlab_resources/avatar/full_body/RocketBox_Male1.osgb') sightlab.addSceneObject("avatar", avatar, gaze = True,avatar = True)
def sightLabExperiment(): while True: yield viztask.waitKeyDown(' ') yield sightlab.startTrial() #Place avatar, name of environment model, avatar and name of standIn avatar avatarPlacer.place(env, avatar, 'avatarStandin')  
# Using the place function from avatarPlacer#set Avatar animation state. To see all animations available open avatar in Inspector avatar.state(1) avatar.state(1)
yield viztask.waitKeyDown(' ') yield sightlab.endTrial()
viztask.schedule(sightlab.runExperiment)viztask.schedule(sightLabExperiment)viz.callback(viz.getEventID('ResetPosition'), sightlab.resetViewPoint)

If you don't have a standin Avatar, the Avatar will be placed at the default position of 2 meters back and rotated 180 degrees to face the user. Can also override the position and rotation using this code:

avatar.setPosition(0, 0, 2)

avatar.setEuler(180, 0, 0)

You will also need to add this code to your sessionReplay script in order for the avatar to be seen in the replay. 


env = replay.getEnvironmentObject()

env.getChild('avatarStandin').alpha(0)

Additionally, a few good resources for creating new animations using just a 2D camera are 

More information on avatars in the Vizard Documentation