WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rating: Thread Rating: 7 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 10-21-2008, 02:42 PM
TrashcanPatrol TrashcanPatrol is offline
Member
 
Join Date: Aug 2008
Posts: 43
Hmm... I'm having some difficulty combining this into an environment where there's a door to open. Here is my code so far:

Code:
import viz
viz.go()

SAFE = 1
UNSAFE = 0


RECTANGLE_X = -4
RECTANGLE_Z = 3.4
RECTANGLE_WIDTH = 0.5

openDoor = False
dooropen = False
walk = vizact.walkTo([-3.5,0,3.5])

def handlemyhotspots(id,x,y,z):
	global openDoor
	if id == SAFE:
		openDoor = True
		print 'Door can be opened'
		viz.starthotspot(UNSAFE,viz.RECTANGLE_HOTSPOT_OUT,RECTANGLE_X,RECTANGLE_Z,RECTANGLE_WIDTH,1)
	if id == UNSAFE:
		openDoor = False
		print 'Door can not be opened'
		viz.starthotspot(SAFE,viz.RECTANGLE_HOTSPOT_IN,RECTANGLE_X,RECTANGLE_Z,RECTANGLE_WIDTH,1)

viz.callback(viz.HOTSPOT_EVENT, handlemyhotspots)
viz.starthotspot(SAFE,viz.RECTANGLE_HOTSPOT_IN,RECTANGLE_X,RECTANGLE_Z,RECTANGLE_WIDTH,1)
#viz.starthotspot(TARGET,viz.CIRCLE_HOTSPOT_IN,CIRCLE_X,CIRCLE_Z,CIRCLE_RADIUS) 

room=viz.add('room.wrl')
viz.collision(viz.ON)
door = room.getchild('door-FACES')
import vizcam
vizcam.FlyNavigate()

avatar = viz.add('vcc_male.cfg')

link = viz.link(avatar, viz.MainView)
link.preTrans([0,0,.1])

armup = vizact.boneSpinTo('Bip01 R UpperArm', euler = [0,0,-75], speed = 45)

avatar.addAction(walk)
avatar.addAction(armup)



def mykeyboard(key):
	global dooropen
	if key == 'e' and openDoor == True:
		door.runAction( vizact.spinto(0,1,0, -90, 30.0) )
		dooropen = True
		avatar.action(armup)
		
#Further help: http://www.worldviz.com/vizhelp/commands/viz/starthotspot.htm
		
#	if dooropen == True:
#		print 'The door is open'

#	if key == 'e' and openDoor == True and dooropen == True:
#		door.runAction(vizact.spinto(0,1,0,0,30.0) )

#Need to be able to close door as well, for concept.
#after door is opened, dooropen = True
#if key == 'e' and dooropen == True:
	#door.runAction( vizact.spinto(0,1,0,0,30.0) )
	
viz.callback(viz.KEYBOARD_EVENT,mykeyboard)

avatar.disable(viz.INTERSECTION)
I'm having some trouble controlling the viewpoint. It's linked to the avatar I know, but is there any way to control the avatar to go forward/back with Up, Down and strafe with Left, Right? As well as use the mouse to look around, so the player sees the hand open the door.. is this possible?
Thanks again for sticking around and helping me a bit through this.
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 12:06 PM.


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