本文整理汇总了Python中panda3d.core.Geom.unifyInPlace方法的典型用法代码示例。如果您正苦于以下问题:Python Geom.unifyInPlace方法的具体用法?Python Geom.unifyInPlace怎么用?Python Geom.unifyInPlace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.core.Geom
的用法示例。
在下文中一共展示了Geom.unifyInPlace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: makeCylinder
# 需要导入模块: from panda3d.core import Geom [as 别名]
# 或者: from panda3d.core.Geom import unifyInPlace [as 别名]
def makeCylinder(vdata, numVertices=40):
topCircleGeom = makeCircle(vdata, numVertices, Vec3(0, 0, 1))
bottomCircleGeom = makeCircle(vdata, numVertices, Vec3(0, 0, 0), -1)
body = GeomTristrips(Geom.UHStatic)
j = 40
i = 0
while i < numVertices + 1:
body.addVertex(i)
body.addVertex(j)
i += 1
if j == 40:
j = 2 * numVertices - 1
else:
j -= 1
body.addVertex(i)
body.addVertex(j)
j -= 1
i += 1
body.addVertex(numVertices - 1)
body.addVertex(0)
body.addVertex(numVertices)
body.closePrimitive()
cylinderGeom = Geom(vdata)
cylinderGeom.addPrimitive(body)
cylinderGeom.copyPrimitivesFrom(topCircleGeom)
cylinderGeom.copyPrimitivesFrom(bottomCircleGeom)
cylinderGeom.decomposeInPlace()
cylinderGeom.unifyInPlace()
return cylinderGeom
示例2: MyApp
# 需要导入模块: from panda3d.core import Geom [as 别名]
# 或者: from panda3d.core.Geom import unifyInPlace [as 别名]
#.........这里部分代码省略.........
def drawHere(self, task):
pos = self.fpscamera.getPos()
self.info.setText(
"Position: {0}, {1}, {2} at {3} by {4}".format(
int(pos.x * 100) / 100.0,
int(pos.y * 100) / 100.0,
int(pos.z) / 100.0,
self.fpscamera.getHeading(),
self.fpscamera.getLookAngle(),
)
)
prevPos = self.prevPos
if not prevPos:
self.prevPos = pos
elif (pos - prevPos).length() > 1:
self.drawQuadTo(prevPos, pos, 2)
row = self.vertexWriter.getWriteRow()
numPrims = self.triStrips.getNumPrimitives()
if numPrims == 0:
primVerts = row
else:
primVerts = row - self.triStrips.getPrimitiveEnd(numPrims - 1)
if primVerts >= 4:
self.triStrips.closePrimitive()
if row >= 256:
print "Packing and starting anew"
newGeom = True
self.geom.unifyInPlace(row, False)
else:
newGeom = False
self.completePath()
if newGeom:
self.newVertexData()
self.newGeom()
if not newGeom:
self.triStrips.addConsecutiveVertices(row - 2, 2)
else:
self.drawQuadTo(prevPos, pos, 2)
self.leftColor[1] += 63
self.rightColor[2] += 37
self.prevPos = pos
return task.cont
def drawLineTo(self, pos, color):
self.vertexWriter.addData3f(pos.x, pos.y, pos.z)
# self.normalWriter.addData3f(0, 0, 1)
self.colorWriter.addData4i(color)
self.triStrips.addNextVertices(1)
def drawQuadTo(self, a, b, width):
""" a (to) b are vectors defining a line bisecting a new quad. """
into = b - a
if abs(into.x) + abs(into.y) < 1:
示例3: MyApp
# 需要导入模块: from panda3d.core import Geom [as 别名]
# 或者: from panda3d.core.Geom import unifyInPlace [as 别名]
#.........这里部分代码省略.........
prevPos = self.prevPos
if not prevPos:
self.prevPos = pos
elif (pos - prevPos).length() >= 1:
# self.extendPathQuad(prevPos, pos, 2)
self.extendPathTunnel(prevPos, pos, 3)
self.leftColor[1] += 63
self.rightColor[2] += 37
self.prevPos = pos
return task.cont
def extendPathQuad(self, prevPos, pos, width):
self.drawQuadTo(prevPos, pos, width)
row = self.vertexWriter.getWriteRow()
numPrims = self.triStrips.getNumPrimitives()
if numPrims == 0:
primVerts = row
else:
primVerts = row - self.triStrips.getPrimitiveEnd(numPrims-1)
if primVerts >= 4:
self.triStrips.closePrimitive()
if row >= 256:
print "Packing and starting anew"
newGeom = True
self.geom.unifyInPlace(row, False)
else:
newGeom = False
self.completeQuadPath()
if newGeom:
self.newVertexData()
self.newGeom()
if newGeom:
self.drawQuadTo(prevPos, pos, width)
else:
self.triStrips.addConsecutiveVertices(row - 2, 2)
def extendPathTunnel(self, prevPos, pos, width):
self.drawTunnelTo(prevPos, pos, width)
def drawLineTo(self, pos, color):
self.vertexWriter.addData3f(pos.x, pos.y, pos.z)
# self.normalWriter.addData3f(0, 0, 1)
self.colorWriter.addData4i(color)
self.triStrips.addNextVertices(1)
return 1
def drawQuadTo(self, a, b, width):
""" a (to) b are vectors defining a line bisecting a new quad. """
into = (b - a)
if abs(into.x) + abs(into.y) < 1:
# ensure that if we jump in place, we don't get a thin segment