WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Terrain Following (https://forum.worldviz.com/showthread.php?t=5697)

ruiying 04-18-2016 07:10 AM

Terrain Following
 
Isn't there any quick way to do terrain following in Vizard?

Thanks
Ruiying

Jeff 04-20-2016 01:13 AM

You could detect the ground height using an intersection test and then adjust the height of the viewpoint or object that is flying above. Here is a basic example:

Code:

'''
Use up/down arrows to move view
'''

import viz
import vizact
import vizinfo

viz.setMultiSample(4)
viz.fov(60)
viz.go()

vizinfo.InfoPanel(align=viz.ALIGN_RIGHT_TOP)

viz.clearcolor(viz.SLATE)
viz.addChild('ground.osgb')
viz.move([0,0,-2])

quad = viz.addTexQuad(pos=[0,0,4.5],euler=[0,65,0],scale=[2,10,1],color=viz.RED)
quad2 = viz.addTexQuad(pos=[0,0,13.55],euler=[180,65,0],scale=[2,10,1],color=viz.RED)

vizact.whilekeydown(viz.KEY_UP,viz.MainView.setPosition,[0,0,0.05],viz.REL_LOCAL)
vizact.whilekeydown(viz.KEY_DOWN,viz.MainView.setPosition,[0,0,-0.05],viz.REL_LOCAL)

def adjustHeight():
        x,y,z = viz.MainView.getPosition()
        info = viz.intersect([x,y+0.5,z],[x,y-4,z])
        groundHeight = info.point[1]
        viz.MainView.setPosition([x,groundHeight+3,z])
       
vizact.onupdate(0,adjustHeight)



All times are GMT -7. The time now is 04:19 PM.

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