![]() |
|
|
|
#1
|
|||
|
|||
|
Terrain Following
Isn't there any quick way to do terrain following in Vizard?
Thanks Ruiying |
|
#2
|
|||
|
|||
|
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)
|
![]() |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Infinite Terrain DLC | Pip | Vizard | 0 | 08-29-2014 02:03 AM |
| Near and far clipping on infinite terrain | vijaykiran | Vizard | 2 | 01-21-2011 04:59 AM |
| Plain Infinite Terrain + Sky | kovitch | Vizard | 1 | 12-23-2010 12:09 PM |
| How to make avatars to follow terrain while walking? | yyang | Vizard | 1 | 08-04-2008 02:54 PM |
| generate an infinite terrain | vadrian | Vizard | 4 | 09-15-2004 01:09 PM |