WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 01-18-2012, 12:48 PM
EnvisMJ EnvisMJ is offline
Member
 
Join Date: May 2009
Location: Purdue University, West Lafayette, Indiana
Posts: 44
Texturing a quad from within a class

So I'm trying to texture a quad bound to the screen from within a class.

Can anyone explain why this sample code works :

Code:
image = viz.add('Textures/VialLabels/Inventory Image - WHITE.png')
quad = viz.addTexQuad(viz.SCREEN,align=viz.TEXT_LEFT_BOTTOM,pos=(0,0,0))
quad.texture(image)
quad.setScale(6,3,1)
AND this doesn't?

Code:
import viz

class inventory(object):
	global bulkInventoryBins,medicationVials
	def __init__(self,contentsImage=""):
		self.obj = viz.add('box.wrl')
		self.obj.infoImage = contentsImage
	def showInfoImage(self):
		self.infoQuad = viz.addTexQuad(viz.SCREEN,align=viz.TEXT_LEFT_BOTTOM,pos=(0,0,0))
		self.infoQuad.texture(self.obj.infoImage)
		self.infoQuad.setScale(6,3,1)
	def removeInfoImage(self):
		self.infoQuad.remove()

A = inventory("Textures/VialLabels/Inventory Image - WHITE.png")
A.showInfoImage()
viz.go()
Reply With Quote
  #2  
Old 01-18-2012, 01:00 PM
EnvisMJ EnvisMJ is offline
Member
 
Join Date: May 2009
Location: Purdue University, West Lafayette, Indiana
Posts: 44
Clarification:

With the first piece of code, the quad appears, sized/positioned correctly, and with the texture applied. Also, "quad.remove()" will delete the quad.

With the second piece of code, the quad appears, sized/positioned correctly, however, it remains white with no texture. Also, "self.infoQuad.remove()" doesn't seem to remove it.
Reply With Quote
  #3  
Old 01-18-2012, 01:04 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
In the second example you are not actually creating a texture object. You are just passing the string containing the filename to the texture command. Unfortunately, the texture command silently ignores this error. It will be modified in a future release to raise an exception in this case. Either way, you can fix this problem by modifying the line:
Code:
self.obj.infoImage = contentsImage
to:
Code:
self.obj.infoImage = viz.add(contentsImage)
Reply With Quote
  #4  
Old 01-18-2012, 01:23 PM
EnvisMJ EnvisMJ is offline
Member
 
Join Date: May 2009
Location: Purdue University, West Lafayette, Indiana
Posts: 44
Awesome, thanks. ? Are you the only developer on the forums? Haven't seen anything from Jeff or Gladsome in a while.

Any idea why the remove doesn't seem to be working right?
Reply With Quote
  #5  
Old 01-18-2012, 01:37 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
There should be other developers and support team members active on this forum.

Your sample code never actually calls the removeInfoImage command. I tried adding a call to that command and it seems to work fine. You will need to make sure it is called after showInfoImage since the infoQuad attribute will not have been created yet.
Reply With Quote
  #6  
Old 01-24-2012, 01:12 PM
EnvisMJ EnvisMJ is offline
Member
 
Join Date: May 2009
Location: Purdue University, West Lafayette, Indiana
Posts: 44
ah, thanks :-)
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Jumping to a class object from one of it's components EnvisMJ Vizard 0 04-25-2011 11:22 AM
Collision of an avatar with a quad Frank Verberne Vizard 8 06-04-2008 09:44 AM
quad buffered stereo? halley Vizard 2 10-19-2005 12:28 PM
method of a class instance not accepted as Callback Gilliard Vizard 1 08-10-2005 05:49 PM
texturing on-the-fly objects vr_boyko Vizard 1 05-11-2005 05:06 PM


All times are GMT -7. The time now is 04:20 AM.


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