本文整理汇总了Python中pandac.PandaModules.GeomNode.setName方法的典型用法代码示例。如果您正苦于以下问题:Python GeomNode.setName方法的具体用法?Python GeomNode.setName怎么用?Python GeomNode.setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandac.PandaModules.GeomNode
的用法示例。
在下文中一共展示了GeomNode.setName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from pandac.PandaModules import GeomNode [as 别名]
# 或者: from pandac.PandaModules.GeomNode import setName [as 别名]
#.........这里部分代码省略.........
geom = Geom (vdata)
geom.addPrimitive (lines)
# Add our primitive to the geomnode
self.gnode.addGeom (geom)
def rect (self, width, height, axis):
# 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)
# draw a box
if axis == "x":
vertices.addData3f (0, -width, -height)
vertices.addData3f (0, width, -height)
vertices.addData3f (0, width, height)
vertices.addData3f (0, -width, height)
if axis == "y":
vertices.addData3f (-width, 0, -height)
vertices.addData3f (width, 0, -height)
vertices.addData3f (width, 0, height)
vertices.addData3f (-width, 0, height)
if axis == "z":
vertices.addData3f (-width, -height, 0)
vertices.addData3f (width, -height, 0)
vertices.addData3f (width, height, 0)
vertices.addData3f (-width, height, 0)
for i in range (1, 3):
lines.addVertices(i - 1, i)
lines.addVertices (3, 0)
lines.closePrimitive()
geom = Geom (vdata)
geom.addPrimitive (lines)
# Add our primitive to the geomnode
self.gnode.addGeom (geom)
def generate (self, type, radius=1.0, length=1.0, extents=Point3(1, 1, 1)):
if type == 'sphere':
# generate a simple sphere
self.circle (radius, "x", 0)
self.circle (radius, "y", 0)
self.circle (radius, "z", 0)
if type == 'capsule':
# generate a simple capsule
self.capsule (radius, length, "x")
self.capsule (radius, length, "y")
self.circle (radius, "z", -length / 2)
self.circle (radius, "z", length / 2)
if type == 'box':
# generate a simple box
self.rect (extents[1], extents[2], "x")
self.rect (extents[0], extents[2], "y")
self.rect (extents[0], extents[1], "z")
if type == 'cylinder':
# generate a simple cylinder
self.line ((0, -radius, -length / 2), (0, -radius, length/2))
self.line ((0, radius, -length / 2), (0, radius, length/2))
self.line ((-radius, 0, -length / 2), (-radius, 0, length/2))
self.line ((radius, 0, -length / 2), (radius, 0, length/2))
self.circle (radius, "z", -length / 2)
self.circle (radius, "z", length / 2)
if type == 'ray':
# generate a ray
self.circle (length / 10, "x", 0)
self.circle (length / 10, "z", 0)
self.line ((0, 0, 0), (0, 0, length))
self.line ((0, 0, length), (0, -length/10, length*0.9))
self.line ((0, 0, length), (0, length/10, length*0.9))
if type == 'plane':
# generate a plane
length = 3.0
self.rect (1.0, 1.0, "z")
self.line ((0, 0, 0), (0, 0, length))
self.line ((0, 0, length), (0, -length/10, length*0.9))
self.line ((0, 0, length), (0, length/10, length*0.9))
# rename ourselves to wirePrimBox, etc.
name = self.gnode.getName()
self.gnode.setName(name + type.capitalize())
NP = NodePath (self.gnode) # Finally, make a nodepath to our geom
NP.setColor(0.0, 1.0, 0.0) # Set default color
return NP