WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   add info on avatar (https://forum.worldviz.com/showthread.php?t=3721)

xcuddlex 04-21-2011 09:29 AM

add info on avatar
 
info = vizinfo.add( 'WELCOME.' )
info.translate( .98, .3 )

i think this is how to add info onto the screen
but how can i add this kind of info on specific avatar?
for example i have three avatar
i want to add different info on each avatar when i flash the marker to the webcam.

Jeff 04-21-2011 05:03 PM

You can create a separate info box for each avatar. When a marker is in view change the visibility of the info box:
Code:

info = vizinfo.add('avatar')
info.visible(viz.OFF)

def updateInfo():
        if marker.getVisible():
                info.visible(viz.ON)
        else:
                info.visible(viz.OFF)
               
vizact.ontimer(0,updateInfo)


xcuddlex 04-21-2011 11:33 PM

jeff,
how can i do multiple if statements for the three different avatar ?

Jeff 04-22-2011 01:05 PM

You could have multiple if/else statements one after the other in the timer function.

Or you could keep your markers, models, info boxes in lists and place a loop in the timer function. For each iteration of the loop you can check the visibility of a marker and set the visibility of the related info box. The following example would do that for 3 matrix markers, ids 1,2,3:
Code:

import viz
import vizact
import vizinfo

viz.go()

MARKER_IDS = [1,2,3]
AVATAR_FILES = ['vcc_male.cfg','vcc_female.cfg','duck.cfg']
INFO_POSITIONS = [[0.2,0.8],[0.2,0.6],[0.2,0.4]]
INFO_MESSAGES = ['male','female','duck']

marker_list = []
avatar_list = []
info_list = []

#Add ARToolkit extension
ar = viz.add('artoolkit.dle')

#Create camera using first available webcam
camera = ar.addWebCamera()

for i in range(len(MARKER_IDS)):
       
        marker = camera.addMatrixMarker(MARKER_IDS[i],width=1000)
        avatar = viz.addAvatar(AVATAR_FILES[i])
        avatar.visible(viz.OFF)
        viz.link(marker,avatar)
               
        info = vizinfo.add(INFO_MESSAGES[i])
        info.visible(viz.OFF)
        info.translate(INFO_POSITIONS[i])
       
        marker_list.append(marker)
        avatar_list.append(avatar)
        info_list.append(info)
       
       
def updateVisible():
        for i in range(len(MARKER_IDS)):
                if marker_list[i].getVisible():
                        info_list[i].visible(viz.ON)
                        avatar_list[i].visible(viz.ON)
                else:
                        info_list[i].visible(viz.OFF)
                        avatar_list[i].visible(viz.OFF)
       
vizact.ontimer(0,updateVisible)


xcuddlex 05-01-2011 07:00 AM

it works ! thank you so much jeff


All times are GMT -7. The time now is 06:05 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC