PDA

View Full Version : texturing on-the-fly objects


vr_boyko
05-11-2005, 04:38 PM
I would like to apply a simple texture to an on-the-fly QUAD:


viz.startlayer(viz.QUADS)
viz.vertex(-.5,0,0)
viz.vertex(.5,0,0)
viz.vertex(.5,-DELTA,11)
viz.vertex(-.5,-DELTA,11)
plank = viz.endlayer()

plank.texture("wood.gif")


doesn't do it ... am I doing something wrong?

farshizzo
05-11-2005, 05:06 PM
Hi,

Two problems. First, for each vertex you need to define a texture coordinate. Second, you need to add the texture before you apply it to an object. Sample code:viz.startlayer(viz.QUADS)

#Lower left vertex
viz.texcoord(0,0)
viz.vertex(...)

#Upper left vertex
viz.texcoord(0,1)
viz.vertex(...)

#Upper right vertex
viz.texcoord(1,1)
viz.vertex(...)

#Lower right vertex
viz.texcoord(1,0)
viz.vertex(...)

plank = viz.endlayer()

plank.texture(viz.add('wood.gif'))