本文整理汇总了Python中panda3d.core.GeomVertexWriter.getWriteRow方法的典型用法代码示例。如果您正苦于以下问题:Python GeomVertexWriter.getWriteRow方法的具体用法?Python GeomVertexWriter.getWriteRow怎么用?Python GeomVertexWriter.getWriteRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.core.GeomVertexWriter
的用法示例。
在下文中一共展示了GeomVertexWriter.getWriteRow方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createBox
# 需要导入模块: from panda3d.core import GeomVertexWriter [as 别名]
# 或者: from panda3d.core.GeomVertexWriter import getWriteRow [as 别名]
def createBox(self):
"""
Create the skybox GeomNode
:return:
"""
obj = ''
obj += "# Skybox\n"
obj += 'mtllib skybox.mtl\n'
mtl = '# material for skybox\n'
fmt = GeomVertexFormat.getV3n3t2()
vdata = GeomVertexData('skybox', fmt, Geom.UHStatic)
vdata.setNumRows(24)
vertex = GeomVertexWriter(vdata, 'vertex')
normals = GeomVertexWriter(vdata, 'normal')
texcoord = GeomVertexWriter(vdata, 'texcoord')
node = GeomNode('skybox')
for normal in self.normals:
geom = Geom(vdata)
prim = GeomTriangles(Geom.UHStatic)
idx = vertex.getWriteRow()
verts = self.vertMappings[normal]
tcs = self.getFaceMapping(normal)
for v, t in zip(verts, tcs):
vertex.addData3f(v[0]*2, v[1]*2, v[2]*2)
normals.addData3f(normal)
texcoord.addData2f(t)
obj += 'v {0} {1} {2}\n'.format(v[0]*2, v[1]*2, v[2]*2)
obj += 'vn {0} {1} {2}\n'.format(*normal)
obj += 'vt {0} {1}\n'.format(*t)
tex = self.getFaceTexture(normal)
prim.addVertices(idx, idx + 1, idx + 3)
prim.closePrimitive()
obj += "usemtl {0}\n".format(tex.getName())
obj += 'f {0}/{0} {1}/{1} {2}/{2}\n'.format(1+idx, 1+idx+1, 1+idx+3)
prim.addVertices(idx + 1, idx + 2, idx + 3)
prim.closePrimitive()
obj += "usemtl {0}\n".format(tex.getName())
obj += 'f {0}/{0} {1}/{1} {2}/{2}\n'.format(1+idx+1, 1+idx+2, 1+idx+3)
geom.addPrimitive(prim)
tex.setWrapU(Texture.WMMirror)
tex.setWrapV(Texture.WMMirror)
node.addGeom(geom, RenderState.make(TextureAttrib.make(tex)))
mtl += "newmtl {0}\n".format(tex.getName())
mtl += "Ka 1 1 1\n"
mtl += "Kd 1 1 1\n"
mtl += "map_Kd {0}\n".format(tex.getFilename().toOsSpecific())
return node
示例2: MyApp
# 需要导入模块: from panda3d.core import GeomVertexWriter [as 别名]
# 或者: from panda3d.core.GeomVertexWriter import getWriteRow [as 别名]
#.........这里部分代码省略.........
self.geom.addPrimitive(self.triStrips)
def makeInstructions(self):
OnscreenText(text="Draw Path by Walking", style=1, fg=(1, 1, 0, 1), pos=(0.5, -0.95), scale=0.07)
self.drawText = self.genLabelText("", 0)
self.genLabelText("Walk (W/S/A/D), Jump=Space, Look=PgUp/PgDn", 1)
self.genLabelText(" (hint, go backwards with S to see your path immediately)", 2)
self.genLabelText("ESC: Quit", 3)
def genLabelText(self, text, i):
return OnscreenText(text=text, pos=(-1.3, 0.95 - 0.05 * i), fg=(1, 1, 0, 1), align=TextNode.ALeft, scale=0.05)
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
示例3: MyApp
# 需要导入模块: from panda3d.core import GeomVertexWriter [as 别名]
# 或者: from panda3d.core.GeomVertexWriter import getWriteRow [as 别名]
#.........这里部分代码省略.........
style=1, fg=(1,1,0,1),
pos=(0.5,-0.95), scale = .07)
self.genLabelText("ESC: Quit", 0)
self.instructionText = self.genLabelText("", 1)
def genLabelText(self, text, i):
return OnscreenText(text = text, pos = (-1.3, .95-.05*i), fg=(1,1,0,1),
align = TextNode.ALeft, scale = .05)
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., int(pos.y*100)/100., int(pos.z)/100.,
self.fpscamera.getHeading(), self.fpscamera.getLookAngle()))
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):