本文整理汇总了Python中panda3d.core.GeomVertexWriter.addData4f方法的典型用法代码示例。如果您正苦于以下问题:Python GeomVertexWriter.addData4f方法的具体用法?Python GeomVertexWriter.addData4f怎么用?Python GeomVertexWriter.addData4f使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.core.GeomVertexWriter
的用法示例。
在下文中一共展示了GeomVertexWriter.addData4f方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __build_Star_Sphere
# 需要导入模块: from panda3d.core import GeomVertexWriter [as 别名]
# 或者: from panda3d.core.GeomVertexWriter import addData4f [as 别名]
def __build_Star_Sphere(self, bg_stars):
from panda3d.core import GeomVertexWriter, GeomVertexFormat, GeomVertexData
from panda3d.core import Geom, GeomNode, GeomPoints, AmbientLight
self.star_sphere_np.removeNode()
# Fill GeomVertexData.
vformat = GeomVertexFormat.getV3c4()
vdata = GeomVertexData("Data", vformat, Geom.UHStatic)
vertices = GeomVertexWriter(vdata, "vertex")
colours = GeomVertexWriter(vdata, "color")
for coords in bg_stars:
x, y, z = coords
vertices.addData3f(x, y, z)
colours.addData4f(1, 1, 1, 1)
# Render bg stars.
bg_stars = GeomPoints(Geom.UHStatic)
bg_stars.addNextVertices(_env.STAR_COUNT)
bg_stars_geom = Geom(vdata)
bg_stars_geom.addPrimitive(bg_stars)
star_sphere = GeomNode("star_sphere")
star_sphere.addGeom(bg_stars_geom)
star_sphere_np = NodePath(star_sphere)
star_sphere_np.reparentTo(self.NP)
return star_sphere_np
示例2: make_geom
# 需要导入模块: from panda3d.core import GeomVertexWriter [as 别名]
# 或者: from panda3d.core.GeomVertexWriter import addData4f [as 别名]
def make_geom(vertices, normals, colors, texcoords):
if panda3d is None: raise ImportError("Cannot locate Panda3D")
format = "V3"
if normals is not None:
assert len(normals) == len(vertices)
format += "n3"
if colors is not None:
assert len(colors) == len(vertices)
format += "cp"
if texcoords is not None:
assert len(texcoords) == len(vertices)
format += "t2"
format = getattr(GeomVertexFormat, "get" + format)()
vdata = GeomVertexData("", format, Geom.UHStatic)
v_vertex = GeomVertexWriter(vdata, 'vertex')
if normals is not None: v_normals = GeomVertexWriter(vdata, 'normal')
if colors is not None: v_colors = GeomVertexWriter(vdata, 'color')
if texcoords is not None: v_texcoords = GeomVertexWriter(vdata, 'texcoord')
for n in range(len(vertices)):
v_vertex.addData3f(*vertices[n])
if normals is not None: v_normals.addData3f(*normals[n])
if colors is not None: v_colors.addData4f(*colors[n])
if texcoords is not None: v_texcoords.addData2f(*texcoords[n])
return Geom(vdata)
示例3: makePoints
# 需要导入模块: from panda3d.core import GeomVertexWriter [as 别名]
# 或者: from panda3d.core.GeomVertexWriter import addData4f [as 别名]
def makePoints(n=1000):
""" make a cloud of points that are a single node VS branching and making subnodes to control display """
#points = np.random.uniform(-10,10,(n,4))
points = np.random.randn(n,3)
colors = np.random.rand(n,4)
fmt = GeomVertexFormat.getV3c4() #3 component vertex, w/ 4 comp color
vertexData = GeomVertexData('points', fmt, Geom.UHStatic)
verts = GeomVertexWriter(vertexData, 'vertex')
color = GeomVertexWriter(vertexData, 'color')
for point,clr4 in zip(points,colors):
#for point in points:
verts.addData3f(*point)
#color.addData4f(*point)
color.addData4f(*clr4)
#color.addData4f(.1,.1,.1,1)
#pointCloud = GeomLinestrips(Geom.UHStatic) #this is fucking cool!
pointCloud = GeomTristrips(Geom.UHStatic) #this is fucking cool!
#pointCloud = GeomPoints(Geom.UHStatic)
#pointCloud.addVerticies(*range(n))
pointCloud.addConsecutiveVertices(0,n) #warning may error since n-1?
pointCloud.closePrimitive()
cloud = Geom(vertexData)
cloud.addPrimitive(pointCloud)
return cloud
示例4: draw
# 需要导入模块: from panda3d.core import GeomVertexWriter [as 别名]
# 或者: from panda3d.core.GeomVertexWriter import addData4f [as 别名]
def draw(self):
if self.rendered_mesh != None:
self.reset_draw()
format=GeomVertexFormat.getV3n3cp()
vdata=GeomVertexData('tri', format, Geom.UHDynamic)
vertex=GeomVertexWriter(vdata, 'vertex')
normal=GeomVertexWriter(vdata, 'normal')
color=GeomVertexWriter(vdata, 'color')
v_mapping = {}
i=0
for v in self.verts.values():
vertex.addData3f(v.pos.x,v.pos.y,v.pos.z)
normal.addData3f(v.norm.x, v.norm.y, v.norm.z)
color.addData4f(v.color[0],v.color[1],v.color[2],v.color[3])
v_mapping[v.ID] = i
i += 1
mesh = Geom(vdata)
for f in self.faces.values():
tri = GeomTriangles(Geom.UHDynamic)
tri.addVertex(v_mapping[f.v1.ID])
tri.addVertex(v_mapping[f.v2.ID])
tri.addVertex(v_mapping[f.v3.ID])
tri.closePrimitive()
mesh.addPrimitive(tri)
snode = GeomNode(self.name)
snode.addGeom(mesh)
self.rendered_mesh = render.attachNewNode(snode)
self.rendered_mesh.setTwoSided(True)
示例5: makeSelectRect
# 需要导入模块: from panda3d.core import GeomVertexWriter [as 别名]
# 或者: from panda3d.core.GeomVertexWriter import addData4f [as 别名]
def makeSelectRect():
ctup = (1,1,1,1)
fmt = GeomVertexFormat.getV3c4()
vertexData = GeomVertexData('points', fmt, Geom.UHDynamic)
points = ( #makes nice for Tristrips
(0,0,0),
(0,0,1),
(1,0,0),
(1,0,1),
)
verts = GeomVertexWriter(vertexData, 'vertex')
color = GeomVertexWriter(vertexData, 'color')
for point in points:
verts.addData3f(*point)
color.addData4f(*ctup)
boxLines = GeomLinestrips(Geom.UHDynamic)
boxLines.addVertices(0,1,3,2)
boxLines.addVertex(0)
boxLines.closePrimitive()
boxTris = GeomTristrips(Geom.UHDynamic)
boxTris.addConsecutiveVertices(0,3)
boxTris.closePrimitive()
box = Geom(vertexData)
box.addPrimitive(boxLines)
#box.addPrimitive(boxTris)
return box
示例6: add_plane
# 需要导入模块: from panda3d.core import GeomVertexWriter [as 别名]
# 或者: from panda3d.core.GeomVertexWriter import addData4f [as 别名]
def add_plane(map_width, map_height):
# Prepare the vertex format writers
v_fmt = GeomVertexFormat.getV3n3c4()
v_data = GeomVertexData('TerrainData', v_fmt, Geom.UHStatic)
vertex = GeomVertexWriter(v_data, 'vertex')
normal = GeomVertexWriter(v_data, 'normal')
color = GeomVertexWriter(v_data, 'color')
#texcoord = GeomVertexWriter(v_data, 'texcoord')
# Create a primitive
prim = GeomTrifans(Geom.UHStatic)
poly_color = (uniform(0, 0.05), uniform(0, 0.5), uniform(0.5, 1), 0.5, )
for i, point in enumerate([
(-map_width/2, -map_height/2),
(map_width/2, -map_height/2),
(map_width/2, map_height/2),
(-map_width/2, map_height/2), ]):
x, y = point
vertex.addData3f(x, y, 0)
normal.addData3f(0, 0, 1)
color.addData4f(*poly_color)
#texcoord.addData2f(1, 0)
prim.addVertex(i)
prim.addVertex(0)
prim.closePrimitive()
# Add to the scene graph
geom = Geom(v_data)
geom.addPrimitive(prim)
node = GeomNode('gnode')
node.addGeom(geom)
nodePath = render.attachNewNode(node)
nodePath.setTwoSided(True)
nodePath.setAlphaScale(0.5)
示例7: create_geom
# 需要导入模块: from panda3d.core import GeomVertexWriter [as 别名]
# 或者: from panda3d.core.GeomVertexWriter import addData4f [as 别名]
def create_geom(self, sidelength):
# Set up the vertex arrays
vformat = GeomVertexFormat.getV3n3c4()
vdata = GeomVertexData("Data", vformat, Geom.UHDynamic)
vertex = GeomVertexWriter(vdata, 'vertex')
normal = GeomVertexWriter(vdata, 'normal')
color = GeomVertexWriter(vdata, 'color')
geom = Geom(vdata)
# Write vertex data
for x in range(0, sidelength):
for y in range(0, sidelength):
# vertex_number = x * sidelength + y
v_x, v_y, v_z = self.map_b[(x, y)]
n_x, n_y, n_z = 0.0, 0.0, 1.0
c_r, c_g, c_b, c_a = 0.5, 0.5, 0.5, 0.5
vertex.addData3f(v_x, v_y, v_z)
normal.addData3f(n_x, n_y, n_z)
color.addData4f(c_r, c_g, c_b, c_a)
# Add triangles
for x in range(0, sidelength - 1):
for y in range(0, sidelength - 1):
# The vertex arrangement (y up, x right)
# 2 3
# 0 1
v_0 = x * sidelength + y
v_1 = x * sidelength + (y + 1)
v_2 = (x + 1) * sidelength + y
v_3 = (x + 1) * sidelength + (y + 1)
if (x+y)%1 == 0: # An even square
tris = GeomTriangles(Geom.UHStatic)
tris.addVertices(v_0, v_2, v_3)
tris.closePrimitive()
geom.addPrimitive(tris)
tris = GeomTriangles(Geom.UHStatic)
tris.addVertices(v_3, v_1, v_0)
tris.closePrimitive()
geom.addPrimitive(tris)
else: # An odd square
tris = GeomTriangles(Geom.UHStatic)
tris.addVertices(v_1, v_0, v_2)
tris.closePrimitive()
geom.addPrimitive(tris)
tris = GeomTriangles(Geom.UHStatic)
tris.addVertices(v_2, v_3, v_1)
tris.closePrimitive()
geom.addPrimitive(tris)
# Create the actual node
node = GeomNode('geom_node')
node.addGeom(geom)
# Remember GeomVertexWriters to adjust vertex data later
#self.vertex_writer = vertex
#self.color_writer = color
self.vdata = vdata
return node
示例8: makeSquare
# 需要导入模块: from panda3d.core import GeomVertexWriter [as 别名]
# 或者: from panda3d.core.GeomVertexWriter import addData4f [as 别名]
def makeSquare(x1, y1, z1, x2, y2, z2):
format = GeomVertexFormat.getV3n3cpt2()
vdata = GeomVertexData('square', format, Geom.UHDynamic)
vertex = GeomVertexWriter(vdata, 'vertex')
normal = GeomVertexWriter(vdata, 'normal')
color = GeomVertexWriter(vdata, 'color')
texcoord = GeomVertexWriter(vdata, 'texcoord')
# make sure we draw the sqaure in the right plane
if x1 != x2:
vertex.addData3(x1, y1, z1)
vertex.addData3(x2, y1, z1)
vertex.addData3(x2, y2, z2)
vertex.addData3(x1, y2, z2)
normal.addData3(normalized(2 * x1 - 1, 2 * y1 - 1, 2 * z1 - 1))
normal.addData3(normalized(2 * x2 - 1, 2 * y1 - 1, 2 * z1 - 1))
normal.addData3(normalized(2 * x2 - 1, 2 * y2 - 1, 2 * z2 - 1))
normal.addData3(normalized(2 * x1 - 1, 2 * y2 - 1, 2 * z2 - 1))
else:
vertex.addData3(x1, y1, z1)
vertex.addData3(x2, y2, z1)
vertex.addData3(x2, y2, z2)
vertex.addData3(x1, y1, z2)
normal.addData3(normalized(2 * x1 - 1, 2 * y1 - 1, 2 * z1 - 1))
normal.addData3(normalized(2 * x2 - 1, 2 * y2 - 1, 2 * z1 - 1))
normal.addData3(normalized(2 * x2 - 1, 2 * y2 - 1, 2 * z2 - 1))
normal.addData3(normalized(2 * x1 - 1, 2 * y1 - 1, 2 * z2 - 1))
# adding different colors to the vertex for visibility
color.addData4f(1.0, 0.0, 0.0, 1.0)
color.addData4f(0.0, 1.0, 0.0, 1.0)
color.addData4f(0.0, 0.0, 1.0, 1.0)
color.addData4f(1.0, 0.0, 1.0, 1.0)
texcoord.addData2f(0.0, 1.0)
texcoord.addData2f(0.0, 0.0)
texcoord.addData2f(1.0, 0.0)
texcoord.addData2f(1.0, 1.0)
# Quads aren't directly supported by the Geom interface
# you might be interested in the CardMaker class if you are
# interested in rectangle though
tris = GeomTriangles(Geom.UHDynamic)
tris.addVertices(0, 1, 3)
tris.addVertices(1, 2, 3)
square = Geom(vdata)
square.addPrimitive(tris)
return square
示例9: createTriangle
# 需要导入模块: from panda3d.core import GeomVertexWriter [as 别名]
# 或者: from panda3d.core.GeomVertexWriter import addData4f [as 别名]
def createTriangle(v1, v2, v3, is_flat=False):
x1 = v1.x
y1 = v1.y
z1 = v1.z
x2 = v2.x
y2 = v2.y
z2 = v2.z
x3 = v3.x
y3 = v3.y
z3 = v3.z
format=GeomVertexFormat.getV3n3cp()
vdata=GeomVertexData('tri', format, Geom.UHDynamic)
vertex=GeomVertexWriter(vdata, 'vertex')
normal=GeomVertexWriter(vdata, 'normal')
color=GeomVertexWriter(vdata, 'color')
vertex.addData3f(x1, y1, z1)
vertex.addData3f(x2, y2, z2)
vertex.addData3f(x3, y3, z3)
if is_flat:
normVector = norm(Vec3( (x1 + x2 + x3)/3.0, (y1 + y2 + y3)/3.0, (z1+ z2+ z3)/3.0))
normal.addData3f(normVector)
normal.addData3f(normVector)
normal.addData3f(normVector)
else:
normal.addData3f(norm(Vec3(x1,y1,z1)))
normal.addData3f(norm(Vec3(x2,y2,z2)))
normal.addData3f(norm(Vec3(x3,y3,z3)))
#adding different colors to the vertex for visibility
color.addData4f(0.5,0.5,0.5,1.0)
color.addData4f(0.5,0.5,0.5,1.0)
color.addData4f(0.5,0.5,0.5,1.0)
tri = GeomTriangles(Geom.UHDynamic)
tri.addVertex(0)
tri.addVertex(1)
tri.addVertex(2)
tri.closePrimitive()
output_tri = Geom(vdata)
output_tri.addPrimitive(tri)
return output_tri
示例10: makeAxis
# 需要导入模块: from panda3d.core import GeomVertexWriter [as 别名]
# 或者: from panda3d.core.GeomVertexWriter import addData4f [as 别名]
def makeAxis(): #FIXME make this scale based on zoom???
"""
x y z
r g b
"""
colors = (
(1,0,0,1),
(0,1,0,1),
(0,0,1,1),
(1,0,0,1),
(0,1,0,1),
(0,0,1,1),
)
points = (
(0,0,0),
(0,0,0),
(0,0,0),
(1,0,0),
(0,1,0),
(0,0,1),
)
fmt = GeomVertexFormat.getV3c4() #3 component vertex, w/ 4 comp color
#fmt = GeomVertexFormat.getV3() #3 component vertex, w/ 4 comp color
vertexData = GeomVertexData('points', fmt, Geom.UHStatic)
verts = GeomVertexWriter(vertexData, 'vertex')
color = GeomVertexWriter(vertexData, 'color')
for p,c in zip(points,colors):
verts.addData3f(*p)
color.addData4f(*c)
axisX = GeomLinestrips(Geom.UHStatic)
axisX.addVertices(0,3)
axisX.closePrimitive()
axisY = GeomLinestrips(Geom.UHStatic)
axisY.addVertices(1,4)
axisY.closePrimitive()
axisZ = GeomLinestrips(Geom.UHStatic)
axisZ.addVertices(2,5)
axisZ.closePrimitive()
axis = Geom(vertexData)
axis.addPrimitive(axisX)
axis.addPrimitive(axisY)
axis.addPrimitive(axisZ)
return axis
示例11: update_geometry
# 需要导入模块: from panda3d.core import GeomVertexWriter [as 别名]
# 或者: from panda3d.core.GeomVertexWriter import addData4f [as 别名]
def update_geometry(self):
# The geosphere itself
vertex = GeomVertexWriter(self.sphere_vdata, 'vertex')
normal = GeomVertexWriter(self.sphere_vdata, 'normal')
# u_map and v_map are in [-pi, pi]
u_map_list = [(float(u) / float(self.res[0]) - 0.5) * 2.0 * pi for u in range(0, self.res[0] + 1)]
v_map_list = [(float(v) / float(self.res[1]) - 0.5) * 2.0 * pi for v in range(0, self.res[1] + 1)]
if self.unwrap_state == 0.0: # Flat map
for v_map in v_map_list:
for u_map in u_map_list:
vertex.addData3f(u_map, 0.0, v_map / 2.0)
normal.addData3f(0.0, -1.0, 0.0)
else: # Non-flat map
sphere_radius = 1.0 / self.unwrap_state
sphere_offset = sphere_radius - self.unwrap_state
for v_map in v_map_list:
for u_map in u_map_list:
u_sphere = u_map / sphere_radius
v_sphere = v_map / sphere_radius
# And this, kids, is why you should pay attention in trigonometry.
v_x, v_y, v_z = sin(u_sphere) * cos(v_sphere/2.0) * sphere_radius, \
-cos(u_sphere) * cos(v_sphere/2.0) * sphere_radius + sphere_offset, \
sin(v_sphere / 2.0) * sphere_radius
n_x_un, n_y_un, n_z_un = v_x, sphere_offset - v_y, v_z # FIXME: This is a lie.
length = sqrt(n_x_un**2 + n_y_un**2 + n_z_un**2)
n_x, n_y, n_z = n_x_un / length, n_y_un / length, n_z_un / length
vertex.addData3f(v_x, v_y, v_z)
normal.addData3f(n_x, n_y, n_z)
# The connections between bases
segs_per_connection = 30
vertex = GeomVertexWriter(self.connections_vdata, 'vertex')
color = GeomVertexWriter(self.connections_vdata, 'color')
for c_1_uv, c_2_uv in self.connections:
# s will be [0.0, 1.0]
for s in [float(c)/float(segs_per_connection+1) for c in range(0, segs_per_connection+2)]:
u = (c_1_uv[0] * s) + (c_2_uv[0] * (1.0 - s))
v = (c_1_uv[1] * s) + (c_2_uv[1] * (1.0 - s))
(v_x, v_y, v_z), (n_x, n_y, n_z) = self.uv_to_xyz(u, v)
min_height = 0.0001 * (1.0 - self.unwrap_state)
max_height = (0.2 - min_height) * self.unwrap_state
seg_height = (1.0 - (abs(s-0.5) * 2.0)**2.0) * max_height + min_height
vertex.addData3f(v_x + n_x*seg_height,
v_y + n_y*seg_height,
v_z + n_z*seg_height)
color.addData4f(1, 1, 1, 1)
for c in range(0, len(self.connections)):
for s in range(0, segs_per_connection+1):
seg = GeomLines(Geom.UHDynamic)
seg.addVertices(c*(segs_per_connection+2) + s, c*(segs_per_connection+2) + s + 1)
seg.closePrimitive()
self.connections_geom.addPrimitive(seg)
示例12: createTetraeder
# 需要导入模块: from panda3d.core import GeomVertexWriter [as 别名]
# 或者: from panda3d.core.GeomVertexWriter import addData4f [as 别名]
def createTetraeder(self, iterations):
'''
Note that the first and the last node of the Thetha_Range should be 0 and 180 Degrees
because this will be just one time added to verticies
'''
#Format
format = GeomVertexFormat.getV3n3cpt2()
#VertexData
vdata = GeomVertexData('name', format, Geom.UHDynamic)
##VertexWriter
vertex = GeomVertexWriter(vdata, 'vertex')
normal = GeomVertexWriter(vdata, 'normal')
color = GeomVertexWriter(vdata, 'color')
texcoord = GeomVertexWriter(vdata, 'texcoord')
vertex.addData3f(0,1.434,-0.507)
vertex.addData3f(-1.242,-0.717,-0.507)
vertex.addData3f(1.242,-0.717,-0.507)
vertex.addData3f(0,0,1.521)
color.addData4f(1,1,1,1)
color.addData4f(1,1,1,1)
color.addData4f(1,1,1,1)
color.addData4f(1,1,1,1)
normal.addData3f(0,1.434,-0.507)
normal.addData3f(-1.242,-0.717,-0.507)
normal.addData3f(1.242,-0.717,-0.507)
normal.addData3f(0,0,1.521)
### Create Geom
geom = Geom(vdata)
### Create Primitives
prim = GeomTriangles(Geom.UHStatic)
prim.addVertices(0, 1, 2)
prim.addVertices(0, 1, 3)
prim.addVertices(1, 2, 3)
prim.addVertices(2, 0, 3)
prim.closePrimitive()
geom.addPrimitive(prim)
node = GeomNode('gnode')
node.addGeom(geom)
return node
示例13: makePoint
# 需要导入模块: from panda3d.core import GeomVertexWriter [as 别名]
# 或者: from panda3d.core.GeomVertexWriter import addData4f [as 别名]
def makePoint(point=(0,0,0)):
clr4 = [1,1,1,1]
fmt = GeomVertexFormat.getV3c4() #3 component vertex, w/ 4 comp color
vertexData = GeomVertexData('points', fmt, Geom.UHStatic)
verts = GeomVertexWriter(vertexData, 'vertex')
verts.addData3f(*point)
color = GeomVertexWriter(vertexData, 'color')
color.addData4f(*clr4)
pointCloud = GeomPoints(Geom.UHStatic)
pointCloud.addVertex(0)
pointCloud.closePrimitive()
cloud = Geom(vertexData)
cloud.addPrimitive(pointCloud)
cloudNode = GeomNode('point')
cloudNode.addGeom(cloud)
return cloudNode
示例14: makeCameraTarget
# 需要导入模块: from panda3d.core import GeomVertexWriter [as 别名]
# 或者: from panda3d.core.GeomVertexWriter import addData4f [as 别名]
def makeCameraTarget():
colors = (
(0,0,1,1),
(1,0,0,1),
(0,1,0,1),
(0,0,1,1),
(1,0,0,1),
(0,1,0,1),
)
points = (
(0,0,1),
(-1,0,0),
(0,-1,0),
(0,0,-1),
(1,0,0),
(0,1,0),
(0,0,1),
)
fmt = GeomVertexFormat.getV3c4() #3 component vertex, w/ 4 comp color
#fmt = GeomVertexFormat.getV3() #3 component vertex, w/ 4 comp color
vertexData = GeomVertexData('points', fmt, Geom.UHStatic)
verts = GeomVertexWriter(vertexData, 'vertex')
color = GeomVertexWriter(vertexData, 'color')
for p,c in zip(points,colors):
verts.addData3f(*p)
color.addData4f(*c)
targetTris = GeomTristrips(Geom.UHStatic)
targetTris.addConsecutiveVertices(0,6)
targetTris.addVertex(0)
targetTris.addVertex(1)
targetTris.addVertex(3)
targetTris.addVertex(5)
targetTris.addVertex(2)
targetTris.addVertex(4)
targetTris.addVertex(0)
targetTris.closePrimitive()
target = Geom(vertexData)
target.addPrimitive(targetTris)
return target
示例15: makeGeom
# 需要导入模块: from panda3d.core import GeomVertexWriter [as 别名]
# 或者: from panda3d.core.GeomVertexWriter import addData4f [as 别名]
def makeGeom(index_counter, array,ctup,i,pipe, geomType=GeomPoints):
""" multiprocessing capable geometery maker """
#man = indexMan(('127.0.0.1',5000), authkey='none')
#man.connect()
#index = man.index()
index = {}
fmt = GeomVertexFormat.getV3c4()
vertexData = GeomVertexData('points', fmt, Geom.UHDynamic) #FIXME use the index for these too? with setPythonTag, will have to 'reserve' some
#vertexData.setPythonTag('uid',index.reserve()) #maybe we don't need this? the geom should have it all?
cloudGeom = Geom(vertexData)
#cloudGeom.setPythonTag('uid',index.reserve())
cloudNode = GeomNode('bin %s selectable'%(i))
uid = next(index_counter)
index[uid] = None
cloudNode.setPythonTag('uid',uid) #FIXME we return cloudnode elsewhere... maybe on the other end we can set the uid in the index properly?
points = array
verts = GeomVertexWriter(vertexData, 'vertex')
color = GeomVertexWriter(vertexData, 'color')
for point in points:
index[next(index_counter)]=[point,cloudNode.getPythonTag('uid'),None] #FIXME we're gonna need a decode on the other end?
verts.addData3f(*point)
color.addData4f(*ctup)
points = geomType(Geom.UHDynamic)
points.addConsecutiveVertices(0,len(array))
points.closePrimitive()
cloudGeom.addPrimitive(points)
cloudNode.addGeom(cloudGeom) #TODO figure out if it is faster to add and subtract Geoms from geom nodes...
#output[i] = cloudNode
#print('ping',{i:cloudNode})
#pipe.send((i,))
#out = q.get()
#print('pong',out)
#q.put(out)
if pipe == None:
return cloudNode, index
pipe.send(cloudNode.encodeToBamStream()) #FIXME make this return a pointer NOPE
pipe.send(index) #FIXME make this return a pointer NOPE