WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 09-28-2005, 06:35 PM
vsully vsully is offline
Member
 
Join Date: Sep 2004
Posts: 24
Send a message via AIM to vsully
.translate 'n' .goto

Hi,

Trying to animate an object reseting to a position then moving to locatoin. Right now using a 'myfunc' director function to call a .translate and a .goto.

Problem is, repeated calls to viz.director(myfunc) results in the object moving farther and farther away.

.translates are absolute_world.

thoughts?

second thoughts, it works with simple scripts, but not with the 3dsound and texturing i'm trying. i've attached the portion of the code this deals with.

Code:
import viz

viz.go()

CAR_TRANSFORM = [1,1,1]
CAR_GOTO = 15

#Add mini
mini = viz.add('mini.osgx')
mini.translate(CAR_TRANSFORM, viz.ABSOLUTE_WORLD)

#Mini cooper textures
miniTextures = [viz.add('images/coopers01_chilired.jpg')]

def movecar():	
	#texture car
	mini.texture(miniTextures[0],'default')
	#play sound
	mini.playsound('audio/vwbuggy.wav',viz.PLAY)

	mini.translate(CAR_TRANSFORM, viz.ABSOLUTE_WORLD)
	dest = CAR_TRANSFORM
	dest[2] = dest[2] + CAR_GOTO
	mini.goto(dest, 2, viz.SPEED)

	vizact.waittime(3)
	
def stuff(key):
	viz.director(movecar)
	
viz.callback(viz.KEYUP_EVENT, stuff)

Last edited by vsully; 09-28-2005 at 06:41 PM.
Reply With Quote
  #2  
Old 09-28-2005, 09:55 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

The problem is with the following line:
Code:
dest = CAR_TRANSFORM
In python when you assign a list to a variable, it doesn't make a copy. So when you modify the z coordinate of the dest variable you are also modifying the CAR_TRANSFORM variable. Use the following code to make a copy of the list:
Code:
dest = CAR_TRANSFORM[:]
Reply With Quote
  #3  
Old 09-28-2005, 09:59 PM
vsully vsully is offline
Member
 
Join Date: Sep 2004
Posts: 24
Send a message via AIM to vsully
k thanks - i was thinking it might be something simple like that...
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 11:21 AM.


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