def makeChunkVertices(self, chunk, limitBox): monsterPositions = [] for i, entityRef in enumerate(chunk.Entities): if i % 10 == 0: yield ID = entityRef.id if ID in self.notMonsters: continue pos = entityRef.Position if limitBox and pos not in limitBox: continue monsterPositions.append(pos) if not len(monsterPositions): return monsters = self._computeVertices(monsterPositions, (0xff, 0x22, 0x22, 0x44), offset=True, chunkPosition=chunk.chunkPosition) yield vertexNode = VertexNode(monsters) vertexNode.addState(PolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE)) vertexNode.addState(LineWidth(2.0)) vertexNode.addState(DepthFunc(GL.GL_ALWAYS)) self.sceneNode = Node("monsterLocations") self.sceneNode.addChild(vertexNode) vertexNode = VertexNode(monsters) self.sceneNode.addChild(vertexNode)
def makeChunkVertices(self, chunk, limitBox): tilePositions = [] defaultColor = (0xff, 0xff, 0x33, 0x44) for i, ref in enumerate(chunk.TileEntities): if i % 10 == 0: yield if limitBox and ref.Position not in limitBox: continue if ref.id == "Control": continue tilePositions.append(ref.Position) if not len(tilePositions): return tiles = self._computeVertices(tilePositions, defaultColor, chunkPosition=chunk.chunkPosition) vertexNode = VertexNode([tiles]) polygonMode = PolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE) vertexNode.addState(polygonMode) lineWidth = LineWidth(2.0) vertexNode.addState(lineWidth) depthFunc = DepthFunc(GL.GL_ALWAYS) vertexNode.addState(depthFunc) self.sceneNode = Node("tileEntityLocations") self.sceneNode.addChild(vertexNode) vertexNode = VertexNode([tiles]) self.sceneNode.addChild(vertexNode)
def LineArcNode(p1, p2, color): arcSegments = 20 rgba = [c * 255 for c in color] points = [p1] x, y, z = p1 dx = p2[0] - p1[0] dz = p2[2] - p1[2] dx /= arcSegments dz /= arcSegments heightDiff = p2[1] - p1[1] # maxRise = 8 # initial y-velocity dy = 0.3 if heightDiff >= 0 else -0.3 dy += 2 * heightDiff / arcSegments # the height of p2 without gravity overshot = y + dy * arcSegments - p2[1] # needed gravity so the last point is p2 ddy = -overshot / (arcSegments * (arcSegments - 1) / 2) for i in range(arcSegments): y += dy dy += ddy x += dx z += dz points.append((x, y, z)) arcNode = Node("lineArc") lineNode = LineStripNode(points, rgba) arcNode.addChild(lineNode) arcNode.addState(LineWidth(3.0)) backLineNode = Node("lineArcBack") backLineNode.addChild(lineNode) arcNode.addChild(backLineNode) backLineNode.addState(DepthFunc(GL.GL_GREATER)) backLineNode.addState(LineWidth(1.0)) return arcNode
def makeChunkVertices(self, chunk, limitBox): tilePositions = [] tileColors = [] defaultColor = (0xff, 0x33, 0x33, 0x44) for i, ref in enumerate(chunk.TileEntities): if i % 10 == 0: yield if limitBox and ref.Position not in limitBox: continue if ref.id == "Control": tilePositions.append(ref.Position) cmdText = ref.Command if len(cmdText): if cmdText[0] == "/": cmdText = cmdText[1:] command, _ = cmdText.split(None, 1) color = commandColor(command) tileColors.append(color + (0x44, )) else: tileColors.append(defaultColor) else: continue if not len(tileColors): return tiles = self._computeVertices(tilePositions, tileColors, chunkPosition=chunk.chunkPosition) vertexNode = VertexNode([tiles]) vertexNode.addState(PolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE)) vertexNode.addState(LineWidth(2.0)) vertexNode.addState(DepthFunc(GL.GL_ALWAYS)) self.sceneNode = Node("commandBlockLocations") self.sceneNode.addChild(vertexNode)