WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 09-09-2009, 04:45 AM
krimble krimble is offline
Member
 
Join Date: Nov 2006
Location: Nijmegen
Posts: 63
screenshots using a loop

Hi all,

can somebody help me? I have troubles with my program.
I'm busy writing a small script which is basically a loop where an object rotates in after the rotation it has to make a screenshot of it and store it on the disk with the objects name and rotation degree.

The loop works perfectly it prints out what it has to save on the disk but it doesn't save (well it saves only the last screenshot).

Do I have to approach this differently?

Thanks for your help!

Code:
import viz

viz.go()

viz.clearcolor(.4,.4,.4)

view = viz.get(viz.MAIN_VIEWPOINT)
view.translate(12.416062355041504, 4.3263897895812988, 0)
view.rotate(-90,0,0)

s = viz.add(r"scissors.wrl")
co = viz.add(r"canopener.ive")
c1 = viz.add(r"cubes_01.wrl")
c2 = viz.add(r"cubes_02.wrl")
c3 = viz.add(r"cubes_03.wrl")

objects = [s,co,c1,c2,c3]
objectStrings = ["scissors","canOpener","cubes01","cubes02","cubes03"]

for i in objects :
	i.visible(0)

degreesY = [0,60,120,180,240,300]
degreesZ = [0,60,300]
degreesX = [0,180]


for obj in objects :
	if obj == s :
		object = objectStrings[0]
	elif obj == co :
		object = objectStrings[1]
	elif obj == c1 :
		object = objectStrings[2]
	elif obj == c2 :
		object = objectStrings[3]
	elif obj == c3 :
		object = objectStrings[4]
	obj.visible(1)
	for degree in range(0, len(degreesX)) :
		for i in range(0, len(degreesZ)) :
			for j in range(0, len(degreesY)) :
				obj.rotate(degreesX[degree], degreesY[j], degreesZ[i])
				viz.window.screenCapture('pictures\\' + object + '_' + str(degreesX[degree]) + '_' + str(degreesY[j]) + '_' + str(degreesZ[i]) + '.bmp')
				print "Created: " + object + "_" + str(degreesX[degree]) + "_" + str(degreesY[j]) + "_" + str(degreesZ[i]) + ".bmp"
Reply With Quote
  #2  
Old 09-09-2009, 01:12 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
You should use the viztask module to generate screenshots within a loop. Simply yield one frame in between screenshots and they should all be saved correctly. Here is a sample script:
Code:
import viz
import viztask
viz.go()

model = viz.add('vcc_female.cfg',pos=(0,1,3))

def ScreenShotTask():
	
	for x in range(10):
		
		#Rotate model
		model.setEuler(x*36,0,0)
		
		#Request screen capture at end of frame
		viz.window.screenCapture('image%02d.bmp'%(x))
		
		#Wait for frame
		yield None
	
viztask.schedule( ScreenShotTask() )
Reply With Quote
  #3  
Old 09-14-2009, 03:20 AM
krimble krimble is offline
Member
 
Join Date: Nov 2006
Location: Nijmegen
Posts: 63
Thank you so much, this saves a tons of time!
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
Stop for... loop Johannes Vizard 20 04-01-2014 02:53 AM
Creating a loop to switch between menu pages RodRSpv Vizard 1 03-02-2009 03:19 PM
For Loop in Callbacks? DrunkenBrit Vizard 2 02-19-2009 01:26 AM
screenshots vadrian Vizard 1 04-25-2005 07:17 AM
for loop concatenation for 300 billboarding trees eugcc Vizard 4 04-22-2004 01:46 AM


All times are GMT -7. The time now is 02:19 PM.


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