WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 12-19-2014, 01:14 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
You can do an intersection test to find out the height of the ground below the avatar and then adjust the avatar's height:

Code:
'''
Use up/down arrows to move avatar
'''

import viz
import vizact
import vizmat
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)

avatar = viz.addAvatar('vcc_male2.cfg')
avatar.disable(viz.INTERSECTION)
avatar.state(2)

vizact.whilekeydown(viz.KEY_UP,avatar.setPosition,[0,0,0.03],viz.REL_LOCAL)
vizact.whilekeydown(viz.KEY_DOWN,avatar.setPosition,[0,0,-0.03],viz.REL_LOCAL)

def adjustHeight():
	x,y,z = avatar.getPosition()
	info = viz.intersect([x,y+0.5,z],[x,y-0.5,z])
	groundHeight = info.point[1]
	avatar.setPosition([x,groundHeight,z])
	
vizact.onupdate(0,adjustHeight)
	
view = viz.addView()
view.setPosition([-20,5,9])
view.setEuler([90,15,0])
window = viz.addWindow(view=view)
window.setSize([.4,.4])
window.setPosition([0,1])
Reply With Quote
  #2  
Old 12-22-2014, 12:43 AM
SUJITH_KJ SUJITH_KJ is offline
Member
 
Join Date: Mar 2014
Posts: 7
Thank you Jeff, that was useful.. Can v do it with vizact.walkTo command also?
Reply With Quote
  #3  
Old 12-22-2014, 01:46 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
Yes, you can give a model name as the Y position of the walkTo command. The walkTo will adjust the height of the avatar to match the height of the model:

Code:
import viz
import vizact
import vizmat

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

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.50],euler=[180,65,0],scale=[2,10,1],color=viz.RED)

avatar = viz.addAvatar('vcc_male2.cfg')
avatar.disable(viz.INTERSECTION)
avatar.state(2)

walk1 = vizact.walkTo([0,0,4.5],walkSpeed=2)
walk2 = vizact.walkTo([0,quad,9],walkSpeed=2)
walk3 = vizact.walkTo([0,quad2,13.55],walkSpeed=2)

walk = vizact.sequence([walk1,walk2,walk3])
avatar.runAction(walk)
	
view = viz.addView()
view.setPosition([-20,5,9])
view.setEuler([90,15,0])
window = viz.addWindow(view=view)
window.setSize([.4,.4])
window.setPosition([0,1])
Reply With Quote
  #4  
Old 01-19-2015, 05:57 PM
SUJITH_KJ SUJITH_KJ is offline
Member
 
Join Date: Mar 2014
Posts: 7
Thank you Jeff for the previous programs.. Can the avatar also be made to climb stairs which is vertical? . The above programs work well for stairs which is inclined.. but i am not sure how to do it for stairs which is vertical
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
problem with avatar climp a ramp befl0 Vizard 14 07-30-2014 02:28 PM
.osg biped avatar problem alvinadi Vizard 3 12-20-2011 10:29 AM
Avatar speaking problem Uttama_vizard Vizard 4 03-23-2009 11:29 AM
Problem with letting an avatar face towards another avatar ghazanfar Vizard 2 03-21-2007 02:30 AM
making a talking and imitating avatar marc van gaal Vizard 9 10-20-2006 04:28 AM


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


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