WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rating: Thread Rating: 6 votes, 5.00 average. Display Modes
  #1  
Old 05-26-2008, 10:34 AM
Frank Verberne Frank Verberne is offline
Member
 
Join Date: Mar 2008
Location: Netherlands
Posts: 148
Hi Farshizzo,

Could you post the code for dynamic collision with live characters? The rest of the task is done now, and I have been struggling with the code to create something like you said (collision shapes for each major limb) but haven't been succesfull. I also tried to put avatar.collidemesh() into a timer, but that was too demanding (regarding the CPU I guess).

Thanks in advance!
Reply With Quote
  #2  
Old 05-29-2008, 09:55 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Do you need dynamics on the collision, or do you just need to know when the avatar touches an object?
Reply With Quote
  #3  
Old 05-29-2008, 10:20 AM
Frank Verberne Frank Verberne is offline
Member
 
Join Date: Mar 2008
Location: Netherlands
Posts: 148
I don't really know what the difference is, but what my task is that a participant controlling an avatar has to touch several quads. Each quad has a bounding box around it, and every time the avatar touches the quad (i.e. enters the bounding box) the program checks if the number is the lowest of the 6 quads. If it is, the quad will turn green, otherwise the quad wil become red for a few seconds and then restore itself. This task is done multiple times.

So I think that I only need to know when the avatar (no matter which part of the avatar) touches the quads. Hope that clarifies the situation.
Reply With Quote
  #4  
Old 05-30-2008, 10:45 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Here is a sample script that shows how to setup collisions with the right hand of the avatar. Adding support for other body parts should not be too difficult.
Code:
import viz
viz.go()

#Enable physics
viz.phys.enable()

#Create ground plane
ground = viz.add('tut_ground.wrl')
ground.collidePlane()

#Create static box in front of avatar
box = viz.add('box.wrl',scale=[2,2,2],pos=(0,1,1.7))
box.collideBox()
box.disable(viz.DYNAMICS)

#Create avatar that doesn't like big boxes
avatar = viz.add('vcc_female.cfg')
avatar.state(6)

#Create a collision box and link it to right hand of avatar
rHandBox = viz.add('box.wrl',scale=[0.1,0.1,0.1])
rHandBox.collideBox()
rHandBox.disable(viz.DYNAMICS)
rHandBox.enable(viz.COLLIDE_NOTIFY)
rHandLink = viz.link( avatar.getBone('Bip01 R Hand') , rHandBox )
rHandLink.preTrans([0.05,-0.05,0])

#Comment this line out if you want to see the collision box around the hand
rHandBox.disable(viz.RENDERING)

#List of colors to cycle through
colors = viz.cycle([viz.WHITE,viz.BLUE,viz.RED])

#Change color of box when avatar hits it
def onCollideBegin(e):
	if e.obj1 == rHandBox:
		if e.obj2 == box:
			box.color(colors.next())
viz.callback(viz.COLLIDE_BEGIN_EVENT,onCollideBegin)

#Setup camera navigation
import vizcam
vizcam.PivotNavigate(center=[0,1,0],distance=5)
Reply With Quote
  #5  
Old 05-30-2008, 01:14 PM
Frank Verberne Frank Verberne is offline
Member
 
Join Date: Mar 2008
Location: Netherlands
Posts: 148
Farshizzo: thank you very much for the sample code! It works perfectly. I tried to do the same while using the live characters plugin and for some reason it didn't work then. I guess linking the box directly to the same tracker that also animated the avatar (so the same tracker was linked to a bone using MotionBuilder and to a box) could have been the problem. I will test this solution on monday and I will let you know if I still encounter some problems or if my problems are solved (during the weekends I don't have access to the live characters plugin).
Reply With Quote
  #6  
Old 06-04-2008, 09:44 AM
Frank Verberne Frank Verberne is offline
Member
 
Join Date: Mar 2008
Location: Netherlands
Posts: 148
Hi Farshizzo,

Your solution also worked in the lab! So thanks for your solution!

Yours, Frank
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking through the eyes of an avatar Frank Verberne Vizard 2 04-01-2008 05:52 AM
How to make avatar's eyes to blink when speaking michelcm3 Vizard 12 01-15-2008 08:48 AM
avatar neck too short aa-chris Vizard 2 10-16-2007 09:28 AM
Avatars in an array and link/unlink betancourtb82 Vizard 7 09-05-2006 04:06 PM
avatar animations vduckie Vizard 12 02-27-2006 01:32 PM


All times are GMT -7. The time now is 11:02 PM.


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