本文整理汇总了Python中panda3d.core.GeomVertexFormat.getV3t2方法的典型用法代码示例。如果您正苦于以下问题:Python GeomVertexFormat.getV3t2方法的具体用法?Python GeomVertexFormat.getV3t2怎么用?Python GeomVertexFormat.getV3t2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.core.GeomVertexFormat
的用法示例。
在下文中一共展示了GeomVertexFormat.getV3t2方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: makeTrack
# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3t2 [as 别名]
def makeTrack(segments):
format=GeomVertexFormat.getV3t2()
vdata=GeomVertexData('track', format, Geom.UHStatic)
vertex=GeomVertexWriter(vdata, 'vertex')
texcoord=GeomVertexWriter(vdata, 'texcoord')
vdata2=GeomVertexData('startline', format, Geom.UHStatic)
vertex2=GeomVertexWriter(vdata2, 'vertex')
texcoord2=GeomVertexWriter(vdata2, 'texcoord')
numVertices=0
twat=0
for segmentIndex in range(len(segments)):
currentSegment=segments[segmentIndex]
if segmentIndex==0:
nextSegment=segments[segmentIndex+1]
currentStartLineLeftPoint=Geometry.Point.CreateByInterpolation(currentSegment.getMidPoint(),currentSegment.getLeftPoint(),100,77.5);
currentStartLineRightPoint=Geometry.Point.CreateByInterpolation(currentSegment.getMidPoint(),currentSegment.getRightPoint(),100,77.5);
nextStartLineLeftPoint=Geometry.Point.CreateByInterpolation(nextSegment.getMidPoint(),nextSegment.getLeftPoint(),100,77.5);
nextStartLineRightPoint=Geometry.Point.CreateByInterpolation(nextSegment.getMidPoint(),nextSegment.getRightPoint(),100,77.5);
vertex2.addData3f(nextStartLineLeftPoint.getX(),nextStartLineLeftPoint.getY(),0)
vertex2.addData3f(nextStartLineRightPoint.getX(),nextStartLineRightPoint.getY(),0)
vertex2.addData3f(currentStartLineLeftPoint.getX(),currentStartLineLeftPoint.getY(),0)
vertex2.addData3f(currentStartLineRightPoint.getX(),currentStartLineRightPoint.getY(),0)
texcoord2.addData2f(0.0, 0.0)
texcoord2.addData2f(12.0, 0.0)
texcoord2.addData2f(0.0, 2.0)
texcoord2.addData2f(12.0, 2.0)
vertex.addData3f(currentSegment.leftPoint.getX(),currentSegment.leftPoint.getY(),0)
vertex.addData3f(currentSegment.rightPoint.getX(),currentSegment.rightPoint.getY(),0)
texcoord.addData2f(0.0, 1.0/8*float(twat))
texcoord.addData2f(1.0, 1.0/8*float(twat))
#print('vertex at '+str(segmentIndex)+' with v='+str(1.0/8*float(twat)))
numVertices+=2
twat=twat+1
if twat==9:
#print('surplus at '+str(segmentIndex)+' with v=0.0')
vertex.addData3f(currentSegment.leftPoint.getX(),currentSegment.leftPoint.getY(),0)
vertex.addData3f(currentSegment.rightPoint.getX(),currentSegment.rightPoint.getY(),0)
texcoord.addData2f(0.0, 0.0)
texcoord.addData2f(1.0, 0.0)
numVertices+=2
twat=1
#print('vertices created: '+str(numVertices))
tris=GeomTriangles(Geom.UHDynamic)
bob=0
vertexOffset=0
for index in range(len(segments)):
vertexOffsets=[]
for innerIndex in range(4):
offset=vertexOffset+innerIndex
if offset>numVertices-1:
offset=offset-numVertices
vertexOffsets.append(offset)
tris.addVertex(vertexOffsets[0])
tris.addVertex(vertexOffsets[1])
tris.addVertex(vertexOffsets[3])
tris.closePrimitive()
tris.addVertex(vertexOffsets[0])
tris.addVertex(vertexOffsets[3])
tris.addVertex(vertexOffsets[2])
tris.closePrimitive()
vertexOffset+=2
bob+=1
if bob==8:
vertexOffset+=2
bob=0
tris2=GeomTriangles(Geom.UHDynamic)
tris2.addVertex(0)
tris2.addVertex(3)
tris2.addVertex(1)
tris2.closePrimitive()
tris2.addVertex(0)
tris2.addVertex(2)
tris2.addVertex(3)
tris2.closePrimitive()
track=Geom(vdata)
track.addPrimitive(tris)
startLine=Geom(vdata2)
startLine.addPrimitive(tris2)
snode=GeomNode('tarmac')
#.........这里部分代码省略.........
示例2: __init__
# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3t2 [as 别名]
def __init__(self):
self.textures={}
for k in texMap:
v=texMap[k]
tex=loader.loadTexture("gfx/%s"%v)
tex.setWrapU(Texture.WM_clamp)
tex.setWrapV(Texture.WM_clamp)
self.textures[k]=tex
self.viewPoint=(0,0,0)
self.cubeVtxSrc=[
# 14 vertices per cube mapped
# so that UV coords utilize
# the typical cube unwrap:
#
# #### <-- square texture
# ##U#
# BLFR
# ##D# #=unused
#
# This form uses 14 vertices per cube since
# the extra (worldspace overlapped) vertices
# map different U,V coordinates at the same
# worldspace coordinates, depending on face
#
# x y z u v
(1.00,1.00,1.00,0.00,0.50), # A
(1.00,1.00,0.00,0.00,0.25), # B
(0.00,1.00,1.00,0.25,0.50), # C
(0.00,1.00,0.00,0.25,0.25), # D
(0.00,0.00,1.00,0.50,0.50), # E
(0.00,0.00,0.00,0.50,0.25), # F
(1.00,0.00,1.00,0.75,0.50), # G
(1.00,0.00,0.00,0.75,0.25), # H
(1.00,1.00,1.00,1.00,0.50), # I
(1.00,1.00,0.00,1.00,0.25), # J
(0.00,1.00,1.00,0.50,0.75), # K
(1.00,1.00,1.00,0.75,0.75), # L
(0.00,1.00,0.00,0.50,0.00), # M
(1.00,1.00,0.00,0.75,0.00) # N
]
self.triSrc=[
#
# Faces (QUAD/TRIPAIR)
# using RHR vertex ordering for
# correct face surface normals
#
# front: EFHG/EFH+HGE
# rear: CABD/CAB+BDC
# left: CDFE/CDF+FEC
# right: GHJI/GHJ+JIG
# upper: KEGL/KEG+GLK
# lower: FMNH/FMN+NHF
#
"EFH","HGE",
"CAB","BDC",
"CDF","FEC",
"GHJ","JIG",
"KEG","GLK",
"FMN","NHF"
]
#
# setup cube
#
# one cube node will be generated per non-air block
# since different block id's potentially refer to
# different textures and thus must be separate nodes
# of the scene graph.
#
# 1. vertices
self.cubeVtx=GeomVertexData('blockCube',GeomVertexFormat.getV3t2(),Geom.UHStatic)
self.cubeVtx.setNumRows(len(self.cubeVtxSrc))
vtxW=GeomVertexWriter(self.cubeVtx,'vertex')
txcW=GeomVertexWriter(self.cubeVtx,'texcoord')
for vertex in self.cubeVtxSrc:
vtxW.addData3f(*vertex[0:3])
txcW.addData2f(*vertex[3:5])
# 2. mesh
self.cubeMesh=GeomTriangles(Geom.UHStatic)
for tri in self.triSrc:
for triV in tri:
triVtxId=ord(triV)-65 # changea 'A'-'N' to 0-13
self.cubeMesh.addVertex(triVtxId)
self.cubeMesh.close_primitive()
# 3. geometry (primitive+vertex pair)
self.cubeGeom=Geom(self.cubeVtx)
self.cubeGeom.addPrimitive(self.cubeMesh)
示例3: makeMountains
# 需要导入模块: from panda3d.core import GeomVertexFormat [as 别名]
# 或者: from panda3d.core.GeomVertexFormat import getV3t2 [as 别名]
def makeMountains():
format=GeomVertexFormat.getV3t2()
vdata=GeomVertexData('mountains', format, Geom.UHStatic)
vertex=GeomVertexWriter(vdata, 'vertex')
texcoord=GeomVertexWriter(vdata, 'texcoord')
format2=GeomVertexFormat.getV3c4()
vdata2=GeomVertexData('sky', format2, Geom.UHStatic)
vertex2=GeomVertexWriter(vdata2, 'vertex')
color2=GeomVertexWriter(vdata2, 'color')
numQuads=32
angle=0
textureX=0
angleAdd=math.pi*2/numQuads
textureXAdd=1.0/numQuads
currentQuad=0
numVertices=0
while currentQuad<numQuads:
if currentQuad==0:
vertexX=math.sin(angle)*3000
vertexY=math.cos(angle)*3000
vertex.addData3f(vertexX,vertexY,0.0)
vertex.addData3f(vertexX,vertexY,360.0)
texcoord.addData2f(1.0, 0.0)
texcoord.addData2f(1.0, 1.0)
numVertices=numVertices+2
vertexX=math.sin(angle)*3000
vertexY=math.cos(angle)*3000
vertex.addData3f(vertexX,vertexY,0.0)
vertex.addData3f(vertexX,vertexY,360.0)
vertex2.addData3f(vertexX,vertexY,360.0)
color2.addData4f(45.0/255.0,112.0/255.0,255.0/255.0,1.0)
#color2.addData4f(1.0,1.0,1.0,1.0)
#print('created vertex at '+str(vertexX)+','+str(vertexY)+',2')
#print('created vertex at '+str(vertexX)+','+str(vertexY)+',0')
texcoord.addData2f(textureX, 0.0)
texcoord.addData2f(textureX, 1.0)
#print('texturex is '+str(textureX))
#print('creating vertices v'+str(numVertices)+' and v'+str(numVertices+1))
numVertices=numVertices+2
currentQuad=currentQuad+1
textureX=textureX+textureXAdd
angle=angle+angleAdd
vertex2.addData3f(0.0,0.0,360.0)
#color2.addData4f(1.0,1.0,1.0,1.0)
color2.addData4f(45.0/255.0,112.0/255.0,255.0/255.0,1.0)
currentQuad=0
currentOffset=2
tris=GeomTriangles(Geom.UHDynamic)
#print('creating tris - numVertices is '+str(numVertices))
while currentQuad<numQuads:
vertexOffsets=[]
for innerIndex in range(4):
offset=currentOffset+innerIndex
#print('comparing '+str(offset)+' with '+str(numVertices-1))
if offset>numVertices-1:
offset=offset-numVertices
vertexOffsets.append(offset)
#print('adding tri connecting v'+str(vertexOffsets[0])+', v'+str(vertexOffsets[1])+', v'+str(vertexOffsets[3]))
#print('adding tri connecting v'+str(vertexOffsets[1])+', v'+str(vertexOffsets[3])+', v'+str(vertexOffsets[2]))
tris.addVertex(vertexOffsets[0])
tris.addVertex(vertexOffsets[2])
tris.addVertex(vertexOffsets[1])
tris.closePrimitive()
tris.addVertex(vertexOffsets[1])
tris.addVertex(vertexOffsets[2])
tris.addVertex(vertexOffsets[3])
tris.closePrimitive()
currentOffset=currentOffset+2
currentQuad=currentQuad+1
tris2=GeomTriangles(Geom.UHDynamic)
currentOffset=1
numTris=numQuads
currentTri=0
while currentTri<numTris:
#.........这里部分代码省略.........