WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 06-06-2014, 06:48 AM
befl0 befl0 is offline
Member
 
Join Date: Jun 2014
Posts: 13
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
Reply With Quote
  #2  
Old 06-07-2014, 06:25 AM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
Can you post example code that shows the problem you're having?
Reply With Quote
  #3  
Old 06-09-2014, 02:37 AM
befl0 befl0 is offline
Member
 
Join Date: Jun 2014
Posts: 13
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
Attached Files
File Type: zip ramp.zip (903 Bytes, 3570 views)
Reply With Quote
  #4  
Old 06-10-2014, 12:42 AM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
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.
Reply With Quote
  #5  
Old 06-10-2014, 02:49 AM
befl0 befl0 is offline
Member
 
Join Date: Jun 2014
Posts: 13
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.
Reply With Quote
  #6  
Old 06-10-2014, 08:09 AM
befl0 befl0 is offline
Member
 
Join Date: Jun 2014
Posts: 13
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
Reply With Quote
  #7  
Old 06-10-2014, 09:18 AM
befl0 befl0 is offline
Member
 
Join Date: Jun 2014
Posts: 13
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
Reply With Quote
  #8  
Old 06-11-2014, 02:08 AM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
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()
Reply With Quote
  #9  
Old 06-17-2014, 07:02 AM
befl0 befl0 is offline
Member
 
Join Date: Jun 2014
Posts: 13
Thanks you a lot it's working!
Reply With Quote
  #10  
Old 07-21-2014, 02:50 AM
befl0 befl0 is offline
Member
 
Join Date: Jun 2014
Posts: 13
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
Reply With Quote
  #11  
Old 07-24-2014, 12:21 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
It's difficult to understand the issue without some example code that reproduces it.
Reply With Quote
  #12  
Old 07-28-2014, 07:42 AM
befl0 befl0 is offline
Member
 
Join Date: Jun 2014
Posts: 13
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
Reply With Quote
  #13  
Old 07-29-2014, 07:06 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
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])
Reply With Quote
  #14  
Old 07-30-2014, 02:49 AM
befl0 befl0 is offline
Member
 
Join Date: Jun 2014
Posts: 13
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
Reply With Quote
  #15  
Old 07-30-2014, 03:28 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
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.
Reply With Quote
Reply

Tags
avatar, climp, collision, ramp


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


All times are GMT -7. The time now is 06:18 AM.


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