Vizard 7 » Reference » 3D models » Creating 3D models on-the-fly » Vertex properties
7.6

Vertex properties

In addition to defining the shape of an on-the-fly object, you can also use vertices to define its size and color.  Check out the following section for information on changing vertex parameters dynamically (or after the layer has already been created).

Note: To manipulate an on-the-fly object as a whole, use the commands you would use with any 3d object (<node3d>.setPosition, <node3d>.setScale, <node3d>.color, etc.).

Vertex color

To set vertex color, include viz.vertexColor([r,g,b]) before the vertices you want to effect. Replace [r,g,b] with the color values you want. All the vertices after this command will be effected unless you add another viz.vertexColor([r,g,b]).

viz.startLayer(viz.TRIANGLE_FAN)
viz.vertexColor(1,0,0)#Color the first vertex as red.
viz.vertex(0,1,5)
viz.vertexColor(0,0,1) #Color the rest of the vertices blue.
viz.vertex(-1.5,1.35,10)
viz.vertex(-.25,1.5,10)
viz.vertex(0,.8,10)
viz.vertex(.25,1.5,10)
viz.vertex(1.5,1.35,10)
myPaperairplane = viz.endLayer()

Point size

If your layer is a group of points, use viz.pointSize(<size>) between the viz.startLayer and viz.endLayer commands, replacing <size> with the desired width in pixels.

viz.startLayer(viz.POINTS)
viz.pointSize(5)#Set the size of the points.
viz.vertex(-.5,1,5)
viz.vertex(-.5,2,5)
viz.vertex(.5,1,5)
myPoints = viz.endLayer()

Line width

If your layer consists of lines, use viz.lineWidth(size) between the viz.startLayer and viz.endLayer commands, replacing <size> with the desired width in pixels.

viz.startLayer(viz.LINE_LOOP)
viz.lineWidth(10)#Set the size of the lines.
viz.vertex(-1,1,5)
viz.vertex(-1,2,5)
viz.vertex(0,2,10)
myLoop = viz.endLayer()

Setting the texture coordinates

Include viz.texCoord([x,y]) before adding each vertex for which you want to apply a texture coordinate. Replace [x,y] with the texture coordinates for that vertex.

viz.startLayer(viz.QUADS)
viz.texCoord(0,0)
viz.vertex(-1,1,5)
viz.texCoord(1,0)
viz.vertex(1,1,5)
viz.texCoord(1,1)
viz.vertex(1.5,3,5)
viz.texCoord(0,1)
viz.vertex(-1.5,3,5)
myQuad = viz.endLayer()
myQuad.texture(viz.add('image2.jpg'))

See also

In this section:

Creating 3D models on-the-fly-- the basics

Changing vertices on-the-fly

Creating models on-the-fly command table

Other sections:

3D model transform basics

Tutorial: On-the-fly objects

Example scripts:

3D objects on-the-fly