View Single Post
  #8  
Old 11-30-2004, 03:55 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

Okay, then the lag is coming from loading the textures. You can do two things. Preload all the textures and save them into a list. Or, when you add the textures, you can tell Vizard to use any existing texture with the same filename.
Code:
newtexture = viz.add(texture,viz.TEX_2D,1)
I would recommend that you simply preload all the textures into a python dictionary. I'm assuming the variable 'emotion' is a string.
Code:
#The following code will cache the emotion textures

#Create a python dictionary
self.emotionMap = {}

#A list of all the different emotion names
emotionNames = ['happy','sad','angry']

#Iterate through emotion names and load texture
for emotion in emotionNames:
	texture = self.prefix + '_Bio_UV_Head' + emotion + '.jpg'
	newtexture = viz.add(texture) 
	newtexture.wrap(viz.WRAP_S,viz.REPEAT) 
	newtexture.wrap(viz.WRAP_T,viz.REPEAT)
	#Save the texture in the emotion map
	self.emotionMap[emotion] = newtexture

#Now your changehead method should look like this
def changehead(self, emotion): 
	self.head.texture(self.emotionMap[emotion], 'geom_0')
Reply With Quote