View Single Post
  #2  
Old 09-17-2010, 12:28 PM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
Texturing an on-the-fly object is possible. You'll want to set the texture coordinate assosiated with each vertex with the viz.texcoord command. Apply a texture to the completed object with
Code:
roadTexture = viz.add('road.jpg')
myPolygon.texture(roadTexture)
Texture coordinates go from 0 to 1; [0,0] representing the lower left pixle of the texture, [1,1] upper right (I think). Each pixel of the texture is overlayed on your myPolygon verticies according to the verticie's assosated texture coordinate. If you assign texture coordinates over 1, then you will want to set the wrap mode of the texture to get it to tile, rather than just smear the last pixel in your texture.

Code:
viz.startLayer(viz.POLYGON)

viz.texcoord(0,2)
viz.vertex(-1,1,0)

viz.texcoord(2,2)
viz.vertex(1,1,0)

viz.texcoord(2,0)
viz.vertex(1,-1,0)

viz.texcoord(0,0)
viz.vertex(-1,-1,0)

q = viz.endLayer()
t = viz.add('ball.jpg')
t.wrap(viz.WRAP_S,viz.REPEAT)
t.wrap(viz.WRAP_T,viz.REPEAT)
q.texture(t)
__________________
Paul Elliott
WorldViz LLC
Reply With Quote