WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 04-08-2014, 07:05 AM
Frank Verberne Frank Verberne is offline
Member
 
Join Date: Mar 2008
Location: Netherlands
Posts: 148
First of all, the next time you post your code, put code tags around your code so that indentation is preserved (which is essential for python code). You can do so by copy-pasting the code in the message field, selecting the code, and clicking the # symbol in the message tools. This way, other people can just take the code and run it, without having to figure out the indentation themselves. The chance that you get a timely response increases by doing so.

Second, I noticed that you posted the same question in a different (unrelated) thread. As bad as you would like to get help, there is no need to re-post the same question in a different thread, and especially not in an unrelated thread.

Third, your problem was that with every collision, a new textScreen variable was added, so they got layered instead of changed. I made a global variable for the collision function to solve the problem. Have a look at the manual of Vizard at http://s3.worldviz.com/pdf/Vizard%20...0Book%20R4.pdf. It describes very fundamental parts of Vizard, like the ones you're struggling with.

Code:
import viz
import vizact
viz.phys.enable()
viz.setMultiSample(4)
viz.fov(60)
viz.go()
male = viz.addAvatar('vcc_male.cfg')
male.scale(3,3,3)
ground = viz.add('tut_ground.wrl')
ground.collidePlane()
box = viz.add('box.wrl',scale=[2,2,2],pos=(0,0,5),color = viz.BLUE)
box.collideBox()
box.disable(viz.DYNAMICS)

env=viz.add(viz.ENVIRONMENT_MAP,'sky.jpg')
dome = viz.add('skydome.dlc')
dome.texture(env) 
box1 = viz.add('box.wrl',scale=[1.5,1.5,1.5],pos=(0,0,15),color = viz.RED)
box1.collideBox()
box1.disable(viz.DYNAMICS)

box2 = viz.add('box.wrl',scale=[1.5,1.5,1.5],pos=(-10,0,0),color = viz.RED)
box2.collideBox()
box2.disable(viz.DYNAMICS)

box3 = viz.add('box.wrl',scale=[1.5,1.5,1.5],pos=(-20,0,0),color = viz.RED)
box3.collideBox()
box3.disable(viz.DYNAMICS)

rHandBox = viz.add('box.wrl',scale=[1,1,1])
rHandBox.collideBox()
rHandBox.disable(viz.DYNAMICS)
rHandBox.enable(viz.COLLIDE_NOTIFY)
rHandLink = viz.link( male.getBone('Bip01 R Foot') , rHandBox )
#tweak the position of the box to cover the hand
rHandLink.preTrans([0.05,-0.5,0])

global textScreen
textScreen = viz.addText('Press a',parent=viz.ORTHO,pos=[400,500,0],fontSize=50) 
textScreen.visible(viz.OFF)

def onCollideBegin(g):
	global textScreen
	if g.obj1 == rHandBox:
		print 'collided'
	if g.obj2 == box:
		box.color(viz.RED)
		textScreen.message('santhosh')
		textScreen.visible(viz.ON)
	if g.obj2 == box1:
		box1.color(viz.BLUE)
		textScreen.message('sujith')
		textScreen.message
	if g.obj2 == box2:
		box2.color(viz.BLUE)
		textScreen = viz.addText('Press c',parent=viz.ORTHO,pos=[100,0,0],fontSize=50)
	if g.obj2 == box3:
		box3.color(viz.BLUE)
		textScreen = viz.addText('Press r',parent=viz.ORTHO,pos=[400,200,0],fontSize=50) 
viz.callback(viz.COLLIDE_BEGIN_EVENT,onCollideBegin)

def wukavatar(): 
	walk1 = vizact.walkTo([0,0,5])
	male.addAction(walk1)

vizact.onkeydown('w',wukavatar)

def walkAvatars():
	walk2 = vizact.walkTo([0,0,15])
	male.addAction(walk2)

vizact.onkeydown('c',walkAvatars)
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
input from a text file dig Vizard 5 10-20-2013 01:20 AM
Use saved text file data as replay sources problem mizutani_jun Vizard 4 10-14-2010 04:49 PM
Informationboxes with text snoopy78 Vizard 3 07-16-2009 10:23 AM
Vizard tech tip: Text to Speech Jeff Vizard 1 01-15-2009 09:39 PM
viz.lookat() with 3d text problem shivanangel Vizard 2 04-30-2007 02:34 PM


All times are GMT -7. The time now is 04:58 PM.


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