Created
March 17, 2021 12:06
-
-
Save rdb/276ccea7edd90cca36459630fdd39464 to your computer and use it in GitHub Desktop.
Rendering many points in Panda3D
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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