WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 02-18-2009, 12:51 AM
Moh200jo Moh200jo is offline
Member
 
Join Date: Feb 2009
Posts: 99
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
Reply With Quote
  #2  
Old 02-18-2009, 02:16 AM
DrunkenBrit DrunkenBrit is offline
Member
 
Join Date: Dec 2008
Location: England
Posts: 25
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
__________________
Software Developer
Virtalis Ltd.
www.virtalis.com
Reply With Quote
  #3  
Old 02-18-2009, 02:36 AM
DrunkenBrit DrunkenBrit is offline
Member
 
Join Date: Dec 2008
Location: England
Posts: 25
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.
__________________
Software Developer
Virtalis Ltd.
www.virtalis.com

Last edited by DrunkenBrit; 02-18-2009 at 02:38 AM.
Reply With Quote
  #4  
Old 02-18-2009, 01:07 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
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])
Reply With Quote
  #5  
Old 02-19-2009, 12:32 AM
DrunkenBrit DrunkenBrit is offline
Member
 
Join Date: Dec 2008
Location: England
Posts: 25
Thanks for the info.
__________________
Software Developer
Virtalis Ltd.
www.virtalis.com
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Linking problems with Live Character Frank Verberne Vizard 5 06-04-2008 11:42 AM
Looking through the eyes of an avatar Frank Verberne Vizard 2 04-01-2008 05:52 AM


All times are GMT -7. The time now is 07:35 PM.


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