WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   one side texture (https://forum.worldviz.com/showthread.php?t=2140)

jsnider 07-09-2009 11:25 AM

one side texture
 
I want to put a target on one side of a box. It seems that textures would work the best. I tried
Code:

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:
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


All times are GMT -7. The time now is 07:27 AM.

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