WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 12-20-2010, 03:54 AM
psykoko psykoko is offline
Member
 
Join Date: Dec 2010
Posts: 9
continue loading...

HI.
i am received udp signal from matalb successfuly. throught following coding
Code:
import socket
import struct
viz.go()
UDP_IP="localhost"
UDP_PORT=8020

sock = socket.socket( socket.AF_INET, # Internet
socket.SOCK_DGRAM ) # UDP
sock.bind( (UDP_IP,UDP_PORT) )
while True:
      data, addr = sock.recvfrom( 1024 ) # buffer size is 1024 bytes
      udp = struct.unpack(">d", data)[0]
      right = open('c:\ownership\Hand2.txt', 'a+')
      right.write(str(udp)+'n') 
True.close()


but i have any problem.
this code seems to continue loading screen.

how can solve this problem??
Reply With Quote
  #2  
Old 12-20-2010, 11:06 AM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
Try using a director function to read in your network data. They are documented in the Vizard help and are useful for performing IO operations that would otherwise halt rendering.
Reply With Quote
  #3  
Old 12-20-2010, 08:05 PM
psykoko psykoko is offline
Member
 
Join Date: Dec 2010
Posts: 9
Hi,

hi jeff,
i have solved my problem, thankyou. i did coding as follows

Code:
import socket
import struct
import viz
import viz
import vizmat
import vizinfo
viz.go(viz.PROMPT | viz.STEREO)
UDP_IP="localhost"
UDP_PORT=8000

sock = socket.socket( socket.AF_INET, # Internet
					socket.SOCK_DGRAM ) # UDP
sock.bind( (UDP_IP,UDP_PORT) )


#Add an avatar to the scene
female = viz.add('vcc_female.cfg')
viz.clearcolor(0.5,0.5,1) 
female.setPosition([-0.08,0,0.8]) 
female.setEuler([0,0,0])
female.scale(1.4,1,1)

#speed
MOVE_SPEED = 10
TURN_SPEED = 50

#view point
view = viz.MainView 

#Get a handle to the Arm bone
Forearm = female.getBone('Bip01 R Forearm')
Forearm.lock() 
Forearm.setEuler(0, -5, 0) 


UpperArm = female.getBone('Bip01 R UpperArm')
UpperArm.lock()
UpperArm.setEuler(0, -30, -80) 

Hand = female.getBone('Bip01 R Hand')
Hand.lock()

Head = female.getBone('Bip01 Head')
Head.lock()
Head.setPosition(-100,0,0)


Neck = female.getBone('Bip01 Neck')
Neck.lock()
Neck.setEuler(0,0,-15)



def example1():
	while True:
		data, addr = sock.recvfrom( 1024 ) # buffer size is 1024 bytes
		udp = struct.unpack(">d", data)[0]
		print udp 
		right = open('c:\\ownership\\test.txt', 'a+')
		right.write(str(udp)+'\n') 
		
		if 0 < udp:
			
			a = Forearm.getEuler()
			A = a[2]
			n = max(A -0.5,-90)
			N = A + 90 
			Forearm.setEuler(0,0,n)	
			if n == -90:
				Forearm.setEuler([0,0,N])
					
		else :
			b = Forearm.getEuler()
			B = b[2]
			n2 = min(B +0.2,0)
			Forearm.setEuler(0,0,n2)  
viz.director(example1)

but another problem is induced.
when i load my avartar, udp signal is losed.
but when i down(minimize "_") window seeing avartar, udp signal is receive perfectly,

i want to receive udp singal in window loaded avartar.

how can i?
Reply With Quote
  #4  
Old 12-21-2010, 05:15 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
Try using the director function for just reading in the network data. To update the avatar register a callback function with vizact.ontimer or vizact.onupdate.
Reply With Quote
  #5  
Old 12-23-2010, 07:38 PM
psykoko psykoko is offline
Member
 
Join Date: Dec 2010
Posts: 9
Hi. i did modify my code, but i don't work correctly.
please modify my code
Code:
import viz
import vizmat
import vizinfo
import socket
import struct
viz.go()

#Add an avatar to the scene
female = viz.add('vcc_female.cfg')
viz.clearcolor(0.5,0.5,1) 
female.setPosition([-0.08,0,0.8]) 
female.setEuler([0,0,0])
female.scale(1.4,1,1)



#Get a handle to the Arm bone
Forearm = female.getBone('Bip01 R Forearm')
Forearm.lock() 
Forearm.setEuler(0, -5, 0) 


UpperArm = female.getBone('Bip01 R UpperArm')
UpperArm.lock()
UpperArm.setEuler(0, -30, -80) 

Hand = female.getBone('Bip01 R Hand')
Hand.lock()

Head = female.getBone('Bip01 Head')
Head.lock()
Head.setPosition(-100,0,0)


Neck = female.getBone('Bip01 Neck')
Neck.lock()
Neck.setEuler(0,0,-15)




UDP_IP="localhost"
UDP_PORT=8000

sock = socket.socket( socket.AF_INET, # Internet
					socket.SOCK_DGRAM ) # UDP
sock.bind( (UDP_IP,UDP_PORT) )

udp = 0 
def example1():
	global udp 
	while True:
		data, addr = sock.recvfrom( 1024 ) # buffer size is 1024 bytes
		udp = struct.unpack(">d", data)[0]
	True.close()
viz.director(example1)


def update():
	print udp 
	right = open('c:\\ownership\\test4.txt', 'a+')
	right.write(str(udp)+'\n') 
	
	if 0 < udp:
		a = Forearm.getEuler()
		A = a[2]
		n = max(A -0.5,-90)
		N = A + 90 
		Forearm.setEuler(0,0,n)	
		if n == -90:
			Forearm.setEuler([0,0,N])
					
	else :
		b = Forearm.getEuler()
		B = b[2]
		n2 = min(B +0.2,0)
		Forearm.setEuler(0,0,n2)
	
vizact.ontimer(0,update)
Reply With Quote
  #6  
Old 12-28-2010, 01:52 AM
psykoko psykoko is offline
Member
 
Join Date: Dec 2010
Posts: 9
Hi. worldviz.
is this not solved my problem??

i want to your help.

i don't solved my problem
Reply With Quote
  #7  
Old 01-02-2011, 01:18 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
What's not working?
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
Loading OSG models and orientation Joran Vizard 4 06-18-2009 05:43 AM
intersense with 5DT glove sjp Vizard 2 04-06-2009 07:22 AM
Problems loading WRL file DrunkenBrit Vizard 2 01-29-2009 12:58 AM
Loading .3ds-Files without interrupting Program flow Stefan Vizard 10 06-08-2005 04:44 PM
Script loading problem JRichizzle Vizard 1 03-12-2004 10:03 AM


All times are GMT -7. The time now is 12:56 PM.


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