WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
Old 11-23-2013, 08:35 AM
maya maya is offline
Join Date: Nov 2013
Location: United Arab Emirates
Posts: 21
Exclamation multi user environment tutorial


I have been exploring the multi user tutorial in the reference.
I was trying to control the movement of the avatar (selected object from the object list) using keyboard. I have the code for the movement, but I didn't know how to do it.

this is the code for movement:

import viz
import viztask
import vizmat

#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)

def moveAvatar():	
                          while True:
		#get user input
		newPos = vizmat.Vector()
		if viz.iskeydown('w'):
			#walk forward
			newPos = newPos + [0, 0, 1]
		if viz.iskeydown('s'):
			newPos = newPos + [0, 0, -1]
		if viz.iskeydown('a'):
			newPos = newPos + [-1, 0, 0]
		if viz.iskeydown('d'):
			newPos = newPos + [1, 0, 0]		
		isJumping = False
		isAttacking = False
		if viz.iskeydown(' '):
			isJumping = True
		elif viz.iskeydown('v'):
			isAttacking = True
		if isAttacking:			
			yield viztask.waitTime( 1.5 )
		if newPos.length() > 0 or isJumping:
			if newPos.length() == 0:
				#jumping but no direction key, use current heading
				t = vizmat.Transform()
				t.setTrans([0, 0, 1.8])
				newPos = vizmat.Vector( t.getTrans() )
			newYaw = vizmat.AngleToPoint(0, 0, newPos[0], newPos[2])
			avatar.setEuler(newYaw, 0, 0)
			if not isJumping:
				#just walking				
				cameraEuler = viz.MainView.getEuler()
				avatarRoot.setEuler(cameraEuler[0], 0, 0)
				newPos = newPos * viz.getFrameElapsed()
				avatarRoot.setPosition(newPos, viz.REL_LOCAL)
				yield viztask.waitTime( avatar.getDuration(7)+.01 )
				#compute jump direction
				newJumpPos = vizmat.Transform()
				newJumpPos.setTrans([0, 0, 1.8])
				newJumpPos.postEuler(avatar.getEuler(viz.ABS_GLOBAL)[0], 0, 0)
				avatarRoot.setPosition(newJumpPos.getTrans(), viz.REL_GLOBAL)
		if not (viz.iskeydown(' ') or viz.iskeydown('w') or viz.iskeydown('s') or viz.iskeydown('a') or viz.iskeydown('d') ):
		yield None

import vizcam
camera = vizcam.PivotNavigate()

def moveCamera():
	while True:
		lookAtPos = avatar.getBone('Bip01 Pelvis').getPosition(viz.ABS_GLOBAL)
		lookAtPos[1] = lookAtPos[1] + .5
		yield None	

my questions are:
1. in the moveAvatar function, the position of the avatar is saved in a variable newPos. what part of the multi user tutorial sets the selected object position?

2. how can I change the position of the selected object in the multi user tutorial

multi user environment code:
objectList = ['duck.wrl','logo.wrl','vcc_male.cfg','vcc_female.cfg'] 
obj_choice=vizinput.choose('Connected. Select your character',objectList)
def sendUpdate():
     ori= viz.MainView.getEuler()
     pos = viz.MainView.getPosition()
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
multi user maya Vizard 1 11-18-2013 09:31 AM
Multi User Environment moneim230 Vizard 5 05-17-2011 05:56 PM
begginer tutorial shader? Darkmax Vizard 1 04-15-2010 04:26 PM
Controlling User Input ohad Vizard 1 03-15-2010 05:16 PM
Getting a mirror to work in any environment Frank Verberne Vizard 5 03-27-2008 08:21 AM

All times are GMT -7. The time now is 08:13 AM.

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