WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 09-12-2006, 11:43 AM
JvdBosch JvdBosch is offline
Member
 
Join Date: Sep 2006
Posts: 36
This seems to work, I'll try backing up a few steps and recreate this code in my model.
I added male.disable(viz.DYNAMICS), because else the avatar looks very blurry (drawing error or so?)
AlsoI added gravity and a mousedriven walkto to see how it works.
I'll try to incorporate it into my model tomorrow.

But if anyone has anymore bright ideas how to detect collision with low cpu usage, please share!

Here's the changed code:

Code:
import viz

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

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

logo = viz.add('logo.wrl')
logo.collideMesh()
logo.disable( viz.DYNAMICS )

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

male = viz.add( 'male.cfg' )
male.translate( 0, 1, 4 )
male.collideBox()
male.disable(viz.DYNAMICS)

male.addAction( vizact.walkto( 0, 0, 0 ) )
male.enable( viz.COLLIDE_NOTIFY )

def onCollide(e):
	if e.obj2 == logo:
		print 'logo collide'
	elif e.obj2 == ground:
		print 'ground collide'
	elif e.obj2 == ball:
		print 'ball collide'

viz.callback( viz.COLLIDE_BEGIN_EVENT, onCollide )

def onmousedown(button):
  if button == viz.MOUSEBUTTON_LEFT:
    info = viz.pick(1)
    if info.valid and info.object == ground:
      walk = vizact.walkto(info.point[0],0,info.point[2])
      male.runAction(walk)
	
viz.callback(viz.MOUSEDOWN_EVENT,onmousedown)
Reply With Quote
 


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:37 PM.


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