WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 01-15-2014, 02:44 AM
maya maya is offline
Member
 
Join Date: Nov 2013
Location: United Arab Emirates
Posts: 21
thanks it worked. however, I want to c what the steve module sees infront of him (what he is looking at).

I want it to be in this way as reflected in the upper right view:
this is the code:

Code:
import viz
import viznet
import vizinfo
import vizinput
import viztask
import vizact
import vizshape
import vizproximity
import vizmat
import steve

viz.setMultiSample(4)
viz.fov(60)
viz.go()

# Use the steve module to represent the other user.
# You will actually have no representation of yourself on your own monitor.
player_matrix = viz.Matrix()
avatar = steve.Steve()
avatar.setTracker(player_matrix)

# Add the world
maze = viz.addChild('piazza.osgb')

#Use a prompt to ask the user the network name of the other computer.
target_machine = vizinput.input('Enter the name of the other machine').upper()

#Add a mailbox from which to send messages. This is your outbox.
target_mailbox = viz.addNetwork(target_machine) 

def sendPosition():

     #Retrieve current transform of viewpoint
     mat = viz.MainView.getMatrix()

     #Send position/rotation to target network object
     target_mailbox.send(action=updatePlayer, quat=mat.getQuat(), pos=mat.getPosition())

# Start a timer that sends out data over the network every frame
vizact.ontimer(0,sendPosition)

def updatePlayer(e):
     player_matrix.setPosition(e.pos)
     player_matrix.setQuat(e.quat)

# Listens for any incomming messages
def onNetwork(e):
     if e.sender.upper() == target_machine:
         e.action(e)

# Register network to listen from incomming messages
viz.callback(viz.NETWORK_EVENT, onNetwork)

# Create a new window in the upper left corner
UpperLeftWindow = viz.addWindow(pos=(0,1.0),size=(0.5,0.5))
UpperLeftWindow.visible(0,viz.SCREEN)

#Create a new window in the upper right corner
UpperRightWindow = viz.addWindow(pos=(0.5,1.0),size=(0.5,0.5))
UpperRightWindow.visible(0,viz.SCREEN)

# Create a new viewpoint
BirdView = viz.addView()

#Attach the bird's eye view to the upper left window
UpperLeftWindow.setView(BirdView)

#Move the view above the center of the room
BirdView.setPosition([0,25,0])

#Rotate the view so that it looks down
BirdView.setEuler([0,90,0])

#Create another viewpoint
RearView = viz.addView()

#Attach the rear view to the upper right window
UpperRightWindow.setView(RearView)

#Increase the field-of-view for both windows
UpperLeftWindow.fov(70)
UpperRightWindow.fov(60)

#Add an arrow marker to bird's eye view window to represent our current position/orientation
arrow = viz.addTexQuad(parent=viz.ORTHO,scene=UpperLeftWindow,size=20)
arrow.texture(viz.add('arrow.tif'))

def UpdateViews():

	#Get the current head orientation and position
	yaw,pitch,roll = player_matrix.getEuler()
	pos = player_matrix.getPosition()

	#Move the rear view to the current position
	RearView.setPosition(pos)

	#Rotate the rear view so that it faces behind us
	RearView.setEuler([yaw,0,0])

	#Move arrow to our current location
	x,y,z = UpperLeftWindow.worldToScreen(pos,mode=viz.WINDOW_PIXELS)
	arrow.setPosition([x,y,0])
	arrow.setEuler([0,0,-yaw])

vizact.ontimer(0,UpdateViews)

# Turn on collision detection so we can't go through walls
#viz.collision(viz.ON)
walk1=vizact.moveTo([4,0,0])

walk2=vizact.moveTo([4,0,3])
walk3=vizact.moveTo([7,0,4])

walk4=vizact.moveTo([8.5,0,17])
walk5=vizact.moveTo([10,0,22])
walk6=vizact.moveTo([3,0,23])
walks=vizact.sequence(walk1,walk2, vizact.waittime(1),walk3, vizact.waittime(1),walk4, vizact.waittime(1),walk5,vizact.waittime(1),walk6)
#avatar.addAction(walks)


#avatar.addAction(vizact.walkTo([0,0,7]))

btw, I commented the "add action" .
thanx
Reply With Quote
Reply


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


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