View Single Post
  #1  
Old 05-05-2016, 02:48 AM
rajnishv rajnishv is offline
Member
 
Join Date: Jan 2016
Location: Kalina,Sanatcruz(East),Mumbai,Maharashtra,India
Posts: 94
Smile 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
Reply With Quote