本文整理汇总了Python中panda3d.core.GeomVertexFormat.getV3方法的典型用法代码示例。如果您正苦于以下问题:Python GeomVertexFormat.getV3方法的具体用法?Python GeomVertexFormat.getV3怎么用?Python GeomVertexFormat.getV3使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.core.GeomVertexFormat
的用法示例。
在下文中一共展示了GeomVertexFormat.getV3方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addMeshConvexRB
# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3 [as 别名]
def addMeshConvexRB(self,vertices, faces,ghost=False,**kw):
#step 1) create GeomVertexData and add vertex information
format=GeomVertexFormat.getV3()
vdata=GeomVertexData("vertices", format, Geom.UHStatic)
vertexWriter=GeomVertexWriter(vdata, "vertex")
[vertexWriter.addData3f(v[0],v[1],v[2]) for v in vertices]
#step 2) make primitives and assign vertices to them
tris=GeomTriangles(Geom.UHStatic)
[self.setGeomFaces(tris,face) for face in faces]
#step 3) make a Geom object to hold the primitives
geom=Geom(vdata)
geom.addPrimitive(tris)
#step 4) create the bullet mesh and node
mesh = BulletTriangleMesh()
mesh.addGeom(geom)
shape = BulletConvexHullShape(mesh, dynamic=not ghost)#
if ghost :
inodenp = self.worldNP.attachNewNode(BulletGhostNode('Mesh'))
else :
inodenp = self.worldNP.attachNewNode(BulletRigidBodyNode('Mesh'))
inodenp.node().addShape(shape)
# inodenp.setPos(0, 0, 0.1)
self.setRB(inodenp,**kw)
inodenp.setCollideMask(BitMask32.allOn())
self.world.attachRigidBody(inodenp.node())
return inodenp
示例2: makeRotationGeomNode
# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3 [as 别名]
def makeRotationGeomNode():
vdata = GeomVertexData('rotHandleData', GeomVertexFormat.getV3(),
Geom.UHStatic)
v = GeomVertexWriter(vdata, 'vertex')
radius = 0.7
width = 0.08
res = 30
innerRad = radius - width
for i in xrange(res):
theta = i*(2*pi/res)
v.addData3f(innerRad*sin(theta), innerRad*cos(theta), width/2.0)
v.addData3f(innerRad*sin(theta), innerRad*cos(theta), -width/2.0)
v.addData3f(radius*sin(theta), radius*cos(theta), width/2.0)
v.addData3f(radius*sin(theta), radius*cos(theta), -width/2.0)
circle = Geom(vdata)
# Make prims for the faces of the torus
faces = [GeomTristrips(Geom.UHStatic) for i in xrange(4)]
for i in xrange(res):
i = i*4
faces[0].addVertices(i + 1, i)
faces[1].addVertices(i + 2, i + 1)
faces[2].addVertices(i + 3, i + 2)
faces[3].addVertices(i, i + 3)
for i in xrange(4):
faces[i].addVertices((i + 1) % 4, i)
faces[i].closePrimitive()
circle.addPrimitive(faces[i])
node = GeomNode('geomnode')
node.addGeom(circle)
return node
示例3: makeGeomNode
# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3 [as 别名]
def makeGeomNode():
vdata = GeomVertexData('handleData', GeomVertexFormat.getV3(),
Geom.UHStatic)
v = GeomVertexWriter(vdata, 'vertex')
length = 1.0
gapLen = 0.2
coneLen = 0.18
coneRad = 0.06
circRes = 10
v.addData3f(0, 0, -length/2.0) # back cone butt
v.addData3f(0, 0, -length/2.0 + coneLen) # back cone point
v.addData3f(0, 0, -gapLen/2.0)
v.addData3f(0, 0, gapLen/2.0)
v.addData3f(0, 0, length/2.0 - coneLen) # front cone butt
v.addData3f(0, 0, length/2.0) # font cone point
# Add vertices for the cone's circles.
for z in [-length/2.0, length/2.0 - coneLen]:
for i in xrange(circRes):
theta = i*(2*pi/circRes)
v.addData3f(coneRad*sin(theta), coneRad*cos(theta), z)
lines = Geom(vdata)
# Make prims for the two lines.
for vertices in [(0, 2), (3, 5)]:
line = GeomLines(Geom.UHStatic)
line.addVertices(*vertices)
line.closePrimitive()
lines.addPrimitive(line)
cones = Geom(vdata)
# Make prims for the cones.
for back, circ in [(0, 6), (4, 6 + circRes)]:
point = back + 1
cone = GeomTriangles(Geom.UHStatic)
for i in xrange(circRes):
if i + 1 == circRes:
cone.addVertices(back, circ, circ + i)
cone.addVertices(point, circ + i, circ)
else:
cone.addVertices(back, circ + i + 1, circ + i)
cone.addVertices(point, circ + i, circ + i + 1)
cone.closePrimitive()
cones.addPrimitive(cone)
node = GeomNode('geomnode')
node.addGeom(lines)
node.addGeom(cones)
return node
示例4: makeNode
# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3 [as 别名]
def makeNode(self, pointmap=(lambda x, y: (x, y, 0))):
vt = tuple(self.vertices)
t = Triangulator()
fmt = GeomVertexFormat.getV3()
vdata = GeomVertexData('name', fmt, Geom.UHStatic)
vertex = GeomVertexWriter(vdata, 'vertex')
for x, y in vt:
t.addPolygonVertex(t.addVertex(x, y))
vertex.addData3f(pointmap(x, y))
t.triangulate()
prim = GeomTriangles(Geom.UHStatic)
for n in xrange(t.getNumTriangles()):
prim.addVertices(t.getTriangleV0(n),t.getTriangleV1(n),t.getTriangleV2(n))
prim.closePrimitive()
geom = Geom(vdata)
geom.addPrimitive(prim)
node = GeomNode('gnode')
node.addGeom(geom)
return node
示例5: createPlane
# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3 [as 别名]
def createPlane(width,height):
format=GeomVertexFormat.getV3()
vdata=GeomVertexData("vertices", format, Geom.UHStatic)
vertexWriter=GeomVertexWriter(vdata, "vertex")
vertexWriter.addData3f(0,0,0)
vertexWriter.addData3f(width,0,0)
vertexWriter.addData3f(width,height,0)
vertexWriter.addData3f(0,height,0)
#step 2) make primitives and assign vertices to them
tris=GeomTriangles(Geom.UHStatic)
#have to add vertices one by one since they are not in order
tris.addVertex(0)
tris.addVertex(1)
tris.addVertex(3)
#indicates that we have finished adding vertices for the first triangle.
tris.closePrimitive()
#since the coordinates are in order we can use this convenience function.
tris.addConsecutiveVertices(1,3) #add vertex 1, 2 and 3
tris.closePrimitive()
#step 3) make a Geom object to hold the primitives
squareGeom=Geom(vdata)
squareGeom.addPrimitive(tris)
#now put squareGeom in a GeomNode. You can now position your geometry in the scene graph.
squareGN=GeomNode("square")
squareGN.addGeom(squareGeom)
terrainNode = NodePath("terrNode")
terrainNode.reparentTo(render)
terrainNode.attachNewNode(squareGN)
terrainNode.setX(-width/2)
texGrass = loader.loadTexture("textures/envir-ground.jpg")
terrainNode.setTexture(texGrass)
示例6: makeClickableGeom
# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3 [as 别名]
def makeClickableGeom():
vdata = GeomVertexData('handleData', GeomVertexFormat.getV3(),
Geom.UHStatic)
v = GeomVertexWriter(vdata, 'vertex')
length = 1.0
cylRad = 0.10
circRes = 8
# Add vertices cylinder.
for z in [length/2.0, -length/2.0]:
for i in xrange(circRes):
theta = i*(2*pi/circRes)
v.addData3f(cylRad*sin(theta), cylRad*cos(theta), z)
geom = Geom(vdata)
# Make polys for the circles
CCW = 1
CW = 0
for i, wind in ((0, CCW), (circRes, CW)):
circle = GeomTristrips(Geom.UHStatic)
l = range(i, i+circRes)
for i in xrange(1-wind, (len(l)-wind)/2):
l.insert(2*i+wind, l.pop())
for v in l:
circle.addVertex(v)
circle.closePrimitive()
geom.addPrimitive(circle)
# Make polys for the cylinder.
cyl = GeomTristrips(Geom.UHStatic)
for i in xrange(circRes):
cyl.addVertex(i + circRes)
cyl.addVertex(i)
cyl.addVertex(circRes)
cyl.addVertex(0)
cyl.closePrimitive()
geom.addPrimitive(cyl)
node = GeomNode('geomnode')
node.addGeom(geom)
return node
示例7: line
# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3 [as 别名]
def line (self, start, end):
# since we're doing line segments, just vertices in our geom
format = GeomVertexFormat.getV3()
# build our data structure and get a handle to the vertex column
vdata = GeomVertexData ('', format, Geom.UHStatic)
vertices = GeomVertexWriter (vdata, 'vertex')
# build a linestrip vertex buffer
lines = GeomLinestrips (Geom.UHStatic)
vertices.addData3f (start[0], start[1], start[2])
vertices.addData3f (end[0], end[1], end[2])
lines.addVertices (0, 1)
lines.closePrimitive()
geom = Geom (vdata)
geom.addPrimitive (lines)
# Add our primitive to the geomnode
#self.gnode.addGeom (geom)
return geom
示例8: createModelClone
# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3 [as 别名]
def createModelClone(self,modelFilename):
newVisualCar = loader.loadModel(modelFilename)
geomNodeCollection = newVisualCar.findAllMatches('**/+GeomNode')
simpleTris=[]
self.unmodifiedVertexData=[]
for nodePath in geomNodeCollection:
geomNode = nodePath.node()
for i in range(geomNode.getNumGeoms()):
geom = geomNode.getGeom(i)
vdata = geom.getVertexData()
vertex = GeomVertexReader(vdata, 'vertex')
while not vertex.isAtEnd():
v=vertex.getData3f()
vertexModelX,vertexModelY,vertexModelZ=v
self.unmodifiedVertexData.append([vertexModelX,vertexModelY,vertexModelZ])
for primitiveIndex in range(geom.getNumPrimitives()):
prim=geom.getPrimitive(primitiveIndex)
prim=prim.decompose()
for p in range(prim.getNumPrimitives()):
s = prim.getPrimitiveStart(p)
e = prim.getPrimitiveEnd(p)
singleTriData=[]
for i in range(s, e):
vertex.setRow(prim.getVertex(s))
vi = prim.getVertex(i)
singleTriData.append(vi)
simpleTris.append(singleTriData)
simpleVertices=self.unmodifiedVertexData
format=GeomVertexFormat.getV3()
vdata=GeomVertexData('shadow', format, Geom.UHDynamic)
self.pandaVertexData=vdata
vertex=GeomVertexWriter(vdata, 'vertex')
for vertexIndex in range(len(simpleVertices)):
simpleVertex=simpleVertices[vertexIndex]
vertex.addData3f(0,0,0)
tris=GeomTriangles(Geom.UHStatic)
for index in range(len(simpleTris)):
simpleTri=simpleTris[index]
tris.addVertex(simpleTri[0])
tris.addVertex(simpleTri[1])
tris.addVertex(simpleTri[2])
tris.closePrimitive()
shadow=Geom(vdata)
shadow.addPrimitive(tris)
snode=GeomNode('shadow')
snode.addGeom(shadow)
self.snode=snode