def get_format(): if SimpleTree.geom_vertex_format is None: format_array = GeomVertexArrayFormat() format_array.addColumn(InternalName.make("drawFlag"), 1, Geom.NTUint8, Geom.COther) format = GeomVertexFormat(GeomVertexFormat.getV3n3cpt2()) format.addArray(format_array) SimpleTree.geom_vertex_format = GeomVertexFormat.registerFormat(format) return SimpleTree.geom_vertex_format
def __init__(self): formatArray=GeomVertexArrayFormat() formatArray.addColumn(InternalName.make("drawFlag"), 1, Geom.NTUint8, Geom.COther) format=GeomVertexFormat(GeomVertexFormat.getV3n3cpt2()) format.addArray(formatArray) self.format=GeomVertexFormat.registerFormat(format) bodydata=GeomVertexData("body vertices", format, Geom.UHStatic) self.barkTexture=loader.loadTexture("barkTexture.jpg") treeNodePath=NodePath("Tree Holder") makeFractalTree(bodydata,treeNodePath,Vec3(4,4,7)) treeNodePath.setTexture(self.barkTexture,1) treeNodePath.reparentTo(render) self.accept("q", self.regenTree) self.accept("n", self.newPop) self.accept("w", self.addTree) self.accept("arrow_up", self.upIterations) self.accept("arrow_down", self.downIterations) self.accept("arrow_right", self.upCopies) self.accept("arrow_left", self.downCopies) [self.accept("%d" % i, self.selectBest, ['%d' % i]) for i in range(0,9)] self.numIterations=11 self.numCopies=4 self.upDownEvent = OnscreenText( text="Up/Down: Increase/Decrease the number of Iteratations("+str(self.numIterations)+")", style=1, fg=(1,1,1,1), pos=(-1.3, 0.85), align=TextNode.ALeft, scale = .05, mayChange=True) self.leftRightEvent = OnscreenText( text="Left/Right: Increase/Decrease branching("+str(self.numCopies)+")", style=1, fg=(1,1,1,1), pos=(-1.3, 0.80), align=TextNode.ALeft, scale = .05, mayChange=True) curstudy = 'speedtree.yml' ga = evolve.init_iga({'app_name': curstudy}) self.genomes = ga.draw() self.ga = ga print 'genomes', self.genomes
def CreateVertexFormat(self): """ Creates a custom vertex format. This was needed so that I could add a second array of texture data for having multiple textures for a BlockFace """ array = GeomVertexArrayFormat() array.addColumn(InternalName.make('vertex'), 3, Geom.NTFloat32, Geom.CPoint) array.addColumn(InternalName.make('normal'), 3, Geom.NTFloat32, Geom.CVector) array.addColumn(InternalName.make('texcoord'), 2, Geom.NTFloat32, Geom.CTexcoord) array.addColumn(InternalName.make('texcoord.light'), 2, Geom.NTFloat32, Geom.CTexcoord) gvformat = GeomVertexFormat() gvformat.addArray(array) gvformat = GeomVertexFormat.registerFormat(gvformat) self.geomVertexFormat = gvformat