本文整理汇总了Python中panda3d.core.GeomNode.getNumGeoms方法的典型用法代码示例。如果您正苦于以下问题:Python GeomNode.getNumGeoms方法的具体用法?Python GeomNode.getNumGeoms怎么用?Python GeomNode.getNumGeoms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.core.GeomNode
的用法示例。
在下文中一共展示了GeomNode.getNumGeoms方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PolyGroup
# 需要导入模块: from panda3d.core import GeomNode [as 别名]
# 或者: from panda3d.core.GeomNode import getNumGeoms [as 别名]
class PolyGroup():
# vdata is the Panda3D vertex data object created by the main Mesh
def __init__(self, vdata, tex_idx):
self.vdata = vdata # vertex data, passed in from parent mesh
self.name = 'PolyGroup_'+str(tex_idx)
self.geom = Geom(self.vdata)
self.primitives = GeomTriangles(Geom.UHStatic)
self.geom.addPrimitive(self.primitives)
self.sprite_list_index = 0
self.nodePath = None
# Parameters:
# wld_container - WldContainer parent object
# f - the f36 fragment we are based on
# start_index - index of our first poly in the fragment's polyList polygon list
# n_polys - numer of polys to build
# tex_idx - index of the texture that all our polys share
def build(self, wld_container, f, start_index, n_polys, tex_idx,debug=False):
# f.dump()
self.sprite_list_index = f.fragment1-1 # the fragment1 ref is used as sprite list index
sprite = wld_container.getSprite(tex_idx, self.sprite_list_index)
polyList = f.polyList
poly_idx = start_index
for poly in range(0, n_polys):
p = polyList[poly_idx]
poly_idx += 1
self.primitives.addVertices(p[0], p[1], p[2])
self.node = GeomNode(self.name)
self.node.addGeom(self.geom)
# make a node path for our GEOM, these will be attached under our parent mesh's root
self.nodePath = NodePath(self.node)
# self.nodePath.setRenderModeWireframe()
# self.nodePath.setRenderModeFilled()
# self.nodePath.showBounds()
self.nodePath.setPos(f.centerX, f.centerY,f.centerZ) # translate to correct position
self.nodePath.setAttrib(CullFaceAttrib.make(CullFaceAttrib.MCullCounterClockwise))
# self.nodePath.setAttrib(CullFaceAttrib.make(CullFaceAttrib.MCullClockwise))
# Texture setup
if sprite != None:
# sprite.dump()
if sprite.numtex > 0:
t = sprite.textures[0]
self.nodePath.setTexture(t)
if debug:
print(" polygroup build had texture count: " + str(sprite.numtex) + " AnimDelay: " + str(sprite.anim_delay))
patchInvertDDSV(self.nodePath,t,debug)
if sprite.anim_delay > 0:
geom_num = self.node.getNumGeoms()-1
if debug:
print("Adding geom render state for " + self.name)
from panda3d.core import ColorBlendAttrib
# seems animated "masked" textrue need this in order to function
# dont want to have it on the main zone geoms though cause it breaks
# semi trasparent surfaces (water etc). Probably should move away from making those
# transparent through color blending and simply patch up their alpha channels as needed?
if sprite.masked == 1:
self.node.setAttrib(ColorBlendAttrib.make(ColorBlendAttrib.MAdd,ColorBlendAttrib.OAlphaScale,ColorBlendAttrib.OOne))
sprite.addAnimGeomRenderState( (self.node,geom_num,self.node.getGeomState(geom_num),self.name) )
else:
print 'Error: texture (idx=%i) not found. PolyGroup will be rendered untextured' % (tex_idx)
return 1