WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Precision Position Tracker (PPT) (https://forum.worldviz.com/forumdisplay.php?f=9)
-   -   Regarding Viconnect viewpoint (https://forum.worldviz.com/showthread.php?t=5711)

rajnishv 05-05-2016 02:48 AM

Regarding Viconnect viewpoint
 
Hi Jeff,
#-----------------First Query------------------------------#

1) I want to move my viewpoint to specific point on keyboard event.
I tried using :-


"""
This is a very simple demo, but it also illustrates the use of viewpoints with
vizconnect.

Viewpoints are a method for forcing a display to be at a particular location.
The sample viewpoint in this script places the user at the top of a balcony.

You can test the effect of setting the viewpoint by adjusting the position values
for the viewpoint at the bottom of the script
"""

import viz
import vizact
import vizconnect


# start the vizconnect session stored in the given directory
vizconnect.go("vizconnect_config.py")

# oriMode sets what the viewpoint is resetting to. For example...
# vizconnect.VIEWPOINT_MATCH_DISPLAY
# matches orientation of the display to the orientation of the viewpoint
#
# vizconnect.VIEWPOINT_MATCH_FEET
# matches orientation of the feet to the orientation of the viewpoint
#
# vizconnect.VIEWPOINT_MATCH_BASE
# matches orientation of the base object (transport, avatar, tracker) to the orientation of the viewpoint
#
# Similar for posMode
oriMode = vizconnect.VIEWPOINT_MATCH_DISPLAY
posMode = vizconnect.VIEWPOINT_MATCH_FEET

# Add a viewpoint.
vp = vizconnect.addViewpoint( pos=[-13.24803, 12.28260, 8.83578],
euler=[90, 0, 0],
posMode=posMode,
oriMode=oriMode,
constant=False,
)

# Displays are added to viewpoints, the viewpoint will traverse the scenegraph to
# determine if the display is attached to an avatar, tracker, etc in order to
# perform the requested resets.
vp.add(vizconnect.getDisplay())

# Call reset viewpoints, which forces the display into the viewpoint position.
# This function can be called as often as desired, it is currently also mapped
# onto the insert button.
vizconnect.resetViewpoints()
# add a reset key so when r is pressed the user is moved back back to the viewpoint
vizact.onkeydown('r', vizconnect.resetViewpoints)


# add an environment
viz.add('piazza.osgb')

def onKeyDown(key):
global vp
print key, ' is down.'
if key == viz.KEY_TAB:
print 'you hit the tab key'
vp1 = vizconnect.addViewpoint(pos=[-16.24803, 8.28260, 8.83578],euler=[90, 0, 0],posMode=posMode,oriMode=oriMode,constant=False)

viz.callback(viz.KEYDOWN_EVENT,onKeyDown)

But the viewpoint doesn't change the position on event..for the above code.

#------------------2nd query---------------------#

Secondly i want to change and animate viewpoint(view point of vizconnect not the main view)

And i want to apply action on the viewpoint(viewpoint of vizconnect)
I dont want to apply actions on MainView..

I have tried using and will use the example of dcoumentaion


#link = viz.link(vp, viz.MainView)
#Set the animation speed and mode
SPEED = 4.5
MODE = viz.SPEED
ROTATE_MODE = viz.NO_ROTATE

def SetRotateMode(mode):
global ROTATE_MODE
ROTATE_MODE = mode

def AnimateView(pos):
action = vizact.goto(pos,SPEED,MODE,pivot=(0,1,0),rotate_mo de=ROTATE_MODE)
viz.MainView.runAction(action)(here i want vizconnect viewpoint instead of main view)

#Setup keyboard events
vizact.onkeydown('1',AnimateView,[0,10,-30])
vizact.onkeydown('2',AnimateView,[30,10,0])
vizact.onkeydown('3',AnimateView,[0,10,30])
vizact.onkeydown('4',AnimateView,[-30,20,0])


#Start off by moving to the first location
AnimateView([-16.24803, 8.28260, 8.83578])

Thank You
waiting for ur reply

rajnishv 05-05-2016 04:28 AM

Vizconnect Viewpoint animation via transport.
 
Thank you Jeff, I managed it via Transport..:

The updated code to move the viewpoint...

Code:


#Set the animation speed and mode
SPEED = 12,000
MODE = viz.SPEED
ROTATE_MODE = viz.NO_ROTATE

def gotoViewPointAmeniteis(pos):
global vp
#action = vizact.goto(pos,SPEED,MODE,pivot=(0,1,0),rotate_mo de=ROTATE_MODE)
action = vizact.goto(pos,SPEED,MODE,pivot=vizconnect.getVie wpointDict(),rotate_mode=ROTATE_MODE)
vizconnect.getTransport().getNode3d().runAction(ac tion)


Cheers!!
Thank you
World Viz
Especially Jeff and Kevin

arshbot 03-20-2017 07:50 AM

Is gotoViewPointAmeniteis a callback? How is it run? Should the method be called where a trigger occurs?

rajnishv 03-20-2017 11:03 PM

Hi ArshBot,

I have replied to ur post,pls refer the link:
http://forum.worldviz.com/showthread.php?t=5981

OR

In the above code you have written which links the model and the transports node(containing viewpoint) that is :viz.link(transport.getNode3d(), candela).
That the reason user along with the model is moving.
Pls remove this line of code or comment it.

To understand better on using transports in vizconnect,pls refer tutorials from documentation on Inputs and Transports from Vizconnect Section.

Link:
http://docs.worldviz.com/vizard/vizc...navigators.htm


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

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