WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 02-27-2017, 09:12 AM
mihirradia mihirradia is offline
Member
 
Join Date: Jun 2016
Posts: 44
Hi Jeff,
Its really difficult for me to produce an example that replicates my error. I have attached my code with as short as possible. As I am using the vizconnect tool. I have also attached the vizconnect_desktop.py

my code is
Code:
import csv
import viz
import vizfx
import vizconnect
import vizact
import makingCSVFile
import zspace
import vizshape
import vizcam
import vizinfo
import viznet
import vizinput
from tools import collision_test

filePath = vizinput.fileOpen(filter=[('DAE Files','*.dae'),('OSG Files','*.ive;*.osgb;*.osg'),('VRML Files','*.wrl'),('All File','*.*')],directory='3DModels')
logoss1=None
Listchilderen=[]
GrabedObject=None
ModelsList=[]
ModelsList.append(logoss1)
DissasembeldPart=False
models=None
grabItems=None
class ExplosiveModel(viz.VizNode):
	""" creates a model with a given dae file and gets parts and moves them on specified axes """

	def __init__(self, rowData):
		
		self.isu = vizfx.addChild(filePath)
		logoss1 = self.isu
		Listchilderen = logoss1.getNodeNames()
		viz.VizNode.__init__(self, self.isu.id)
		self.scale = .035125 #this scale is determined by doc (dividing model size by .035, we get desired size)
		self.isu.setScale([self.scale]*30)
		self.current = 0 #index of current
		self.rowData = rowData[:]
		self.layerParents = []
		self.partDict = {}
		for tool in vizconnect.getToolsWithMode('Grabber'):
			tool.getRaw().setCollisionTester(collision_test.Distance(node=tool.getRaw(), distanceThreshold=1000))

def initZSpace():
	import zspace

	viz.setMultiSample(8)
	viz.clearcolor(viz.SLATE)

	#initialize zSpace display
	display = zspace.init()

	#Scale up the zSpace display to avoid having to
	#scale down all the models to fit within the display viewport
	display.setScale(200)

	#save handle to wand tracker
	wandTracker = zspace.getWandTracker()
	wandTracker.setLedEnabled(True)


SEND_UPDATE_TIMER = 1

UPDATE = viznet.id('update')
CLIENT_DISCONNECTED = viznet.id('client_disconnected')
CHAT = viznet.id('chat')

SERVER_NAME=viz.input('Enter Server Name')
while not viznet.client.connect(SERVER_NAME,port_in=14951,port_out=14950):
    if viz.ask('Could not connect to ' + SERVER_NAME + ' would you like to try another?'):
        SERVER_NAME=viz.input('Enter Server Name')
    else:
        viz.quit()
        break


#___________________________________________________________________________________
#-----------------------------------------------------------------------------------	
def update(e):
	# need to edit this
	global grabbedObject
	global grabItems,models, filePath
	global ModelsList,logoss1,DissasembeldPart,Listchilderen, xmodel
	if e.client != viz.getComputerName():
		try:
			
			
			if e.DisAssPart==True and DissasembeldPart==False:
				
				

				for i in Listchilderen:
					if i.startswith("Inst"):
						xmodel=logoss1.getChild(i)
						
						ModelsList.append(xmodel)
								
				models = viz.cycle(ModelsList)
				grabItems = set(models)
				DissasembeldPart=True
				e.GrabObj.setPosition(e.pos)
				e.GrabObj.setEuler(e.ori)
				
			elif e.DisAssPart==False and DissasembeldPart==True:
				
				for i1 in ModelsList:
					i1.remove()
				logoss1.remove()
				logoss1 = viz.add(filePath)
				logoss1.setPosition([0,0,0])
				logoss1.setScale([0.1,0.1,0.1])
				models = viz.cycle([logoss1])
				grabItems = set(models)
				DissasembeldPart=False
				e.GrabObj.setPosition(e.pos)
				e.GrabObj.setEuler(e.ori)
				
		
				
			else:
				
				e.GrabObj.setPosition(e.pos)
				e.GrabObj.setEuler(e.ori)
				
						
		except KeyError:
			print 'errooooooooor'
		#print '-------------update client'
viz.callback(UPDATE,update)
#___________________________________________________________________________________
#-----------------------------------------------------------------------------------
def client_disconnected(e):
	viz.callback(CLIENT_DISCONNECTED,client_disconnected)
#___________________________________________________________________________________
#-----------------------------------------------------------------------------------
def sendUpdate(): 
	global GrabedObject, DissasembeldPart
	if GrabedObject!=None:
		ori= GrabedObject.getEuler()
		pos = GrabedObject.getPosition()
		GrabObj=GrabedObject
		DisAssPart=DissasembeldPart
	
		viznet.client.sendAll(UPDATE,client=viz.getComputerName(),pos=pos,ori=ori,GrabObj=GrabObj,DisAssPart=DisAssPart )
	
vizact.ontimer(.001,sendUpdate)
#___________________________________________________________________________________
#-----------------------------------------------------------------------------------
def onStopServer(e):
   
    viz.quit()
viz.callback(viznet.SERVER_DISCONNECT_EVENT,onStopServer)

#___________________________________________________________________________________
#-----------------------------------------------------------------------------------

#alternatively, you could use the desktop                               
vizconnect.go('vizconnect_desktop.py') #desktop vizconnect setup

rowData = []
#read csv data for part numbers per step
with open('names.csv', 'rb') as csvfile:
	reader = csv.reader(csvfile)
	for row in reader:
		rowData.append([row[0], row[1], row[2].split()])
print rowData

#Set the animation speed and mode
SPEED = 1200
MODE = viz.SPEED
ROTATE_MODE = viz.PIVOT_ROTATE

def AnimateView(pos):
	global GrabedObject
	action = vizact.goto(pos,SPEED,MODE,pivot=vizconnect.getViewpointDict(),rotate_mode=ROTATE_MODE)
	GrabedObject = vizconnect.getTransport().getRaw()
	vizconnect.getTransport().getNode3d().runAction(action)
	
model = ExplosiveModel(rowData)
model.setScale([0.02]*3)

viz.clearcolor(viz.GRAY) #change background color if desired

#Start off by moving to the first location
AnimateView([0,2,-15])
Attached Files
File Type: zip vizconnect_desktop.zip (8.2 KB, 3875 views)
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Client Server Networking Problem mihirradia Vizard 5 02-21-2017 09:46 PM
Client Server Networking Problem pattie Vizard 12 07-04-2013 09:11 AM
networking problem Chapre Vizard 2 02-17-2012 08:17 AM
Problem with server Events vOliver Vizard 2 09-15-2010 02:21 PM
Linking problems with Live Character Frank Verberne Vizard 5 06-04-2008 11:42 AM


All times are GMT -7. The time now is 04:18 AM.


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