WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   mainview (https://forum.worldviz.com/showthread.php?t=1822)

Moh200jo 02-18-2009 12:51 AM

mainview
 
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.
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

Code:

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:

Code:

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:

Code:

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.

Jeff 02-18-2009 01:07 PM

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

Code:

view = viz.MainView
link = viz.link(female, view)
link.preTrans([0,0,-1])


DrunkenBrit 02-19-2009 12:32 AM

Thanks for the info.


All times are GMT -7. The time now is 02:49 AM.

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