WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 09-16-2010, 05:48 AM
kay kay is offline
Member
 
Join Date: Oct 2009
Posts: 10
Change position of MainView after COLLISION_EVENT

hi,

I would like to set the MainView to a new position after there was a COLLISION_EVENT. Calling viz.MainView.setPosition(...) leads to a "RuntimeError: maximum recursion depth exceeded".

Code:
viz.collision(viz.ON)

def onCollision(info):
	viz.MainView.setPosition([0,0,0])

viz.callback(viz.COLLISION_EVENT,onCollision)
Using viz.MainView.reset(viz.HEAD_POS) works. But how do I change the reset position? The default is (0,1.82,0).

Code:
viz.collision(viz.ON)

def onCollision(info):
	viz.MainView.reset(viz.HEAD_POS)

viz.callback(viz.COLLISION_EVENT,onCollision)
Thank you very much for suggestions.
Reply With Quote
  #2  
Old 09-16-2010, 12:54 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
You're getting that error in the first piece of code because the viewpoint is being placed in a location that causes a collision when the collision event occurs.

In the second piece of code the viewpoint is set to [0,1.82,0] unless the eyeheight has been changed. That command will always move the view above the origin.

If you want to move the viewpoint somewhere else use
Code:
viz.MainView.setPosition()
but make sure the position is not at ground level or colliding with another object.
Reply With Quote
  #3  
Old 09-17-2010, 04:59 AM
kay kay is offline
Member
 
Join Date: Oct 2009
Posts: 10
hi jeff,

I tried viz.MainView.setPosition() with other positions (non-colliding!), e.g., simply

Code:
viz.collision(viz.ON)

def onCollision(info):
	viz.MainView.setPosition([0,1.82,0])

viz.callback(viz.COLLISION_EVENT,onCollision)
I still get the "RuntimeError: maximum recursion depth exceeded". Calling viz.MainView.setPosition(), e.g.,

Code:
viz.collision(viz.ON)

def onCollision(info):
        viz.MainView.reset(viz.HEAD_POS)
	viz.MainView.setPosition([0,1.82,0])

viz.callback(viz.COLLISION_EVENT,onCollision)
also leads to the RuntimeError.

Any other ideas? Isn't possible to change the default of viz.HEAD_POS?
Reply With Quote
  #4  
Old 09-17-2010, 03:21 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
What do you have loaded in your scene? Can you post an example script that reproduces the error?
Reply With Quote
  #5  
Old 09-23-2010, 06:09 AM
kay kay is offline
Member
 
Join Date: Oct 2009
Posts: 10
hi,

i tried to find a reproducible example. The maximum recursion depth error doesn't appear allways. Often everything work smoothly now.

However ... use either the intialPos inside the tunnel and go to the outside and collide with it or use the outside initialPos and collide with the inside of the tunnel in the example below. The error should appear then.

Code:
import viz
viz.go()


ob=viz.add('playground.wrl')
ob.setScale(1.5,1.5,1.5)

#initialPos=[14.,0.75,13.5]  # inside tunnel
initialPos=[6.,0.75,13.5]    # outside tunnel

viz.MainView.setPosition(initialPos) 
viz.MainView.eyeheight(initialPos[1])
viz.collision(viz.ON)                            
viz.MainView.setPosition(initialPos) 

print viz.MainView.getPosition()



def onCollision(info):
    print "collision at ", info.point
    viz.MainView.setPosition(initialPos)
  
viz.callback(viz.COLLISION_EVENT,onCollision)

By the way, here is the full error, maybe this helps to understand what's happening:

Traceback (most recent call last):
File "<string>", line 0, in ?
File "C:\Program Files (x86)\WorldViz\Vizard30/python\viz.py", line 367, in __init__
self.object = _GetNode(data[7])
RuntimeError: maximum recursion depth exceeded
Reply With Quote
  #6  
Old 10-07-2010, 06:06 PM
masaki masaki is offline
Member
 
Join Date: Jan 2008
Posts: 63
Hi,

Try turning collision off before changing the view position, then turn it back on.
Code:
def onCollision(info):
	print "collision at ", info.point
	viz.collision(viz.OFF)   
	viz.MainView.setPosition(initialPos)
	viz.collision(viz.ON)
Best,
Masaki
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
Change model alpha and memory leak hosier Vizard 2 06-25-2009 11:55 AM
writing joystick position to a data file Saz Vizard 3 12-17-2008 06:18 AM
How can you dynamically change the gain on a tracker-based CaveView? michaelrepucci Vizard 2 09-23-2008 08:18 AM
Randomly and Continuously Change Avatar's Face Texture Karla Vizard 4 08-22-2008 01:14 PM
Avatar always returns in initial position pattie Vizard 2 08-31-2006 09:15 PM


All times are GMT -7. The time now is 06:20 AM.


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