WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 04-18-2016, 07:10 AM
ruiying ruiying is offline
Member
 
Join Date: Apr 2016
Posts: 1
Terrain Following

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

Thanks
Ruiying
Reply With Quote
  #2  
Old 04-20-2016, 01:13 AM
Jeff Jeff is online now
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,466
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)
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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


All times are GMT -7. The time now is 01:12 AM.


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