|
#1
|
|||
|
|||
problem with avatar climp a ramp
Hey,
I am trying to make the avatar climb a ramp with the collision. But when I detect the collision I can't move forward. But when I make a U-turn with my avatar I can move backward. I don't know why if anyone can help me, thanks |
#2
|
|||
|
|||
Can you post example code that shows the problem you're having?
|
#3
|
|||
|
|||
import viz
import vizact import vizcam import time from StopWatch import StopWatch from Start import Start from Line import Line from Square180 import Square180 from CircledCylinder import CircledCylinder from EightFigure import EightFigure from Square360 import Square360 from ReverseGate import ReverseGate viz.setMultiSample(4) viz.fov(60) viz.go(viz.FULLSCREEN) #This code adds a ground for them to stand on. env = viz.addChild('ground_grass.osgb') env.collidePlane() Light = viz.add(viz.LIGHT) Light.position(0,1,0,0) Light.intensity(1) Light.spread(180) view=viz.MainView viz.phys.enable() male = viz.addAvatar('vcc_male2.cfg') male.state(6) view.setPosition(0,0.3,0) link = viz.link(view, male) link.preTrans([0,-0.8,0.45]) link.setEuler([None,-20,None]) #link.preTrans([0,-0.12,0.35]) MOVE_SPEED = 5 TURN_SPEED = 60 viz.phys.enable() def updateMove(): if viz.key.isDown(viz.KEY_UP): view.move([0,0,+MOVE_SPEED*viz.elapsed()],viz.BODY_ORI) elif viz.key.isDown(viz.KEY_DOWN): view.move([0,0,-MOVE_SPEED*viz.elapsed()],viz.BODY_ORI) elif viz.key.isDown(viz.KEY_RIGHT): view.setEuler([TURN_SPEED*viz.elapsed(),0,0],viz.BODY_ORI,viz.REL_PARENT) elif viz.key.isDown(viz.KEY_LEFT): view.setEuler([-TURN_SPEED*viz.elapsed(),0,0],viz.BODY_ORI,viz.REL_PARENT) pass vizact.ontimer(0,updateMove) rampe=viz.addChild('rampe.wrl') rampe.setPosition(0,0,1) rampe.setEuler(0,90,0) rampe.collideBox() rampe.disable(viz.DYNAMICS) rFootBox = viz.add('box.wrl',scale=[0.1,0.1,0.1]) rFootBox.collideBox() rFootBox.disable(viz.DYNAMICS) rFootBox.enable(viz.COLLIDE_NOTIFY) rFoot = male.getBone('Bip01 R Foot') rFoot.lock() rFootLink = viz.link( rFoot , rFootBox ) rFootLink.preTrans([0.05,0.15,0.18]) rFootBox.disable(viz.RENDERING) lFootBox = viz.add('box.wrl',scale=[0.1,0.1,0.1]) lFootBox.collideBox() lFootBox.disable(viz.DYNAMICS) lFootBox.enable(viz.COLLIDE_NOTIFY) lFoot = male.getBone('Bip01 L Foot') lFoot.lock() lFootLink = viz.link( lFoot , lFootBox ) lFootLink.preTrans([0,0.15,0.18]) lFootBox.disable(viz.RENDERING) def collidBox(e): global poleArray if (e.obj1 == rFootBox) or (e.obj1 == lFootBox): if(e.obj2==rampe): view.collision(viz.ON) view.gravity(9.8) viz.collision(viz.OFF) viz.callback(viz.COLLIDE_BEGIN_EVENT,collidBox) This is my code. I put the ramp I create with sketchup in a zip folder. Thanks |
#4
|
|||
|
|||
I'm not sure I understand your code. What is the reason for setting up physics on the avatar if it's linked to the viewpoint? Perhaps all you need is viewpoint collision with the stepsize command to control when the viewpoint and avatar stops or moves up/down the ramp. Take a look at the viewpoint collision tutorial for more on this topic.
|
#5
|
|||
|
|||
I put collidebox on the avatar for other reasons. So when I put the view.collision(viz.ON) at first in my programm but after the view.setPosition(), my avatar was not allowed to move forwards. But I can do a U-turn with him and move backwards. So I really don't know why.
Thanks for helping me. |
#6
|
|||
|
|||
I found why. I put the view on the knees of my avatar and the view detected that like an obstacle. It's possible to put the avatar in not obstacles?
Thanks |
#7
|
|||
|
|||
I asked a wrong question, it is possible to disable the collision between the view and the avatar but not between avatar and others objects ? Thanks
|
#8
|
|||
|
|||
Yes, here's an example. The viewpoint will go through the avatar but the ball will collide with it:
Code:
import viz viz.go() viz.collision(viz.ON) viz.eyeheight(1.5) viz.phys.enable() dojo = viz.addChild('dojo.osgb') dojo.collideMesh() avatar = viz.addAvatar('vcc_male2.cfg',pos=[0,0,5],euler=[180,0,0]) avatar.collideBox() avatar.disable(viz.INTERSECTION) ball = viz.addChild('beachball.osgb',pos=[0,5,5]) ball.collideSphere() |
#9
|
|||
|
|||
Thanks you a lot it's working!
|
#10
|
|||
|
|||
Hi,
I meet a problem again with this situation. I have no longer avatar and the view is controlled by the vizard glasses. The wheelchair is controlled by that : http://www.worldviz.com/newsletter/w...nica-de-madrid So when I want to climb the ramp the wheelchair go through it. I enable the physics, the collision, my ramp is a collideBox. I hope your understand my issue and you can help me. Thank you in advance Bérengère |
#11
|
|||
|
|||
It's difficult to understand the issue without some example code that reproduces it.
|
#12
|
|||
|
|||
Hi,
It's difficult to put a code because it's working with a VRPN. I hope I will be more explicit. I controlled a wheelchair to do a race. In this race the wheelchair have to climb the ramp I had in this topic. But the viewpoint is controlled by the glasses so the viz.collision(viz.ON) is not working. So I don't know how to climb the ramp to the wheelchair. I hope I was more clear. Thanks |
#13
|
|||
|
|||
Here's an example where the wheelbarrow goes up a ramp with the viewpoint:
Code:
import viz viz.setMultiSample(4) viz.fov(60) viz.go() viz.clearcolor(viz.SLATE) viz.addChild('ground.osgb') viz.MainView.collision( viz.ON ) #Make gravity weaker. viz.MainView.gravity(2) quad = viz.addTexQuad(pos=[0,0,4],euler=[0,65,0],scale=[2,10,1],color=viz.RED) quad2 = viz.addTexQuad(pos=[0,0,14],euler=[180,65,0],scale=[2,10,1],color=viz.RED) wheelbarrow = viz.addChild('wheelbarrow.ive') #Disable intersection so wheelbarrow does not collide with view wheelbarrow.disable(viz.INTERSECTION) wheelLink = viz.link(viz.MainView,wheelbarrow) #move wheelbarrow to ground level wheelLink.preTrans([0,-1.8,0]) 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]) |
#14
|
|||
|
|||
Hi!
this code works thanks to the viewpoint collision but if you put the wheelbarrow 2 meters in front of the view, it is possible to goes up the ramp before the viewpoint collide the ramp ? Thanks |
#15
|
|||
|
|||
No, if the viewpoint is offset from the wheelbarrow the viewpoint collision won't work here. You can control the wheelbarrow directly and link the viewpoint to it with an offset. The wheelbarrow's height has to be manually adjusted each frame according to the height of the ground to go up the ramp. You can use the viz.intersect command to help determine the height of the ground.
|
Tags |
avatar, climp, collision, ramp |
Thread Tools | |
Display Modes | Rate This Thread |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Avatar Material Problem | Erikvdb | Vizard | 1 | 03-04-2014 04:46 AM |
Unexpected Avatar lookAt() behavior when using yield statements | chris2307 | Vizard | 2 | 12-17-2013 03:58 AM |
.osg biped avatar problem | alvinadi | Vizard | 3 | 12-20-2011 11:29 AM |
Avatar speaking problem | Uttama_vizard | Vizard | 4 | 03-23-2009 12:29 PM |
Problem with letting an avatar face towards another avatar | ghazanfar | Vizard | 2 | 03-21-2007 03:30 AM |