WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   setPosition() and collision (https://forum.worldviz.com/showthread.php?t=5279)

mape2k 02-08-2015 08:05 AM

setPosition() and collision
 
Hello,

I have a question about the setPosition() function, specifically when using it to move the viewpoint:

when I enable collision for the viewpoint (by viz.MainView.collision(viz.ON)), the setPosition() command will not move the viewpoint when there is an object in the path to the desired position. This is very counter intuitive and has caused me some frustration with a complex scene with complex movement command (I thought the error was in my coding!).

Is there a better way to move the viewpoint around? Right now I have to disable collision and re-enable it whenever I move the viewpoint.

Here is a small example:

Code:

import viz
import viztask
import vizshape

arena = viz.addChild('pit.osgb')

view = viz.MainView
view.collision(viz.ON)

eyelvl = 2

def main():

        view.setEuler(0,0,0)
        view.setPosition([0,eyelvl,0])
       
        yield viztask.waitKeyDown('b')
       
        view.setPosition([0,eyelvl,8])
       
        yield viztask.waitKeyDown('b')
       
        view.setPosition([0,eyelvl,0])
       
        cube1 = vizshape.addBox(size = [1,1,1],splitFaces = True)
        cube1.setPosition([0,eyelvl,6])
        cube1.color(viz.RED)
       
        cube2 = vizshape.addBox(size = [1,1,1],splitFaces = True)
        cube2.setPosition([-2,eyelvl,6])
        cube2.color(viz.GREEN)
       
        yield viztask.waitKeyDown('b')
       
        view.setPosition([0,eyelvl,8])
       
        yield viztask.waitKeyDown('b')
       
        cube2.setPosition([2,eyelvl,6])
       
viztask.schedule(main())

viz.go()

Best regards from Germany,
Johannes

Jeff 02-10-2015 08:45 AM

It sounds like you've found a good workaround. I'll let our developers know about this issue and if they have other suggestions I'll reply here.

mape2k 02-18-2015 06:07 AM

Thank you!


All times are GMT -7. The time now is 11:53 PM.

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