2 Demonstrates how to create a mesh from scratch and to set color per vertex data.
7 def makePyramidMesh(mesh, side=20.0):
15 mesh.GetFace(0).SetVerts(0, 1, 2)
16 mesh.GetFace(0).SetEdgeVisFlags(1, 1, 0)
17 mesh.GetFace(1).SetVerts(0, 2, 3)
18 mesh.GetFace(1).SetEdgeVisFlags(1, 1, 0)
19 mesh.GetFace(2).SetVerts(0, 3, 1)
20 mesh.GetFace(2).SetEdgeVisFlags(1, 1, 0)
21 mesh.GetFace(3).SetVerts(1, 2, 3)
22 mesh.GetFace(3).SetEdgeVisFlags(1, 1, 0)
23 mesh.InvalidateGeomCache()
24 mesh.InvalidateTopologyCache()
27 def outputChannel(mc, name):
34 mc.NumTextureVertices)
35 for tv
in mc.TextureVertices:
40 for tf
in mc.TextureFaces:
42 "Texture vertex indices %d, %d, %d" % (tf.A, tf.B, tf.C))
45 def outputChannels(mesh):
46 outputChannel(mesh.DefaultMap,
"default")
47 outputChannel(mesh.AlphaMap,
"alpha")
48 outputChannel(mesh.ColorPerVertexMap,
"color per vertex")
49 outputChannel(mesh.ShadingMap,
"shading")
54 tri = MaxPlus.TriObject._CastFrom(geom)
60 mesh.ColorPerVertexMap.SetNumTextureVertices(2)
61 mesh.ColorPerVertexMap.SetTextureVertex(0,
MaxPlus.Point3(1, 0, 0))
62 mesh.ColorPerVertexMap.SetTextureVertex(1,
MaxPlus.Point3(0, 0, 1))
63 mesh.ColorPerVertexMap.SetTextureFace(0, 0, 0, 1)
64 mesh.ColorPerVertexMap.SetTextureFace(1, 0, 1, 1)
65 mesh.ColorPerVertexMap.SetTextureFace(2, 1, 1, 1)
66 mesh.ColorPerVertexMap.SetTextureFace(3, 0, 0, 0)
68 node.VertexColorMode =
True
70 if __name__ ==
"__main__":