View Single Post
  #1  
Old 03-20-2017, 08:26 AM
arshbot arshbot is offline
Member
 
Join Date: Mar 2017
Posts: 8
Model moves with Vizconnect

import viz
import vizact
import vizconnect


# start the vizconnect session stored in the given directory
vizconnect.go("HTC_Config.py")
vizconnect.getTransport('main_transport')

oriMode = vizconnect.VIEWPOINT_MATCH_DISPLAY
posMode = vizconnect.VIEWPOINT_MATCH_FEET


current_pos=[-53.32425, -0.78460, -29.09994]
vp=vizconnect.addViewpoint( pos=current_pos,
posMode=posMode,
oriMode=oriMode,
constant=False,
)
mylight = viz.addSpotLight(spread=180, pos=(10, 100, 0))
mylight.intensity(100)
vp.add(vizconnect.getDisplay())
vizconnect.resetViewpoints()

# add an environment
candela = viz.add('foo.osgb')

viz.add('tut_ground.wrl')

view = viz.MainView
viz.clearcolor(viz.SKYBLUE)

SPEED = 12.0
MODE = viz.SPEED

transport = vizconnect.getTransport('main_transport')
viz.link(transport.getNode3d(), candela)

viz.MainView.move([0,0,-6])

def gotoViewPointAmeniteis(pos):
........global vp
........action = vizact.goto(pos,SPEED,MODE,pivot=vizconnect.getVie wpointDict())
........vizconnect.getTransport('main_transport'). getNode3d().runAction(action)

def move():
........if viz.key.isDown(viz.KEY_UP):
................print 'key is up'
................#view.move([0,0,MOVE_SPEED*viz.elapsed()],viz.BODY_ORI
................global current_pos
................current_pos[2] += 5
................gotoViewPointAmeniteis(current_pos )
........elif viz.key.isDown(viz.KEY_DOWN):
................print 'key is down'
................#view.move([0,0,-MOVE_SPEED*viz.elapsed()],viz.BODY_ORI
................current_pos[2] -= 5
................gotoViewPointAmeniteis(current_pos )

vizact.ontimer(0, move)




The script I have attempts to move the user throughout the model, however what I have learned is happening is that the model that is the main environment is moving with the user, instead of being stationary. I learned this because of the spotlight. The spotlight is stationary while the rest of the model moves. How can I lock the model in place so the user can move about? I am also using an HTC Vive and would like to use the wands to move, but for now I am content with using the keyboard since it's simpler.
Reply With Quote