![]() |
|
#1
|
|||
|
|||
|
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?? |
|
#2
|
|||
|
|||
|
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.
|
|
#3
|
|||
|
|||
|
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? |
|
#4
|
|||
|
|||
|
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.
|
|
#5
|
|||
|
|||
|
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)
|
|
#6
|
|||
|
|||
|
Hi. worldviz.
is this not solved my problem?? i want to your help. i don't solved my problem |
|
#7
|
|||
|
|||
|
What's not working?
|
![]() |
|
|
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 |