WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 09-06-2007, 10:44 AM
Elittdogg Elittdogg is offline
Member
 
Join Date: Aug 2007
Posts: 77
Question Object animation using a picture?

I need to animate a picture such that it moves forward a bit and backward a bit. Kind of like a moving room. I'm having trouble; here's what I've got:

import viz

tex1 = viz.add('picture.jpg')
quad = viz.add(viz.TEXQUAD)
quad.translate(0,1,12)
quad.scale(12.8, 10.24)
quad.texture(tex1)

moveForward = vizact.move(0,0,2,5)
moveBackward = vizact.move(0,0,-2,5)
#tex1.add(moveForward)
#tex1.add(moveBackward)
MovingRoom = vizact.sequence(moveForward,moveBackward,4)


def onkeydown(key):
if key == ' ':
tex1.add(MovingRoom)

viz.callback(viz.KEYDOWN_EVENT,onkeydown)

But when I run the script I get this error message:
Traceback (most recent call last):
File "Moving Room 3.py", line 25, in onkeydown
tex1.add(MovingRoom)
AttributeError: VizTexture instance has no attribute 'add'

Which, I guess, makes sense to me. But I wondering if there is a way around this. Like, how can I make it such that the picture moves forward X distance for Y duration and then backward X distance for Y duration...etc (i.e. put that in a loop/timer). Namely, I'd like the picture to keep moving forward and backward the entire time the script is running.

Thanks for the help.
Reply With Quote
  #2  
Old 09-06-2007, 11:37 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
You almost had it. You need to add the MovingRoom action to the quad, not the texture. Your code should look something like this:
Code:
import viz
viz.go()

tex1 = viz.add('picture.jpg')
quad = viz.add(viz.TEXQUAD)
quad.translate(0,1,12)
quad.scale(12.8, 10.24)
quad.texture(tex1)

moveForward = vizact.move(0,0,2,5)
moveBackward = vizact.move(0,0,-2,5)
MovingRoom = vizact.sequence(moveForward,moveBackward,4)


def onkeydown(key):
	if key == ' ':
		quad.add(MovingRoom)

viz.callback(viz.KEYDOWN_EVENT,onkeydown)
Reply With Quote
  #3  
Old 09-10-2007, 09:12 AM
Elittdogg Elittdogg is offline
Member
 
Join Date: Aug 2007
Posts: 77
Thank you for your help. It makes so much sense in retrospect.
Reply With Quote
Reply

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


All times are GMT -7. The time now is 05:33 AM.


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