Could someone shows me a to draw just a triangle programmatically on the screen using panda3d and python?
I tried but… I can not see anything!
from direct.showbase.ShowBase import ShowBase
from panda3d.core import *
class MyApp(ShowBase):
def __init__(self):
ShowBase.__init__(self)
format = GeomVertexFormat.getV3()
vdata = GeomVertexData('geoide', format, Geom.UHStatic)
vertex = GeomVertexWriter(vdata, 'vertex')
vertex.addData3f(0, 0, 0)
vertex.addData3f(0, 0, 5)
vertex.addData3f(0, 5, 5)
prim = GeomTriangles(Geom.UHStatic)
prim.addVertices(0, 1, 2)
#prim.closePrimitive()
geom = Geom(vdata)
geom.addPrimitive(prim)
node = GeomNode('gnode')
node.addGeom(geom)
nodePath = render.attachNewNode(node)
print(nodePath)
app = MyApp()
app.run()
[/code]