WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 09-08-2006, 01:25 PM
pbeeson pbeeson is offline
Member
 
Join Date: Aug 2006
Posts: 31
Collidemesh with Avatars

It seems as if the mesh that collidemesh uses for the Male and Female avatars is the default pose (with their arms outstretched). This is true even is the avatars are in another state (e.g. lady.state(1)). Is there a way to get around this? Or am I doing somehting worng: I am calling collidemesh() after I set the avatar's state.
Reply With Quote
  #2  
Old 09-08-2006, 01:40 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

Setting the state of the avatar does not immediately affect its mesh state. You must wait until the next frame is drawn to ensure the mesh has been modified to reflect the new state. So you need to wait a frame and then call collideMesh() if you want it to reflect the new state.
Reply With Quote
  #3  
Old 09-08-2006, 05:53 PM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
Also, be sure to remove the previous mesh VizPhysicsShape object with <VizNode>.collideNone() if you don't want the old Shape colliding with things or adding to the Avatar's mass.
__________________
Paul Elliott
WorldViz LLC
Reply With Quote
  #4  
Old 09-11-2006, 02:53 PM
pbeeson pbeeson is offline
Member
 
Join Date: Aug 2006
Posts: 31
There is no collideNone() function.

Plus, even if I wait 10 frames, occasionally, I still run into an avatar as if its arms were outstreched even though I waited 10 frames before calling collidemesh() after setting its to state(1) (standing with arms by side).
Reply With Quote
  #5  
Old 09-11-2006, 04:22 PM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
Here is a little script that keeps changing the collideMesh shape of the avatar. I think this is what you want to do. Run it with the latest Vizard Beta release.

Code:
import viz

CHANGE_STATE_TIMER = 0
SET_COLLIDE_SHAPE_TIMER = 1

viz.go()
viz.MainView.setPosition( 0, 2, -5 )
viz.phys.enable()

g = viz.add( 'tut_ground.wrl' )
g.collidePlane()

male = viz.add( 'male.cfg' )
male.currentState = 1
male.state( male.currentState )

def onTimer(num):
	if num == CHANGE_STATE_TIMER:
		male.currentState = (male.currentState+1) % 2
		male.state( male.currentState )
		viz.starttimer( SET_COLLIDE_SHAPE_TIMER, .2, viz.FOREVER )
	elif num == SET_COLLIDE_SHAPE_TIMER:
		male.collideNone()
		male.collideMesh()
		male.disable( viz.DYNAMICS )
	
viz.callback(viz.TIMER_EVENT,onTimer)
viz.starttimer( CHANGE_STATE_TIMER, 3, viz.FOREVER )


ball = viz.add('ball.wrl')
g=ball.collideSphere()

def shootAhead():
	ball.reset()
	view = viz.get(viz.MAIN_VIEWPOINT)
	ball.translate(view.get(viz.HEAD_POS))
	vec = viz.Vector(view.get(viz.VIEW_LOOK)[:3])
	ball.setVelocity(vec*20)
vizact.onkeydown(' ',shootAhead)
__________________
Paul Elliott
WorldViz LLC
Reply With Quote
  #6  
Old 09-11-2006, 04:38 PM
pbeeson pbeeson is offline
Member
 
Join Date: Aug 2006
Posts: 31
I'm not using version 3.0. Thus, I don't have collideNone(). Can you provide me help with version 2.5? I've switched to using collidebox instead of collide mesh for the time being to get around this problem, but I'd like a better answer.

In v 2.5, if you do the following for two avatar then later use collidingwith(), sometimes the collisions occur as if the avatars are in state #1 (correct behavior), and sometimes one or both of the avatars provide collision info as if they were still in the idle pose (arms outstreatched). Can't get this to work properly every time.

Code:
def fixmesh(avatar):
   viz.waitframe(10)
   avatar.collidemesh()

avatar=viz.add('Female.cfg')
avatar.state(1)
avatar.visible(viz.ON)
avatar.translate(x,y,theta)
viz.director(fix_mesh,avatar)
Reply With Quote
  #7  
Old 09-11-2006, 04:50 PM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
I suggest that you start using Vizard 3.0. It has vastly improved physics support. You can download it here:

http://www.worldviz.com/download/?id=9
__________________
Paul Elliott
WorldViz LLC
Reply With Quote
  #8  
Old 09-11-2006, 07:44 PM
pbeeson pbeeson is offline
Member
 
Join Date: Aug 2006
Posts: 31
Although I plan to switch to Vizard 3.0 at some point, given that I need to gather and analyze data for a grant proposal due next week, I'm sticking with version 2.5 for now. So, any help you can give men with my problem in version 2.5 would be welcome.

It's kind of distressing that several of my recent posts on Vizard 2.5 problems have been answered with "switch to version 3.0". If I want to switch to the 3.0 beta, I can only use this for a limited time, then I am unsure as to how much it will cost my supervisor to upgrade our entire lab.

On a more positive note, I have received excellent support on many of the previous problems/questions I've had with Vizard 2.5.

Last edited by pbeeson; 09-11-2006 at 07:57 PM.
Reply With Quote
  #9  
Old 09-11-2006, 08:09 PM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
Let me try and address your very reasonable 3.0 concerns.

--There will be beta licenses avalable until 3.0 is released.
--Upgrading will be free.
--Vizard 3.0 is very backwards compatable. Just give your script a quick spin in 3.0. Even if your project is quite complex I doubt it would take more than an hour of work to migrate over.
__________________
Paul Elliott
WorldViz LLC
Reply With Quote
  #10  
Old 09-11-2006, 08:36 PM
pbeeson pbeeson is offline
Member
 
Join Date: Aug 2006
Posts: 31
Unhappy

So, in desparation, I installed version 3.0, and as I suspected, enough has changed to make it appear infeasible to port my code in 1 day (I am on a bit of a time crunch here).

Mainly, collidingwith doesn't work.

Code:
for x in self.collidables:
   info = x.collidingwith(obj,1)
   print info.intersected
Returns:
True
False
True
False
.
.
.
It flips back and forth between true and false for the entire list of objects.
But, the same code works fine in version 2.5 (note I added the collideNone() commands before the collidemesh() commands before running in v3).

So, given that I can't refactor thousands of lines of code in a day, I was hoping you could solve the original version 2.5 problem. Or fill me in on how to EASILY get v3.0 working --- by easily I mean 1-2 lines of changes (I don't have time to play with the new physics engine and collision events, though they look cool).

Thanks for all the help

Last edited by pbeeson; 09-11-2006 at 08:39 PM.
Reply With Quote
  #11  
Old 09-11-2006, 08:55 PM
pbeeson pbeeson is offline
Member
 
Join Date: Aug 2006
Posts: 31
Problem demonstration

EXAMPLE of bug with v3.0 and collidingwith()

Code:
import viz

CHANGE_STATE_TIMER = 0
SET_COLLIDE_SHAPE_TIMER = 1
CHECK_COLLIDE=2

viz.go()
viz.MainView.setPosition( 0, 0, -25 )

male = viz.add( 'male.cfg' )
male.state(1)
male.translate(10,0,0)

male2 = viz.add( 'male.cfg' )
male2.state(1)
male2.translate(-10,0,0)

def onTimer(num):
	if num == SET_COLLIDE_SHAPE_TIMER:
		male.collideNone()
		male.collideMesh()
		male.disable( viz.DYNAMICS )
		male2.collideNone()
		male2.collideMesh()
		male2.disable( viz.DYNAMICS )
	elif num==CHECK_COLLIDE:
		info=male.collidingwith(male2,1)
		print info.intersected
		
viz.callback(viz.TIMER_EVENT,onTimer)
viz.starttimer( SET_COLLIDE_SHAPE_TIMER, 1, 1 )
viz.starttimer( CHECK_COLLIDE, 2, viz.FOREVER )
Reply With Quote
  #12  
Old 09-11-2006, 08:59 PM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
You can replace the collidewith function with viz.phys.intersectNode()

For your previous for loop collidewith code replace with:

Code:
if x in viz.phys.intersectNode( obj ):
	print 'intersected'
else:
	print 'not intersected'
__________________
Paul Elliott
WorldViz LLC
Reply With Quote
  #13  
Old 09-11-2006, 09:02 PM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
Any other 3.0 migration problems?
__________________
Paul Elliott
WorldViz LLC
Reply With Quote
  #14  
Old 09-11-2006, 09:26 PM
pbeeson pbeeson is offline
Member
 
Join Date: Aug 2006
Posts: 31
It looks like viz.phys.intersectLine is faster than the old viz.intersect. But, the old intersect would ignore objects that were not visible.

1) Is there any way to tell viz.phys.intersectLine to ignore certain objects? object.disable(viz.COLLISION) doesn't seem to work, neither does turning off visibilty.
I can run viz.phys.intersectLine(begin,end,True) to get a list and then check object IDs, but I don't know if there is an easier way (especially considering that if you have many objects, it might be an optimzation to not check for intersections with particular objects at certain times). (This is also where thread 729 ended up).

2) Is there any way to get better documentation on these commands that he skeletal docs in the Vizard Help or in Python help()?

Last edited by pbeeson; 09-11-2006 at 11:37 PM.
Reply With Quote
  #15  
Old 09-12-2006, 10:51 AM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
1) viz.phys.intersectLine() works on the physics simulation level so it only intersects with physics shapes. To have it ignore nodes, remove their VizPhysicsShape with a call to collideNone().

2) Vizard Help is the best option right now. Of course the forum is fairly good too
__________________
Paul Elliott
WorldViz LLC
Reply With Quote
Reply


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


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


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