本文整理汇总了Python中panda3d.core.GeomVertexFormat.getV3c4方法的典型用法代码示例。如果您正苦于以下问题:Python GeomVertexFormat.getV3c4方法的具体用法?Python GeomVertexFormat.getV3c4怎么用?Python GeomVertexFormat.getV3c4使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.core.GeomVertexFormat
的用法示例。
在下文中一共展示了GeomVertexFormat.getV3c4方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _makeGeom
# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3c4 [as 别名]
def _makeGeom(array,ctup,i,pipe, geomType=GeomPoints): #XXX testing multiple Geom version ... for perf seems like it will be super slow
#SUUUPER slow TONS of draw calls
#wwwayyy better to make a bunch of geoms ahead of time...
""" multiprocessing capable geometery maker """
fmt = GeomVertexFormat.getV3c4()
cloudNode = GeomNode('bin %s selectable'%(i))
for point in array:
vertexData = GeomVertexData('poitn', fmt, Geom.UHStatic)
GeomVertexWriter(vertexData, 'vertex').addData3f(*point)
GeomVertexWriter(vertexData, 'color').addData4f(*ctup)
#verts.addData3f(*point)
#color.addData4f(*ctup)
points = geomType(Geom.UHStatic)
points.addVertex(0)
points.closePrimitive()
cloudGeom = Geom(vertexData)
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)
pipe.send(cloudNode.encodeToBamStream()) #FIXME make this return a pointer NOPE
示例2: __build_Star_Sphere
# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3c4 [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
示例3: makeSimpleGeom
# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3c4 [as 别名]
def makeSimpleGeom(array, ctup, geomType = GeomPoints, fix = False):
fmt = GeomVertexFormat.getV3c4()
vertexData = GeomVertexData('points', fmt, Geom.UHDynamic) #FIXME use the index for these too? with setPythonTag, will have to 'reserve' some
cloudGeom = Geom(vertexData)
cloudNode = GeomNode('just some points')
verts = GeomVertexWriter(vertexData, 'vertex')
color = GeomVertexWriter(vertexData, 'color')
if fix:
if len(ctup) == len(array):
for point,c in zip(array, ctup):
verts.addData3f(*point)
color.addData4f(*c)
else:
for point in array:
verts.addData3f(*point)
color.addData4f(*ctup)
else:
for point in array:
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...
if fix:
return cloudNode.__reduce__()
else:
return cloudNode # decoding fails becuase ForkingPickler is called for reasons beyond comprehension
示例4: makePoints
# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3c4 [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
示例5: newVertexData
# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3c4 [as 别名]
def newVertexData(self):
fmt = GeomVertexFormat.getV3c4()
# fmt = GeomVertexFormat.getV3n3c4()
self.vertexData = GeomVertexData("path", fmt, Geom.UHStatic)
self.vertexWriter = GeomVertexWriter(self.vertexData, "vertex")
# self.normalWriter = GeomVertexWriter(self.vertexData, 'normal')
self.colorWriter = GeomVertexWriter(self.vertexData, "color")
示例6: makeSimpleGeomBuffer
# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3c4 [as 别名]
def makeSimpleGeomBuffer(array, color, geomType=GeomPoints):
""" massively faster than the nonbuffer version """
full = [tuple(d) for d in np.hstack((array,color))]
fmt = GeomVertexFormat.getV3c4()
vertexData = GeomVertexData('points', fmt, Geom.UHDynamic) #FIXME use the index for these too? with setPythonTag, will have to 'reserve' some
cloudGeom = Geom(vertexData)
cloudNode = GeomNode('just some points')
vertexData.setNumRows(len(array))
mem_array = vertexData.modifyArray(0)
view = memoryview(mem_array)
arr = np.asarray(view)
arr[:] = full
points = geomType(Geom.UHDynamic)
points.addConsecutiveVertices(0,len(array))
points.closePrimitive()
cloudGeom.addPrimitive(points)
cloudNode.addGeom(cloudGeom)
return cloudNode
示例7: makeSelectRect
# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3c4 [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
示例8: makeAxis
# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3c4 [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
示例9: makePoint
# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3c4 [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
示例10: makeCameraTarget
# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3c4 [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
示例11: makeGeom
# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3c4 [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
示例12: make_cube
# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3c4 [as 别名]
def make_cube(x, y, z): # FIXME make prism
""" make x, y, z sized cube (ints pls) """
colors = [[1,1,1,0] for i in range(8)]
#colors[0] = np.array((1,1,1,1))
#colors[1] = np.array((1,0,0,0))
#colors[2] = np.array((0,1,0,0))
#colors[5] = np.array((0,0,1,0))
points = (
(0,0,0),
(0,0,z),
(0,y,0),
(0,y,z),
(x,0,0),
(x,0,z),
(x,y,0),
(x,y,z),
)
order = [0, 5, 1, 7, 3, 2, 1, 0, 5, 4, 7, 6, 2, 4, 0] # perfect for clockwise
#order = [2, 6, 3, 7, 5, 6, 4, 2, 0, 3, 1, 4, 0, 4]
#order.reverse()
#order = [4, 3, 7, 8, 5, 3, 1, 4, 2, 7, 6, 5, 2, 1]
fmt = GeomVertexFormat.getV3c4()
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,8)
for i in order:
targetTris.addVertex(i)#-1)
targetTris.closePrimitive()
target = Geom(vertexData)
target.addPrimitive(targetTris)
return target
示例13: __init__
# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3c4 [as 别名]
def __init__(self, mp):
vdata = GeomVertexData("name_me", GeomVertexFormat.getV3c4(), Geom.UHStatic)
vertex = GeomVertexWriter(vdata, "vertex")
color = GeomVertexWriter(vdata, "color")
primitive = GeomTristrips(Geom.UHStatic)
film_size = base.cam.node().getLens().getFilmSize()
x = film_size.getX() / 2.0
z = x * 256.0 / 240.0
vertex.addData3f(x, 90, z)
vertex.addData3f(-x, 90, z)
vertex.addData3f(x, 90, -z)
vertex.addData3f(-x, 90, -z)
color.addData4f(VBase4(*mp["backgroundcolor1"]))
color.addData4f(VBase4(*mp["backgroundcolor1"]))
color.addData4f(VBase4(*mp["backgroundcolor2"]))
color.addData4f(VBase4(*mp["backgroundcolor2"]))
primitive.addNextVertices(4)
primitive.closePrimitive()
geom = Geom(vdata)
geom.addPrimitive(primitive)
self.node = GeomNode("sky")
self.node.addGeom(geom)
base.camera.attachNewNode(self.node)
示例14: makeGrid
# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3c4 [as 别名]
def makeGrid(rng = 1000, spacing = 10): #FIXME make this scale based on zoom???
ctup = (.3,.3,.3,1)
xs = range(-rng,rng+1,spacing)
ys = xs
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 i,d in enumerate(xs):
switch1 = (-1) ** i * rng
switch2 = (-1) ** i * -rng
#print(d,switch1,0)
verts.addData3f(d, switch1, 0)
verts.addData3f(d, switch2, 0)
color.addData4f(*ctup)
color.addData4f(*ctup)
for i,d in enumerate(ys):
switch1 = (-1) ** i * rng
switch2 = (-1) ** i * -rng
verts.addData3f(switch1, d, 0)
verts.addData3f(switch2, d, 0)
color.addData4f(*ctup)
color.addData4f(*ctup)
gridLines = GeomLinestrips(Geom.UHStatic)
gridLines.addConsecutiveVertices(0, vertexData.getNumRows())
gridLines.closePrimitive()
grid = Geom(vertexData)
grid.addPrimitive(gridLines)
return grid
示例15: renderCharts
# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3c4 [as 别名]
def renderCharts(facegraph, verts, vert_indices, lineset=None):
from meshtool.filters.panda_filters.pandacore import getVertexData, attachLights, ensureCameraAt
from meshtool.filters.panda_filters.pandacontrols import KeyboardMovement, MouseDrag, MouseScaleZoom, ButtonUtils
from panda3d.core import GeomTriangles, Geom, GeomNode, GeomVertexFormat, GeomVertexData, GeomVertexWriter, LineSegs
from direct.showbase.ShowBase import ShowBase
vformat = GeomVertexFormat.getV3c4()
vdata=GeomVertexData('tris', vformat, Geom.UHDynamic)
vertex=GeomVertexWriter(vdata, 'vertex')
color=GeomVertexWriter(vdata, 'color')
colors = gen_color3(len(facegraph))
numtris = 0
for chart, data in facegraph.nodes_iter(data=True):
curcolor = next(colors)
for tri in data['tris']:
triv = verts[vert_indices[tri]]
vertex.addData3f(triv[0][0], triv[0][1], triv[0][2])
vertex.addData3f(triv[1][0], triv[1][1], triv[1][2])
vertex.addData3f(triv[2][0], triv[2][1], triv[2][2])
color.addData4f(curcolor[0],curcolor[1], curcolor[2], 1)
color.addData4f(curcolor[0],curcolor[1], curcolor[2], 1)
color.addData4f(curcolor[0],curcolor[1], curcolor[2], 1)
numtris += 1
tris=GeomTriangles(Geom.UHDynamic)
tris.addConsecutiveVertices(0, 3*numtris)
tris.closePrimitive()
linenodes = []
if lineset:
for lines in lineset:
ls = LineSegs()
ls.setThickness(4)
curcolor = next(colors)
ls.setColor(curcolor[0]/256.0, curcolor[1]/256.0, curcolor[2]/256.0, 1)
tuples = False
for blah in lines:
if isinstance(blah, tuple):
tuples = True
break
if tuples:
for i, j in lines:
frompt = verts[i]
topt = verts[j]
ls.moveTo(frompt[0], frompt[1], frompt[2])
ls.drawTo(topt[0], topt[1], topt[2])
else:
for i in range(len(lines)-1):
frompt = verts[lines[i]]
topt = verts[lines[i+1]]
ls.moveTo(frompt[0], frompt[1], frompt[2])
ls.drawTo(topt[0], topt[1], topt[2])
linenodes.append(ls.create())
pgeom = Geom(vdata)
pgeom.addPrimitive(tris)
node = GeomNode("primitive")
node.addGeom(pgeom)
p3dApp = ShowBase()
#attachLights(render)
geomPath = render.attachNewNode(node)
for linenode in linenodes:
geomPath.attachNewNode(linenode)
#geomPath.setRenderModeWireframe()
ensureCameraAt(geomPath, base.cam)
boundingSphere = geomPath.getBounds()
base.cam.setPos(boundingSphere.getCenter() + boundingSphere.getRadius())
base.cam.lookAt(boundingSphere.getCenter())
KeyboardMovement()
ButtonUtils(geomPath)
MouseDrag(geomPath)
MouseScaleZoom(geomPath)
#render.setShaderAuto()
p3dApp.run()