Übersicht: ich eine kleine Minecraft'like Generation Skript mit Python erstellt habe und Panda3D, ich habe in einem Thread setzt es so kann ich time.sleep() und andere Funktionen aber irgendwelche Ideen, warum der Thread abstürzt?Panda3D Python threading Abstürze
Was ich getan habe: Ich habe ein kleines Minecraft'like Generation Skript erstellt mit Python und Panda3D.
Das Problem: Ich kann Threading mit Panda3D nicht verwenden.
Hier ist alle der Code, den ich erstellt habe:
from direct.showbase.ShowBase import ShowBase
from panda3d.core import *
import perlin, colorsys, time
import thread
scaleX = 0.05
scaleZ = 0.05
blockSize = 1
size = 16
bottom = -70
waiter = 0.001
sn = perlin.SimplexNoise()
def threaded_generator():
for x in range(size):
for z in range(size):
time.sleep(waiter)
y = sn.noise2(x*scaleX, z*scaleZ)
# Load the environment model.
cube = loader.loadModel("Test")
# Reparent the model to render.
cube.reparentTo(render)
# Apply scale and position transforms on the model.
cube.setScale(blockSize, blockSize, blockSize)
cube.setPos(x*blockSize, z*blockSize, round(y))
cy = round(y)
while cy > bottom:
cy -= 1
cube = loader.loadModel("Test")
# Reparent the model to render.
cube.reparentTo(render)
# Apply scale and position transforms on the model.
cube.setScale(blockSize, blockSize, blockSize)
cube.setPos(x*blockSize, z*blockSize, round(cy))
class MyApp(ShowBase):
def __init__(self):
ShowBase.__init__(self)
#Ambient
alight = AmbientLight('alight')
alight.setColor(VBase4(0.2, 0.2, 0.2, 1))
alnp = render.attachNewNode(alight)
render.setLight(alnp)
#Directional
dlight = DirectionalLight('dlight')
dlight.setColor(VBase4(0.8, 0.8, 0.5, 1))
dlnp = render.attachNewNode(dlight)
dlnp.setHpr(0, -60, 0)
render.setLight(dlnp)
#Cubes
print("Ding!")
thread.start_new_thread(threaded_generator,())
app = MyApp()
app.run()
Für mich ist es beginnt ein wenig zu erzeugen,
dann hält er an, es scheint nicht zu fertig, manchmal hört es ziemlich schnell auf und manchmal hört es nach ein paar Sekunden auf.
~ Coolq :)
Einfädeln Klingt cool, aber während ich eigentlich keine Panda3d Installation auf meinem PC habe, kann ich nicht Testen Sie es :( – linusg
Kein Problem! Es war spät, als ich das veröffentlichte, sorry! –