Thread: View
View Single Post
  #1  
Old 03-11-2009, 08:51 PM
nlfrnassimi nlfrnassimi is offline
Member
 
Join Date: Feb 2009
Posts: 37
View

I have tried to link my view to my avatar and make it first point of view. I have assigned r key to make avatar and view go to a certain point and also created another view to be able to change my view. I have tried to look side, up and down by pressing certain keys but they don't work properly and another problem is that my animated path (r key ) doesn't work now.

Please take a look at my code. and tell me what are the mistakes that I have made.



import viz

viz.go()

viz.add('tut_ground.wrl')

view = viz.MainView

character = viz.add('vcc_male.cfg') # Add a CAL3D based avatar
character.state(1) # Activate the walking state

viewLink = viz.link( character, view)
viewLink.setDstFlag( viz.LINK_HEAD)
viewLink.preTrans( [-.4, .1, 0] )

vizact.whilekeydown(viz.KEY_UP,character.rotate,1, 0,0,vizact.elapsed(-15),viz.REL_PARENT)
vizact.whilekeydown(viz.KEY_DOWN,character.rotate,-1,0,0,vizact.elapsed(-15),viz.REL_PARENT)
vizact.whilekeydown(viz.KEY_RIGHT,character.rotate ,0,1,0,vizact.elapsed(15),viz.REL_PARENT)
vizact.whilekeydown(viz.KEY_LEFT,character.rotate, 0,1,0,vizact.elapsed(-15),viz.REL_PARENT)


def characterWalk (key):
if key == 'r':
character.state(2)
walk = vizact.walkTo([10,0,0],1,45)
character.addAction(walk)

viz.callback(viz.KEYBOARD_EVENT, characterWalk)

secondView = viz.addView()
secondView.setPosition(10,2,20)
secondView.rotate(220)

def anotherView (key):
if key == 'v':
viz.MainWindow.viewpoint(secondView)

viz.callback(viz.KEYBOARD_EVENT, anotherView,priority=1)
Reply With Quote