#1
|
|||
|
|||
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) Code:
viz.collision(viz.ON) def onCollision(info): viz.MainView.reset(viz.HEAD_POS) viz.callback(viz.COLLISION_EVENT,onCollision) |
#2
|
|||
|
|||
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() |
#3
|
|||
|
|||
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) 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) Any other ideas? Isn't possible to change the default of viz.HEAD_POS? |
#4
|
|||
|
|||
What do you have loaded in your scene? Can you post an example script that reproduces the error?
|
#5
|
|||
|
|||
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 |
#6
|
|||
|
|||
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) Masaki |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Change model alpha and memory leak | hosier | Vizard | 2 | 06-25-2009 10:55 AM |
writing joystick position to a data file | Saz | Vizard | 3 | 12-17-2008 05:18 AM |
How can you dynamically change the gain on a tracker-based CaveView? | michaelrepucci | Vizard | 2 | 09-23-2008 07:18 AM |
Randomly and Continuously Change Avatar's Face Texture | Karla | Vizard | 4 | 08-22-2008 12:14 PM |
Avatar always returns in initial position | pattie | Vizard | 2 | 08-31-2006 08:15 PM |