PDA

View Full Version : one side texture


jsnider
07-09-2009, 11:25 AM
I want to put a target on one side of a box. It seems that textures would work the best. I tried

target=viz.add('box.wrl')
pic = viz.addTexture('tex.jpg')
target.texture(pic)

where tex.jpg is a 256x256 image of a bullseye, but it puts the texture on all sides (as I assume it should). Is there anyway around that or a different approach that would work better?
Thanks,
Joe

farshizzo
07-09-2009, 12:52 PM
You can use the undocumented vizshape module to create a box with each face split into a separate sub-node, allowing you to apply a different texture. Here is some sample code:import viz
import vizshape
viz.go()

#Create box with each face split into separate sub-node
box = vizshape.addBox([1,1,1],splitFaces=True,pos=(0,1.8,4))
box.addAction(vizact.spin(0,1,0,45))

#Create textures
t1 = viz.add('image1.jpg')
t2 = viz.add('image2.jpg')

#Apply first texture to front/back face
box.texture(t1,node='front')
box.texture(t1,node='back')

#Apply second texture to left/right face
box.texture(t2,node='left')
box.texture(t2,node='right')

jsnider
07-09-2009, 02:17 PM
Thank you. That worked perfect. :D
Joe