Skip to content

Instantly share code, notes, and snippets.

@rdb
Created March 17, 2021 12:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rdb/276ccea7edd90cca36459630fdd39464 to your computer and use it in GitHub Desktop.
Save rdb/276ccea7edd90cca36459630fdd39464 to your computer and use it in GitHub Desktop.
Rendering many points in Panda3D
from panda3d.core import *
from random import random
num_points = 100000
vdata = GeomVertexData('points', GeomVertexFormat.get_v3(), GeomEnums.UH_static)
vdata.set_num_rows(num_points)
vertex = GeomVertexWriter(vdata, 'vertex')
for i in range(num_points):
vertex.set_data3(random() - 0.5, random() - 0.5, random() - 0.5)
primitive = GeomPoints(GeomEnums.UH_static)
primitive.add_next_vertices(num_points)
geom = Geom(vdata)
geom.add_primitive(primitive)
gnode = GeomNode('points')
gnode.add_geom(geom)
# Render the node
from direct.showbase.ShowBase import ShowBase
base = ShowBase()
base.set_background_color((0, 0, 0))
base.render.attach_new_node(gnode)
base.cam.set_y(-5)
base.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment