Mirror Demo

Mirror Demo

Located in ExampleScripts - Mirror_Demo

This demo allows you to view your reflection in a virtual mirror in VR. With features such as avatar swapping, facial expression tracking, body tracking, and customizable environments. Facial Expression data can also be saved to a file and analyzed afterwards. This demo is located in SightLab under "ExampleScripts- Mirror_Demo". See below for the minimum code for just adding a mirror.   

Configure Settings

Edit the MirrorConfig.py file to adjust the following parameters:

Run the Demo

Follow the instructions below to run the demo with your customized settings

There is also a version called "virtual_mirror_w_slider" that lets you see a panel that shows the data from all of the face tracking parameters. 

Code to add mirror to your own scene (would need to copy the mirror.py file from "sightlab_utils" if not running with SightLab). If wanting to use own environment, you can use Inspector (Tools- Inspector) to add a 2D plane (any image will work) to your scene, then place it where you want and name it 'mirror' (right click and rename). 

Note if you're not seeing the mirror, you may need to adjust the rotation by adjusting the "euler" values


#Import the mirror modulefrom sightlab_utils.mirror import addReflection
#Need to manually set the avatar head to see in the mirroravatarPath = 'sightlab_resources/avatar/head/Male1.osgb'
head = vizfx.addAvatar(avatarPath)sightlab.setAvatarHead(head)
sightlab.sceneObjects[AVATAR_HEAD_OBJECT] = avatarPath
bb_mirror = env.getBoundingBox(node='mirror')
# Check if the bounding box is valid (i.e., the 'mirror' node exists)if bb_mirror.valid():    scale = [bb_mirror.size[0], bb_mirror.size[1], 1.0]    pos = bb_mirror.center    pos[2] -= (bb_mirror.size[2] * 0.5) + 0.01else:    bb = viz.addTexQuad()    scale = [1.0, 1.0, 1.0] # Scale factors for x, y, and z    pos = [0, 2, 1] # Position coordinates for x, y, and z # Create reflection for left eyeleftEyeQuad = viz.addTexQuad(scale=scale, pos=pos, euler=(180,0,0))leftEyeQuad.disable(viz.LIGHTING)addReflection(leftEyeQuad,eye=viz.LEFT_EYE) # Create reflection for right eyerightEyeQuad = viz.addTexQuad(scale=scale, pos=pos, euler=(180,0,0))rightEyeQuad.disable(viz.LIGHTING)addReflection(rightEyeQuad,eye=viz.RIGHT_EYE)