Example #1
0
def GenerateCollisionEgg(heightmap, output, input='data/collision3k.egg', scale=100.0):
    input_egg = EggData()
    input_egg.read(input)
    output_egg = EggData()
    output_egg.setCoordinateSystem(CS_default)
    output_egg.stealChildren(input_egg)
    VertexPool = output_egg.getChildren()[1]
    print("Generating mesh, this may take a while...", end="")
    for i in range(VertexPool.getHighestIndex()):
        if i%20000 == 0:
            try:
                base.graphicsEngine.renderFrame()
                print('.', end="")
            except:
                pass
        vert = VertexPool.getVertex(i)
        x0, y0, _ = vert.getPos3()
        #x, y = int(floor(x0+0.5)), int(floor(y0+0.5))
        x, y = int(x0), int(y0)
        if x==512: x=511
        elif x==0: x=1
        if y==512: y=511
        elif y==0: y=1
        vert.setPos(LPoint3d(x0, y0, heightmap.getBright(x,512-y)*scale))

    output_egg.writeEgg(output)
Example #2
0
class epic():
    def __init__(self):
        self.egg = EggData()
        self.loadFile()
        list = self.getUVList(self.egg)
        self.setupGraph(list)

    def setupGraph(self, pointsList):  #pointsList is LPoint2d
        for point in pointsList:
            #plt.plot(np.array([point[0], point[1]]))
            plt.scatter(point[0], point[1])
        plt.grid(True)
        plt.savefig("test.png")
        plt.title(self.egg.egg_filename)
        plt.show()

    def getUVList(self, eggFile):
        uvList = []
        # Some models don't get pass through the vertexPool check
        # so the UVs for smaller models don't get picked up
        for vertexPool in eggFile.getChildren():
            if not isinstance(vertexPool, EggVertexPool):
                continue
            for vertex in vertexPool:
                if not vertex.hasUv():
                    continue
                uvList.append(vertex.getUv())  #matplotlib lol
        return uvList

    def browseModel(self):
        path = Path(
            askopenfilename(filetypes=(("Panda3D Model Files", "*.egg"),
                                       ("EGG", "*.egg"))))
        return path

    def loadFile(self):
        filename = self.browseModel()
        if str(filename) == ".":
            return
        try:
            self.egg.read(filename)
        except:
            print(str(filename) + " could not be loaded!")
Example #3
0
            shutil.copyfile(errorImage, filecheck)
            continue

        shutil.copyfile(filepath, filecheck)


# if outputFile:
#    if path.exists('texList.txt'):
#        os.remove('texList.txt')

with open('texList.txt', 'w+') as fp:
    pass

for model in eggFiles:
    egg = EggData()
    egg.read(model)
    texList = getTextureList(egg)
    cloneTextureDirs(texList, model)
    if verboseList:
        print(model, texList)
    if outputFile:
        with open('texList.txt', 'a') as f:
            print("%s\n%s\n" % (model, texList), file=f)

# Post migration
dirList = []
for dirs in os.listdir(os.path.join(eggDir, eggOutputDir)):
    dirList.append(os.path.join(eggDir, eggOutputDir, dirs))

#print(os.path.join(eggDir, eggOutputDir))