ruiying
04-18-2016, 07:10 AM
Isn't there any quick way to do terrain following in Vizard?
Thanks
Ruiying
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:
'''
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.setPos ition,[0,0,0.05],viz.REL_LOCAL)
vizact.whilekeydown(viz.KEY_DOWN,viz.MainView.setP osition,[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)
vBulletin® v3.8.7, Copyright ©2000-2024, vBulletin Solutions, Inc.