WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 10-14-2014, 07:07 AM
BSUGeek BSUGeek is offline
Member
 
Join Date: Oct 2014
Posts: 23
Question Help Printing to Different files

My scene is with an avatar out of view and he's walking around the room. When he walks into view I want my code to print his coordinates once to an xml file. When he's in view again I want to print his coordinates once to a separate xml file...etc, etc.

I'm having trouble getting the code to print to separate xml files while he's in view. any help would be greatly appreciated! below is my snippet of code.

Code:
#Checks If Avatar is visible
def dostuff():
	num = 1
	while(viz.MainWindow.isCulled(avatar, eye = viz.LEFT_EYE)==0):
			elapsed_time = viz.tick() - start_time
			x_pos = avatar.getPosition()[0]
			y_pos = avatar.getPosition()[1]
			z_pos = avatar.getPosition()[2]
			
		#Make a string out of the data. 
			dataTag1 = '<position>'
			XPosition = 'x position:  ' + str(round(x_pos))
			YPosition = '  y position:  ' + str(y_pos)
			ZPosition = '  z position:  ' + str(z_pos)
			dataTag2 = '</position>\n'
			dataTime1 = '<time>'
			time = str(round(elapsed_time))
			dataTime2 = '</time>\n'
			question_data = open('VRProject'+str(num)+'.xml','w')
			num = num + 1
			
			#Write the data to our file.
			question_data.write(declaration)
			question_data.write(dataTag1) 
			question_data.write(XPosition) 
			question_data.write(YPosition) 
			question_data.write(ZPosition) 
			question_data.write(dataTag2) 
			question_data.write(dataTime1) 
			question_data.write(time) 
			question_data.write(dataTime2)
			question_data.write(enddeclaration)
					
			#Flush the internal buffer.
			question_data.close()
	
vizact.ontimer(1,dostuff)
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
How are files associated/how should they be saved (python script + images) mhead10 Vizard 1 03-26-2012 10:58 AM
How to edit the skin tones of the complete characters' cfg files? vEsotu Vizard 3 09-23-2008 12:07 PM
Which software can be used to edit .cfg (CAL3D) files luakt Vizard 4 09-12-2008 07:18 AM
loading large wav files in vizard tommahhh Vizard 1 05-16-2005 03:23 PM
Including Files that Include Other Files vjosh Vizard 1 09-21-2004 04:44 PM


All times are GMT -7. The time now is 10:37 AM.


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