PDA

View Full Version : Applying texture or colour to an on-the-fly object


tomo_the_third
06-22-2009, 03:04 AM
Hello I am sorry that this must seem a very low-tech question compared to the others in this forum but I'm trying to meet a deadline and I'm getting frequently frustrated by the Vizard tutorials.

I am creating an "on-the-fly" object and need to add texture or colour to its faces. I wish to make the faces of the corner a different colour or different texture. How do I go about doing this?

I include the code for my object here:

#start corner

RADIUS = 0.12

#topandbottom vertices
viz.startlayer(viz.LINES)
viz.vertexcolor(0, 0.6, 0)
viz.vertex(-RADIUS, -RADIUS, -RADIUS)
viz.vertex(-RADIUS, -RADIUS, RADIUS)
viz.vertex(-RADIUS, -RADIUS, -RADIUS)
viz.vertex( RADIUS, -RADIUS, -RADIUS)

viz.startlayer(viz.LINES)
viz.vertex(-RADIUS, RADIUS, -RADIUS)
viz.vertex(-RADIUS, RADIUS, RADIUS)
viz.vertex(-RADIUS, RADIUS, -RADIUS)
viz.vertex( RADIUS, RADIUS, -RADIUS)

#Sides
viz.startlayer(viz.LINES)
viz.vertex(-RADIUS, -RADIUS, -RADIUS)
viz.vertex(-RADIUS, RADIUS, -RADIUS)
viz.vertex( RADIUS, RADIUS, -RADIUS)
viz.vertex( RADIUS, -RADIUS, -RADIUS)
viz.startlayer(viz.LINES)
viz.vertex(-RADIUS, -RADIUS, RADIUS)
viz.vertex(-RADIUS, RADIUS, RADIUS)

macorner = viz.endlayer()

#position corner 1.5m away
macorner.translate(0, 1.8, 1.5)
macorner.setAxisAngle( [0, 1, 0 , -45] )

#end corner

Jeff
06-22-2009, 11:12 AM
You could add two on-the-fly quads inside your lines as the faces you want to apply texture or color to. This page in the docs show an example of applying a texture to an on-the-fly quad.

http://www.worldviz.com/vizhelp/VizHelp.htm#Setting_vertex_colors_and_sizes.htm