WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Model moves with Vizconnect (https://forum.worldviz.com/showthread.php?t=5981)

arshbot 03-20-2017 08:26 AM

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.

rajnishv 03-20-2017 10:57 PM

Hi ArshBot,

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

arshbot 03-23-2017 06:38 AM

Thanks! That did the job!


All times are GMT -7. The time now is 08:33 AM.

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