#1
|
|||
|
|||
heya everybody, just a quick one
Heya, im new to the forum- ive encountered this error message, my code is as follows,
Quote:
i know i must be missing an object somewhere cant find it though Thankyou for your help Code:
#################### ###COPYRIGHT 2008 FC### ################### import viz import vizinfo viz.go() #remove movement of screen wi mouse viz.mouse(viz.OFF) info = vizinfo.add( '' ) info.translate( .98, .1 ) info.titlebgcolor(1,0,0) viz.clearcolor(0.5,0.5,1) #Add object that vizinfo GUI objects will modify #=============male or female male = viz.add('vcc_male.cfg') female = viz.add('vcc_female.cfg') #==========morphing face========# male_morphing_face= male.face('morph_head.vzf') female_morphing_face = female.face('morph_head.vzf') #============morphing face end============# male = info.add(viz.RADIO,0,'Male') female = info.add(viz.RADIO,0,'Female') vizact.onbuttondown( male, male.color,viz.BLUE)#Keyboard commands that modify the info box vizact.onbuttondown( female,female.color,viz.WHITE) #Keyboard commands that modify the info box #===========male or female end male.setPosition(0,1,3) male.setPosition(0,1,3) female.setAxisAngle(0,1,0, 180) female.setAxisAngle(0,1,0, 180) #===============set angles directions of models #============Initialize info box with some instructions#================= info = vizinfo.add( 'Set the appearence of your employee' ) info.title( 'Employee Spin' ) #Set title text info.drag( viz.ON ) #Make the title bar draggable #Add slider in info box slider = info.add( viz.SLIDER, 'Spin Speed' ) slider.setScale( 2, 2, 2 ) slider.label.color( viz.RED ) #colours=================== #Add radio buttons red = info.add( viz.RADIO, 0, 'Red' ) white = info.add( viz.RADIO, 0, 'White' ) blue = info.add( viz.RADIO, 0, 'Blue' ) #Set callbacks for changing color with radio buttons vizact.onbuttondown( red, male.color, viz.RED ) vizact.onbuttondown( white, male.color, viz.WHITE ) vizact.onbuttondown( blue, male.color, viz.BLUE ) vizact.onbuttondown( red, female.color, viz.RED ) vizact.onbuttondown( white, female.color, viz.WHITE ) vizact.onbuttondown( blue, female.color, viz.BLUE ) #colors end=================== #====================INFO WINDOW OPTIONS#============ def keyboardEvent( key ): if key == 'e': info.expand() #Maximize info box elif key == 's': info.shrink() #Minimize info box elif key == 'm': info.message( viz.input('Your employee\n\'s name:') ) #Change directions message elif key == 't': info.title( viz.input('Enter title text:') ) #Change title message viz.callback( viz.KEYBOARD_EVENT, keyboardEvent ) #======================INFO WINDOW OPTIONS def sliderEvent( pos ): #Make wheelbarrow spin according to slider position male.runAction( vizact.spin(0, -1, 0, 500 * pos) ) female.runAction( vizact.spin(0, -1, 0, 500 * pos) ) vizact.onslider( slider, sliderEvent ) #=====================actions of characters - MALE========================# def mykeyboard(key): if key == '1': male.state(1) elif key == '2': male.state(2) elif key == '3': male.state(3) elif key == '4': male.state(4) elif key == '5': male.state(5) elif key == '6': male.state(6) elif key == '7': male.state(7) elif key == '8': male.state(8) elif key == '9': male.state(9) elif key == '0': male.state(10) elif key == 'a': male.state(11) elif key == 'b': male.state(12) elif key == 'c': male.state(13) elif key == 'd': male.state(14) elif key == 'e': male.state(15) viz.callback(viz.KEYBOARD_EVENT,mykeyboard) #=====================actions of characters - FEMALE========================# def mykeyboard(key): if key == '1': female.state(1) elif key == '2': female.state(2) elif key == '3': female.state(3) elif key == '4': female.state(4) elif key == '5': female.state(5) elif key == '6': female.state(6) elif key == '7': female.state(7) elif key == '8': female.state(8) elif key == '9': female.state(9) elif key == '0': female.state(10) elif key == 'a': female.state(11) elif key == 'b': female.state(12) elif key == 'c': female.state(13) elif key == 'd': female.state(14) elif key == 'e': female.state(15) viz.callback(viz.KEYBOARD_EVENT,mykeyboard) #------------------adding a slider to change the heads #add slider for smile smile_slider = viz.add(viz.SLIDER) smile_slider.translate(0.25,0.1) #slider 2 for face more to the world ollie_slider = viz.add(viz.SLIDER) ollie_slider.translate(0.75,.1) #------------------end slider #---------morph head #add two differnt face images first_texture = viz.add('stan.jpg') second_texture = viz.add('ollie.jpg') #paste both faces to the head male_morphing_face.texture(first_texture) male_morphing_face.texture(second_texture, '',1) female_morphing_face.texture(first_texture) female_morphing_face.texture(second_texture, '',1) #frag program to blend textures blend = viz.add('multiexblend.fp') male_morphing_face.apply(blend) blend.param(0,0) #bledning it #5 female_morphing_face.apply(blend) blend.param(0,0) #bledning it #--------------end morph head #--------slider function |
#2
|
|||
|
|||
The quotes you put around the highlightes section of code caused it to lose all formatting. You need to repost that section without putting it inside the quotes tag.
|
#3
|
|||
|
|||
Cool, iv added it below, regards
Code:
import viz import vizinfo viz.go() #remove movement of screen wi mouse viz.mouse(viz.OFF) info = vizinfo.add( '' ) info.translate( .98, .1 ) info.titlebgcolor(1,0,0) viz.clearcolor(0.5,0.5,1) #Add object that vizinfo GUI objects will modify #=============male or female male = viz.add('vcc_male.cfg') female = viz.add('vcc_female.cfg') #==========morphing face========# male_morphing_face= male.face('morph_head.vzf') female_morphing_face = female.face('morph_head.vzf') #============morphing face end============# male = info.add(viz.RADIO,0,'Male') female = info.add(viz.RADIO,0,'Female') vizact.onbuttondown( male, male.color,viz.BLUE)#Keyboard commands that modify the info box vizact.onbuttondown( female,female.color,viz.WHITE) #Keyboard commands that modify the info box #===========male or female end male.setPosition(0,1,3) male.setPosition(0,1,3) female.setAxisAngle(0,1,0, 180) female.setAxisAngle(0,1,0, 180) #===============set angles directions of models #============Initialize info box with some instructions#================= info = vizinfo.add( 'Set the appearence of your employee' ) info.title( 'Employee Spin' ) #Set title text info.drag( viz.ON ) #Make the title bar draggable #Add slider in info box slider = info.add( viz.SLIDER, 'Spin Speed' ) slider.setScale( 2, 2, 2 ) slider.label.color( viz.RED ) #colours=================== #Add radio buttons red = info.add( viz.RADIO, 0, 'Red' ) white = info.add( viz.RADIO, 0, 'White' ) blue = info.add( viz.RADIO, 0, 'Blue' ) #Set callbacks for changing color with radio buttons vizact.onbuttondown( red, male.color, viz.RED ) vizact.onbuttondown( white, male.color, viz.WHITE ) vizact.onbuttondown( blue, male.color, viz.BLUE ) vizact.onbuttondown( red, female.color, viz.RED ) vizact.onbuttondown( white, female.color, viz.WHITE ) vizact.onbuttondown( blue, female.color, viz.BLUE ) #colors end=================== #====================INFO WINDOW OPTIONS#============ def keyboardEvent( key ): if key == 'e': info.expand() #Maximize info box elif key == 's': info.shrink() #Minimize info box elif key == 'm': info.message( viz.input('Your employee\n\'s name:') ) #Change directions message elif key == 't': info.title( viz.input('Enter title text:') ) #Change title message viz.callback( viz.KEYBOARD_EVENT, keyboardEvent ) #======================INFO WINDOW OPTIONS def sliderEvent( pos ): #Make wheelbarrow spin according to slider position male.runAction( vizact.spin(0, -1, 0, 500 * pos) ) female.runAction( vizact.spin(0, -1, 0, 500 * pos) ) vizact.onslider( slider, sliderEvent ) #=====================actions of characters - MALE========================# def mykeyboard(key): if key == '1': male.state(1) elif key == '2': male.state(2) elif key == '3': male.state(3) elif key == '4': male.state(4) elif key == '5': male.state(5) elif key == '6': male.state(6) elif key == '7': male.state(7) elif key == '8': male.state(8) elif key == '9': male.state(9) elif key == '0': male.state(10) elif key == 'a': male.state(11) elif key == 'b': male.state(12) elif key == 'c': male.state(13) elif key == 'd': male.state(14) elif key == 'e': male.state(15) viz.callback(viz.KEYBOARD_EVENT,mykeyboard) #=====================actions of characters - FEMALE========================# def mykeyboard(key): if key == '1': female.state(1) elif key == '2': female.state(2) elif key == '3': female.state(3) elif key == '4': female.state(4) elif key == '5': female.state(5) elif key == '6': female.state(6) elif key == '7': female.state(7) elif key == '8': female.state(8) elif key == '9': female.state(9) elif key == '0': female.state(10) elif key == 'a': female.state(11) elif key == 'b': female.state(12) elif key == 'c': female.state(13) elif key == 'd': female.state(14) elif key == 'e': female.state(15) viz.callback(viz.KEYBOARD_EVENT,mykeyboard) #------------------adding a slider to change the heads #add slider for smile smile_slider = viz.add(viz.SLIDER) smile_slider.translate(0.25,0.1) #slider 2 for face more to the world ollie_slider = viz.add(viz.SLIDER) ollie_slider.translate(0.75,.1) #------------------end slider #---------morph head #add two differnt face images first_texture = viz.add('stan.jpg') second_texture = viz.add('ollie.jpg') #paste both faces to the head male_morphing_face.texture(first_texture) male_morphing_face.texture(second_texture, '',1) female_morphing_face.texture(first_texture) female_morphing_face.texture(second_texture, '',1) #frag program to blend textures blend = viz.add('multiexblend.fp') male_morphing_face.apply(blend) blend.param(0,0) #bledning it #5 female_morphing_face.apply(blend) blend.param(0,0) #bledning it #--------------end morph head #--------slider function #Define the slider function to handle the information #from the sliders. def myslider(obj,pos): if obj == smile_slider: #Morph the face to its first (0) morph target. male_morphing_face.morph(0,pos) female_morphing_face.morph(0,pos) if obj == ollie_slider: #Blend the fact texture to the second texture. blend.param(0,pos) #Morph the face to its second (1) morph target. male_morphing_face.morph(1,pos) female_morphing_face.morph(1,pos) viz.callback(viz.SLIDER_EVENT,myslider) ##INFOBOX smile_box = vizinfo.add( 'This tutorial demonstrates the use of the vizinfo module.' ) smile_box.translate( .40, .1 ) #Initialize info box with some instructions smile_box = vizinfo.add( 'Check out the smile' ) smile_box.title( 'Smile' ) #Set title text smile_box.drag( viz.ON ) #Make the title bar draggable |
#4
|
|||
|
|||
Thanks, that's much better now. The problem is that the if block starting on the line if obj == ollie_slider: is not indented properly. You need to indent that block of code so that it is part of the myslider function. Otherwise, that code is part of the global scope, which does not contain an obj variable, hence the error.
|
#5
|
|||
|
|||
thankyou
thanks a lot, its always the simple ones that catch me out!
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
quick display question | timbo | Vizard | 1 | 07-09-2008 03:53 PM |
Quick Question | nige777 | Vizard | 5 | 05-08-2008 05:50 AM |