WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   problem with avatar climp a ramp (https://forum.worldviz.com/showthread.php?t=5061)

befl0 06-06-2014 05:48 AM

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 :)

Jeff 06-07-2014 05:25 AM

Can you post example code that shows the problem you're having?

befl0 06-09-2014 01:37 AM

1 Attachment(s)
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

Jeff 06-09-2014 11:42 PM

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.

befl0 06-10-2014 01:49 AM

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.

befl0 06-10-2014 07:09 AM

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

befl0 06-10-2014 08:18 AM

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

Jeff 06-11-2014 01:08 AM

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()


befl0 06-17-2014 06:02 AM

Thanks you a lot it's working!

befl0 07-21-2014 01:50 AM

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

Jeff 07-24-2014 11:21 AM

It's difficult to understand the issue without some example code that reproduces it.

befl0 07-28-2014 06:42 AM

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

Jeff 07-29-2014 06:06 PM

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])


befl0 07-30-2014 01:49 AM

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

Jeff 07-30-2014 02:28 PM

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.


All times are GMT -7. The time now is 01:38 PM.

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