View Full Version : mainview
Moh200jo
02-18-2009, 12:51 AM
I am trying to make the mainview to keep its moving with the avatar’s moving and speeds as well, I tried with the following simple code. import viz
viz.go()
# add room
room = viz.add('court.ive')
# add subject
female= viz.add('vcc_female.cfg')
female.setPosition([0,0,0])
female.state(2)
walk=vizact.move(0,0,5,5)
female.addAction(walk)
viz.MainView.getPosition(female.getPosition())
print female.getPosition
But does not working
DrunkenBrit
02-18-2009, 02:16 AM
viz.MainView.getPosition(female.getPosition())
You're invoking the wrong function for a start, you need to call 'viz.MainView.setPosition' not 'viz.MainView.getPosition'.
This will only occur once though, you'll need a timer callback function to constantly acquire the position of the avatar and assign it to the main view position.
Something like:
def myTimer(num):
newPosition = female.getPosition()
offset = [0,0,5] # Maybe add an offset so the camera isn't directly ontop of the avatar to keep it in view?
viz.MainView.setPosition(newPosition+offset)
viz.callback(viz.TIMER_EVENT,myTimer) # Pass callback
viz.starttimer(0,0.5,viz.FOREVER) # Start the timer
DrunkenBrit
02-18-2009, 02:36 AM
Sorry, that above callback won't work right...try this:
def myTimer(num):
newPosition = female.getPosition()
newPosition[2] = newPosition[2]-2 # Move back in Z a bit
newPosition[1] = newPosition[1]+1.5 # Move up in Y a bit
viz.MainView.setPosition(newPosition)
print female.getPosition()
Also alter the 'viz.starttimer(0,0.5,viz.FOREVER)' to 'viz.starttimer(0,0.05,viz.FOREVER)' for a smoother motion.
you can also try linking the viewpoint to the avatar. This following lines create a link and then creates an offset so the view is behind the avatar
view = viz.MainView
link = viz.link(female, view)
link.preTrans([0,0,-1])
DrunkenBrit
02-19-2009, 12:32 AM
Thanks for the info.
vBulletin® v3.8.7, Copyright ©2000-2024, vBulletin Solutions, Inc.