WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 12-16-2013, 11:53 AM
maya maya is offline
Member
 
Join Date: Nov 2013
Location: United Arab Emirates
Posts: 21
I have posted the wrong code. so plz ignore it. below is the right code.

I managed to simulate an avatar walking randomly. however, I wanted the avatar to pick up the cellphone when he reaches the red sphere. I have the code for that but I did not know how to do it in a simulated way (without pressing any key)

this is the code that I am working on:
Code:
import viz
import viznet
import vizinfo
import vizinput
import viztask
import vizact
import vizshape
import vizproximity
import vizmat
viz.go()

viz.go()
viz.MainView.setPosition([0,0.1,0])
viz.setMultiSample(4)
#Increase the Field of View
viz.MainWindow.fov(60)

#avatarRoot = viz.addGroup()
avatarRoot = viz.add('marker.wrl')
cameraLookAtNode = viz.addGroup(parent=avatarRoot, pos=[0, 1.5, 0])
avatar = viz.add('vcc_male.cfg', parent=avatarRoot)
#avatar.state(1)
#viz.collision(viz.ON)



piazza = viz.add('piazza.osgb')
sphere = vizshape.addSphere(radius=0.2)
sphere.setPosition(0,0,20)
sphere.color(viz.RED)

text = viz.addText('radiation source',parent=sphere)
text.setPosition([-0.3,0.3,0])
text.setScale([0.2]*3)
text.color(viz.RED)
text.visible(viz.ON)

text_2D = viz.addText('radiation source area', viz.SCREEN )
text_2D.setPosition(0,0,20)
text_2D.color(viz.RED)
t=text_2D.visible(viz.OFF)

tex = viz.addTexture('logo.jpg')




#maze = viz.add('tankmaze.wrl')
#def onKeyDown(key): 
     #if key == viz.iskeydown ('t' ):
walk1=vizact.walkTo([4,0,0])
walk2=vizact.walkTo([4,0,3])
walk3=vizact.walkTo([7,0,4])

walk4=vizact.walkTo([8.5,0,17])
walk5=vizact.walkTo([10,0,22])
walk6=vizact.walkTo([3,0,23])

#walk=vizact.walkTo([0,0,15])

def changeState() :
    
    #Add the cellphone model
    cell = viz.addChild('phone.3ds')

    #Get the right hand bone of the avatar
    hand = avatar.getBone('Bip01 R Hand')

    #Link the cellphone to the hand
    CellLink = viz.link(hand,cell)

    #Tweek the cellphone link so it fits snuggly in the hand
    CellLink.preTrans( [0.06,-0.08,0.08] )
    CellLink.preEuler( [0,0,180] )
#thick = vizact.method()

walks=vizact.sequence(walk1,walk2, vizact.waittime(1),walk3, vizact.waittime(1),walk4, vizact.waittime(1),walk5,vizact.waittime(1),walk6)
viz.collision(viz.ON)

avatar.addAction(walks)



    #Make the avatar use the cellphone when the 'w' key is pressed
#vizact.onkeydown('w',avatar.execute,15)

#vizact.onkeydown('t',walk)

#Register the callback which to call the 'onKeyDown' function. 
#viz.callback(viz.KEYDOWN_EVENT,onKeyDown) 
	



#Create proximity manager
manager = vizproximity.Manager()

#Add main viewpoint as proximity target
target = vizproximity.Target(avatar)
manager.addTarget(target)

sensor = vizproximity.Sensor( vizproximity.CircleArea(5),source=sphere)

manager.addSensor(sensor)

def EnterProximity(e):
    text_2D.visible(viz.ON)
    quad = viz.addTexQuad()
    quad.setPosition([0,1,20])
    quad.texture(tex) # The quad will now display the tree picture
    spin=vizact.sequence(vizact.waittime(1), vizact.spin(0,1,0,20))
    vizact.addCallback
    quad.addAction(spin)

    
def ExitProximity(e):
    text_2D.visible(viz.OFF)
    

manager.onEnter(sensor,EnterProximity)
manager.onExit(sensor,ExitProximity)
Reply With Quote
 

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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
random coding Saz Vizard 1 05-27-2010 05:44 PM
random speed and associated coding Saz Vizard 1 05-20-2010 04:03 AM
Getting a mirror to work in any environment Frank Verberne Vizard 5 03-27-2008 08:21 AM
custom avatar random walk krimble Vizard 2 03-20-2007 03:23 AM
Random Seeds Vygreif Vizard 1 04-27-2006 09:21 PM


All times are GMT -7. The time now is 01:24 AM.


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